- release_tracks: [ALPHA, GA]
  command_type: GENERIC
  help_text:
    brief: Update the given Cloud Security Command Center (SCC) posture deployment.
    description: |
      Update a Cloud Security Command Center (SCC) posture deployment.

      Fields specified in update-mask flag are updated. Updatable fields are description and posture_name with posture_revision-id.
      The target_resource for a posture deployment cannot be updated. The posture deployment to be updated should be in ACTIVE State.
      An empty or "*" update-mask implies that posture-id and posture-revision-id are to be updated.
      If posture details of posture deployment need to be updated, then the desired posture needs to be in ACTIVE state.
      LRO operation ID is returned as the response of the command.

    examples: |
      Update the description of the posture deployment named `foo-posture-deployment` in the organization `organizations/123/locations/global`:
        $ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment --update-mask=description --description="updated-description"

      Update posture deployment named `foo-posture-deployment` with the posture named `foo-posture` and revision_id `abcdefgh` in the organization `organizations/123/locations/global`:
        $ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment --update-mask=posture_id,posture_revision-id --posture-id=foo-posture --posture-revision-id=abcdefgh

       Update posture deployment named `foo-posture-deployment` with the posture named `foo-posture` and revision_id `abcdefgh` in the organization `organizations/123/locations/global`:
        $ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment  --posture-id=foo-posture --posture-revision-id=abcdefgh

  request:
    collection: securityposture.organizations.locations.postureDeployments
    api_version: v1alpha
    method: patch
    GA:
      api_version: v1

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.scc.resources:posture_deployment
      help_text: |
          The posture deployment to update. For example organizations/<organizationID>/locations/<location>/postureDeployments/<postureDeploymentID>.

    params:
    - group:
        params:
        - arg_name: posture-id
          api_field: postureDeployment.postureId
          required: true
          help_text: |
            Relative name of the posture to be updated, like `organizations/<organizationID>/locations/<location>/postures/<postureID>`.
        - arg_name: posture-revision-id
          api_field: postureDeployment.postureRevisionId
          required: true
          help_text: |
            Revision ID of the posture to be updated.

    - arg_name: description
      api_field: postureDeployment.description
      help_text: |
        Updated description of posture deployment.

    - arg_name: update-mask
      api_field: updateMask
      help_text: |
        Comma-separated string containing list of fields to be updated.

    - arg_name: etag
      api_field: postureDeployment.etag
      required: false
      help_text: |
          Etag is an optional flag. If the provided Etag doesn't match the server generated Etag, the update operation won't proceed.

  async:
    collection: securityposture.organizations.locations.operations
    extract_resource_result: false

  output:
    format: yaml
