
    S                        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 dd
lmZ ddlmZ d Zd Z ej$                  ej&                  j(                         G d dej*                               Z ej$                  ej&                  j.                  ej&                  j0                         G d dej*                               Zy)zSet the IAM policy for a model.    )absolute_import)division)unicode_literals)models)base)iam_util)endpoint_util)flags)models_util)region_utilc                     t        j                  ddd      j                  |        t        j                  d      j                  |        t	        j
                  |        y )NTzto set IAM policy for)
positionalrequiredverb)include_global)r
   GetModelResourceArgAddToParserGetRegionArgr   AddArgForPolicyFileparsers    0lib/surface/ai_platform/models/set_iam_policy.py_AddSetIamPolicyArgsr      sI    "$$/K$7D)55f=
v&    c                     t        j                  |       }t        j                  |      5  t	        j
                  t        j                         | j                  | j                        cd d d        S # 1 sw Y   y xY w)N)region)
r   	GetRegionr	   MlEndpointOverridesr   SetIamPolicyr   ModelsClientmodelpolicy_file)argsr   s     r   _Runr$   &   sT      &&((7##F$7$7$94::$($4$46 877s   =A33A<c                   &    e Zd ZdZed        Zd Zy)SetIamPolicyGA  Set the IAM policy for a model.

  Sets the IAM policy for the given model as defined in a JSON or YAML file.

  See https://cloud.google.com/iam/docs/managing-policies for details of
  the policy file format and contents.

  ## EXAMPLES
  The following command will read am IAM policy defined in a JSON file
  'policy.json' and set it for the model `my_model`:

    $ {command} my_model policy.json
  c                     t        |        y Nr   r   s    r   ArgszSetIamPolicyGA.Args=   
     r   c                     t        |      S r)   r$   selfr#   s     r   RunzSetIamPolicyGA.RunA       :r   N__name__
__module____qualname____doc__staticmethodr+   r1    r   r   r&   r&   -         ! !r   r&   c                   &    e Zd ZdZed        Zd Zy)SetIamPolicyBetar'   c                     t        |        y r)   r*   r   s    r   r+   zSetIamPolicyBeta.ArgsU   r,   r   c                     t        |      S r)   r.   r/   s     r   r1   zSetIamPolicyBeta.RunY   r2   r   Nr3   r9   r   r   r<   r<   E   r:   r   r<   N)r7   
__future__r   r   r    googlecloudsdk.api_lib.ml_enginer   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   $googlecloudsdk.command_lib.ml_enginer	   r
   r   r   r   r$   ReleaseTracksReleaseTrackGACommandr&   ALPHABETAr<   r9   r   r   <module>rJ      s    & &  ' 3 ( 3 > 6 < <'6 D%%(()T\\  *. D%%++T->->-C-CDt||  Er   