
                         0   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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SKJr  SSS.r\R&                  " \R(                  R*                  5      \R,                   " S S\R.                  5      5       5       rg)z?Command to create connection profiles for a database migration.    )absolute_import)division)unicode_literals)resource_args)base)
exceptions)flags)create_helper)sqlserver_flags)
console_ioFCreate a Database Migration Service connection profile for SQL Server.a          To create a source connection profile my-source-profile for SQL Server:

            $ {command} my-source-profile --region=us-central1
            --gcs-bucket=bucket-name --gcs-prefix=prefix/path

        To create a destination connection profile my-dest-profile for SQL
        Server:

            $ {command} my-dest-profile --region=us-central1
            --cloudsql-instance=cloudsql-id
        )DESCRIPTIONEXAMPLESc                   P    \ rS rSrSr\r\S 5       rS r	S r
S rS rS rS	 rS
rg)
_SQLServer1   r   c                    [         R                  " U S5        [        R                  " U 5        [        R                  " U 5        [        R
                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        g)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 createN)r   (AddSqlServerConnectionProfileResourceArgcp_flagsAddNoAsyncFlagAddDisplayNameFlagAddRoleFlag%AddSslServerOnlyOrRequiredConfigGroupAddSslFlagsr   AddCloudSqlInstanceFlagsAddCpDetailsFlagAddDatabaseFlagr	   AddLabelsCreateFlags)parsers    Flib/surface/database_migration/connection_profiles/create/sqlserver.pyArgs_SQLServer.Args8   s     ::6;OF#' 226: ,,V4$$V,V$	v&    c                 p   U R                  U5        UR                  R                  R                  5       nUR	                  5       R                  5       nUR                  (       a  [        R                  " S5      Ul	        [        R                  " 5       nUR                  U R                  5       UUUS5      $ )a  Create a Database Migration Service connection profile.

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: 	SQLSERVER)_ValidateArgsCONCEPTSconnection_profileParseParentRelativeNameprompt_for_passwordr   PromptPasswordpasswordr
   CreateHelpercreateReleaseTrack)selfargsconnection_profile_ref
parent_refhelpers        r    Run_SQLServer.RunL   s     	t!]]==CCE'..0==?J //0IJdm'')F== r#   c                 H    U R                  U5        U R                  U5        g)z(Validates the arguments for the command.N)_ValidateHeterogeneousOrDagArgs$_ValidateHomeogeneousDestinationArgsr2   r3   s     r    r&   _SQLServer._ValidateArgsg   s    ((.--d3r#   c                 v    UR                  S5      (       a  U R                  U5        g U R                  U5        g )Ndbm_port)IsKnownAndSpecified_ValidateDagArgs_ValidateHeterogeneousArgsr<   s     r    r:   *_SQLServer._ValidateHeterogeneousOrDagArgsl   s/    
++
D!
%%d+r#   c                 v   UR                  S5      (       a  UR                  c  [        R                  " SS5      eUR                  c  [        R                  " SS5      eUR                  S5      (       a  [        R                  " SS	5      eUR                  S
5      (       a  [        R                  " SS5      egg)zEValidates the arguments for heterogeneous source connection profiles.hostN
--usernamez'Username must be specified with --host.z
--passwordz'Password must be specified with --host.cloudsql_instance--cloudsql-instancez/Cloud SQL instance can not be used with --host.cloudsql_project_id--cloudsql-project-idz1Cloud SQL project ID can not be used with --host.)r@   usernamer   BadArgumentExceptionr.   r<   s     r    rB   %_SQLServer._ValidateHeterogeneousArgsr   s    ''		--5
 	
 
	--5
 	
 
	!	!"5	6	6--!=
 	
 
	!	!"7	8	8--#?
 	
 
9! (r#   c                     UR                  S5      (       d  [        R                  " SS5      eUR                  c  [        R                  " SS5      eUR                  S5      (       d=  UR                  S5      (       a'  UR                  S:X  a  [        R                  " S	S
5      eUR                  S5      (       a  [        R                  " SS5      eUR                  S5      (       a  [        R                  " SS5      eg)zKValidates the arguments for DAG HMM source/destination connection profiles.rolez--rolez'Role must be specified with --dbm-port.NrF   z+Username must be specified with --dbm-port.rG   DESTINATIONrH   zLCloud SQL instance must be specified with --dbm-port and --role=DESTINATION.rI   rJ   z5Cloud SQL project ID can not be used with --dbm-port.databasez
--databasez)Database can not be used with --dbm-port.)r@   r   rL   rK   rO   r<   s     r    rA   _SQLServer._ValidateDagArgs   s    ##F++++

3  }}++

7 
 $$%899$$V,,II&++
! 
  566++
!
A  
++++

5  ,r#   c                 $   UR                  S5      (       dz  UR                  S5      (       ac  UR                  S:X  aR  UR                  c  [        R                  " SS5      eUR                  S5      (       a  [        R                  " SS	5      egggg)
zIValidates the arguments for homeogeneous destination connection profiles.rE   rO   rP   NrH   z=Cloud SQL instance must be specified with --role=DESTINATION.
gcs_bucketz--gcs-bucketz3GCS bucket can not be used with --role=DESTINATION.)r@   rO   rG   r   rL   r<   s     r    r;   /_SQLServer._ValidateHomeogeneousDestinationArgs   s     $$V,,$$V,,II&				'--!K
 	
 
	!	!,	/	/--A
 	
 
0 ' - -r#    N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr!   r7   r&   r:   rB   rA   r;   __static_attributes__rV   r#   r    r   r   1   s>     O-' '&64
,
0B
r#   r   N)r[   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   googlecloudsdk.callioper   r   -googlecloudsdk.command_lib.database_migrationr	   Agooglecloudsdk.command_lib.database_migration.connection_profilesr
   r   r   googlecloudsdk.core.consoler   r\   ReleaseTracksr1   GADefaultUniverseOnlyCommandr   rV   r#   r    <module>rj      s    F &  ' C ( . ? [ _ ] 2 	Q	& D%%(()H
 H
  *H
r#   