
    
                     >   S 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
  \R                  " \R                  R                  \R                  R                  \R                  R                  5      \R                    " S S	\R"                  5      5       5       rg
)z'Sets the IAM policy for the repository.    )absolute_import)division)unicode_literals)
sourcerepo)base)iam_utilc                   .    \ rS rSrSr\S 5       rS rSrg)SetIamPolicy   zSet 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                 |    U R                  SSSS9  U R                  SSS9  U R                  R                  S5        g )	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ArgsSetIamPolicy.Args,   sP    
)0I  K
3  5
 !!),    c                 J   [         R                  " UR                  5      n[         R                  " 5       n[        R
                  " UR                  UR                  R                  5      u  pEUR                  X$5      n[        R                  " UR                  5       S5        U$ )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   RunSetIamPolicy.Run7   sy     

tyy
)C F"<<&//002F  -FSXXZ0Mr    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r+   __static_attributes__r-   r   r   r
   r
      s     
 - -r   r
   N)r2   
__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   