
    +                        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lmZ ddlmZ ddlmZ  ej(                  ej*                  j,                         G d dej.                               Z ej(                  ej*                  j2                  ej*                  j4                         G d de             Zy)z%Command to copy a model in Vertex AI.    )absolute_import)division)unicode_literals)
operations)client)apis)base)	constants)endpoint_util)flags)models_util)operations_util)region_utilc                   8     e Zd ZdZ fdZed        Zd Z xZS )CopyV1  Copy a model.

  ## EXAMPLES

  To copy a model `123` of project `example` from region `us-central1` to region
  `europe-west4`, run:

    $ {command} --source-model=projects/example/locations/us-central1/models/123
      --region=projects/example/locations/europe-west4
  c                    t        t        | 
  |i | t        j                  t
        j                  t
        j                  t
        j                           }t        j                  ||j                        j                  | _        y )Nr   messages)superr   __init__r   GetClientInstancer
   AI_PLATFORM_API_NAMEAI_PLATFORM_API_VERSION
GA_VERSIONr   ModelsClientMESSAGES_MODULEr   )selfargskwargsclient_instance	__class__s       lib/surface/ai/models/copy.pyr   zCopyV1.__init__.   sm    	&$ $1&1,,&&)))*>*>?AO '' 0022:( 	M    c                 L    t        j                  | t        j                         y Nr   AddCopyModelFlagsr   PromptForOpRegionparsers    r#   ArgszCopyV1.Args7       	FK$A$ABr$   c                    |j                   j                  j                         }|j                         d   }t	        j
                  t        j                  |      5  t        j                  t        j                  t        j                  t        j                           }t        j                  ||j                        j                  ||j                   |j"                  |j$                  |j&                        }t)        j*                  t-        j.                  ||j                        |t1        j2                  |j4                              cd d d        S # 1 sw Y   y xY wNlocationsId)versionregionr   )operations_clientopop_ref)CONCEPTSr2   ParseAsDictr   AiplatformEndpointOverridesr
   r   r   r   r   r   r   r   r   r   source_modelkms_key_namedestination_model_iddestination_parent_modelr   WaitForOpMayber   OperationsClientr   ParseModelOperationnamer   r   destination_region_refdestination_regionr!   	operations         r#   Runz
CopyV1.Run;   s   !]]11779/668G		2	2$$-?
A..

(
(

+
+I,@,@
ACo %% "2244:F$d&7&79J9J'')F)F5H 
 ++&77$/N/NP00@	B
A 
A 
As   C3EE#	__name__
__module____qualname____doc__r   staticmethodr,   rF   __classcell__r"   s   @r#   r   r   !   s)    	; C CBr$   r   c                   8     e Zd ZdZ fdZed        Zd Z xZS )CopyV1Beta1r   c                 r    t        t        | 
  |i | t        j                         j
                  | _        y r&   )r   rP   r   r   r   r   )r   r   r    r"   s      r#   r   zCopyV1Beta1.__init__\   s-    	+t%t6v6'')22DMr$   c                 L    t        j                  | t        j                         y r&   r'   r*   s    r#   r,   zCopyV1Beta1.Args`   r-   r$   c                    |j                   j                  j                         }|j                         d   }t	        j
                  t        j                  |      5  t        j                  t        j                  t        j                  t        j                           }t        j                  ||j                        j                  ||j                   |j"                  |j$                  |j&                        }t)        j*                  t-        j.                         |t1        j2                  |j4                              cd d d        S # 1 sw Y   y xY wr/   )r6   r2   r7   r8   r   r9   r
   BETA_VERSIONr   r   r   r   r   r   r   rP   r:   r;   r<   r=   r   r>   r   r?   r   r@   rA   rB   s         r#   rF   zCopyV1Beta1.Rund   s   !]]11779/668G		2	2&&/A
C..

(
(

+
+I,B,B
CEo %% "2244?K$d&7&79J9J'')F)F5H 
 ++&77900@B
C 
C 
Cs   C&EErG   rN   s   @r#   rP   rP   O   s)    	3 C CBr$   rP   N)rK   
__future__r   r   r   googlecloudsdk.api_lib.air    googlecloudsdk.api_lib.ai.modelsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.air
   r   r   r   r   r   ReleaseTracksReleaseTrackGACreateCommandr   ALPHABETArP    r$   r#   <module>rb      s    , &  ' 0 3 , ( 3 7 / 5 9 5 D%%(()*BT *B **BZ D%%++T->->-C-CD$B& $B E$Br$   