
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSS.rSS jr\	R*                  " \	R,                  R.                  5       " S S\	R0                  5      5       r\	R*                  " \	R,                  R4                  5       " S S\5      5       r\	R*                  " \	R,                  R8                  5       " S S\5      5       rg)z$Command for labels update to images.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)flags)labels_util)
exceptions)logz6*{command}* updates labels for a Compute Engine image.a        To update labels ``k0'' and ``k1'' and remove labels with key ``k3'', run:

        $ {command} example-image --update-labels=k0=value1,k1=value2 --remove-labels=k3

        k0 and k1 will be added as new labels if not already present.

      Labels can be used to identify the image and to filter them like:

        $ {parent_command} list --filter='labels.k1:value2'

      To list only the labels when describing a resource, use --format:

        $ {parent_command} describe example-image --format="default(labels)"

    )DESCRIPTIONEXAMPLESc                 x   [         R                  " SS9Ul        UR                  R                  USS9  [        R
                  " U5        UR                  SSS9  UR                  SS	S9  U R                  R                  nUR                  R                  /n[        UR                  5        Vs/ s H  ofU;  d  M
  UPM     sn5      nUR                  S
USS9  U(       aV  UR                  5       nUR                  S[        R                  " 5       S[        R                   SS9  UR                  SSSS9  ggs  snf )z5Add arguments used for parsing in all command tracks.F)pluralupdate)operation_typez--descriptionz+An optional text description for the image.)helpz--familyzName of the image family to use. If an image family is specified when you create an instance or disk, the latest non-deprecated image in the family is used.z--architecturezSpecifies the architecture or processor type that this image can support. For available processor types on Compute Engine, see https://cloud.google.com/compute/docs/cpu-platforms.)choicesr   z--update-user-licensesLICENSEzList of user licenses to be updated on an image. These user licenses replace all existing user licenses. If this flag is not provided, all existing user licenses remain unchanged.)typemetavaractionr   z--clear-user-licenses
store_truez.Remove all existing user licenses on an image.)r   r   N)images_flagsMakeDiskImageArgDISK_IMAGE_ARGAddArgumentr
   AddUpdateLabelsFlagsadd_argumentImageArchitectureValueValuesEnumARCHITECTURE_UNSPECIFIEDnamesortednamesadd_mutually_exclusive_groupr   ArgListUpdateAction)	messagesclsparsersupport_user_licensesarchitecture_enum_typeexcluded_enumsearchitecture_choicesscopes	            $lib/surface/compute/images/update.py_CommonArgsr3   5   sV   #44EB#   A""6*9  < 	:   $>>EE*CCHHI.(..0L0Q^4Kq0LN" @	  	 //1E	   "''E  G 
