
                            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dZ G d de      Z e
j,                  e
j.                  j0                         G d dee
j2                               Z e
j,                  e
j.                  j6                         G d dee
j2                               Zy)z?Command to update connection profiles for a database migration.    )absolute_import)division)unicode_literals)api_util)connection_profiles)resource_args)base)flags)oracle_flags)sqlserver_flags)
console_ioa	  
        Update a Database Migration Service connection profile.
        - Draft connection profile: the user can update all flags available in
        `connection-profiles create` command.
        - Existing connection profile: the user can update a limited list of
        flags, see `connection-profiles update` Synopsis.
        - If a migration job is using the connection profile, then updates to
        fields `host`, `port`, `username`, and `password` will propagate to the
        destination instance.
        z        To update the username of a connection profile:

            $ {command} my-profile --region=us-central1
            --username=new-user
        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)_Update7Update a Database Migration Service connection profile.c                    t        j                  | d       t        j                  |        t        j                  |        t        j
                  |        t        j                  |        t        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	to updateN)r   AddConnectionProfileResourceArgcp_flagsAddDisplayNameFlagAddUsernameFlagAddPasswordFlagGroupAddHostFlagAddPortFlagAddDbmPortFlagAddCaCertificateFlagAddPrivateKeyFlagr
   AddLabelsUpdateFlagsparsers    <lib/surface/database_migration/connection_profiles/update.pyArgsz_Update.Args:   s     11&+F'V$!!&)  F#!!&)v&	v&    c                    |j                   j                  j                         }|j                  rt	        j
                  d      |_        t        j                  | j                               }|j                  |j                         |      }t        j                  | j                               }t        j                  | j                               }t        j                  | j                               }|j!                  d|j"                  |j$                  |j&                        }|j(                  j+                  |j-                  |j.                              S )a-  Update a Database Migration Service connection profiles.

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

    Returns:
      A dict object representing the operations resource describing the create
      operation if the create was successful.
    zPlease Enter Password: z+datamigration.projects.locations.operations)operationsId
projectsIdlocationsId)name)CONCEPTSconnection_profileParseprompt_for_passwordr   PromptPasswordpasswordr   ConnectionProfilesClientReleaseTrackUpdateRelativeNamer   GetClientInstanceGetMessagesModuleGetResourceParserCreater(   r&   r'   projects_locations_operationsGet2DatamigrationProjectsLocationsOperationsGetRequestr%   )	selfargsconnection_profile_ref	cp_clientresult_operationclientmessagesresource_parseroperation_refs	            r!   Runz_Update.RunN   s-    "]]==CCE //0IJdm#<<I ''(>(K(K(M(,. ''(9(9(;<F))$*;*;*=>H001B1B1DEO#**5%**)44*66	 + 8M //33CC++ 	D 	-. .r#   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr"   rC    r#   r!   r   r   5   s!    ?-' '&!.r#   r   c                        e Zd ZdZed        Zy)UpdateAlphar   c                     t         j                  |        t        j                  |        t        j                  |        y )N)r   r"   r   AddCertificateFlagAddInstanceFlagr   s    r!   r"   zUpdateAlpha.Argsv   s*    LL'V$r#   NrD   rE   rF   rG   rJ   r"   rK   r#   r!   rM   rM   r   s    ?% %r#   rM   c                        e Zd ZdZed        Zy)UpdateGAr   c                    t         j                  |        t        j                  |        t        j                  |        t        j
                  |        t        j                  | dd        t        j                  |        t        j                  |        t        j                  |        t        j                  | d       y )NF)hiddenchoices)required)r   r"   r   AddClientCertificateFlagAddCloudSQLInstanceFlagAddAlloydbClusterFlagAddSslTypeFlagr   AddSourceUpdateFlagAddCloudSqlProjectIdFlagAddDatabaseFlagr   AddDatabaseServiceFlagr   s    r!   r"   zUpdateGA.Args   s    LL%%f-$$V,""6*ud ''/,,V4V$''?r#   NrQ   rK   r#   r!   rS   rS   }   s    ?@ @r#   rS   N)rG   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   r   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.database_migrationr
   Agooglecloudsdk.command_lib.database_migration.connection_profilesr   r   r   googlecloudsdk.core.consoler   rH   objectr   ReleaseTracksr0   ALPHACommandrM   GArS   rK   r#   r!   <module>rk      s    F &  ' > I C ( ? _ Z ] 2			,:.f :.z D%%++,%'4<< % -% D%%(()@w @ *@r#   