
                            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                  j                         ej"                   G d d	ej$                                      Zd
dddde_        y)z)Command to set IAM policy for a resource.    )base_classes)base)flags)scope)backend_buckets_utils)iam_utilc                   &    e Zd ZdZed        Zd Zy)SetIamPolicy?Set the IAM policy binding for a Compute Engine backend bucket.c                 p    t         j                  j                  | d       t        j                  |        y )NsetIamPolicy)operation_type)r   &GLOBAL_REGIONAL_BACKEND_BUCKET_ARG_IAMAddArgumentr   AddArgForPolicyFile)parsers    5lib/surface/compute/backend_buckets/set_iam_policy.pyArgszSetIamPolicy.Args    s0    	00<<~ =    (    c                    t        j                  | j                               }|j                  }t        j
                  j                  ||j                  t        j                  j                  t        j                  |j                              }t        j                  |j                  |j                   j"                        }t        j$                  |_        t)        j*                  |||      S )N)default_scopescope_lister)r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALcompute_flagsGetDefaultScopeListerr   ParsePolicyFilepolicy_filemessagesPolicy!MAX_LIBRARY_IAM_SUPPORTED_VERSIONversionr   r
   )selfargsholderr   backend_bucket_refpolicys         r   RunzSetIamPolicy.Run'   s    **4+<+<+>?F]]F44FF'1188&<<V]]K	 	G 	
  %%d&6&68N8NOF??FN --FF r   N)__name__
__module____qualname____doc__staticmethodr   r.    r   r   r
   r
      s     H) )r   r
   r   z^
    Sets the IAM policy for the given backend bucket as defined in a
    JSON or YAML file.  a      The following command will read an IAM policy defined in a JSON file
    'policy.json' and set it for the backend bucket `my-backend-bucket`:

      $ {command} my-backend-bucket policy.json --region=REGION

      $ {command} my-backend-bucket policy.json --global

      $ {command} my-backend-bucket policy.json

    See https://cloud.google.com/iam/docs/managing-policies for details of the
    policy file format and contents.
    z    This command uses the compute/alpha API. The full documentation for this
    API can be found at: https://cloud.google.com/compute/)briefDESCRIPTIONEXAMPLESzAPI REFERENCEN)r2   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r!   r   r   2googlecloudsdk.command_lib.compute.backend_bucketsr   googlecloudsdk.command_lib.iamr   ReleaseTracksr   ALPHADefaultUniverseOnlyCommandr
   detailed_helpr4   r   r   <module>rB      s    0 8 ( E E T D 3 D%%++,4<<   -> O>' r   