
    K                     f    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  G d d	e      Zy
)zDesignCenter Spaces API.    )absolute_import)division)unicode_literals)utils)base)iam_utilc                   Z    e Zd ZdZej
                  j                  fdZd Zd Z	d Z
d Zy)SpacesClientz'Client for Spaces in design center API.c                     t        j                  |      | _        t        j                  |      | _        | j                  j
                  | _        y )N)api_lib_utilsGetClientInstanceclientGetMessagesModulemessagesprojects_locations_spaces_spaces_client)selfrelease_tracks     2lib/googlecloudsdk/api_lib/design_center/spaces.py__init__zSpacesClient.__init__   s8    11-@DK!33MBDM++??D    c                 p    | j                   j                  |      }| j                  j                  |      S )zFetch the IAM Policy attached to the sepcified space.

    Args:
      space_id: str, the space id.

    Returns:
      The spaces's IAM Policy.
    )resource)r   6DesigncenterProjectsLocationsSpacesGetIamPolicyRequestr   GetIamPolicy)r   space_idget_reqs      r   r   zSpacesClient.GetIamPolicy"   s=     	LL 	M 	
 
 ++G44r   c                 z    t        j                  || j                  j                        }| j	                  ||      S )a  Sets an space's IamPolicy to the one provided.

    If 'policy_file' has no etag specified, this will BLINDLY OVERWRITE the IAM
    policy!

    Args:
        space_id: str, the space id..
        policy_file: a policy file.

    Returns:
        The IAM Policy.
    )r   ParsePolicyFiler   Policy_SetIamPolicyHelper)r   r   policy_filepolicys       r   SetIamPolicyzSpacesClient.SetIamPolicy3   s3     %%k4==3G3GHF##Hf55r   c                     | j                   j                  || j                   j                  |            }| j                  j	                  |      S )N)r#   )r   setIamPolicyRequest)r   6DesigncenterProjectsLocationsSpacesSetIamPolicyRequestSetIamPolicyRequestr   r$   )r   r   r#   set_reqs       r   r!   z SpacesClient._SetIamPolicyHelperC   sV    LL $ A A !B !  	M 	
  ++G44r   c                     | j                   j                  |      }| j                   j                  ||      }| j                  j	                  |      S )zTests the IAM permissions for the specified space.

    Args:
      space_id: str, the space id.
      permissions: list of str, the permissions to test.

    Returns:
      The TestIamPermissionsResponse.
    )permissions)r   testIamPermissionsRequest)r   TestIamPermissionsRequest<DesigncenterProjectsLocationsSpacesTestIamPermissionsRequestr   TestIamPermissions)r   r   r+   test_iam_perm_reqtest_reqs        r   r/   zSpacesClient.TestIamPermissionsL   s`     ?? @ ! 	RR&7 	S 	
 
 11(;;r   N)__name__
__module____qualname____doc__r   ReleaseTrackALPHAr   r   r$   r!   r/    r   r   r
   r
      s.    /#'#4#4#:#: @
5"6 5<r   r
   N)r5   
__future__r   r   r   $googlecloudsdk.api_lib.design_centerr   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   objectr
   r8   r   r   <module>r>      s*     &  ' G ( 3C<6 C<r   