
                            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dZ e
j$                  e
j&                  j(                  e
j&                  j*                         G d de             Z e
j$                  e
j&                  j*                         G d dee
j0                               Z e
j$                  e
j&                  j(                         G d dee
j0                               Zy)z:Command to update migration jobs for a database migration.    )absolute_import)division)unicode_literals)api_util)migration_jobs)resource_args)base)flags)loga  
        Update a Database Migration Service migration job.
        - Draft migration job: user can update all available flags.
        - Any other state can only update flags: `--display-name`,
        `--dump-path`, and connectivity method flags.
        a          To update the source and destination connection profiles of a draft
        migration job:

            $ {command} my-migration-job --region=us-central1 --source=new-src
            --destination=new-dest

        To update the display name of a running migration job:

            $ {command} my-migration-job --region=us-central1
            --display-name=new-name

        )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)_Update2Update a Database Migration Service migration job.c                 ^   t        j                  | d       t        j                  |        t        j                  |        t        j
                  |        t        j                  |        t        j                  | t        j                  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 updateN)r   AddMigrationJobResourceArgsmj_flagsAddNoAsyncFlagAddDisplayNameFlagAddTypeFlagAddDumpGroupFlagAddConnectivityGroupFlagApiTypeUPDATEr
   AddLabelsUpdateFlagsparsers    7lib/surface/database_migration/migration_jobs/update.pyArgsz_Update.Args:   sv     --fkBF#' f%%%fh.>.>.E.EF	v&    c                 x   |j                   j                  j                         }|j                   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(                  |j0                  |j2                        }
|j4                  j7                  |j9                  |
j:                              S )a'  Update 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 update
      operation if the update was successful.
    no_asyncz6Waiting for migration job [{}] to be updated with [{}]zUpdated migration job {} [{}]Nz+datamigration.projects.locations.operations)operationsId
projectsIdlocationsId)name)CONCEPTSmigration_jobParsesourcedestinationr   MigrationJobsClientReleaseTrackUpdateRelativeNamer   GetClientInstanceGetMessagesModuleGetResourceParserIsKnownAndSpecifiedr   statusPrintformatmigrationJobsIdr&   	HandleLRO projects_locations_migrationJobsCreater$   r%   projects_locations_operationsGet2DatamigrationProjectsLocationsOperationsGetRequestr#   )selfargsmigration_job_ref
source_refdestination_ref	mj_clientresult_operationclientmessagesresource_parseroperation_refs              r   Runz_Update.RunJ   s    3399;%%++-Jmm//557O2243D3D3FGI ''(9(F(F(H(2OTK ''(9(9(;<F))$*;*;*=>H001B1B1DEO
+	jj
B
I
I//1A1F1FHI !1@@B 
jj6==

+
+-=-B-BD E#**5%**$//%11	 + 3M //33CC++ 	D 	-. .r    N)__name__
__module____qualname____doc__staticmethodr   rI    r    r   r   r   6   s    :' ',.r    r   c                   $    e Zd ZdZeZed        Zy)UpdateGAr   c                 \   t         j                  |        t        j                  |        t        j                  |        t        j
                  |        t        j                  |        t        j                  | d       t        j                  |        t        j                  | d       y )NT)	is_update)
r   r   r   AddDumpParallelLevelFlagAddDumpTypeFlagAddFilterFlagAddCommitIdFlag*AddSqlServerHomogeneousMigrationConfigFlag2AddMigrationJobObjectsConfigFlagForCreateAndUpdate#AddHeterogeneousMigrationConfigFlagr   s    r   r   zUpdateGA.Args   st    LL%%f-V$6"V$77$O??G004Hr    NrJ   rK   rL   rM   DETAILED_HELPdetailed_helprN   r   rO   r    r   rQ   rQ   y   s    :-I Ir    rQ   c                   $    e Zd ZdZeZed        Zy)UpdateAlphar   c                 .    t         j                  |        y )N)r   r   r   s    r   r   zUpdateAlpha.Args   s    LLr    Nr[   rO   r    r   r_   r_      s    :- r    r_   N)rM   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   r   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.database_migrationr
   <googlecloudsdk.command_lib.database_migration.migration_jobsr   googlecloudsdk.corer   r\   ReleaseTracksr-   ALPHAGAobjectr   CommandrQ   r_   rO   r    r   <module>rl      s    A &  ' > D C ( ? Z #		2 D%%++T->->-A-AB?.f ?. C?.D D%%(()Iw I *I" D%%++,'4<<  -r    