
    
                     >   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
  ej                  ej                  j                  ej                  j                  ej                  j                        ej                    G d d	ej"                                      Zy
)z'Sets the IAM policy for the repository.    )absolute_import)division)unicode_literals)
sourcerepo)base)iam_utilc                   &    e Zd ZdZed        Zd Zy)SetIamPolicya  Set the IAM policy for the named repository.

  This command sets the IAM policy for the given repository from the
  policy in the provided file.

  ## EXAMPLES

  To set the IAM policy, issue the following command:

    $ {command} REPOSITORY_NAME POLICY_FILE

  c                     | j                  ddd       | j                  dd       | j                  j                  d       y )	NnameREPOSITORY_NAMEzName of the repository.)metavarhelppolicy_filezsJSON or YAML file with IAM policy. See https://cloud.google.com/resource-manager/reference/rest/Shared.Types/Policy)r   default)add_argumentdisplay_info	AddFormat)parsers    *lib/surface/source/repos/set_iam_policy.pyArgszSetIamPolicy.Args,   sP    
)0I  K
3  5
 !!),    c                 F   t        j                  |j                        }t        j                         }t	        j
                  |j                  |j                  j                        \  }}|j                  ||      }t	        j                  |j                         d       |S )a  Sets the IAM policy for the repository.

    Args:
      args: argparse.Namespace, the arguments this command is run with.

    Returns:
      (sourcerepo_v1_messsages.Policy) The IAM policy.

    Raises:
      sourcerepo.RepoResourceError: on resource initialization errors.
      iam_util.BadFileException: if the YAML or JSON file is malformed.
      iam_util.IamEtagReadError: if the etag is badly formatted.
      apitools.base.py.exceptions.HttpError: on request errors.
    repo)r   	ParseRepor   Sourcer   ParseYamlOrJsonPolicyFiler   messagesPolicyr
   LogSetIamPolicyName)selfargsressourcepolicyunused_maskresults          r   RunzSetIamPolicy.Run7   s}     

tyy
)C F"<<&//002FK  f-FSXXZ0Mr   N)__name__
__module____qualname____doc__staticmethodr   r)    r   r   r
   r
      s     
 - -r   r
   N)r-   
__future__r   r   r   googlecloudsdk.api_lib.sourcer   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   ReleaseTracksReleaseTrackGAALPHABETADefaultUniverseOnlyUpdateCommandr
   r/   r   r   <module>r;      s    . &  ' 4 ( 3 $++1143D3D3I3I .4%% . .r   