
                            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 e	j(                   e	j*                  e	j,                  j.                         G d de	j0                                      Z e	j*                  e	j,                  j4                         G d de             Z e	j*                  e	j,                  j8                         G d de             Zy)z(Creates a new AlloyDB secondary cluster.    )absolute_import)division)unicode_literals)api_util)cluster_operations)base)cluster_helper)flags)resource_args)log)
properties)	resourcesc                   6    e Zd ZdZdddZed        Zd Zd Zy)	CreateSecondary>Create a new AlloyDB SECONDARY cluster within a given project.z{description}z        To create a new cluster, run:

          $ {command} my-cluster --region=us-central1 --primary-cluster=projects/12345/locations/us-central1/clusters/cluster1
        )DESCRIPTIONEXAMPLESc                    t        j                  | j                               }t        j                  j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  ||       t        j                  |       t        j                  |dd       y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    clusterzjThe 'AlloyDB Service Agent' service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter')permission_infoN)r   GetMessagesModuleReleaseTrackr   
ASYNC_FLAGAddToParserr
   	AddRegion
AddClusterAddPrimaryClusterAddAllocatedIPRangeName0AddContinuousBackupConfigFlagsForCreateSecondary)AddAutomatedBackupFlagsForCreateSecondaryAddTagskms_resource_argsAddKmsKeyResourceArg)clsparseralloydb_messagess      0lib/surface/alloydb/clusters/create_secondary.pyArgszCreateSecondary.Args.   s      11#2B2B2DEOO'	OOF	V	F#	!!&)	::6B	33F<LM	MM&**9	    c                 0    t        j                  |||      S N)r	   )ConstructCreatesecondaryRequestFromArgsGAselfr&   location_refargss       r'   'ConstructCreateSecondaryRequestFromArgsz7CreateSecondary.ConstructCreateSecondaryRequestFromArgsG   s    CC,. .r)   c                    t        j                  | j                               }|j                  }|j                  }|j
                  j                  dt        j                  j                  j                  j                  |j                        }| j                  |||      }|j                  j                  |      }t         j"                  j%                  |j&                  d      }t(        j*                  j-                  dj/                  |j1                                      |j2                  s%t5        j6                  |d| j                                |S )zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made
    zalloydb.projects.locations)
projectsIdlocationsIdz%alloydb.projects.locations.operations)
collectionzOperation ID: {}zCreating cluster)r   AlloyDBClientr   alloydb_clientr&   resource_parserCreater   VALUEScoreproject	GetOrFailregionr1   projects_locations_clustersCreatesecondaryr   REGISTRYParseRelativeNamenamer   statusPrintformatNameasync_r   Await)	r.   r0   clientr7   r&   r/   reqopop_refs	            r'   RunzCreateSecondary.RunL   s    ##D$5$5$78F**N..))00$$$))11;;KK 1 L
 
6
6,C 
	3	3	C	CC	HB11
C 2 F JJ'..v{{}=>;;v'94;L;L;NOIr)   N)	__name__
__module____qualname____doc__detailed_helpclassmethodr(   r1   rN    r)   r'   r   r       s7     G %-  0.
r)   r   c                   2     e Zd ZdZe fd       Zd Z xZS )CreateSecondaryBetar   c                 ,    t         t        |   |       y r+   )superrW   r(   r$   r%   	__class__s     r'   r(   zCreateSecondaryBeta.Argsp   s    	
s(0r)   c                 0    t        j                  |||      S r+   )r	   +ConstructCreatesecondaryRequestFromArgsBetar-   s       r'   r1   z;CreateSecondaryBeta.ConstructCreateSecondaryRequestFromArgst   s    EE,. .r)   rO   rP   rQ   rR   rT   r(   r1   __classcell__r[   s   @r'   rW   rW   l   s    F1 1.r)   rW   c                   2     e Zd ZdZe fd       Zd Z xZS )CreateSecondaryAlphar   c                 ,    t         t        |   |       y r+   )rY   rb   r(   rZ   s     r'   r(   zCreateSecondaryAlpha.Args~   s    	
)&1r)   c                 0    t        j                  |||      S r+   )r	   ,ConstructCreatesecondaryRequestFromArgsAlphar-   s       r'   r1   z<CreateSecondaryAlpha.ConstructCreateSecondaryRequestFromArgs   s     FF, r)   r^   r`   s   @r'   rb   rb   z   s    F2 2r)   rb   N)rR   
__future__r   r   r   googlecloudsdk.api_lib.alloydbr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.alloydbr	   r
   googlecloudsdk.command_lib.kmsr   r"   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr   GACreateCommandr   BETArW   ALPHArb   rU   r)   r'   <module>rr      s    / &  ' 3 = ( = 4 M # * ) D%%(()Gd(( G * GT D%%**+
./ 
. ,
. D%%++,.  -r)   