MCPcopy Create free account
hub / github.com/auth0/auth0-cli / updateLogStreamsCustomWebhookCmd

Function updateLogStreamsCustomWebhookCmd

internal/cli/log_streams_http.go:164–302  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

162}
163
164func 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 {

Callers 1

updateLogStreamCmdFunction · 0.85

Calls 14

WaitingFunction · 0.92
errInvalidLogStreamTypeFunction · 0.85
apiHTTPContentFormatForFunction · 0.85
ErrorfMethod · 0.80
AskUMethod · 0.80
SelectUMethod · 0.80
AskPasswordUMethod · 0.80
LogStreamUpdateMethod · 0.80
RegisterStringUMethod · 0.80
RegisterStringMethod · 0.80
ReadMethod · 0.65

Tested by

no test coverage detected