- release_tracks: [ALPHA, GA]
  help_text:
    brief: Update a Key.
    description: Update a reCAPTCHA Key.
    examples: |
        To update the information of a reCAPTCHA key, run:

          $ {command} test-key --labels="foo=bar" --web --domains=test.com.mx

  request:
    collection: recaptchaenterprise.projects.keys
    modify_request_hooks:
    - googlecloudsdk.command_lib.recaptcha.hooks:SanitizePlatformSettings

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.recaptcha.resources:keys
      help_text: |
        The reCAPTCHA Key to update.
    params:
    - arg_name: display-name
      required: false
      api_field: googleCloudRecaptchaenterpriseV1Key.displayName
      help_text: |
        A human-readable name for the key. Typically a site or app name.
    - api_field: googleCloudRecaptchaenterpriseV1Key.labels.additionalProperties
      arg_name: labels
      metavar: KEY=VALUE
      required: false
      help_text: |
        List of label KEY=VALUE pairs to add.
      type:
        arg_dict:
          flatten: true
          spec:
          - api_field: key
          - api_field: value
    - group:
        mutex: true
        params:
        - group:
            help_text: |
              Options for the creation of a site key for web.
            params:
            - arg_name: web
              required: true
              type: bool
              help_text: |
                Creates a Key configured for websites.
            - arg_name: allow-amp-traffic
              api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.allowAmpTraffic
              help_text: |
                Whether this key can be used on AMP (Accelerated Mobile Pages) websites.
            - group:
                mutex: true
                required: false
                params:
                - arg_name: allow-all-domains
                  api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.allowAllDomains
                  help_text: |
                    If set, domain name enforcement will NOT be enabled on this key.
                - arg_name: domains
                  api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.allowedDomains
                  help_text: |
                    Domains or subdomains of websites allowed to use the key. All subdomains of an
                    allowed domain are automatically allowed. A valid domain requires a host and must
                    not include any path, port, query or fragment.

                    Examples of valid domains:
                         'example.com'
                         'subdomain.example.com'
            - arg_name: security-preference
              api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.challengeSecurityPreference
              help_text: |
                Represents the possible challenge frequency and difficulty configurations for a web key.
                            usability: show fewer and easier challenges.
                            balance: show balanced (in amount and difficulty) challenges.
                            security: show more and harder challenges.
            - group:
                help_text: |
                  Configure if you want to use the POLICY_BASED_CHALLENGE option.
                required: false
                params:
                - arg_name: default-score-threshold
                  type: float
                  api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.challengeSettings.defaultSettings.scoreThreshold
                  help_text: |
                    The global threshold to be used for POLICY_BASED_CHALLENGE if no action specific one exists.
                - arg_name: action-score-thresholds
                  api_field: googleCloudRecaptchaenterpriseV1Key.webSettings.challengeSettings.actionSettings
                  help_text: |
                    The action to score threshold used for POLICY_BASED_CHALLENGE. For example:
                    --action-score-thresholds=login='{"scoreThreshold": "0.3"}',signup='{"scoreThreshold": "0.1"}'
                    or --action-score-thresholds=file_path.(json|yaml)
                  repeated: true
                  type: arg_object
        - group:
            help_text: |
              Options for the creation of a site key for iOS.
            params:
            - arg_name: ios
              required: true
              type: bool
              help_text: |
                Creates a Key configured for iOS devices.
            - group:
                mutex: true
                required: false
                params:
                - arg_name: allow-all-bundle-ids
                  api_field: googleCloudRecaptchaenterpriseV1Key.iosSettings.allowAllBundleIds
                  help_text: |
                    If set, bundle id enforcement will NOT be enabled on this key.
                - arg_name: bundle-ids
                  api_field: googleCloudRecaptchaenterpriseV1Key.iosSettings.allowedBundleIds
                  help_text: |
                    iOS bundle ids of apps allowed to use the key.

                    Example of a valid bundle id:
                       'com.companyname.productname.appname'
            - group:
                required: false
                help_text: |
                  Fields that are required to perform Apple-specific integrity checks (recommended
                  for iOS keys).
                params:
                - arg_name: private-key-file
                  api_field: googleCloudRecaptchaenterpriseV1Key.iosSettings.appleDeveloperId.privateKey
                  required: true
                  type: "googlecloudsdk.calliope.arg_parsers:FileContents:"
                  help_text: |
                    File path to a private key (downloaded as a text file with a .p8 file extension)
                    generated for your Apple Developer account. Ensure that DeviceCheck is
                    enabled for the private key.
                - arg_name: key-id
                  api_field: googleCloudRecaptchaenterpriseV1Key.iosSettings.appleDeveloperId.keyId
                  required: true
                  help_text: The Apple developer key ID (10-character string).
                - arg_name: team-id
                  api_field: googleCloudRecaptchaenterpriseV1Key.iosSettings.appleDeveloperId.teamId
                  required: true
                  help_text: |
                    The Apple team ID (10-character string) owning the provisioning profile
                    used to build your application.
        - group:
            help_text: |
              Options for the creation of a site key for Android.
            params:
            - arg_name: android
              required: true
              type: bool
              help_text: |
                Creates a Key configured for Android devices.
            - group:
                mutex: true
                required: true
                params:
                - arg_name: allow-all-package-names
                  api_field: googleCloudRecaptchaenterpriseV1Key.androidSettings.allowAllPackageNames
                  help_text: |
                    If set, package name enforcement will NOT be enabled on this key.
                - arg_name: package-names
                  api_field: googleCloudRecaptchaenterpriseV1Key.androidSettings.allowedPackageNames
                  help_text: |
                    Android package names of apps allowed to use the key.

                    Example of a valid package name:
                         'com.companyname.appname'
        - group:
            help_text: |
              Options for the creation of a site key for Express.
            params:
            - arg_name: express
              required: true
              type: bool
              help_text: |
                Creates a Key configured for Express assessments.
  output:
    format: none
