
                         D   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 dd	lmZ dd
lmZ  e
j                   e
j"                  j$                  e
j"                  j&                  e
j"                  j(                         G d de
j*                               Zy)z7Command for setting metadata on project zonal metadata.    )absolute_import)division)unicode_literals)base_classes) instance_settings_metadata_utils)base)flags)log)
propertiesc                   .    e Zd ZdZddiZed        Zd Zy)AddMetadataav  Add or update project zonal metadata.

  *{command}* is used to add or update project zonal metadata for your VM
  instances. Project zonal metadata values propagate to all VMs within the
  specified zone. Every VM has access to a metadata server that you can use to
  query the configured project zonal metadata values. To set metadata for
  individual instances, use `gcloud compute instances add-metadata`. For
  information about metadata, see
  [](https://cloud.google.com/compute/docs/metadata).

  Only the metadata keys that you provide in the command get mutated. All other
  existing metadata entries remain the same.
  EXAMPLESa          To set the project zonal metadata with key=value in the zone ``us-central1-a''
        for the project ``my-gcp-project'', run:

        $ {command} --metadata=key=value
        --zone=us-central1-a --project=my-gcp-project

        For more information and examples for setting project zonal metadata, see
        [](https://cloud.google.com/compute/docs/metadata/setting-custom-metadata#set-custom-project-zonal-metadata)
      c                 .    t        j                  |        y )N)r	   $ProjectZonalMetadataAddMetadataFlags)parsers    1lib/surface/compute/project_zonal_metadata/add.pyArgszAddMetadata.Args;   s    	..v6    c           	      F   t        j                  | j                               }|j                  }|j                  j
                  }|j                  j                  t        j                  j                  j                  j                         |j                        }|j                  |d|fg      d   }|j                  }t!        j"                  |j$                  t!        j&                  |j$                              rDt(        j*                  j-                  dj/                  |j                               |j$                  S |j                  j1                  |j                  j3                  |t!        j4                  |j                  |j$                              t        j                  j                  j                  j                         t!        j6                  |j$                  j9                               |j                        }|j                  |d|fgd	      d   S )
N)projectzoneGetr   zNNo change requested; skipping update for project zonal metadata in zone [{0}].)fingerprintmetadata)instanceSettingsr   
updateMaskr   PatchT)no_followup)r   ComputeApiHolderReleaseTrackclientapitools_clientr   messages!ComputeInstanceSettingsGetRequestr   VALUEScorer   	GetOrFailr   MakeRequestsr   metadata_utils'IsRequestMetadataSameAsExistingMetadatar   ConstructMetadataDictr
   statusPrintformat#ComputeInstanceSettingsPatchRequestInstanceSettings(ConstructInstanceSettingsMetadataMessageConstructUpdateMaskkeys)	selfargsholderr!   serviceget_requestexisting_instance_settingsr   requests	            r   RunzAddMetadata.Run?   s   **4+<+<+>?F]]F$$55G//CC!!&&..88: D K "(!4!4
5+	&'""	 -88K==,,&//	
 
jj : ? ?@ (000ooAA99##LL : 
 !!&&..88:!55dmm6H6H6JKYY B 
G 
7G	$%   	 	r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r;    r   r   r   r      s1    
  	 
 	- 7 7%	r   r   N)r?   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r)   googlecloudsdk.callioper   9googlecloudsdk.command_lib.compute.project_zonal_metadatar	   googlecloudsdk.corer
   r   ReleaseTracksr    ALPHABETAGAUpdateCommandr   rB   r   r   <module>rM      s    > &  ' 7 ] ( K # * T..33T5F5F5I5IE	$$$ E	E	r   