(cli *cli)
| 124 | } |
| 125 | |
| 126 | func updateLogStreamsDatadogCmd(cli *cli) *cobra.Command { |
| 127 | var inputs struct { |
| 128 | id string |
| 129 | name string |
| 130 | piiConfig string |
| 131 | filters string |
| 132 | datadogAPIKey string |
| 133 | datadogRegion string |
| 134 | } |
| 135 | |
| 136 | cmd := &cobra.Command{ |
| 137 | Use: "datadog", |
| 138 | Args: cobra.MaximumNArgs(1), |
| 139 | Short: "Update an existing Datadog log stream", |
| 140 | Long: "Build interactive dashboards and get alerted on critical issues.\n\n" + |
| 141 | "To update interactively, use `auth0 logs streams create datadog` with no arguments.\n\n" + |
| 142 | "To update non-interactively, supply the log stream name and other information through the flags.", |
| 143 | Example: ` auth0 logs streams update datadog |
| 144 | auth0 logs streams update datadog <log-stream-id> --name <name> |
| 145 | auth0 logs streams update datadog <log-stream-id> --name <name> --region <region> |
| 146 | auth0 logs streams update datadog <log-stream-id> --name <name> --region <region> --api-key <api-key> --filters '[{"type":"category","name":"user.fail"},{"type":"category","name":"scim.event"}]' |
| 147 | auth0 logs streams update datadog <log-stream-id> --name <name> --region <region> --api-key <api-key> --pii-config '{"log_fields": ["first_name", "last_name"], "method": "mask", "algorithm": "xxhash"}' |
| 148 | auth0 logs streams update datadog <log-stream-id> -n <name> -r <region> -k <api-key> -c null |
| 149 | auth0 logs streams update datadog <log-stream-id> -n mylogstream -r eu -k 121233123455 --json |
| 150 | auth0 logs streams update datadog <log-stream-id> -n mylogstream -r eu -k 121233123455 --json-compact`, |
| 151 | RunE: func(cmd *cobra.Command, args []string) error { |
| 152 | if len(args) == 0 { |
| 153 | err := logStreamID.Pick(cmd, &inputs.id, cli.logStreamPickerOptionsByType(logStreamTypeDatadog)) |
| 154 | if err != nil { |
| 155 | return err |
| 156 | } |
| 157 | } else { |
| 158 | inputs.id = args[0] |
| 159 | } |
| 160 | |
| 161 | var oldLogStream *management.LogStream |
| 162 | if err := ansi.Waiting(func() (err error) { |
| 163 | oldLogStream, err = cli.api.LogStream.Read(cmd.Context(), inputs.id) |
| 164 | return err |
| 165 | }); err != nil { |
| 166 | return fmt.Errorf("failed to read log stream with ID %q: %w", inputs.id, err) |
| 167 | } |
| 168 | |
| 169 | if oldLogStream.GetType() != string(logStreamTypeDatadog) { |
| 170 | return errInvalidLogStreamType(inputs.id, oldLogStream.GetType(), string(logStreamTypeDatadog)) |
| 171 | } |
| 172 | |
| 173 | if err := logStreamName.AskU(cmd, &inputs.name, oldLogStream.Name); err != nil { |
| 174 | return err |
| 175 | } |
| 176 | |
| 177 | existingConfig, _ := json.Marshal(oldLogStream.GetPIIConfig()) |
| 178 | if err := logStreamPIIConfig.AskU(cmd, &inputs.piiConfig, auth0.String(string(existingConfig))); err != nil { |
| 179 | return err |
| 180 | } |
| 181 | |
| 182 | existingFilters, _ := json.Marshal(oldLogStream.GetFilters()) |
| 183 | if err := logStreamFilters.AskU(cmd, &inputs.filters, auth0.String(string(existingFilters))); err != nil { |
no test coverage detected