Skip to content

Commit

Permalink
feat: apis delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Jan 25, 2021
1 parent 0ddf743 commit bfb25a5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
deviceCodeEndpoint = "https://auth0.auth0.com/oauth/device/code"
oauthTokenEndpoint = "https://auth0.auth0.com/oauth/token"
// TODO(jfatta) extend the scope as we extend the CLI:
scope = "openid create:actions create:clients create:resource_servers create:connections create:hooks create:rules delete:actions delete:clients delete:connections delete:hooks delete:rules read:actions read:clients read:resource_servers read:connections read:hooks read:logs read:rules update:actions update:clients update:resource_servers update:connections update:hooks update:rules"
scope = "openid create:actions create:clients create:resource_servers create:connections create:hooks create:rules delete:actions delete:clients delete:resource_servers delete:connections delete:hooks delete:rules read:actions read:clients read:resource_servers read:connections read:hooks read:logs read:rules update:actions update:clients update:resource_servers update:connections update:hooks update:rules"
audiencePath = "/api/v2/"
)

Expand Down
39 changes: 37 additions & 2 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func apisCmd(cli *cli) *cobra.Command {
cmd.AddCommand(listApisCmd(cli))
cmd.AddCommand(createApiCmd(cli))
cmd.AddCommand(updateApiCmd(cli))
cmd.AddCommand(deleteApiCmd(cli))

return cmd
}
Expand Down Expand Up @@ -93,8 +94,8 @@ auth0 apis create --name myapi --identifier http://my-api

func updateApiCmd(cli *cli) *cobra.Command {
var flags struct {
id string
name string
id string
name string
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -128,3 +129,37 @@ auth0 apis update --id id --name myapi

return cmd
}

func deleteApiCmd(cli *cli) *cobra.Command {
var flags struct {
id string
}

cmd := &cobra.Command{
Use: "delete",
Short: "Delete an API",
Long: `Deletes an API:
auth0 apis delete --id id
`,
RunE: func(cmd *cobra.Command, args []string) error {
manager := &management.ResourceServerManager{Management: cli.api}

err := ansi.Spinner("Deleting API", func() error {
return manager.Delete(flags.id)
})

if err != nil {
return err
}

return nil
},
}

cmd.Flags().StringVarP(&flags.id, "id", "i", "", "ID of the API.")

mustRequireFlags(cmd, "id")

return cmd
}

0 comments on commit bfb25a5

Please sign in to comment.