
                         R   d Z ddlmZ ddlmZ ddlmZ ddl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"                  e
j$                  j&                  e
j$                  j(                  e
j$                  j*                         G d
 de
j,                                      Zy)z9Command to update a policy on the given attachment point.    )absolute_import)division)unicode_literalsN)policies)base)policies_flags)logc                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)UpdatezDUpdate the policy on the given attachment point with the given name.EXAMPLESaP            The following command updates the IAM policy ``my-deny-policy'', which
          is attached to the resource project ``123'' and has the etag ``abc'':

            $ {command} my-deny-policy --attachment-point=cloudresourcemanager.googleapis.com/projects/123 --kind=denypolicies --policy-file=policy.json --etag=abc
          c                 b   t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j
                         j                  |        t        j                         j                  |        y )N)flagsGetAttachmentPointFlagAddToParserGetKindFlagGetPolicyIDFlagGetPolicyFileFlagGetEtagFlag)parsers    "lib/surface/iam/policies/update.pyArgszUpdate.Args-   su    	  "..v6	##F+	''/	))&1	##F+    c                 t   |j                   j                         }t        j                  |      }t        j                  |      }|j
                  j                  dd      }dddd}|t        j                  j                  k(  r+t        j                  |j                  |j                        }nr|t        j                  j                  k(  r+t        j                  |j                  |j                        }n*t        j                  |j                  |j                        }dj                  ||j                   |j"                        |_        |j&                  }||j&                  }||_        |j(                  j+                  |      }	t-        j.                  |	j$                  ||j                      d	       |	S )
N/z%2F
denyPolicyprincipalAccessBoundaryPolicyaccessboundaryPolicy)denypoliciesprincipalaccessboundarypoliciesaccessboundarypolicieszpolicies/{}/{}/{}T)is_async)calliope_commandReleaseTrackapisGetClientInstanceGetMessagesModuleattachment_pointreplacer   ALPHAParseYamlOrJsonPolicyFilepolicy_fileGoogleIamV2alphaPolicyBETAGoogleIamV2betaPolicyGoogleIamV2Policyformatkind	policy_idnameetagr   r   r	   UpdatedResource)
selfargsrelease_trackclientmessagesr'   kindspolicyr4   results
             r   Runz
Update.Run5   so   ))668M##M2F%%m4H,,44S%@ %+J"8E ))///--d.>.>.6.M.MOf	$++00	0--d.>.>.6.L.LNf --d.>.>.6.H.HJf &,,-=tyy-1^^=FK 99D|[[dFK__##F+FU499%5EMr   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r>    r   r   r   r      s@     M 
(//  - , ,"r   r   )rB   
__future__r   r   r   rC   googlecloudsdk.api_lib.iamr   r$   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   r   googlecloudsdk.corer	   UniverseCompatibleReleaseTracksr#   r)   r-   GAUpdateCommandr   rG   r   r   <module>rQ      s    @ &  '  7 ( B # D%%++T->->-C-C%%((*7T 7* 7r   