
    8              	          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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rSr\R>                  \R@                  " \RB                  RD                  5      \
RF                  " \
RH                  RJ                  5       " S S\RL                  \
RN                  5      5       5       5       r(\R>                  \R@                  " \RB                  RR                  5      \
RF                  " \
RH                  RR                  5       " S S\(5      5       5       5       r*\R>                  \R@                  " \RB                  RV                  5      \
RF                  " \
RH                  RX                  5       " S S\(5      5       5       5       r-g)zdeployments update command.    )absolute_import)division)unicode_literals)
exceptions)dm_api_util)dm_base)	dm_labels)apis)base)alpha_flags)dm_util)dm_write)flags)importer)	arg_utils)labels_util)log)
propertiesNi  c                      \ rS rSrSrSS0r\R                  " \R                  " SS5      R                  R                  5      r\R                  " S\R                  " SS5      R                  R                  SS	S
9r\R                  " S\R                  " SS5      R                  R                  SS	S
9r\\R(                  R*                  4S j5       rS rS rS rSrg)Update.   Update a deployment based on a provided config file.

This command will update a deployment with the new config file provided.
Different policies for create, update, and delete policies can be specified.
EXAMPLESa  
To update an existing deployment with a new config YAML file, run:

  $ {command} my-deployment --config=new_config.yaml

To update an existing deployment with a new config template file, run:

  $ {command} my-deployment --template=new_config.{jinja|py}

To update an existing deployment with a composite type as a new config, run:

  $ {command} my-deployment --composite-type=<project-id>/composite:<new-config>


To preview an update to an existing deployment without actually modifying the resources, run:

  $ {command} my-deployment --config=new_config.yaml --preview

To apply an update that has been previewed, provide the name of the previewed deployment, and no config file:

  $ {command} my-deployment

To specify different create, update, or delete policies, include any subset of the following flags:

  $ {command} my-deployment --config=new_config.yaml --create-policy=acquire --delete-policy=abandon

To perform an update without waiting for the operation to complete, run:

  $ {command} my-deployment --config=new_config.yaml --async

To update an existing deployment with a new config file and a fingerprint, run:

  $ {command} my-deployment --config=new_config.yaml --fingerprint=deployment-fingerprint

Either the `--config`, `--template`, or `--composite-type` flag is required unless launching an already-previewed update to a deployment. If you want to update a deployment's metadata, such as the labels or description, you must run a separate command with `--update-labels`, `--remove-labels`, or `--description`, as applicable.

