
                         :   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ZdZ e
j,                  e
j.                  j0                        e
j2                   G d de
j4                                      Zy)z:Command to create a database migration private connection.    )absolute_import)division)unicode_literals)api_util)private_connections)resource_args)base)flags)concept_parsers)presentation_specs)logz.Create a Database Migration private connectionae      To create a private connection with VPC Peering called 'my-private-connection', run:

        $ {command} my-private-connection --region=us-central1 --display-name=my-private-connection --vpc=vpc-example --subnet=10.0.0.0/29

        To create a private connection with PSC Interface called 'my-privateConnection', run:

        $ {command} my-private-connection --location=us-central1 --display-name=my-private-connection --network-attachment=network-attachment-example

        To use a private connection, all migrations and connection profiles that use this configuration must be in the same region.


   c                   @    e Zd ZdZeedZed        Zed        Z	d Z
y)Createz/Create a Database Migration private connection.)DESCRIPTIONEXAMPLESc                 d   t        j                  | d       t        j                  |        t        j                  |        t        j
                  |        t        j                  |        t        j                  |        | j                  dd      }|j                  d      }|j                  ddd       t        j                  d	t        j                         d
|d      }t        j                  |g      j!                  |       |j                  d      }t        j"                  |       y)a/  Common arguments for all release tracks.

    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.
      release_track: Some arguments are added based on the command release
        track.
    z	to createT)mutexrequiredz(Arguments for VPC Peering configuration.)helpz--subnetz)A free subnet for peering. (CIDR of /29).)r   r   z--vpcz,Resource ID of the VPC network to peer with.)groupr   z>Arguments for Private Service Connect Interface configuration.N)r   AddPrivateConnectionResourceArgpc_flagsAddDisplayNameFlagAddNoAsyncFlagAddSkipValidationFlagAddValidateOnlyFlagr
   AddLabelsCreateFlags	add_groupadd_argumentr   ResourcePresentationSpecGetVpcResourceSpecr   ConceptParserAddToParserAddNetworkAttachmentFlag)parserrelease_trackconfig_groupvpc_peering_groupvpc_spec	psc_groups         <lib/surface/database_migration/private_connections/create.py
CommonArgszCreate.CommonArgs5   s    11&+F'F#""6*  (	v&##$#>L$..7 /  ""< #  "::((*6H !!8*-99:KL &&M ' I %%i0    c                 `    t         j                  | t        j                  j                         y)z@Args is called by calliope to gather arguments for this command.N)r   r,   r	   ReleaseTrackGA)r%   s    r+   ArgszCreate.Argsb   s      fd//223r-   c                    |j                   j                  j                         }|j                         j	                         }t        j                  | j                               }|j                  ||j                  |      }t        j                  | j                               }t        j                  | j                               }t        j                  | j                               }|j                  d      rt        j                   j#                  dj%                  |j                  |j&                               t        j(                  |||j*                         t        j                   j#                  dj%                  |j                  |j&                               y|j                  d|j&                  |j,                  |j.                        }	|j0                  j3                  |j5                  |	j6                              S )	a$  Create a Database Migration private connection.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      A dict object representing the operations resource describing the create
      operation if the create was successful.
    )r&   no_asyncz;Waiting for private connection [{}] to be created with [{}]z"Created private connection {} [{}]Nz+datamigration.projects.locations.operations)operationsId
projectsIdlocationsId)name)CONCEPTSprivate_connectionParseParentRelativeNamer   PrivateConnectionsClientr/   r   privateConnectionsIdr   GetClientInstanceGetMessagesModuleGetResourceParserIsKnownAndSpecifiedr   statusPrintformatr7   	HandleLRO%projects_locations_privateConnectionsr5   r6   projects_locations_operationsGet2DatamigrationProjectsLocationsOperationsGetRequestr4   )
selfargsprivate_connection_ref
parent_ref	pc_clientresult_operationclientmessagesresource_parseroperation_refs
             r+   Runz
Create.Rung   s    "]]==CCE'..0==?J#<<'')+I ''*??G ''(9(9(;<F))$*;*;*=>H001B1B1DEO
+	jj
G
N
N$99##%&
 !1EEG 
jj;BB
 
5
57G7L7LN O#**5%**)44*66	 + 8M //33CC++ 	D 	-. .r-   N)__name__
__module____qualname____doc__r   r   detailed_helpstaticmethodr,   r1   rU    r-   r+   r   r   /   s=     8"-8D-*1 *1X 4 4,.r-   r   N)rY   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   r   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.database_migrationr
   Agooglecloudsdk.command_lib.database_migration.private_connectionsr   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   r   ReleaseTracksr/   r0   UniverseCompatibleCommandr   r\   r-   r+   <module>rg      s    A &  ' > I C ( ? _ D G #> D%%(()b.T\\ b.  *b.r-   