(cli *cli)
| 255 | } |
| 256 | |
| 257 | func updateEventStreamCmd(cli *cli) *cobra.Command { |
| 258 | var inputs struct { |
| 259 | ID string |
| 260 | Name string |
| 261 | Status string |
| 262 | Subscriptions []string |
| 263 | Configuration string |
| 264 | } |
| 265 | |
| 266 | cmd := &cobra.Command{ |
| 267 | Use: "update", |
| 268 | Args: cobra.MaximumNArgs(1), |
| 269 | Short: "Update an event stream", |
| 270 | Long: "Update an event stream.\n\n" + |
| 271 | "To update interactively, use `auth0 event-streams update` with no arguments.\n\n" + |
| 272 | "To update non-interactively, supply the event id, name, status, subscriptions and " + |
| 273 | "configuration through the flags. An event stream type CANNOT be updated hence the configuration " + |
| 274 | "should match the schema based on the type of event stream. Configuration for `eventbridge` streams " + |
| 275 | "cannot be updated." + |
| 276 | "Only deployed actions can be used for action configuration", |
| 277 | Example: ` auth0 event-streams update <event-id> |
| 278 | auth0 event-streams update <event-id> --name my-event-stream |
| 279 | auth0 event-streams update <event-id> --name my-event-stream --status enabled |
| 280 | auth0 event-streams update <event-id> --name my-event-stream --status enabled --subscriptions "user.created,user.updated" |
| 281 | auth0 event-streams update <event-id> --name my-event-stream --status disabled --subscriptions "user.deleted" --configuration '{"aws_account_id":"325235643634","aws_region":"us-east-2"}' |
| 282 | auth0 event-streams update <event-id> --name my-event-stream --status enabled --subscriptions "user.created" --configuration '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"0909090909"}}' |
| 283 | auth0 event-streams create <event-id> --name my-event-stream --subscriptions "user.updated" --configuration '{"action_id":"b053e4ca-8b14-4233-b615-bd3bdb353977"}' |
| 284 | auth0 event-streams update <event-id> -n my-event-stream --status enabled -s "user.created" -c '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"987654321"}}`, |
| 285 | RunE: func(cmd *cobra.Command, args []string) error { |
| 286 | if len(args) > 0 { |
| 287 | inputs.ID = args[0] |
| 288 | } else { |
| 289 | if err := eventStreamID.Pick(cmd, &inputs.ID, cli.eventStreamPickerOptions); err != nil { |
| 290 | return err |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | var oldEventStream *management.EventStream |
| 295 | err := ansi.Waiting(func() (err error) { |
| 296 | oldEventStream, err = cli.api.EventStream.Read(cmd.Context(), inputs.ID) |
| 297 | return err |
| 298 | }) |
| 299 | if err != nil { |
| 300 | return fmt.Errorf("failed to read event stream with ID %q: %w", inputs.ID, err) |
| 301 | } |
| 302 | |
| 303 | if e := eventStreamName.AskU(cmd, &inputs.Name, nil); e != nil { |
| 304 | return e |
| 305 | } |
| 306 | if e := eventStreamStatus.AskU(cmd, &inputs.Status, nil); e != nil { |
| 307 | return e |
| 308 | } |
| 309 | |
| 310 | if e := eventStreamSubscriptions.AskManyU(cmd, &inputs.Subscriptions, nil); e != nil { |
| 311 | return e |
| 312 | } |
| 313 | |
| 314 | if e := eventStreamConfig.AskU(cmd, &inputs.Configuration, nil); e != nil { |
no test coverage detected