(cli *cli)
| 47 | ) |
| 48 | |
| 49 | func createLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command { |
| 50 | var inputs struct { |
| 51 | name string |
| 52 | httpEndpoint string |
| 53 | httpContentType string |
| 54 | httpContentFormat string |
| 55 | httpAuthorization string |
| 56 | piiConfig string |
| 57 | filters string |
| 58 | } |
| 59 | |
| 60 | cmd := &cobra.Command{ |
| 61 | Use: "http", |
| 62 | Args: cobra.NoArgs, |
| 63 | Short: "Create a new Custom Webhook log stream", |
| 64 | Long: "Specify a URL you'd like Auth0 to post events to.\n\n" + |
| 65 | "To create interactively, use `auth0 logs streams create http` with no arguments.\n\n" + |
| 66 | "To create non-interactively, supply the log stream name and other information through the flags.", |
| 67 | Example: ` auth0 logs streams create http |
| 68 | auth0 logs streams create http --name <name> |
| 69 | auth0 logs streams create http --name <name> --endpoint <endpoint> |
| 70 | auth0 logs streams create http --name <name> --endpoint <endpoint> --type <type> |
| 71 | auth0 logs streams create http --name <name> --endpoint <endpoint> --type <type> --format <format> |
| 72 | auth0 logs streams create http --name <name> --endpoint <endpoint> --type <type> --format <format> --filters '[{"type":"category","name":"auth.login.fail"},{"type":"category","name":"auth.signup.fail"}]' |
| 73 | auth0 logs streams create http --name <name> --endpoint <endpoint> --type <type> --format <format> --pii-config '{"log_fields": ["first_name", "last_name"], "method": "hash", "algorithm": "xxhash"}'' |
| 74 | auth0 logs streams create http --name <name> --endpoint <endpoint> --type <type> --format <format> --authorization <authorization> |
| 75 | auth0 logs streams create http -n <name> -e <endpoint> -t <type> -f <format> -a <authorization> |
| 76 | auth0 logs streams create http -n mylogstream -e "https://example.com/webhook/logs" -t "application/json" -f "JSONLINES" -a "AKIAXXXXXXXXXXXXXXXX" --json |
| 77 | auth0 logs streams create http -n mylogstream -e "https://example.com/webhook/logs" -t "application/json" -f "JSONLINES" -a "AKIAXXXXXXXXXXXXXXXX" --json-compact`, |
| 78 | RunE: func(cmd *cobra.Command, args []string) error { |
| 79 | if err := logStreamName.Ask(cmd, &inputs.name, nil); err != nil { |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | if err := httpEndpoint.Ask(cmd, &inputs.httpEndpoint, nil); err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | if err := httpContentType.Ask(cmd, &inputs.httpContentType, nil); err != nil { |
| 88 | return err |
| 89 | } |
| 90 | |
| 91 | if err := httpContentFormat.Select(cmd, &inputs.httpContentFormat, httpContentFormatOptions, nil); err != nil { |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | if err := httpAuthorization.AskPassword(cmd, &inputs.httpAuthorization); err != nil { |
| 96 | return err |
| 97 | } |
| 98 | |
| 99 | var piiConfig *management.LogStreamPiiConfig |
| 100 | if err := logStreamPIIConfig.Ask(cmd, &inputs.piiConfig, auth0.String("{}")); err != nil { |
| 101 | return err |
| 102 | } |
| 103 | |
| 104 | if inputs.piiConfig != "{}" { |
| 105 | if err := json.Unmarshal([]byte(inputs.piiConfig), &piiConfig); err != nil { |
| 106 | return fmt.Errorf("provider: %s credentials invalid JSON: %w", inputs.piiConfig, err) |
no test coverage detected