
                         8   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  e	j                  e	j                  j                   e	j                  j"                  e	j                  j$                         G d
 de	j&                               Zy)z+Command to describe an Organization Policy.    )absolute_import)division)unicode_literals)
exceptions)org_policies)base)org_policies_base)org_policies_flagsc                   :    e Zd ZdZdZed        Zd Zed        Zy)Describea  Describe an Organization Policy.

  Describes an Organization Policy associated with the specified resource.

  ## EXAMPLES

  The following command retrieves an Organization Policy
  for constraint `serviceuser.services` on project `foo-project`:

    $ {command} serviceuser.services --project=foo-project

  The following command retrieves the effective Organization Policy
  for constraint `serviceuser.services` on project `foo-project`:

    $ {command} serviceuser.services --project=foo-project --effective
  zyThis policy has been set with Tags through Organization Policy V2 API, please use `gcloud org-policies` commands instead.c                     t        j                  |        t        j                  |        t        j                  ddddd      j                  |        y )Nz--effective
store_trueFzShow the effective policy.)actionrequireddefaulthelp)flagsAddIdArgToParserAddParentResourceFlagsToParserr   ArgumentAddToParser)parsers    5lib/surface/resource_manager/org_policies/describe.pyArgszDescribe.Args4   sE    	6"	((0MM)+
 ,7;v+>    c                 H   t        j                  |      }|j                  s`|j                  t        j                  |            }|j
                  .|j
                  dk(  rt        j                  | j                        |S |j                  | j                  |            }|S )N   )r	   OrgPoliciesService	effectiveGetOrgPolicyGetOrgPolicyRequestversionr   ResourceManagerErrorPOLICY_V2_WARNINGGetEffectiveOrgPolicyGetEffectiveOrgPolicyRequest)selfargsserviceresponses       r   RunzDescribe.Run?   s    2248G>>%%

/
/
57h				%(*:*:a*?--d.D.DEE O ..

+
+D
13hOr   c                 n   t        j                         }t        j                  |       }|j	                  t        j
                  | j                              }| j                  r|j                  ||      S | j                  r|j                  ||      S | j                  r|j                  ||      S y )N)
constraint)
projectsIdgetEffectiveOrgPolicyRequest)organizationsIdr/   )	foldersIdr/   )r   OrgPoliciesMessagesr	   GetResourcer&   FormatConstraintidproject8CloudresourcemanagerProjectsGetEffectiveOrgPolicyRequestorganization=CloudresourcemanagerOrganizationsGetEffectiveOrgPolicyRequestfolder7CloudresourcemanagerFoldersGetEffectiveOrgPolicyRequest)r(   mresource_idrequests       r   r&   z%Describe.GetEffectiveOrgPolicyRequestL   s    ((*A#//5K,,009 - ;G ||GG w H H H			LL%G M M M	FFg G G Gr   N)	__name__
__module____qualname____doc__r$   staticmethodr   r+   r&    r   r   r   r      s<    "+ ? ?  r   r   N)rB   
__future__r   r   r   'googlecloudsdk.api_lib.resource_managerr   r   googlecloudsdk.callioper   +googlecloudsdk.command_lib.resource_managerr	   r
   r   ReleaseTracksReleaseTrackALPHABETAGADescribeCommandr   rD   r   r   <module>rO      s{    2 &  ' > @ ( I S D%%++T->->-C-C%%((*>t## >*>r   