
                         ,   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  ej                  ej                  j                  ej                  j                   ej                  j"                         G d	 d
ej$                               Zy)zMCommand to list Organization Policies associated with the specified resource.    )absolute_import)division)unicode_literals)org_policies)base)org_policies_base)org_policies_flagsc                   F    e Zd ZdZed        Zd Zed        Zed        Zy)Lista  List Organization Policies associated with the specified resource.

  ## EXAMPLES

  The following command lists all set Organization Policies associated with
  project `foo-project`:

    $ {command} --project=foo-project

  The following command lists all available constraints in addition to set
  Organization Policies associated with project `foo-project`:

    $ {command} --project=foo-project --show-unset
  c                     t        j                  |        t        j                  ddddd      j	                  |        | j
                  j                  d       y )Nz--show-unset
store_trueFz
        Show available constraints. For more information about constraints, see
        https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints
        )actionrequireddefaulthelpz
          table(
            constraint,
            listPolicy.yesno(no="-", yes="SET"),
            booleanPolicy.yesno(no="-", yes="SET"),
            etag
          )
        )flagsAddParentResourceFlagsToParserr   ArgumentAddToParserdisplay_info	AddFormat)parsers    1lib/surface/resource_manager/org_policies/list.pyArgsz	List.Args.   sR    	((0MM [ 
!! #     c                    t        j                  |      }|j                  | j                  |            }|j                  r|j                  | j                  |            }|j                  D cg c]  }|j                   }}t        j                         }|j                  D ]F  }|j                  |vs|j                  j                  |j                  |j                               H |j                  S c c}w )N)
constraint)r   OrgPoliciesServiceListOrgPoliciesListOrgPoliciesRequest
show_unset!ListAvailableOrgPolicyConstraints(ListAvailableOrgPolicyConstraintsRequestpoliciesr   r   OrgPoliciesMessagesconstraintsnameappend	OrgPolicy)	selfargsserviceresponser&   policyexisting_policiesmessagesr   s	            r   RunzList.RunC   s    2248G&&t'B'B4'HIH==

7
7
=?k;C;L;LM;L6,,;LM113h#//*??"33



"
"  JOO <> 0
  Ns   0C:c                 0   t        j                         }t        j                  |       }|j	                         }| j
                  r|j                  ||      S | j                  r|j                  ||      S | j                  r|j                  ||      S y )N)
projectsIdlistOrgPoliciesRequest)organizationsIdr4   )	foldersIdr4   )r   r%   r   GetResourcer    project2CloudresourcemanagerProjectsListOrgPoliciesRequestorganization7CloudresourcemanagerOrganizationsListOrgPoliciesRequestfolder1CloudresourcemanagerFoldersListOrgPoliciesRequestr+   r0   resource_idrequests       r   r    zList.ListOrgPoliciesRequestT   s    //1H#//5K--/G||HH  I B B			MM%g N G G	GG H A Ar   c                 0   t        j                         }t        j                  |       }|j	                         }| j
                  r|j                  ||      S | j                  r|j                  ||      S | j                  r|j                  ||      S y )N)r3   (listAvailableOrgPolicyConstraintsRequest)r5   rB   )r6   rB   )r   r%   r   r7   r#   r8   DCloudresourcemanagerProjectsListAvailableOrgPolicyConstraintsRequestr:   ICloudresourcemanagerOrganizationsListAvailableOrgPolicyConstraintsRequestr<   CCloudresourcemanagerFoldersListAvailableOrgPolicyConstraintsRequestr>   s       r   r#   z-List.ListAvailableOrgPolicyConstraintsRequestd   s    //1H#//5K??AG||ZZ 3: [ < < 
		__%3: ` < < 
YY3: Z < < r   N)	__name__
__module____qualname____doc__staticmethodr   r1   r    r#    r   r   r   r      sH      ("    r   r   N)rI   
__future__r   r   r   'googlecloudsdk.api_lib.resource_managerr   googlecloudsdk.callioper   +googlecloudsdk.command_lib.resource_managerr   r	   r   ReleaseTracksReleaseTrackALPHABETAGAListCommandr   rK   r   r   <module>rV      s|     T &  ' @ ( I S D%%++T->->-C-C%%((*[4 [*[r   