
    k.                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  S r	S r
  S S	 jrS!S
 jrS"S jrS!S jrS!S jrS!S jrS rS rS rS rS rS"S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS rS rS#S jr g)$z?Flags and helpers for the connection profiles related commands.    )absolute_import)division)unicode_literals)api_util)arg_parsersc                 *    SnU R                  SSUS9  g)z+Adds a --no-async flag to the given parser.zAWaits for the operation in progress to complete before returning.z
--no-async
store_trueactionhelpNadd_argumentparser	help_texts     Nlib/googlecloudsdk/command_lib/database_migration/connection_profiles/flags.pyAddNoAsyncFlagr      s    )l<iH    c                 (    SnU R                  SUS9  g)z/Adds a --display-name flag to the given parser.z    A user-friendly name for the connection profile. The display name can
    include letters, numbers, spaces, and hyphens, and must start with a letter.
    z--display-namer   Nr   r   s     r   AddDisplayNameFlagr       s    ) 	&Y7r   c                 "   U R                  SSS9nU(       a?  UR                  SSSS9n[        USS9  UR                  5       n[        USS9  [        XaS9  O[        USS9  [        XAS9  [	        USS9  [        USS9  U(       a  [        USS9  gg)	z9Adds the database connectivity flags to the given parser.FrequiredmutexTzAuthentication method.)r   r   r   )
for_creater   N)	add_groupAddEnableIamAuthenticationFlagAddUsernameFlagAddPasswordFlagGroupAddHostFlagAddPortFlagAddDatabaseFlag)r   require_passwordwith_database_namesupports_iam_authdatabase_params_groupauthentication_groupbuiltin_auth_groups          r   AddDatabaseParamsFlagsr+   )   s     !**E*G0::U)A ;  ##7DI-779&6+G)D9.J#d3#d3)E: r   c                 (    SnU R                  SX!S9  g)z+Adds a --database flag to the given parser.z9    The name of the specific database within the host.
  z
--databaser   r   Nr   r   r   r   s      r   r$   r$   >   s    ) 	lFr   Nc                 6    U(       d  SnU R                  SX!S9  g)z+Adds a --username flag to the given parser.z        Username that Database Migration Service uses to connect to
        the database. Database Migration Service encrypts the value when storing
        it.
    z
--usernamer-   Nr   r.   s      r   r    r    F   s!    	I
 	lFr   c                 f    U R                  USS9nUR                  SSS9  UR                  SSSS	9  g
)zDAdds --password and --prompt-for-password flags to the given parser.Tr   z
--passwordz          Password for the user that Database Migration Service uses to
          connect to the database. Database Migration Service encrypts
          the value when storing it, and the field is not returned on request.
          r   z--prompt-for-passwordr	   z8Prompt for the password used to connect to the database.r
   N)r   r   )r   r   password_groups      r   r!   r!   Q   sS     ##XT#B.   E  Gr   c                 (    SnU R                  SX!S9  g)z%Adds --host flag to the given parser.a*      IP or hostname of the database.
    When `--psc-service-attachment` is also specified, this field value should be:
    1. For Cloud SQL PSC enabled instance - the dns_name field (e.g <uid>.<region>.sql.goog.).
    2. For Cloud SQL PSA instance (vpc peering) - the private ip of the instance.
  z--hostr-   Nr   r.   s      r   r"   r"   b   s    ) 	hYBr   c                 2    SnU R                  SX![        S9  g)z%Adds --port flag to the given parser.z$    Network port of the database.
  z--port)r   r   typeNr   intr.   s      r   r#   r#   m   s     ) 	hYLr   c                 6    SnU R                  SUS[        SS9  g)z)Adds --dbm-port flag to the given parser.z)    The Database Mirroring (DBM) port.
  z
