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

Function updateBotDetectionCmdRun

internal/cli/attack_protection_bot_detection.go:168–272  ·  view source on GitHub ↗
(cli *cli, inputs *botDetectionInputs)

Source from the content-addressed store, hash-verified

166}
167
168func updateBotDetectionCmdRun(cli *cli, inputs *botDetectionInputs) func(cmd *cobra.Command, args []string) error {
169 return func(cmd *cobra.Command, args []string) error {
170 var current *managementv2.GetBotDetectionSettingsResponseContent
171 if err := ansi.Waiting(func() (err error) {
172 current, err = cli.apiv2.AttackProtectionBotDetection.Get(cmd.Context())
173 return err
174 }); err != nil {
175 return err
176 }
177
178 bdUpdate := &managementv2.UpdateBotDetectionSettingsRequestContent{}
179 noLocalFlagSet := noLocalFlagSet(cmd)
180
181 // Set bot detection level.
182 if bdFlags.BotDetectionLevel.IsSet(cmd) || noLocalFlagSet {
183 if err := bdFlags.BotDetectionLevel.AskU(cmd, &inputs.BotDetectionLevel, stringPtr(current.BotDetectionLevel.Ptr())); err != nil {
184 return err
185 }
186 if inputs.BotDetectionLevel == "" {
187 inputs.BotDetectionLevel = string(current.GetBotDetectionLevel())
188 }
189 botDetectionLevel, err := managementv2.NewBotDetectionLevelEnumFromString(inputs.BotDetectionLevel)
190 if err != nil {
191 return err
192 }
193 bdUpdate.SetBotDetectionLevel(&botDetectionLevel)
194 }
195
196 // Set challenge password policy.
197 if bdFlags.ChallengePasswordPolicy.IsSet(cmd) || noLocalFlagSet {
198 if err := bdFlags.ChallengePasswordPolicy.AskU(cmd, &inputs.ChallengePasswordPolicy, stringPtr(current.ChallengePasswordPolicy.Ptr())); err != nil {
199 return err
200 }
201 if inputs.ChallengePasswordPolicy == "" {
202 inputs.ChallengePasswordPolicy = string(current.GetChallengePasswordPolicy())
203 }
204 challengePasswordPolicy, err := managementv2.NewBotDetectionChallengePolicyPasswordFlowEnumFromString(inputs.ChallengePasswordPolicy)
205 if err != nil {
206 return err
207 }
208 bdUpdate.SetChallengePasswordPolicy(&challengePasswordPolicy)
209 }
210
211 // Set challenge passwordless policy.
212 if bdFlags.ChallengePasswordlessPolicy.IsSet(cmd) || noLocalFlagSet {
213 if err := bdFlags.ChallengePasswordlessPolicy.AskU(cmd, &inputs.ChallengePasswordlessPolicy, stringPtr(current.ChallengePasswordlessPolicy.Ptr())); err != nil {
214 return err
215 }
216 if inputs.ChallengePasswordlessPolicy == "" {
217 inputs.ChallengePasswordlessPolicy = string(current.GetChallengePasswordlessPolicy())
218 }
219 challengePasswordlessPolicy, err := managementv2.NewBotDetectionChallengePolicyPasswordlessFlowEnumFromString(inputs.ChallengePasswordlessPolicy)
220 if err != nil {
221 return err
222 }
223 bdUpdate.SetChallengePasswordlessPolicy(&challengePasswordlessPolicy)
224 }
225

Callers 1

updateBotDetectionCmdFunction · 0.85

Calls 10

WaitingFunction · 0.92
noLocalFlagSetFunction · 0.85
stringPtrFunction · 0.85
GetMethod · 0.80
IsSetMethod · 0.80
AskUMethod · 0.80
AskManyUMethod · 0.80
AskBoolUMethod · 0.80
BotDetectionUpdateMethod · 0.80
UpdateMethod · 0.65

Tested by

no test coverage detected