
                             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dZ G d d      Ze
j                   e
j                   e
j"                  j$                         G d de
j&                                      Zy)z;Command to restart migration jobs for a database migration.    )absolute_import)division)unicode_literals)api_util)migration_jobs)resource_args)base)logzk
        Fetch objects for a Database Migration Service migration job by connection to the source.
        zw        To fetch source objects for a migration job:

          $ {command} MIGRATION_JOB --region=us-central1
        )DESCRIPTIONEXAMPLESc                       e Zd ZdZd Zy)_MigrationJobObjectInfoz>Container for migration job object data using in list display.c                    |j                   | _         |j                  | _        |j                  |j                  nd | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _	        y )N)
namesourceObjectsource_objecterrorstatephase
createTimecreate_time
updateTimeupdate_time)selfmessages     Elib/surface/database_migration/migration_jobs/fetch_source_objects.py__init__z _MigrationJobObjectInfo.__init__*   sc    DI --D")--";DJDJDJ))D))D    N)__name__
__module____qualname____doc__r    r   r   r   r   '   s
    F*r   r   c                   &    e Zd ZdZed        Zd Zy)FetchSourceObjectszYFetch objects for a Database Migration Service migration job by connection to the source.c                 f    t        j                  | d       | j                  j                  d       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 restartz
            table(
              source_object,
              state:label=STATE,
              phase:label=PHASE,
              error:label=ERROR
            )
          N)r   AddOnlyMigrationJobResourceArgsdisplay_info	AddFormat)parsers    r   ArgszFetchSourceObjects.Args9   s-     11&,G
!! # r   c                    |j                   j                  j                         }t        j                  | j                               }|j                  |j                               }t        j                  | j                               }t        j                  j                  dj                  |j                  |j                               t        j                   |||j"                  d       t        j                  j                  dj                  |j                  |j                               |j%                  |      }|D cg c]  }t'        |       c}S c c}w )a;  Fetch source objects for a Database Migration Service migration job.

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

    Returns:
      A dict object representing the operations resource describing the restart
      operation if the restart was successful.
    z@Waiting for migration job [{}] to fetch source objects with [{}]T)no_resourcez0Fetched source objects for migration job {} [{}])CONCEPTSmigration_jobParser   MigrationJobsClientReleaseTrackr%   RelativeNamer   GetClientInstancer
   statusPrintformatmigrationJobsIdr   	HandleLRO projects_locations_migrationJobsListObjectsr   )r   argsmigration_job_ref	mj_clientresult_operationclientobjos           r   RunzFetchSourceObjects.RunK   s$    3399;2243D3D3FGI 33&&( ''(9(9(;<FJJJ	!113C3H3H	I
 //	 JJ:AA--/?/D/D	
 

 1
2C0341#A&444s   EN)r   r    r!   r"   staticmethodr+   rC   r#   r   r   r%   r%   4   s     b "(5r   r%   N)r"   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   r   r   googlecloudsdk.callioper	   googlecloudsdk.corer
   DETAILED_HELPr   DefaultUniverseOnlyReleaseTracksr2   GACommandr%   r#   r   r   <module>rN      s    B &  ' > D C ( #		
* 
* D%%(()=5 =5 * =5r   