
    1                     j   d Z ddlmZ ddlmZ ddlmZ ddl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$                  e
j&                  j(                  e
j&                  j*                  e
j&                  j,                         G d de
j.                                      Zy)z%Command for bigtable clusters create.    )absolute_import)division)unicode_literalsN)clusters)util)base)	arguments)	arg_utils)logc                   T    e Zd ZdZd ej
                  d      iZed        Zd Z	d Z
y)CreateClusterzCreate a bigtable cluster.EXAMPLESa[            To add a cluster in zone `us-east1-c` to the instance with id
          `my-instance-id`, run:

            $ {command} my-cluster-id --instance=my-instance-id --zone=us-east1-c

          To add a cluster with `10` nodes, run:

            $ {command} my-cluster-id --instance=my-instance-id --zone=us-east1-c --num-nodes=10

          c                     t        j                  | d       t        j                  |       j                         j	                         j                         j                          t        j                  | d       y)z Register flags for this command.zto describeclusterN)r	   AddClusterResourceArgArgAdderAddClusterZoneAddAsyncAddScalingArgsForClusterCreateAddClusterNodeScalingFactorAddKmsKeyResourceArg)parsers    'lib/surface/bigtable/clusters/create.pyArgszCreateCluster.Args5   sU     ##FM:nxxz"@"@"BC^C^C`""695    c                    | j                  |      }|j                  j                  j                         }t	        j
                  ||      }t        j                  |      }|j                  rDt        j                  |j                         dj                  |j                               d       yt        j                  |dj                  |j                                     S )zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    zbigtable cluster {0}T)kindis_asyncNzCreating bigtable cluster {0})_ClusterCONCEPTSr   Parser   Creater   GetOperationRefasync_r   CreatedResourceRelativeNameformatNameAwaitCluster)selfargsr   cluster_ref	operationoperation_refs         r   RunzCreateCluster.Run>   s     mmD!G--''--/KW5I((3M{{	

$
$
&%,,[-=-=-?@ '..{/?/?/ABD Dr   c                    t        j                         }|j                  j                  j                  }t        j                  |j                  |j                  j                        }|j                  |j                  |t        j                  |j                        |      }t        j                  |      }|r|j                  |      |_        |j                   $|j"                  |j$                  |j&                  Mt)        j*                  |j                   |j"                  |j$                  |j&                        |_        d |_        |S )N)
serveNodesnodeScalingFactorlocationdefaultStorageType)
kmsKeyName)autoscaling_minautoscaling_maxautoscaling_cpu_targetautoscaling_storage_target)r   GetAdminMessagesCluster!DefaultStorageTypeValueValuesEnumSTORAGE_TYPE_UNSPECIFIEDr
   ChoiceToEnumnode_scaling_factor NodeScalingFactorValueValuesEnum	num_nodesLocationUrlzoner	   GetAndValidateKmsKeyNameEncryptionConfigencryptionConfigautoscaling_min_nodesautoscaling_max_nodesr8   r9   r   BuildClusterConfigclusterConfigr1   )r*   r+   msgsstorage_typer?   r   kms_keys          r   r   zCreateCluster._ClusterW   s'     "D66OO  $00  55 ll>>-!!$)),'	  )G 006G!%!6!6'!6!Jg""."".##/''3&994444!%!<!<%)%D%D	Fg  gNr   N)__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r/   r    r   r   r   r      sE    
 # 
(// 
 
- 6 6D2 r   r   )rQ   
__future__r   r   r   rR   googlecloudsdk.api_lib.bigtabler   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.bigtabler	   $googlecloudsdk.command_lib.util.apisr
   googlecloudsdk.corer   UniverseCompatibleReleaseTracksReleaseTrackGABETAALPHACreateCommandr   rV   r   r   <module>rd      s    , &  '  4 0 ( 9 : # $++00$2C2C2I2ITD&& T Tr   