(cli *cli, inputs *botDetectionInputs)
| 166 | } |
| 167 | |
| 168 | func 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 |
no test coverage detected