Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support audience or ID for api operations #183

Merged
merged 1 commit into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"errors"
"fmt"
"net/url"

"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/prompt"
Expand Down Expand Up @@ -122,11 +123,11 @@ auth0 apis show <id>
inputs.ID = args[0]
}

api := &management.ResourceServer{ID: &inputs.ID}
var api *management.ResourceServer

if err := ansi.Waiting(func() error {
var err error
api, err = cli.api.ResourceServer.Read(inputs.ID)
api, err = cli.api.ResourceServer.Read(url.PathEscape(inputs.ID))
return err
}); err != nil {
return fmt.Errorf("Unable to get an API with Id '%s': %w", inputs.ID, err)
Expand Down Expand Up @@ -229,7 +230,7 @@ auth0 apis update <id> --name myapi

if err := ansi.Waiting(func() error {
var err error
current, err = cli.api.ResourceServer.Read(inputs.ID)
current, err = cli.api.ResourceServer.Read(url.PathEscape(inputs.ID))
return err
}); err != nil {
return fmt.Errorf("Unable to load API. The Id %v specified doesn't exist", inputs.ID)
Expand Down Expand Up @@ -258,7 +259,7 @@ auth0 apis update <id> --name myapi
}

if err := ansi.Waiting(func() error {
return cli.api.ResourceServer.Update(inputs.ID, api)
return cli.api.ResourceServer.Update(current.GetID(), api)
}); err != nil {
return fmt.Errorf("An unexpected error occurred while trying to update an API with Id '%s': %w", inputs.ID, err)
}
Expand Down Expand Up @@ -307,7 +308,7 @@ auth0 apis delete <id>
}

return ansi.Spinner("Deleting API", func() error {
err := cli.api.ResourceServer.Delete(inputs.ID)
err := cli.api.ResourceServer.Delete(url.PathEscape(inputs.ID))
if err != nil {
return fmt.Errorf("An unexpected error occurred while attempting to delete an API with Id '%s': %w", inputs.ID, err)
}
Expand Down