(cli *cli)
| 162 | } |
| 163 | |
| 164 | func updateLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command { |
| 165 | var inputs struct { |
| 166 | id string |
| 167 | name string |
| 168 | httpEndpoint string |
| 169 | httpContentType string |
| 170 | httpContentFormat string |
| 171 | httpAuthorization string |
| 172 | piiConfig string |
| 173 | filters string |
| 174 | } |
| 175 | |
| 176 | cmd := &cobra.Command{ |
| 177 | Use: "http", |
| 178 | Args: cobra.MaximumNArgs(1), |
| 179 | Short: "Update an existing Custom Webhook log stream", |
| 180 | Long: "Specify a URL you'd like Auth0 to post events to.\n\n" + |
| 181 | "To update interactively, use `auth0 logs streams create http` with no arguments.\n\n" + |
| 182 | "To update non-interactively, supply the log stream name and other information through the flags.", |
| 183 | Example: ` auth0 logs streams update http |
| 184 | auth0 logs streams update http <log-stream-id> --name <name> |
| 185 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> |
| 186 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> --type <type> |
| 187 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> --type <type> --filters '[{"type":"category","name":"user.fail"},{"type":"category","name":"scim.event"}]' |
| 188 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> --type <type> --pii-config '{"log_fields": ["first_name", "last_name"], "method": "mask", "algorithm": "xxhash"}' |
| 189 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> --type <type> --format <format> |
| 190 | auth0 logs streams update http <log-stream-id> --name <name> --endpoint <endpoint> --type <type> --format <format> --authorization <authorization> |
| 191 | auth0 logs streams update http <log-stream-id> -n <name> -e <endpoint> -t <type> -f <format> -a <authorization> -c null |
| 192 | auth0 logs streams update http <log-stream-id> -n mylogstream -e "https://example.com/webhook/logs" -t "application/json" -f "JSONLINES" -a "AKIAXXXXXXXXXXXXXXXX" --json |
| 193 | auth0 logs streams update http <log-stream-id> -n mylogstream -e "https://example.com/webhook/logs" -t "application/json" -f "JSONLINES" -a "AKIAXXXXXXXXXXXXXXXX" --json-compact`, |
| 194 | RunE: func(cmd *cobra.Command, args []string) error { |
| 195 | if len(args) == 0 { |
| 196 | err := logStreamID.Pick(cmd, &inputs.id, cli.logStreamPickerOptionsByType(logStreamTypeHTTP)) |
| 197 | if err != nil { |
| 198 | return err |
| 199 | } |
| 200 | } else { |
| 201 | inputs.id = args[0] |
| 202 | } |
| 203 | |
| 204 | var oldLogStream *management.LogStream |
| 205 | if err := ansi.Waiting(func() (err error) { |
| 206 | oldLogStream, err = cli.api.LogStream.Read(cmd.Context(), inputs.id) |
| 207 | return err |
| 208 | }); err != nil { |
| 209 | return fmt.Errorf("failed to read log stream with ID %q: %w", inputs.id, err) |
| 210 | } |
| 211 | |
| 212 | if oldLogStream.GetType() != string(logStreamTypeHTTP) { |
| 213 | return errInvalidLogStreamType(inputs.id, oldLogStream.GetType(), string(logStreamTypeHTTP)) |
| 214 | } |
| 215 | |
| 216 | if err := logStreamName.AskU(cmd, &inputs.name, oldLogStream.Name); err != nil { |
| 217 | return err |
| 218 | } |
| 219 | |
| 220 | existingConfig, _ := json.Marshal(oldLogStream.GetPIIConfig()) |
| 221 | if err := logStreamPIIConfig.AskU(cmd, &inputs.piiConfig, auth0.String(string(existingConfig))); err != nil { |
no test coverage detected