
    G                     8   S r SSKrSSKJrJr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	KJr  SS
KJr  \" S5      r\	R*                  " \	R,                  R.                  5      \	R0                   " S S\R2                  \	R4                  5      5       5       rg)zACommand to create conversion workspaces for a database migration.    N)OptionalTypeTypeVar)resource_args)base)
exceptions)command_mixin)flags)labels_util)datamigration_v1_messagesGlobalSettingsValuec                       \ rS rSrSrSSS.r\S\R                  SS4S	 j5       r	S
\R                  S\\R                     4S jrS
\R                  SS4S jrS
\R                  S\\   S\4S jrSrg)Create   z9Create a Database Migration Service conversion workspace.zI
        Create a Database Migration Service conversion workspace.
      aM          To create a conversion workspace:

            $ {command} my-conversion-workspace --region=us-central1
            --display-name=cw1
            --source-database-engine=ORACLE
            --source-database-version=11
            --destination-database-engine=POSTGRESQL
            --destination-database-version=15
      )DESCRIPTIONEXAMPLESparserreturnNc                 :   [         R                  " U S5        [        R                  " U 5        [        R                  " U 5        [        R
                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        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.
z	to createN)	r   !AddConversionWorkspaceResourceArgcw_flagsAddNoAsyncFlagAddDisplayNameFlagAddDatabaseEngineFlagsAddDatabaseProviderFlagsAddDatabaseVersionFlagAddGlobalSettingsFlag)r   s    >lib/surface/database_migration/conversion_workspaces/create.pyArgsCreate.Args4   sh     33FKHF#'##F+%%f-##F+""6*    argsc                 ^   U R                  U5        UR                  R                  R                  5       nU R                  R
                  R                  UR                  5       R                  5       UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                   U R#                  UU R                  R
                  R$                  R&                  R(                  S9S9
nU R+                  UUSUR-                  S5      S9$ )a  Create a Database Migration Service conversion workspace.

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"   global_settings_value_cls)

parent_refconversion_workspace_iddisplay_namesource_database_providersource_database_enginesource_database_versiondestination_database_providerdestination_database_enginedestination_database_versionglobal_settingsCreatedno_async)conversion_workspace_refresult_operationoperation_namesync)_ValidateEngineProviderFlagsCONCEPTSconversion_workspaceParseclientcrudr   ParentRelativeNameconversionWorkspacesIdr'   r(   r)   r*   r+   r,   r-   _BuildGlobalSettingsmessagesConversionWorkspacer   HandleOperationResultIsKnownAndSpecified)selfr"   r1   r2   s       r   Run
Create.RunD   s    	%%d+#}}AAGGI{{''..+224AAC 8 O O&&!%!>!>#:: $ < <&*&H&H$($D$D%)%F%F11&*kk&6&6&?&?&S&S&g&g 2 
 /   %%!9) %%j1	 &  r!   c                 ,   UR                   UR                  R                  ;  af  [        R                  " SSUR                   SUR                    SSR                  [        [        UR                  R                  5      5       S35      eUR                  UR                  R                  ;  af  [        R                  " SSUR                   S	UR                   SSR                  [        [        UR                  R                  5      5       S35      eg
)z(Validates the engine and provider flags.z4--source_database_engine, --source_database_providerzSource database engine z2 is not supported by the source database provider z.
Supported providers are: z, .z>--destination_database_engine, --destination_database_providerzDestination database engine z7 is not supported by the destination database provider N)
r(   r)   supported_providersr   InvalidArgumentExceptionjoinmapstrr+   r,   )rC   r"   s     r   r5   #Create._ValidateEngineProviderFlagsj   s    	%%**>>	? //
@#D$?$?#@ A++, -iiC!<!<!P!PQRSSTV  	**//CC	D //
J()I)I(J K001 2iiC!A!A!U!UVWXXY[ 	Dr!   r$   c                     UR                   c  0 Ul         UR                   R                  SSS9  [        R                  " UUSS9$ )a  Builds the global settings for the conversion workspace.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
    with.
  global_settings_value_cls: The class to use for the global settings value.

Returns:
  A global settings value object.
*true)filterv2r.   )r"   
labels_clslabels_dest)r.   updater   ParseCreateArgs)rC   r"   r$   s      r   r>   Create._BuildGlobalSettings   sM     #dsv6&&,% r!    )__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodargparseArgumentParserr   	Namespacer   r?   	OperationrD   r5   r   r   r>   __static_attributes__rX   r!   r   r   r      s     B
	
	-  +8** +t + +$h(( $Xh6H6H-I $Lx/A/A d 4 "&&9!: 	r!   r   )r]   r`   typingr   r   r   )googlecloudsdk.api_lib.database_migrationr   googlecloudsdk.callioper   r   Cgooglecloudsdk.command_lib.database_migration.conversion_workspacesr	   r
   r   $googlecloudsdk.command_lib.util.argsr   6googlecloudsdk.generated_clients.apis.datamigration.v1r   r?   r   ReleaseTracksReleaseTrackGADefaultUniverseOnly ConversionWorkspacesCommandMixinCommandr   rX   r!   r   <module>rq      s    H  * * C ( . ] a < h34  D%%(()y];;T\\ y  *yr!   