More information is available at https://cloud.google.com/deployment-manager/docs/deployments/updating-deployments.
deploymentmanagerv2z--create-policyz;Create policy for resources that have changed in the updatezcreate-or-acquire)help_strdefaultv2betac                    [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        U R	                  SSSS9  U R                  5       n[         R                  " U5        U[        R                  R                  [        R                  R                  4;   a  UR	                  SSSS9  [        R                  " U SS	9  U R	                  S
SSSSS9  U[        R                  R                  [        R                  R                  4;   a*  [        R                  R                  R!                  U 5        O)[        R"                  R                  R!                  U 5        [        R$                  R                  R!                  U 5        [         R&                  " U 5        U R(                  R+                  [         R,                  5        g)a@  Args is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go
      on the command line after this command. Positional arguments are
      allowed.
  version: The version this tool is running as. base.ReleaseTrack.GA
      is the default.
z--descriptionz&The new description of the deployment.description)helpdestz--manifest-idzMManifest Id of a previous deployment. This flag cannot be used with --config.manifest_idF)enable_clearz	--previewzdPreview the requested update without making any changes to the underlying resources. (default=False)preview
store_true)r!   r"   r   actionN)r   AddDeploymentNameFlagAddPropertiesFlagAddAsyncFlagadd_argumentadd_mutually_exclusive_groupAddConfigFlagsr   ReleaseTrackALPHABETAr   AddUpdateLabelsFlagsr   _create_policy_v2beta_flag_map
choice_argAddToParser_create_policy_flag_map_delete_policy_flag_mapAddFingerprintFlagdisplay_info	AddFormatRESOURCES_AND_OUTPUTS_FORMAT)parserversiongroups      4lib/surface/deployment_manager/deployments/update.pyArgsUpdate.Argss   s~    
'	F#	v
5   //1E	4$$**D,=,=,B,BCC
4	   $$V%@
0   4$$**D,=,=,B,BCC++66BB6J$$//;;FC
""--99&A	V$
!!%"D"DE    c                 R    U(       d   [         R                  R                  S5        gg)zCalled after resources are displayed if the default format was used.

Args:
  resources_were_displayed: True if resources were displayed.
z1No resources or outputs found in your deployment.N)r   statusPrint)selfresources_were_displayeds     r>   EpilogUpdate.Epilog   s     $	jjJK $rA   c           
      P   U R                   R                  UR                  S[        R                  R
                  R                  R                  0SS9nUR                  S5      (       d&  UR                  (       a  [        R                  Ul        SnU R                  R                  UR                  S9nUR                   c  UR"                  c  UR$                  bP  [&        R(                  " U R                  UR                   UR"                  UR$                  UR                  S9Ul        OU R-                  5       [.        R,                  R0                  [.        R,                  R2                  4;   av  UR4                  (       ae  [&        R6                  " U R8                  U R                  [:        R<                  " 5       UR                  UR4                  UR                  5      Ul         U R8                  R>                  RA                  U R                  RC                  [:        R<                  " 5       UR                  S	95      nURD                  (       a&  [F        RH                  " URD                  5      Ul"        OURD                  =(       d    S
Ul"        U R-                  5       [.        R,                  R0                  4;   aA  URJ                  (       a0  [F        RL                  " U R                  URJ                  5      Ul%        U RO                  X5      Ul(        U R-                  5       [.        R,                  RR                  L =(       d    UR4                  (       + nUR                   (       + =(       a:    U=(       a1    [U        URV                  5      =(       d    [U        URX                  5      nURZ                  c  URZ                  Ul-        OJURZ                  (       a  URZ                  R]                  5       (       a  SUl-        OURZ                  Ul-         U(       a  [        Rj                  Ul         [l        Rn                  Rq                  URr                  5      Rt                  nU R-                  5       [.        R,                  R0                  [.        R,                  R2                  4;   a4  [l        Rv                  Rq                  URx                  5      Rt                  n	O3[l        Rz                  Rq                  URx                  5      Rt                  n	U R                  R}                  U[:        R<                  " 5       UR                  UR~                  U R                  R|                  R                  U	5      U R                  R|                  R                  U5      S9n
U R8                  n[        R                  " U5      UR                  S'   UR>                  Rm                  U
5      n[f        R                  " U R8                  U R                  [:        R<                  " 5       UR                  5      nU(       aH  UR                  (       a  [        R                  " S5        [        R                  R                  S5        U$ [F        R                  " URD                  5        UR                  (       a  U$ URt                  n [        R                  " U R8                  U R                  US[:        R<                  " 5       [        S9n[F        R                  " US5        [f        R                  " U R8                  U R                  [:        R<                  " 5       UR                  5      $ ! [^        R`                   a*  n[b        Rd                  " U[f        Rh                  5      eSnAff = f! [^        R`                   a*  n[b        Rd                  " U[f        Rh                  5      eSnAff = f! [^        R`                   a*  n[b        Rd                  " U[f        Rh                  5      eSnAff = f)as  Run 'deployments update'.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Returns:
  If --async=true, returns Operation to poll.
  Else, returns a struct containing the list of resources and list of
    outputs in the deployment.

Raises:
  HttpException: An http error response was received while executing api
      request.
projectzdeploymentmanager.deployments)params
collectionformatF)nameN)configtemplatecomposite_typer   )rJ   
deploymentrA   )deploymentResourcerJ   rR   r%   createPolicydeletePolicyzX-Cloud-DM-PatchzEUpdating Deployment metadata is synchronous, --async flag is ignored.z2Update deployment metadata completed successfully.update)timeoutr   )P	resourcesParsedeployment_namer   VALUEScorerJ   	GetOrFailIsSpecifiedasync_r   OPERATION_FORMATrM   messages
DeploymentrR   rO   rP   rQ   r   BuildTargetConfigtargetr.   r   r/   r0   r#   BuildTargetConfigFromManifestclientr   
GetProjectdeploymentsGet&DeploymentmanagerDeploymentsGetRequestfingerprintr   DecodeFingerprint
credentialCredentialFrom_GetUpdatedDeploymentLabelslabelsGAboolupdate_labelsremove_labelsr    isspaceapitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATDEPLOYMENT_FORMATr   r6   GetEnumForChoicedelete_policyrN   r2   create_policyr5   )DeploymentmanagerDeploymentsUpdateRequestr%   CreatePolicyValueValuesEnumDeletePolicyValueValuesEnumsix	text_typeadditional_http_headersFetchDeploymentr   warningrC   rD   PrintFingerprintr   WaitForOperationOPERATION_TIMEOUTLogOperationStatusFetchResourcesAndOutputs)rE   argsdeployment_refpatch_requestrR   current_deploymentno_manifesterrorparsed_delete_flagparsed_create_flagrequestrf   	operationupdated_deploymentop_names                  r>   Run
Update.Run   s=     ^^)):,,1199CCD2 * 4N H%%$++**dkM))&& * J KKDMM$9##+"44
--==,,__&j 


$"3"3"9"9"&"3"3"8"8": :"@@
++t}}





#
#T%5%5tHj
(K;;2266
--
>
>((*'22 ?  
		!(!:!:4;K;K!L

 "4!?!?!F3
 
			!2!2!8!8 9	9doo ' 6 6t}}7;!H

 ::
$j &&(&&))* C262B2B.B ++o @+ @
t!!
"
>d4+=+=&> 				!!3!?!?
4#3#3#;#;#=#=!%
!%!1!1
 ++dk)K!99JJ


"d 				



!
!4#4#4#9#9! 
 11BB""$$(D 	
 **;;""$$(D 	 GG'$$&#..,,OO334FGOO334FG H Jg {{f;>==
<f$$%78$$++G4i '66
++t}}g&8&8&:

#
#% 
;;
++ 	

MN!!1==> {{g
M--KKMM %'	 	""9h7 11$++t}}292D2D2F2@2K2KM M (( K$$UK,I,IJJKZ (( K$$UK,I,IJJK !** M&&uk.K.KLLMs]   )G!]% 7]% ]% 2I^&   ^&  A_' %^#9%^^#&_$:%__$'`%;%`  `%c                     [         R                  " U5      n[         R                  " U5      n[        R                  " UR
                  U R                  R                  X45      $ )N)r   GetUpdateLabelsDictFromArgsGetRemoveLabelsListFromArgsr	   UpdateLabelsrp   ra   DeploymentLabelEntry)rE   r   rR   rs   rt   s        r>   ro   "Update._GetUpdatedDeploymentLabelsE  sO    ;;DAM;;DAM!!*"3"3"&--"D"D"/@ @rA    N)__name__
__module____qualname____firstlineno____doc__detailed_helpr   GetDeleteFlagEnumMapr
   GetMessagesModuler~   r   r6   r   ChoiceEnumMapperr   r5   r2   staticmethodr   r.   rq   r?   rG   r   ro   __static_attributes__r   rA   r>   r   r   .   s      %'-R "66148112M2MP &66148112M2ML!# $-#=#=18<112M2ML!$#  ,,// 0F 0FdLTMl@rA   r   c                   (    \ rS rSrSr\S 5       rSrg)UpdateAlphaiM  r   c                     [         R                  U [        R                  R                  S9  [
        R                  " U 5        U R                  R                  [
        R                  5        g N)r<   )
r   r?   r   r.   r/   r   AddCredentialFlagr8   r9   r:   r;   s    r>   r?   UpdateAlpha.ArgsW  sF    
KK 1 1 7 7K8!!&)
!!+"J"JKrA   r   Nr   r   r   r   r   r   r?   r   r   rA   r>   r   r   M  s     L LrA   r   c                   (    \ rS rSrSr\S 5       rSrg)
UpdateBetai^  r   c                 \    [         R                  U [        R                  R                  S9  g r   )r   r?   r   r.   r0   r   s    r>   r?   UpdateBeta.Argsh  s    
KK 1 1 6 6K7rA   r   Nr   r   rA   r>   r   r   ^  s     8 8rA   r   ).r   
__future__r   r   r   apitools.base.pyr   rv   )googlecloudsdk.api_lib.deployment_managerr   r   r	   googlecloudsdk.api_lib.utilr
   googlecloudsdk.callioper   -googlecloudsdk.command_lib.deployment_managerr   r   r   r   r   $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   r   UnicodeIsSupportedReleaseTracksr.   rq   UseDmApiDmApiVersionV2UpdateCommand	DmCommandr   r/   r   r0   V2BETAr   r   rA   r>   <module>r      s    " &  ' > A = ? , ( . E A B ? B : < # * 
   D%%(()'&&))*Y@T!2!2 Y@ + * Y@x D%%++,'&&,,-L& L . - L D%%**+'&&--.	8 	8 / , 	8rA   