
                            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 ddlmZ ddlmZ ddlmZ ddl m!Z! dZ"ejF                   ejH                  ejJ                  jL                  ejJ                  jN                  ejJ                  jP                         G d dejR                                      Z*y)z Command to create a new project.    )absolute_import)division)unicode_literals)
exceptions)projects_api)projects_util)
operations)
enable_api)apis)arg_parsers)base)flags)util)labels_util)log)
properties)
console_iozProject IDs are immutable and can be set only during project creation. They must start with a lowercase letter and can have lowercase ASCII letters, digits or hyphens. Project IDs must be between 6 and 30 characters.c                   B    e Zd ZdZdej
                  iZed        Zd Z	y)Createa  Create a new project.

  Creates a new project with the given project ID. By default, projects are not
  created under a parent resource. To do so, use either the `--organization` or
  `--folder` flag.

  ## EXAMPLES

  The following command creates a project with ID `example-foo-bar-1`, name
  `Happy project` and label `type=happy`:

    $ {command} example-foo-bar-1 --name="Happy project" --labels=type=happy

  By default, projects are not created under a parent resource. The following
  command creates a project with ID `example-2` with parent `folders/12345`:

    $ {command} example-2 --folder=12345

  The following command creates a project with ID `example-3` with parent
  `organizations/2048`:

    $ {command} example-3 --organization=2048

  ## SEE ALSO

  {see_also}
  see_alsoc           	         t        j                  |        t        j                         rt	        j
                  dt              }nt	        j
                  dt              }| j                  dd|ddj                  t                     | j                  dd	
       | j                  ddt        j                  j                  j                  j                         dk(  rdndt	        j                  dd             | j                  dddd       t        j                         j!                  |        t        j"                  d      j!                  |        t        j$                  d      j!                  |        y)zDefault argument specification.z[a-z][a-z0-9-]{5,29}zD^(?!.*-$)(((?:[a-z][\.a-z0-9-]{2,29})\:?)?(?:[a-z][a-z0-9-]{5,29})$)id
PROJECT_ID?z+ID for the project you want to create.

{0})metavartypenargshelpz--namezWName for the project you want to create. If not specified, will use project id as name.)r   z--enable-cloud-apis
store_truezgoogleapis.comTFz2Enable `cloudapis.googleapis.com` during creation.zThis is not available.
)defaultuniverse_help)actionr    r   z--set-as-defaultz5Set newly created project as [core/project] property.zto use as a parentN)r   AddCreateLabelsFlagsr   IsDefaultUniverser   RegexpValidatorID_DESCRIPTIONadd_argumentformatVALUEScoreuniverse_domainGetUniverseHelpTextr   TagsFlagAddToParserOrganizationIdFlagFolderIdFlag)parsertype_s     lib/surface/projects/create.pyArgszCreate.ArgsR   sa    $$V,##%))
!>e ))
Q
e <CC
   =   !!11557;KK ))H4
  
 D	   
NN  (	12>>vF	+,88@    c           	      t   t        j                  |d       |j                  }|sV|j                  rJt	        j
                  |j                        }|r)t        j                  ddj                  |      d      r|}|st        j                  dd      t	        j                  |      }t        j                  |t        j                         j                   j"                        }t        j$                  |t        j                         j                   j&                        }	 t)        j*                  ||j                  t)        j,                  t        j.                  |            ||	      }t;        j<                  |d       t?        j@                        }|jB                  r9t;        jD                  d       tG        jH                  |jK                         d       |jL                  rYtO        jP                  d      }	tO        jR                  |	|       t:        jT                  jW                  dj                  |             t?        jX                  |t[        j\                  dd      j                         S # t0        j2                  $ r. d
}t5        j6                  t        j8                  |             Y Jw xY w)z"Default Run method implementation.F)parent_requiredzNo project ID provided.zUse [{}] as project IDT)throw_if_unattendedr   z4an ID or a name must be provided for the new project)display_nameparentlabelstagszyProject creation failed. The project ID you specified is already in use by another project. Please try an alternative ID.)is_asyncz!Enabling cloudapis.googleapis.comzcloudapis.googleapis.comzcore/projectz)Updated property [core/project] to [{0}].cloudresourcemanagerv1)/r   CheckParentFlagsr   namecommand_lib_util
IdFromNamer   PromptContinuer(   r   RequiredArgumentExceptionParseProjectr   ParseCreateArgsr   GetMessagesProjectLabelsValueGetTagsFromFlags	TagsValuer   r   ParentNameToResourceIdGetParentFromFlagsapitools_exceptionsHttpConflictErrorcore_exceptionsreraiseHttpExceptionr   CreatedResourcer	   WaitForOperationenable_cloud_apisdebugr
   EnableServiceNameset_as_defaultr   
FromStringPersistPropertystatusPrintExtractOperationResponser   GetMessagesModule)
selfargs
project_id	candidateproject_refr<   r=   	create_opmsgproject_propertys
             r4   Runz
Create.Run   s1    
47J$))"--dii8i	z00
#
"
)
))
4"$ 
00
NP P"//
;K((m'')11==?F!!m'')11;;=D=%%
yy44&&t,.i d3++I6I 	ii34{//13MN#..~>  !1:>	jjBz*, ..y/3/E/E3I37099@B B' 00 =c j66s;<	=s   "A
I6 6=J76J7N)
__name__
__module____qualname____doc__project_flags!CREATE_DELETE_IN_CONSOLE_SEE_ALSOdetailed_helpstaticmethodr5   rj    r6   r4   r   r   0   s4    8 }NNO-0A 0Ad2Br6   r   N)+rn   
__future__r   r   r   apitools.base.pyr   rP   +googlecloudsdk.api_lib.cloudresourcemanagerr   r   'googlecloudsdk.api_lib.resource_managerr	   googlecloudsdk.api_lib.servicesr
   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.projectsr   ro   r   rC   +googlecloudsdk.command_lib.resource_manager$googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corerR   r   r   googlecloudsdk.core.consoler   r&   UniverseCompatibleReleaseTracksReleaseTrackGABETAALPHACreateCommandr   rs   r6   r4   <module>r      s    ' &  ' > D E > 6 , / ( . F H = < = # * 2E D%%(($*;*;*@*@%%++-DBT DB- DBr6   