
                  	       2   d 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 dd	lmZ ej                   ej                   ej"                  j$                        ej&                   G d
 de
j(                  ej*                                             Zy)zBCommand to convert conversion workspaces for a database migration.    N)resource_args)application_code_converter)conversion_params)base)command_mixin)flags)concept_parsersc                   h    e Zd ZdZdddZedej                  ddfd       Zd	ej                  fd
Z
y)ConvertApplicationCodezConvert the application code.z
        Convert the provided source code from accessing the source database to
        accessing the destination database.
      zz        To convert the application code:

            $ {command} --source-file=Path/to/source --region=us-central1
      )DESCRIPTIONEXAMPLESparserreturnNc                 4   t         j                  j                  dt        j                         dd      j                  |        t        j                  |        t        j                  |        t        j                  |        t        j                  |        y)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--regionzThe location of the resource.T)
group_helprequiredN)r	   ConceptParserForResourcer   GetRegionResourceSpecAddToParsercw_flagsAddSourceDialectFlagAddTargetDialectFlagAddSourceDetailsFlagAddTargetPathFlag)r   s    Plib/surface/database_migration/conversion_workspaces/convert_application_code.pyArgszConvertApplicationCode.Args1   sv     !!--++-2	 . 
 k&!!&)!!&)!!&)v&    argsc                 t   t        j                  |j                  j                  j	                         j                         |j                  |j                  |j                  |j                  |j                        }t        j                  || j                  j                        }|j                          y)zConvert the application code.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.
    )namesource_dialecttarget_dialectsource_foldertarget_pathsource_file)params	ai_clientN)r   ApplicationCodeConversionParamsCONCEPTSregionParseRelativeNamer"   r#   r$   r%   r&   r   ApplicationCodeConverterclientaiConvert)selfr   r'   	converters       r   RunzConvertApplicationCode.RunD   s     >>]]!!'')668****(($$$$F +CC++..I r   )__name__
__module____qualname____doc__detailed_helpstaticmethodargparseArgumentParserr   	Namespacer4    r   r   r   r      sR     &


- '8** 't ' '$h(( r   r   )r8   r;   )googlecloudsdk.api_lib.database_migrationr   Sgooglecloudsdk.api_lib.database_migration.conversion_workspaces.app_code_conversionr   r   googlecloudsdk.callioper   Cgooglecloudsdk.command_lib.database_migration.conversion_workspacesr   r   r   (googlecloudsdk.command_lib.util.conceptsr	   HiddenReleaseTracksReleaseTrackGADefaultUniverseOnly ConversionWorkspacesCommandMixinCommandr   r>   r   r   <module>rK      s    I  C z q ( ] a D D%%(()822LL8  * 8r   