
    
                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ  e	j                  e	j                  j                          G d d	e	j"                               Zy
)z6Implements command to update a specified guest policy.    )absolute_import)division)unicode_literals)utils)base)
propertiesc                   &    e Zd ZdZed        Zd Zy)UpdatezUpdate the specified guest policy for a project.

  ## EXAMPLES

    To update the guest policy `policy1` in the project `project1`, run:

          $ {command} policy1 \
          --file=path_to_config_file --project=project1

  c                 \    | j                  dt        d       | j                  ddd       y)	See base class.	POLICY_IDz#Name of the guest policy to update.)typehelpz--fileTa          The JSON or YAML file with the updated guest policy.

        If this file specifies an etag value, the update succeeds only if
        the policy that is already in place has a matching etag value. If no
        etag value is specified, the specifications in the updated policy file
        replaces the existing policy.

        For information about the guest policy format, see https://cloud.google.com/compute/docs/osconfig/rest/v1beta/projects.guestPolicies.
        )requiredr   N)add_argumentstr)parsers    6lib/surface/compute/os_config/guest_policies/update.pyArgszUpdate.Args(   s>     #$I  K
	      c                    | j                         }t        j                  |      }t        j                  |      }t	        j
                  |j                  |j                        \  }}t        j                  j                  j                  j                         }|j                  |t	        j                  d||j                        d      }|j                   }	|	j#                  |      S )r   projectsN)guestPolicyname
updateMask)ReleaseTrackosconfig_api_utilsGetClientInstanceGetClientMessagesosconfig_command_utils"GetResourceAndUpdateFieldsFromFilefileGuestPolicyr   VALUEScoreproject	GetOrFail)OsconfigProjectsGuestPoliciesPatchRequestGetGuestPolicyUriPathr   projects_guestPoliciesPatch)
selfargsrelease_trackclientmessagesguest_policy_r&   requestservices
             r   Runz
Update.Run;   s    %%'M11-@F!33MBH !
C
C	H((*\ $$,,668G@@ #991	 A G ++G==!!r   N)__name__
__module____qualname____doc__staticmethodr   r5    r   r   r
   r
      s     	  $"r   r
   N)r9   
__future__r   r   r   (googlecloudsdk.api_lib.compute.os_configr   r   googlecloudsdk.callioper   ,googlecloudsdk.command_lib.compute.os_configr    googlecloudsdk.corer   ReleaseTracksr   BETACommandr
   r;   r   r   <module>rD      sW    = &  ' P ( X * D%%**+2"T\\ 2" ,2"r   