
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr  S
S0r\R                    " S S\R"                  5      5       rg)z2Command for creating a role from an existing role.    )absolute_import)division)unicode_literals)util)base)RequiredArgumentException)iam_util)logEXAMPLESaB            To create a copy of an existing role ``spanner.databaseAdmin'' into an organization
          with ``1234567'', run:

            $ {command} --source="roles/spanner.databaseAdmin" --destination=CustomViewer --dest-organization=1234567

          To create a copy of an existing role ``spanner.databaseAdmin'' into a project with
          ``PROJECT_ID'', run:

            $ {command} --source="roles/spanner.databaseAdmin" --destination=CustomSpannerDbAdmin --dest-project=PROJECT_ID

          To modify the newly created role see the roles update command.
        c                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)Copy/   zYCreate a role from an existing role.

This command creates a role from an existing role.
c                     U R                  SSS9  U R                  SSS9  U R                  SSS9  U R                  SS	S9  U R                  S
SS9  U R                  SSS9  g )Nz--sourcezsThe source role ID. For predefined roles, for example: roles/viewer. For custom roles, for example: myCompanyAdmin.)helpz--destinationzEThe destination role ID for the new custom role. For example: viewer.z--source-organizationz<The organization of the source role if it is an custom role.z--dest-organizationz)The organization of the destination role.z--source-projectz7The project of the source role if it is an custom role.z--dest-projectz$The project of the destination role.)add_argument)parsers    lib/surface/iam/roles/copy.pyArgs	Copy.Args8   s    
9  :
 %  & #  $ $O  Q
#  $ E  G    c           	         [         R                  " 5       u  p#UR                  c  [        SS5      eUR                  c  [        SS5      e[
        R                  " UR                  UR                  UR                  SSS9n[
        R                  " UR                  UR                  SS9nUR                  R                  UR                  US	95      nUR                  UR                   UR"                  S
9n[         R$                  " X#[
        R&                  " UR                  UR                  5      UR(                  5      nUR+                  5       n	U	(       a+  [,        R.                  " SSR1                  U	5      -   S-   5        UR3                  5       n
U
(       a+  [,        R.                  " SSR1                  U
5      -   S-   5        UR5                  5       n[
        R6                  " U5        UR9                  5       n[
        R:                  " U5        UR=                  5       nXl        UR                  R?                  URA                  URC                  XqR                  S9US95      n[
        RD                  " U5        U$ )Nsourcezthe source role is required.destinationz!the destination role is required.zthe source custom role)	attributeparameter_namezthe destination custom role)r   )name)titledescriptionz<Permissions don't support custom roles and won't be added: [z, z] 
zHPermissions not applicable to the current resource and won't be added: [)roleroleId)createRoleRequestparent)#r   GetClientAndMessagesr   r   r   r	   GetRoleNamesource_organizationsource_projectGetParentNamedest_organizationdest_projectorganizations_rolesGetIamOrganizationsRolesGetRequestRoler   r   PermissionsHelperGetResourceReferenceincludedPermissionsGetNotSupportedPermissionsr
   warningjoinGetNotApplicablePermissionsGetApiDisabledPermissonsApiDisabledPermissionsWarningGetTestingPermissionsTestingPermissionsWarningGetValidPermissionsCreate"IamOrganizationsRolesCreateRequestCreateRoleRequestSetRoleStageIfAlpha)selfargsclientmessagessource_role_namedest_parentsource_rolenew_rolepermissions_helpernot_supported_permissionsnot_applicable_permissionsapi_diabled_permissionstesting_permissionsvalid_permissionsresults                  r   RunCopy.RunP   sg   002F{{%h0NOO%m&IK K++  *! ((/1K
 ,,00006F0GIK }}++  -H //080M0M484E4E484J4J1L 1<0O0O	Q
 !3 M M O 	kk
JII/0139:; "4!O!O "!	kk99%?@ACIJK 1IIK**+BC,BBD&&':;*>>@#4 ''..33&88&6&6 9 8 	4 	 !F
   (Mr    N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr   rM   __static_attributes__rO   r   r   r   r   /   s'    
  -G G.6r   r   N)rT   
__future__r   r   r   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   "googlecloudsdk.calliope.exceptionsr   googlecloudsdk.command_lib.iamr	   googlecloudsdk.corer
   rU   UniverseCompatibleCommandr   rO   r   r   <module>ra      s[     9 &  ' + ( H 3 # 	$ V4<< V Vr   