MCPcopy Create free account
hub / github.com/auth0/auth0-cli / apiCmd

Function apiCmd

internal/cli/api.go:70–101  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

68)
69
70func apiCmd(cli *cli) *cobra.Command {
71 inputs := apiCmdInputs{
72 renderer: cli.renderer,
73 }
74
75 cmd := &cobra.Command{
76 Use: "api <method> <url-path>",
77 Args: cobra.RangeArgs(0, 2),
78 Short: "Makes an authenticated HTTP request to the Auth0 Management API",
79 Long: fmt.Sprintf(
80 `Makes an authenticated HTTP request to the [Auth0 Management API](%s) and returns the response as JSON.
81
82Method argument is optional, defaults to %s for requests without data and %s for requests with data.
83
84Additional scopes may need to be requested during authentication step via the %s flag. For example: %s.`,
85 apiDocsURL, "`GET`", "`POST`", "`--scopes`", "`auth0 login --scopes read:client_grants`",
86 ),
87 Example: ` auth0 api get "tenants/settings"
88 auth0 api "stats/daily" -q "from=20221101" -q "to=20221118"
89 auth0 api delete "actions/actions/<action-id>" --force
90 auth0 api clients --data "{\"name\":\"ssoTest\",\"app_type\":\"sso_integration\"}"
91 cat data.json | auth0 api post clients`,
92 RunE: apiCmdRun(cli, &inputs),
93 }
94
95 cmd.SetUsageTemplate(apiUsageTemplate())
96 cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation when using the delete method.")
97 apiFlags.Data.RegisterString(cmd, &inputs.RawData, "")
98 apiFlags.QueryParams.RegisterStringMap(cmd, &inputs.RawQueryParams, nil)
99
100 return cmd
101}
102
103func apiUsageTemplate() string {
104 return fmt.Sprintf(

Callers 1

addSubCommandsFunction · 0.85

Calls 4

apiCmdRunFunction · 0.85
apiUsageTemplateFunction · 0.85
RegisterStringMethod · 0.80
RegisterStringMapMethod · 0.80

Tested by

no test coverage detected