(cli *cli)
| 68 | ) |
| 69 | |
| 70 | func 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 | |
| 82 | Method argument is optional, defaults to %s for requests without data and %s for requests with data. |
| 83 | |
| 84 | Additional 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 | |
| 103 | func apiUsageTemplate() string { |
| 104 | return fmt.Sprintf( |
no test coverage detected