
    r                         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  ej                  ej                  j                        ej                   G d d	ej                   ej"                                      Zy)
z^Command to import rules in a conversion workspaces for a database migration from config files.    N)resource_args)base)command_mixin)flags)logc                   l    e Zd ZdZdddZedej                  ddfd       Zd	ej                  ddfd
Z
y)ImportRuleszJImport mapping rules in a Database Migration Service conversion workspace.z
        Import mapping rules in a Database Migration Service conversion
        workspace from a configuration file. For example, for Oracle to
        PostgreSQL migrations that could be an Ora2Pg config file.
      z        To import rules in a conversion workspace:

            $ {command} my-conversion-workspace --region=us-central1
            --file-format=ORA2PG --config-files=PATH1/config1.conf,PATH2/config2.conf
        )DESCRIPTIONEXAMPLESparserreturnNc                     t        j                  | d       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to import rulesN)r   !AddConversionWorkspaceResourceArgcw_flagsAddImportFileFormatFlagAddConfigFilesFlagAddAutoCommitFlag)r   s    Dlib/surface/database_migration/conversion_workspaces/import_rules.pyArgszImportRules.Args-   s?     33F<MN$$V,'v&    argsc                    |j                   j                  j                         }| j                  j                  j                  |j                         |j                  |j                  |j                        }|j                  Et        j                  j                  d|j                   d|j                  j                   d       yt        j                  j                  d|j                          y)zImport rules in a Database Migration Service conversion workspace.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.
    )nameconfig_filesfile_formatauto_commitNz0Imported mapping rules for conversion workspace z failed with error [])CONCEPTSconversion_workspaceParseclient
operationsr	   RelativeNamer   r   r   errorr   statusPrintconversionWorkspacesIdmessage)selfr   conversion_workspace_refresult_operations       r   RunzImportRules.Run:   s      $}}AAGGI {{--99%224&&$$$$	 :  )	jj&==> ?%++334A7 
jj&==>@r   )__name__
__module____qualname____doc__detailed_helpstaticmethodargparseArgumentParserr   	Namespacer,    r   r   r	   r	      sZ     S

- 
'8** 
't 
' 
'h(( T r   r	   )r0   r3   )googlecloudsdk.api_lib.database_migrationr   googlecloudsdk.callioper   Cgooglecloudsdk.command_lib.database_migration.conversion_workspacesr   r   r   googlecloudsdk.corer   ReleaseTracksReleaseTrackGADefaultUniverseOnly ConversionWorkspacesCommandMixinCommandr	   r6   r   r   <module>rA      sk    e  C ( ] a # D%%(():-@@$,, :  *:r   