
                         j   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dZ ej$                  ej&                  j(                         G d dej*                               Z ej$                  ej&                  j.                         G d dej*                               Zy)z&Set the IAM policy for an application.    )absolute_import)division)unicode_literals)utils)client)base)flags)iam_utilz{description}a           To set the application IAM policy using a json file 'my_policy.json' for
        the Application `my-app` in location `us-east1`, run:

          $ {command} my-app --location=us-east1 /path/to/my_policy.json

        To set the application IAM policy using a yaml file 'my_policy.yaml` for
        the Application `my-app` in location `us-east1`, run:

          $ {command} my-app --location=us-east1 /path/to/my_policy.yaml
        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)SetIamPolicyGASet the IAM policy for an Apphub application as defined in a JSON/YAML file.

     See https://cloud.google.com/iam/docs/managing-policies for details of
        the policy file format and contents.
  c                 X    t        j                  |        t        j                  |        y Nr	   AddSetIamPolicyFlagsr
   AddArgForPolicyFileparsers    1lib/surface/apphub/applications/set_iam_policy.pyArgszSetIamPolicyGA.Args4       	v&  (    c                     t        j                  t        j                  j                        }t        j                  |      }|j                  |j                         |j                        S N)release_track)app_idpolicy_file)
apisApplicationsClientr   ReleaseTrackGAapi_lib_utilsGetApplicationRefSetIamPolicyRelativeNamer   selfargsr   app_refs       r   RunzSetIamPolicyGA.Run9   sZ    $$43D3D3G3GHF--d3G##%43C3C   r   N	__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr   r,    r   r   r   r   +   %    
 !-) )r   r   c                   *    e Zd ZdZeZed        Zd Zy)SetIamPolicyAlphar   c                 X    t        j                  |        t        j                  |        y r   r   r   s    r   r   zSetIamPolicyAlpha.ArgsJ   r   r   c                     t        j                  t        j                  j                        }t        j                  |      }|j                  |j                         |j                        S r   )
r    r!   r   r"   ALPHAr$   r%   r&   r'   r   r(   s       r   r,   zSetIamPolicyAlpha.RunO   sZ    $$43D3D3J3JKF--d3G##%43C3C   r   Nr-   r5   r   r   r8   r8   A   r6   r   r8   N)r1   
__future__r   r   r   googlecloudsdk.api_lib.apphubr   r$   *googlecloudsdk.api_lib.apphub.applicationsr   r    googlecloudsdk.callioper   !googlecloudsdk.command_lib.apphubr	   googlecloudsdk.command_lib.iamr
   r2   ReleaseTracksr"   r#   Commandr   r;   r8   r5   r   r   <module>rD      s    - &  ' @ E ( 3 3 #
  D%%(()T\\  ** D%%++,  -r   