
                             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 e	j                   G d
 de	j                               Zy)z1Command to create a fleet scope RBAC RoleBinding.    )absolute_import)division)unicode_literals)client)util)base)	resources)labels_utilc                   &    e Zd ZdZed        Zd Zy)Createa  Create an RBAC RoleBinding.

  This command can fail for the following reasons:
  * The RBAC RoleBinding already exists.
  * The caller does not have permission to access the given scope.

  ## EXAMPLES

  To create an admin RBAC RoleBinding `RBRB` in scope `SCOPE` for user
  `person@google.com`, run:

    $ {command} RBRB --scope=SCOPE --role=admin
    --user=person@google.com

  To create a viewer RBAC RoleBinding `RBRB` in scope `SCOPE` for group
  `people@google.com`, run:

    $ {command} RBRB --scope=SCOPE --role=viewer
    --group=people@google.com

  To create an RBAC RoleBinding with a custom role `custom-role` in scope
  `SCOPE` for user `person@google.com`, run:

    $ {command} RBRB --scope=SCOPE --role=admin
    --user=person@google.com
    --custom-role=custom-role
  c                    t        j                  |t        j                  | j	                            d       |j                  d      }|j                  dt        d       |j                  dt        d	       |j                  d      }|j                  d
g dd       |j                  dt        d       t        j                  |       y )NzqName of the RBAC RoleBinding to be created. Must comply with RFC 1123 (up to 63 characters, alphanumeric and '-'))api_versionrbacrb_helpT)requiredz--userzUser for the RoleBinding.)typehelpz--groupzGroup for the RoleBinding.z--role)admineditviewz;Predefined role to assign to principal (admin, edit, view).)choicesr   z--custom-rolez#Custom role to assign to principal.)
r	   AddScopeRBACResourceArgr   VERSION_MAPReleaseTrackadd_mutually_exclusive_groupadd_argumentstrr
   AddCreateLabelsFlags)clsparsergrouproledefs       =lib/surface/container/fleet/scopes/rbacrolebindings/create.pyArgszCreate.Args:   s    %%$$S%5%5%78$	 ///>E	(  
 
)  
 1141@G)J  
 2  
 $$V,    c                    t        j                  | j                               }t        j                  |j
                        }|j                  |j                  j                  j                  d       j                         }|j                  }|j                  t        j                  |      |j                  ||j                   |j"                  |      S )N)release_track)	additions)rolecustom_roleuserr    labels)r   FleetClientr   r
   Diffr+   ApplymessagesRBACRoleBindingLabelsValue	GetOrNoner)   CreateScopeRBACRoleBindingr	   RBACResourceNamer(   r*   r    )selfargsfleetclientlabels_diffr+   r)   s         r"   Runz
Create.Run]   s    $$43D3D3FGK""T[[9K,,88$ik  ""K11""4(YYYYjj 2  r$   N)__name__
__module____qualname____doc__classmethodr#   r9    r$   r"   r   r      s!    8  -  -Dr$   r   N)r=   
__future__r   r   r   &googlecloudsdk.api_lib.container.fleetr   r   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr	   $googlecloudsdk.command_lib.util.argsr
   DefaultUniverseOnlyCreateCommandr   r?   r$   r"   <module>rG      sL    8 &  ' 9 7 ( @ < OT O Or$   