=  ?  Ms   .	D7;D7c                   T    \ rS rSrSrSr\r\S 5       r	S r
S	S jr\S
S j5       rSrg)Updateb   Update a Compute Engine image.Nc                 `    U R                  SS9R                  R                  n[        X USS9  g )NTno_httpFr,   _GetApiHolderclientr)   r3   r*   r+   r)   s      r2   ArgsUpdate.Argsi   s-       .55>>HvUC    c                 "    U R                  USS9$ )NFr;   _Run)selfargss     r2   Run
Update.Runn   s    99T977rB   c           	         [         R                  " U R                  5       5      nUR                  nUR                  R                  nU R
                  R                  XR                  [        R                  " U5      S9n/ nS n[        R                  R                  U5      n	U	R                  5       (       a  UR                  R                  R                  R!                  UR"                  " S0 UR%                  5       D65      n
U	R'                  UR(                  R*                  U
R,                  5      nUR.                  (       ao  UR1                  UR2                  UR4                  UR)                  U
R6                  UR,                  S9S9nUR9                  UR                  R                  SU45        SnUR;                  5       nUR=                  S5      (       a  UR>                  Ul        SnUR=                  S5      (       a  UR@                  Ul         SnUR=                  S	5      (       a,  UR:                  RC                  URD                  5      Ul"        SnU(       a]  UR=                  S
5      (       d  UR=                  S5      (       a1  UR=                  S
5      (       a  URF                  Ul$        O/ Ul$        SnU(       aQ  URK                  UR2                  UURM                  5       S9nUR9                  UR                  R                  SU45        / nURO                  X5      nU(       a  [P        RR                  " U5      eU(       a.  [T        RV                  RY                  SR[                  U5      5        U$ )N)scope_lister)labelFingerprintlabels)projectresourceglobalSetLabelsRequest	SetLabelsFfamilyTdescriptionarchitectureupdate_user_licensesclear_user_licenses)rN   imageResourceimagePatchzUpdated [{0}]. ).r   ComputeApiHolderReleaseTrackr>   r)   r   ResolveAsResource	resourcesr	   GetDefaultScopeListerr
   DiffFromUpdateArgsMayHaveUpdatesapitools_clientimagesGetComputeImagesGetRequestAsDictApplyGlobalSetLabelsRequestLabelsValuerM   needs_updateComputeImagesSetLabelsRequestrN   rX   rL   appendr    IsSpecifiedrR   rS   r!   rT   rU   userLicensesComputeImagesPatchRequestNameAsyncRequestsr   
MultiErrorr   statusPrintformat)rF   rG   r,   holderr>   r)   	image_refrequestsresultlabels_diffrX   labels_updaterequestshould_patchimage_resourceerrors_to_collects                   r2   rE   Update._Runq   s   **4+<+<+>?F]]F}}%%H##55008 6 :I HF ""11$7K!!##mm++2266

*
*
@Y-=-=-?
@Be!''

)
)
5
5u||Em 
	#	#88%%__++!&!7!7$++ , -	 9 . 	//66WMNL^^%N!!"kknl&&#'#3#3n l''$,NN$N$N


%n!l$"2"23I"J"J"&"2"23H"I"I			0	1	1&*&?&?#&(#l22##&  3 "g oov--44gwGH!!(>F!!"344	jj'..y9:MrB   c                 L    [         R                  " U R                  5       U5      $ N)r   r[   r\   )r*   r:   s     r2   r=   Update._GetApiHolder   s    (()9)9);WEErB   rZ   TF)__name__
__module____qualname____firstlineno____doc__r   DETAILED_HELPdetailed_helpclassmethodr@   rH   rE   r=   __static_attributes__rZ   rB   r2   r5   r5   b   sE    &.-D D8EN F FrB   r5   c                   :    \ rS rSrSrSr\r\S 5       r	SS jr
Srg)
UpdateBeta   r7   Nc                 `    U R                  SS9R                  R                  n[        X USS9  g NTr9   r;   r<   r?   s      r2   r@   UpdateBeta.Args   -       .55>>HvTBrB   c                 $    U R                  U5      $ r   rD   rF   rG   support_update_architectures      r2   rH   UpdateBeta.Run       99T?rB   rZ   r   r   r   r   r   r   r   r   r   r   r@   rH   r   rZ   rB   r2   r   r      (    &.-C CrB   r   c                   :    \ rS rSrSrSr\r\S 5       r	SS jr
Srg)UpdateAlpha   r7   Nc                 `    U R                  SS9R                  R                  n[        X USS9  g r   r<   r?   s      r2   r@   UpdateAlpha.Args   r   rB   c                 $    U R                  U5      $ r   rD   r   s      r2   rH   UpdateAlpha.Run   r   rB   rZ   r   r   rZ   rB   r2   r   r      r   rB   r   Nr   )r   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   )googlecloudsdk.command_lib.compute.imagesr   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer   r   r   r3   ReleaseTracksr\   GAUpdateCommandr5   BETAr   ALPHAr   rZ   rB   r2   <module>r      s    + &  ' 7 0 ( 4 K < * # 	A		.*?Z D%%(()WFT WF *WFt D%%**+  , D%%++,*  -rB   