- release_tracks: [GA, BETA, ALPHA]

  help_text:
    brief: |
      Update a Managed Microsoft AD domain.
    description: |
      Update the metadata and/or configuration parameters of a managed
      Microsoft AD domain.

      This command can fail for the following reasons:
        * The AD domain specified does not exist.
        * The active account does not have permission to update the given
          AD domain.
    examples: |
      The following command updates an AD domain with the name
      `my-domain.com` to add the two labels, `env` and `service` and to add a
      provisioned region `us-west1`:

        $ {command} my-domain.com --update-labels=env=test,service=foo \
        --add-region=us-west1

      This peers the domain `my-domain.com` to the network `my-network`.

        $ {command} my-domain.com
        --add-authorized-networks=projects/my-project/global/networks/my-network

  async:
    collection: managedidentities.projects.locations.global.operations

  request: &request
    ALPHA:
      api_version: v1alpha1
      modify_request_hooks:
      - googlecloudsdk.command_lib.active_directory.domains_update_util:CheckFieldsSpecified
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdatePatchRequest
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdateLabels
      - googlecloudsdk.command_lib.active_directory.flags:UpdateAuditLogsEnabled
      - googlecloudsdk.command_lib.active_directory.flags:AddRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:AddAuthorizedNetworksFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveAuthorizedNetworksFlag
    BETA:
      api_version: v1beta1
      modify_request_hooks:
      - googlecloudsdk.command_lib.active_directory.domains_update_util:CheckFieldsSpecified
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdatePatchRequest
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdateLabels
      - googlecloudsdk.command_lib.active_directory.flags:UpdateAuditLogsEnabled
      - googlecloudsdk.command_lib.active_directory.flags:AddRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:AddAuthorizedNetworksFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveAuthorizedNetworksFlag
    GA:
      api_version: v1
      modify_request_hooks:
      - googlecloudsdk.command_lib.active_directory.domains_update_util:CheckFieldsSpecified
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdatePatchRequest
      - googlecloudsdk.command_lib.active_directory.domains_update_util:UpdateLabels
      - googlecloudsdk.command_lib.active_directory.flags:UpdateAuditLogsEnabled
      - googlecloudsdk.command_lib.active_directory.flags:AddRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveRegionFlag
      - googlecloudsdk.command_lib.active_directory.flags:AddAuthorizedNetworksFlag
      - googlecloudsdk.command_lib.active_directory.flags:RemoveAuthorizedNetworksFlag
    collection: managedidentities.projects.locations.global.domains
    method: patch

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.active_directory.resources:domain
      help_text: |
        Name of the Managed Microsoft AD domain you want to update.
    additional_arguments_hook: googlecloudsdk.command_lib.active_directory.flags:AdditionalDomainUpdateArguments
    params:
    - arg_name: enable-audit-logs
      type: bool
      action: store_true
      api_field: domain.auditLogsEnabled
      help_text: |
        If specified, Active Directory data audit logs are enabled for the domain.