--dbm-portFT)r   r   r4   hiddenNr5   r   s     r   AddDbmPortFlagr9   u   s)    ) 	UT  r   c                    U R                  5       nXR                  :X  a  [        USSS9  [        US5        UR                  5       n[	        USS9  [
        R                  " U5      S:X  a  [        USS9  g[        USS9  g)zFAdds ssl server only & server client config group to the given parser.FNr8   choicesTr   v1alpha2)	r   GAAddSslTypeFlagAddCaCertificateFlagAddPrivateKeyFlagr   GetApiVersionAddCertificateFlagAddClientCertificateFlag)r   release_track
ssl_configclient_certs       r   AddSslConfigGrouprH      sq    !*&&&:eT:z4($$&+K$/M*j8{T2[48r   c                 <    U R                  5       n[        US5        g)z6Adds ssl server only config group to the given parser.TN)r   r@   r   rF   s     r   AddSslServerOnlyConfigGrouprK      s    !*z4(r   c                 T    U R                  5       n[        US/ SQS9  [        U5        g)zAAdds ssl server only & required config group to the given parser.F)SERVER_ONLYREQUIREDNONEr;   N)r   r?   r@   rJ   s     r   %AddSslServerOnlyOrRequiredConfigGrouprP      s*    !*(K z"r   c                 R    SnU R                  S[        R                  " 5       SUS9  g)z,Adds a --ssl-flags flag to the given parser.z    Comma-separated list of SSL flags used for establishing SSL connection to
    the database. Use an equals sign to separate the flag name and value.
    Example: `--ssl-flags ssl_mode=enable,server_certificate_hostname=server.com`.
  z--ssl-flagsz
FLAG=VALUE)r4   metavarr   N)r   r   ArgDictr   s     r   AddSslFlagsrT      s3    )
 	 	  r   c                 B    SnU(       d  / SQnU R                  SUUUS9  g)z)Adds --ssl-type flag to the given parser.z%    The type of SSL configuration.
  )rM   SERVER_CLIENTrN   rO   z
--ssl-type)r   r<   r8   Nr   )r   r8   r<   r   s       r   r?   r?      s2    ) 
BG	  r   c                 (    SnU R                  SX!S9  g)z/Adds --ca-certificate flag to the given parser.a      x509 PEM-encoded certificate of the CA that signed the database
    server's certificate. The value for this flag needs to
    be the content of the certificate file, not the path to the file.
    For example, on a Linux machine you can use command substitution:
    <code>--ca-certificate=$(</path/to/certificate_file.pem)</code>.
    Database Migration Service will use this certificate to verify
    it's connecting to the correct host. Database Migration Service encrypts the
    value when storing it.
  z--ca-certificater-   Nr   r.   s      r   r@   r@      s    	) 	(yLr   c                 (    SnU R                  SX!S9  g)z,Adds --certificate flag to the given parser.ag      x509 PEM-encoded certificate that will be used by the replica to
    authenticate against the database server. The value for this flag needs to
    be the content of the certificate file, not the path to the file.
    For example, on a Linux machine you can use command substitution:
    <code>--ca-certificate=$(</path/to/certificate_file.pem)</code>.
  z--certificater-   Nr   r.   s      r   rC   rC      s    ) 	oIIr   c                 (    SnU R                  SX!S9  g)z3Adds --client-certificate flag to the given parser.a      x509 PEM-encoded certificate that will be used by the replica to
    authenticate against the database server.  The value for this flag needs to
    be the content of the certificate file, not the path to the file.
    For example, on a Linux machine you can use command substitution:
    <code>--ca-certificate=$(</path/to/certificate_file.pem)</code>.
    Database Migration Service encrypts the value when storing it.
  z--client-certificater-   Nr   r.   s      r   rD   rD      s    ) 	,9Pr   c                 (    SnU R                  SX!S9  g)z,Adds --private-key flag to the given parser.a      Unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with
    the Client Certificate.  The value for this flag needs to
    be the content of the certificate file, not the path to the file.
    For example, on a Linux machine you can use command substitution:
    <code>--ca-certificate=$(</path/to/certificate_file.pem)</code>.
    Database Migration Service encrypts the value when storing it.
  z--private-keyr-   Nr   r.   s      r   rA   rA      s    ) 	oIIr   c                 (    SnU R                  SX!S9  g)z)Adds --instance flag to the given parser.zt    If the source is a Cloud SQL database, use this field to provide the Cloud
    SQL instance ID of the source.
  z
--instancer-   Nr   r.   s      r   AddInstanceFlagr\      s    ) 	lFr   c                 (    SnU R                  SX!S9  g)z2Adds --cloudsql-instance flag to the given parser.z    If the source or destination is a Cloud SQL database, then use this field
    to provide the respective Cloud SQL instance ID.
  z--cloudsql-instancer-   Nr   r.   s      r   AddCloudSQLInstanceFlagr^      s    ) 	+)Or   c                 (    SnU R                  SX!S9  g)z4Adds the --alloydb-cluster flag to the given parser.zf    If the destination is an AlloyDB cluster, use this field to provide the
    AlloyDB cluster ID.
  z--alloydb-clusterr-   Nr   r.   s      r   AddAlloydbClusterFlagr`      s    ) 	)	Mr   c                 0    SnSS/nU R                  SXS9  g)z)Adds --provider flag to the given parser.z0    Database provider, for managed databases.
  RDSCLOUDSQLz
--providerr   r<   Nr   r   r   r<   s      r   AddProviderFlagrf   	  s(    ) J'lDr   c                 0    SnSS/nU R                  SXS9  g)z%Adds --role flag to the given parser.z#The role of the connection profile.SOURCEDESTINATIONz--rolerd   Nr   re   s      r   AddRoleFlagrj     s$    3)}%'hY@r   c           
          SnU(       a  U R                  SUSSSSUS9  g
U R                  USSS9nUR                  SUSSSSSS9  UR                  S	USSSSSS9  g
)z:Adds --enable-iam-authentication flag to the given parser.zUse IAM database authentication to connect to the database. The username will be overridden by the DMS service agent principal. This flag is only supported for PostgreSQL Destinations.z--enable-iam-authenticationstore_constTenable_iam_authentication)r   r   constdestr8   r   )r   r   r8   Fz--disable-iam-authenticationN)r   r   )r   r   r   r   iam_authentication_groups        r   r   r     s    B 
 
%(    &//d  0   ))%( *  ))&( * r   )TFF)F)FN)FF)!__doc__
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   googlecloudsdk.callioper   r   r   r+   r$   r    r!   r"   r#   r9   rH   rK   rP   rT   r?   r@   rC   rD   rA   r\   r^   r`   rf   rj   r    r   r   <module>rv      s    F &  ' > /I8 59GL;*GGG"CM9)#M	J
Q
JGPNEA&r   