(cli *cli)
| 106 | } |
| 107 | |
| 108 | func updateLogStreamsSumoLogicCmd(cli *cli) *cobra.Command { |
| 109 | var inputs struct { |
| 110 | id string |
| 111 | name string |
| 112 | sumoLogicSource string |
| 113 | piiConfig string |
| 114 | filters string |
| 115 | } |
| 116 | |
| 117 | cmd := &cobra.Command{ |
| 118 | Use: "sumo", |
| 119 | Args: cobra.MaximumNArgs(1), |
| 120 | Short: "Update an existing Sumo Logic log stream", |
| 121 | Long: "Visualize logs and detect threats faster with security insights.\n\n" + |
| 122 | "To update interactively, use `auth0 logs streams create sumo` with no arguments.\n\n" + |
| 123 | "To update non-interactively, supply the log stream name and other information through the flags.", |
| 124 | Example: ` auth0 logs streams update sumo |
| 125 | auth0 logs streams update sumo <log-stream-id> --name <name> |
| 126 | auth0 logs streams update sumo <log-stream-id> --name <name> --source <source> |
| 127 | auth0 logs streams update sumo <log-stream-id> --name <name> --source <source> --filters '[{"type":"category","name":"user.fail"},{"type":"category","name":"scim.event"}]' |
| 128 | auth0 logs streams update sumo <log-stream-id> --name <name> --source <source> --pii-config '{"log_fields": ["first_name", "last_name"], "method": "mask", "algorithm": "xxhash"}' |
| 129 | auth0 logs streams update sumo <log-stream-id> -n <name> -s <source> -c null |
| 130 | auth0 logs streams update sumo <log-stream-id> -n "mylogstream" -s "demo.sumo.com" --json |
| 131 | auth0 logs streams update sumo <log-stream-id> -n "mylogstream" -s "demo.sumo.com" --json-compact`, |
| 132 | RunE: func(cmd *cobra.Command, args []string) error { |
| 133 | if len(args) == 0 { |
| 134 | err := logStreamID.Pick(cmd, &inputs.id, cli.logStreamPickerOptionsByType(logStreamTypeSumo)) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | } else { |
| 139 | inputs.id = args[0] |
| 140 | } |
| 141 | |
| 142 | var oldLogStream *management.LogStream |
| 143 | if err := ansi.Waiting(func() (err error) { |
| 144 | oldLogStream, err = cli.api.LogStream.Read(cmd.Context(), inputs.id) |
| 145 | return err |
| 146 | }); err != nil { |
| 147 | return fmt.Errorf("failed to read log stream with id %q: %w", inputs.id, err) |
| 148 | } |
| 149 | |
| 150 | if oldLogStream.GetType() != string(logStreamTypeSumo) { |
| 151 | return errInvalidLogStreamType(inputs.id, oldLogStream.GetType(), string(logStreamTypeSumo)) |
| 152 | } |
| 153 | |
| 154 | if err := logStreamName.AskU(cmd, &inputs.name, oldLogStream.Name); err != nil { |
| 155 | return err |
| 156 | } |
| 157 | |
| 158 | existingConfig, _ := json.Marshal(oldLogStream.GetPIIConfig()) |
| 159 | if err := logStreamPIIConfig.AskU(cmd, &inputs.piiConfig, auth0.String(string(existingConfig))); err != nil { |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | existingFilters, _ := json.Marshal(oldLogStream.GetFilters()) |
| 164 | if err := logStreamFilters.AskU(cmd, &inputs.filters, auth0.String(string(existingFilters))); err != nil { |
| 165 | return err |
no test coverage detected