
                             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
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  G d dej8                        Zy)zCCommand to create a new workforce pool under a parent organization.    )absolute_import)division)unicode_literals)util)waiter)arg_parsers)base)
exceptions)concepts)iam_util)identity_pool_waiter)flags)	yaml_data)concept_parsers)log)	resourcesc                   ,    e Zd ZdZed        Zd Zd Zy)Createa  Create a new workforce pool under an organization.

  Creates a workforce pool under an organization given a valid organization ID.

  ## EXAMPLES

  The following command creates a workforce pool with ID `my-workforce-pool`
  in the organization ``12345'':

    $ {command} my-workforce-pool --organization=12345

  The following command creates a workforce pool with ID `my-workforce-pool`
  with explicit values for all required and optional parameters:

    $ {command} my-workforce-pool --organization=12345 --location=global
    --display-name="My Workforce Pool" --description="My workforce pool
    description." --session-duration="7200s" --disabled
  c                    t         j                  j                  d      }t        j                  j                  dt        j                  j                  |j                         d      dd      j                  |        t        j                  | d       | j                  dd	
       | j                  dd
       | j                  ddd       | j                  dd
       | j                  ddt        j                  dt         idg      d       | j                  ddd       t"        j$                  j                  |        y )Nziam.workforce_poolworkforce_poolT)is_positionalzThe workforce pool to create.)requiredcreatez--display-namezMA display name for the workforce pool. Cannot exceed 32 characters in length.)helpz--descriptionzMA description for the workforce pool. Cannot exceed 256 characters in length.z
--disabled
store_truez.Whether or not the workforce pool is disabled.)actionr   z--session-durationa"  How long the Google Cloud access tokens, console sign-in sessions, and gcloud sign-in sessions from this workforce pool are valid. Must be greater than 15 minutes (900s) and less than 12 hours (43200s). If not configured, minted credentials will have a default duration of one hour (3600s).z--allowed-servicesappenddomain)specrequired_keyszServices allowed for web sign-in with the workforce pool. The flag accepts multiple values with the key as `domain` and value as the domain of the service allowed for web sign-in. If not set, by default all the services are allowed.)r   typer   z--disable-programmatic-signinz6Disable programmatic sign-in for workforce pool users.)r   ResourceYAMLDataFromPathr   ConceptParserForResourcer   ResourceSpecFromYamlGetDataAddToParserr   AddParentFlagsadd_argumentr   ArgDictstrr	   
ASYNC_FLAG)parserworkforce_pool_datas     )lib/surface/iam/workforce_pools/create.pyArgszCreate.Args8   sd   #44== !!--&&'') 	' 	
 	( .  k&	*
&   &   =  
 N  	   C

5   'E  
 	OO'    c                    t        j                         \  }}|j                  st        j                  dd      t        j                  |j                  d d      }|j                  j                  j                         }|j                  ||j                  |j                  |j                  |j                  | j                  ||            }|j                   j#                  |j%                  t'        j(                  |      |j*                  |            }t,        j.                  j1                  dj3                  |j*                               |j4                  r:t,        j.                  j1                  dj3                  |j6                               |S t8        j:                  j=                  |j6                  d	      }t?        j@                  |j                   |jB                        }	tE        jF                  |	|d
j3                  |j6                        d      }
t,        j.                  j1                  dj3                  |j*                               |
S )Nz--organizationz4Should specify the organization for workforce pools.zworkforce pool)parentdisplayNamedescriptiondisabledsessionDurationaccessRestrictions)locationworkforcePoolIdworkforcePoolzCreate request issued for: [{}]z Check operation [{}] for status.z'iam.locations.workforcePools.operations)
collectionz'Waiting for operations [{}] to completei )max_wait_mszCreated workforce pool [{}].)$r   GetClientAndMessagesorganizationgcloud_exceptionsRequiredArgumentExceptionr   GetParentNameCONCEPTSr   ParseWorkforcePooldisplay_namer7   r8   session_durationCreateAccessRestrictionslocations_workforcePoolsr   'IamLocationsWorkforcePoolsCreateRequestr   ParseLocationworkforcePoolsIdr   statusPrintformatasync_namer   REGISTRYParseRelativeNamer   IdentityPoolOperationPoller#locations_workforcePools_operationsr   WaitFor)selfargsclientmessagesparent_nameworkforce_pool_refnew_workforce_poollro_reflro_resourcepollerresults              r1   Runz
Create.Runw   s   002FH77

@  ((4!1K 55;;=!//%%$$--88xH 0  --4488((..??, 	9 	
G JJ)00//	
 {{	jj9@@NOn%%77!J 8 L "==''22F ^^188F	F JJ&--//	
 Mr3   c                     |j                  d      s|j                  d      rV|j                         }|j                  d      r|j                  |_        |j                  d      r|j                  |_        |S y )Nallowed_servicesdisable_programmatic_signin)IsSpecifiedAccessRestrictionsrf   allowedServicesrg   disableProgrammaticSignin)rY   rZ   r\   access_restrictionss       r1   rJ   zCreate.CreateAccessRestrictions   s{    *+t/?/?%0 %779			,	-.2.C.C+			7	8,, 	5 ! r3   N)__name__
__module____qualname____doc__staticmethodr2   rd   rJ    r3   r1   r   r   $   s'    & <( <(|=~r3   r   N)rp   
__future__r   r   r   googlecloudsdk.api_lib.iamr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r	   r
   rB    googlecloudsdk.calliope.conceptsr   googlecloudsdk.command_lib.iamr   r   .googlecloudsdk.command_lib.iam.workforce_poolsr   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   CreateCommandr   rr   r3   r1   <module>r~      sO    J &  ' + . / ( C 5 3 ? @ : D # )^T ^r3   