
                         x   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 e
j$                   e
j&                  e
j(                  j*                         G d de
j,                                      Ze
j$                   e
j&                  e
j(                  j0                         G d de
j,                                      Ze
j$                   e
j&                  e
j(                  j4                         G d de
j,                                      Zd Zd Zd Zd Zd Z y)4Reset SSL materials according to the reset SSL mode.    )absolute_import)division)unicode_literals)api_util)
operations)validate)base)flags)log)
properties)
console_ioc                   &    e Zd ZdZed        Zd Zy)ResetSslConfigBaser   c                     t        |        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.
    N)AddBaseArgsparsers    -lib/surface/sql/instances/reset_ssl_config.pyArgszResetSslConfigBase.Args$   s         c                 6    t        || j                               S a0  Reset SSL materials according to the reset SSL mode.

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

    Returns:
      A dict object representing the operations resource describing the
      resetSslConfig operation if the reset was successful.
    RunBaseResetSslConfigCommandReleaseTrackselfargss     r   RunzResetSslConfigBase.Run/        (d.?.?.ABBr   N__name__
__module____qualname____doc__staticmethodr   r     r   r   r   r           = Cr   r   c                   &    e Zd ZdZed        Zd Zy)ResetSslConfigBetar   c                 0    t        |        t        |        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.
    N)r   AddBetaArgsr   s    r   r   zResetSslConfigBeta.ArgsB   s     r   c                 6    t        || j                               S r   r   r   s     r   r    zResetSslConfigBeta.RunM   r!   r   Nr"   r(   r   r   r+   r+   =   r)   r   r+   c                   &    e Zd ZdZed        Zd Zy)ResetSslConfigAlphar   c                 F    t        |        t        |        t        |        yr-   )r   r.   AddAlphaArgsr   s    r   r   zResetSslConfigAlpha.Args`   s     r   c                 6    t        || j                               S r   r   r   s     r   r    zResetSslConfigAlpha.Runl   r!   r   Nr"   r(   r   r   r1   r1   [   s     =	 	Cr   r1   c                    t        j                  t         j                        }|j                  }|j                  }t        j                  | j                         |j                  j                  | j                  dt        j                  j                  j                  j                  id      }|j                  |j                  |j                        }d}t!        |      rd| j#                  d      rS|j                  j$                  j'                  | j(                  j+                               |_        | j(                  dk(  rd}t-        j.                  |d	d	
       |j0                  j3                  |      }|j                  j5                  d|j6                  |j                        }	| j8                  r@|j:                  j=                  |j?                  |	j                  |	j@                              S t:        jB                  jE                  ||	d       tF        jH                  jK                  djM                  |             y)aX  Reset SSL materials according to the reset SSL mode.

  Args:
    args: argparse.Namespace, The arguments that this command was invoked with.
    release_track: string, The release track GA/BETA/ALPHA.

  Returns:
    A dict object representing the operations resource describing the
    resetSslConfig operation if the reset was successful.
  projectzsql.instances)params
collection)r6   instancezkResetting your SSL configuration will delete all client certificates and generate a new server certificate.modeSYNC_FROM_PRIMARYzWSyncing related SSL configs from the primary may cause SSL update operations if needed.T)messagedefaultcancel_on_nozsql.operations)	operationr6   )r6   r?   zResetting SSL configz#Reset SSL config for [{resource}].
)resourceN)'r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer9   resource_parserParser   VALUEScorer6   	GetOrFail!SqlInstancesResetSslConfigRequestIsBetaOrNewerIsSpecifiedModeValueValuesEnumlookup_by_namer:   upperr   PromptContinue	instancesResetSslConfigCreatenameasync_r   GetSqlOperationsGetRequestr?   OperationsV1Beta4WaitForOperationr   statuswriteformat)
r   release_trackclientrC   rD   instance_refreq
prompt_msgresult_operationoperation_refs
             r   r   r   z   s    h::;&  *$$,
.''--
mm**//77AAB  . , 	66""\-B-B 	7 	#,  =!d&6&6v&>==QQ``		CH yy''# 
 J4P))88=((// %%"" 0 - 
[[  $$,,!))]5L5L 	- 	
  //-!7 **,33\3Jr   c                      y)z(Adds alpha args and flags to the parser.Nr(   )unused_parsers    r   r3   r3      s    r   c                 8    | j                  dddddddd	       y)
z'Adds beta args and flags to the parser.z--modez7Refresh all TLS configs. This is the default behaviour.zRefreshes the replication-related TLS configuration settings provided by the primary instance. Not applicable to on-premises replication instances.)ALLr;   FNz%Selectively refresh the SSL materialsT)choicesrequiredr=   helphidden)add_argumentr   s    r   r.   r.      s3    J4 2  r   c                     t         j                  j                  |        | j                  dt        j
                  d       y)z'Adds base args and flags to the parser.r9   zCloud SQL instance ID.)	completerrk   N)r
   
ASYNC_FLAGAddToParserrm   r   InstanceCompleterr   s    r   r   r      s6    //f%''#  r   c                 z    | t         j                  j                  k(  xs | t         j                  j                  k(  S )z3Returns true if the release track is beta or newer.)r
   r   BETAALPHA)r^   s    r   rL   rL      s6     t((--- 2	$++11	1r   N)!r&   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   DefaultUniverseOnlyReleaseTracksr   GACommandr   rt   r+   ru   r1   r   r3   r.   r   rL   r(   r   r   <module>r      s    ; &  ' / 1 / ( 0 # * 2 D%%(()C C * C8 D%%**+C C , C8 D%%++,C$,, C - C:>B
&r   