
    N                     |   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                   e	j"                  j$                         G d	 d
e	j&                                      Ze	j                   e	j                   e	j"                  j*                         G d de                    Zy)z Set the IAM policy for a secret.    )absolute_import)division)unicode_literals)api)base)iam_util)argsc                   .    e Zd ZdZddiZed        Zd Zy)SetIamPolicyzSet the IAM policy binding for a secret.

  Sets the IAM policy for the given secret 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.
  EXAMPLESz          The following command will read an IAM policy defined in a JSON file
    'policy.json' and set it for the secret 'my-secret':

        $ {command} my-secret policy.json
          c                    t        j                  | dddd       t        j                  | dd       t        j                  |        t
        j                  j                  |        t
        j                  j                  |        t
        j                  j                  |        t
        j                  j                  |        t
        j                  j                  |        y )N Tz3Name of the secret for which to set the IAM policy.)purpose
positionalrequired	help_textzto set iam policyF)r   hidden)secrets_args	AddSecretAddLocationr   AddArgForPolicyFiler   URI_FLAGRemoveFromParserFILTER_FLAG
LIMIT_FLAGPAGE_SIZE_FLAGSORT_BY_FLAG)parsers    %lib/surface/secrets/set_iam_policy.pyArgszSetIamPolicy.Args/   s    G V-@O  (MM""6*%%f-OO$$V,((0&&v.    c                    t        j                  | j                               }|j                  j                  j                         }t        j                  |      }t        j                  |j                  |j                        \  }}t        j                  |      j                  ||||j                        }t        j                  |j                         d       |S )N)version)api_version)secret_locationsecret)secrets_apiGetApiFromTrackReleaseTrackCONCEPTSr&   ParseGetMessagesr   ParseYamlOrJsonPolicyFilepolicy_filePolicySecretsr   locationLogSetIamPolicyName)selfr	   r$   
secret_refmessagespolicyupdate_maskresults           r   RunzSetIamPolicy.Run@   s    --d.?.?.ABK%%++-J&&{;H"<<(//FK   [9FFFK G F Z__.9Mr!   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr    r:    r!   r   r   r      s1      - / / r!   r   c                       e Zd ZdZddiZy)SetIamPolicyBetazSet the IAM policy for a secret.

  Sets the IAM policy for the given secret.

  Returns an empty policy if the resource does not have a policy
  set.
  r   z|          To print the IAM policy for secret named 'my-secret', run:

        $ {command} my-secret [--location=]
          N)r;   r<   r=   r>   r?   rA   r!   r   rC   rC   N   s      -r!   rC   N)r>   
__future__r   r   r   googlecloudsdk.api_lib.secretsr   r'   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   "googlecloudsdk.command_lib.secretsr	   r   DefaultUniverseOnlyReleaseTracksr)   GAListCommandr   BETArC   rA   r!   r   <module>rN      s    ' &  ' = ( 3 C D%%(().4## . * .b D%%**+|  , r!   