
                             S r SSKJr  SSKJr  SSKJr  SSK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\
R"                  5      rg)z,Command for spanner instance configs create.    )absolute_import)division)unicode_literalsN)instance_config_operations)instance_configs)base)
exceptions)flags)labels_utilc                   V    \ rS rSrSrS\R                  " S5      0r\S 5       r	S r
Srg)	Create   z.Create a Cloud Spanner instance configuration.EXAMPLESa,          To create a custom Cloud Spanner instance configuration based on an existing Google-managed configuration (`nam3`) by adding a `READ_ONLY` type replica in location `us-east4`, run:

          $ {command} custom-instance-config
            --clone-config=nam3
            --add-replicas=location=us-east4,type=READ_ONLY

        To create a custom Cloud Spanner instance configuration based on another custom configuration (`custom-instance-config`) by adding a `READ_ONLY` type replica in location `us-east1` and removing a `READ_ONLY` type replica in location `us-east4`, run:

          $ {command} custom-instance-config1
            --clone-config=custom-instance-config
            --add-replicas=location=us-east1,type=READ_ONLY
            --skip-replicas=location=us-east4,type=READ_ONLY
        c                 d   U R                  SS[        R                  SS9  U R                  SSS9  U R                  SS	S9  [        R                  R                  U 5        [        R                  " U 5        U R                  S
SSSS9  SnU R                  SS9nUR                  S5      n[        R                  " USUS9  UR                  SSSS9  UR                  S5      nUR                  SSS[        R                  SS9  [        R                  " USSSS9  [        R                  " USS SS9  g!)"zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go on
    the command line after this command. Positional arguments are allowed.
configINSTANCE_CONFIGzCloud Spanner instance configuration. The 'custom-' prefix is required to avoid name conflicts with Google-managed configurations.)metavar	completerhelp--display-namezThe name of this instance configuration as it appears in UIs. Must specify this option if creating an instance-config with --replicas.)r   z--etagz(Used for optimistic concurrency control.z--validate-only
store_trueFzbIf specified, validate that the creation will succeed without creating the instance configuration.)actiondefaultr   a7          The geographic placement of nodes in this instance configuration and
        their replication types.

        *location*::: The location of the serving resources, e.g. "us-central1".

        *type*::: The type of replica.

        Items in the list are separated by ":". The allowed values and formats
        are as follows.

        *READ_ONLY*::::

        Read-only replicas only support reads (not writes). Read-only
        replicas:

          * Maintain a full copy of your data.

          * Serve reads.

          * Do not participate in voting to commit writes.

          * Are not eligible to become a leader.

        *READ_WRITE*::::

        Read-write replicas support both reads and writes. These
        replicas:

          * Maintain a full copy of your data.

          * Serve reads.

          * Can vote whether to commit a write.

          * Participate in leadership election.

          * Are eligible to become a leader.

        *WITNESS*::::

        Witness replicas don't support reads but do participate in
        voting to commit writes. Witness replicas:

          * Do not maintain a full copy of data.

          * Do not serve reads.

          * Vote whether to commit writes.

          * Participate in leader election but are not eligible to become
            leader.

        T)requiredzECommand-line flags to setup a custom instance configuration replicas:z
--replicas)nametextz--base-configzkThe name of the Google-managed instance configuration, based on which your custom configuration is created.)r   r   zPCommand-line flags to setup a custom instance configuration using clone options:z--clone-configzThe ID of the instance config, based on which this configuration is created. The clone is an independent copy of this config. Available configurations can be found by running "gcloud spanner instance-configs list")r   r   r   r   z--add-replicasz6Add new replicas while cloning from the source config.)r   r   r   z--skip-replicasz{Skip replicas from the source config while cloning. Each replica in the list must exist in the source config replicas list.N)add_argumentr
   InstanceConfigCompleterr   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlagsadd_mutually_exclusive_groupadd_argument_groupReplicaFlag)parserreplica_help_textclone_or_manualmanual_flagsclone_flagss        .lib/surface/spanner/instance_configs/create.pyArgsCreate.Args3   s    !//F	  G    A  C 	OO'$$V,
/	  5l 9949HO"55OQL	l<MNz   "44ZK !//1  2 
E	
 
E    c           	      &   UR                   (       a7  [        R                  " UR                   5      n[        R                  " X5      nOUR	                  S5      (       d  [
        R                  " SS5      e[        R                  " UR                  UR                  UR                  UR                  UR                  UR                  UR                  5      nUR                  (       d  UR                  (       a  U$ [         R"                  " US5      $ )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:
  Instance config create response.
display_namer   zMust specify --display-name.zCreating instance-config)clone_configr   GetCreateUsingExistingConfigIsSpecifiedc_exceptionsInvalidArgumentExceptionCreateUsingReplicasr   r/   base_configreplicasvalidate_onlylabelsetagasync_r   Await)selfargsr   ops       r*   Run
Create.Run   s       ##D$5$56f55dCbn--33<> 	> //T=N=N040@0@$--040B0BDKK04		;b {{d((i%++B0JKKr-    N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpstaticmethodr+   rA   __static_attributes__rC   r-   r*   r   r      s?    6 
//  -$ x xtLr-   r   )rH   
__future__r   r   r   rI   googlecloudsdk.api_lib.spannerr   r   googlecloudsdk.callioper   r	   r4   "googlecloudsdk.command_lib.spannerr
   $googlecloudsdk.command_lib.util.argsr   CreateCommandr   rC   r-   r*   <module>rT      s>    3 &  '  E ; ( > 4 <nLT nLr-   