
                             S r SSKJr  SSKJr  SSKJr  SSK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S jrSS jrS rS rg)zUtilities for Policies API.    )absolute_import)division)unicode_literalsN)messages)encoding)apis)base)
exceptions)iam_util)yamlc                     U [         R                  R                  :X  a  [        R                  " SSUS9$ U [         R                  R
                  :X  a  [        R                  " SSUS9$ [        R                  " SSUS9$ )Niamv2alpha)no_httpv2betav2)r	   ReleaseTrackALPHAr   GetClientInstanceBETA)release_trackr   s     *lib/googlecloudsdk/api_lib/iam/policies.pyr   r   !   si    d''---!!%GDD))...!!%7CC!!%w??    c                 B    U=(       d    [        U 5      nUR                  $ N)r   MESSAGES_MODULE)r   clients     r   GetMessagesModuler   *   s    5&}5&			r   c           	         [         R                  " U 5      n [        R                  " X5      nU$ ! [        [
        R                  4 a?  n[        R                  " SR                  U [        R                  " U5      5      5      eSnAf[
        R                  [        R                  4 a?  n[        R                   " SR                  U [        R                  " U5      5      5      eSnAff = f)a  Create an IAM V2 Policy protorpc.Message from YAML or JSON formatted file.

Returns the parsed policy object.
Args:
  policy_file_path: Path to the YAML or JSON IAM policy file.
  policy_message_type: Policy message type to convert YAML to.

Returns:
  policy that is a protorpc.Message of type policy_message_type filled in
  from the JSON or YAML policy file
Raises:
  BadFileException if the YAML or JSON file is malformed.
  IamEtagReadError if the etag is badly formatted.
zKPolicy file [{0}] is not a properly formatted YAML or JSON policy file. {1}Nz<The etag of policy file [{0}] is not properly formatted. {1})r   	load_pathr   PyValueToMessageAttributeErrorapitools_messagesValidationErrorgcloud_exceptionsBadFileExceptionformatsix	text_typeDecodeErrorbinasciiErrorr   IamEtagReadError)policy_file_pathpolicy_message_typepolicy_to_parsepolicyes        r   ParseYamlOrJsonPolicyFiler3   /   s     NN#34/1&&':LF 
- +;;	< G

,
,	!6"2CMM!4DEG G 
'
'	8 1

#
#FMMcmmA.	01 11s!   0 C*
:B'C*+:C%%C*c                    [        U5      n[        U5      n/ nUS;   a  SR                  X5      nUR                  R	                  UR                  US95      R                  nU HF  nUR                  R                  UR                  UR                  S95      n	UR                  U	5        MH     U$ [        R                  " SU5      e)aJ  Gets the IAM Deny policies for an organization.

Args:
  resource_id: id for the resource
  resource_type: what type of a resource the id represents. Either
    organization, project, or folder
  release_track: ALPHA or BETA or GA

Returns:
  The output from the ListPolicies API call for deny policies for the passed
  resource.
)organizationfolderprojectzDpolicies/cloudresourcemanager.googleapis.com%2F{}s%2F{}/denypolicies)parent)nameresource_type)r   r   r'   policiesListPoliciesIamPoliciesListPoliciesRequestGetIamPoliciesGetRequestr9   appendr%   UnknownArgumentException)
resource_idr:   r   r   r   policies_to_returnattachment_pointpolicies_to_fetchpolicy_metadatar1   s
             r   ListDenyPoliciesrG   N   s     ]+&}-(;;]dd$ 44//# 	0 	%&&.h  -""

(
(o.B.B
(
CEf' -
 22?3@	B Br   )Fr   )__doc__
__future__r   r   r   r+   apitools.base.protorpcliter   r#   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   r
   r%   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer   r(   r   r   r3   rG    r   r   <module>rQ      sD    " &  '  D % , ( C 3 $ 
@ 
>#Br   