
                         z   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(                  e	j&                  j*                  e	j&                  j,                         G d de	j.                                      Zy)zRestarts an AlloyDB instance.    )absolute_import)division)unicode_literals)api_util)instance_operations)base)flags)instance_helper)log)
properties)	resourcesc                   6    e Zd ZdZdddZed        Zd Zd Zy)	Restartz4Restarts an AlloyDB instance within a given cluster.z{description}zz        To restart an instance, run:

          $ {command} my-instance --cluster=my-cluster --region=us-central1
        )DESCRIPTIONEXAMPLESc                     t         j                  j                  |        t        j                  | d       t        j
                  |        t        j                  |        t        j                  |        y)zxSpecifies additional command flags.

    Args:
      parser: argparse.Parser, Parser object for command line inputs
    FN)r   
ASYNC_FLAGAddToParserr	   
AddClusterAddInstance	AddRegion
AddNodeIds)parsers    (lib/surface/alloydb/instances/restart.pyArgszRestart.Args2   sN     	OO'	VU#	f	OOF	V    c                     t        j                  |j                  d      |j                  d      |j                  d            S )Nalloydb_messagesproject_refargs)r
   ConstructRestartRequestFromArgsget)selfkwargss     r   ConstructRestartRequestzRestart.ConstructRestartRequest?   s:    ::

%&

=!

6 r   c                    t        j                  | j                               }|j                  }|j                  }|j
                  j                  dt        j                  j                  j                  j                  |j                  |j                  |j                        }| j                  |||      }|j                   j#                  |      }t$        j&                  j)                  |j*                  d      }t,        j.                  j1                  dj3                  |j5                                      |j6                  s&t9        j:                  |d| j                         d       |S )	zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made.
    z-alloydb.projects.locations.clusters.instances)
projectsIdlocationsId
clustersIdinstancesId)r   r   r    z%alloydb.projects.locations.operations)
collectionzOperation ID: {}zRestarting instanceF)r   AlloyDBClientReleaseTrackalloydb_clientr   resource_parserCreater   VALUEScoreproject	GetOrFailregionclusterinstancer%   %projects_locations_clusters_instancesr   r   REGISTRYParseRelativeNamenamer   statusPrintformatNameasync_r   Await)	r#   r    clientr.   r   r   reqopop_refs	            r   RunzRestart.RunF   s4    ##D$5$5$78F**N..((//7$$))11;;KK<<MM 0 K 
&
&) ' C 
	=	=	E	Ec	JB11
C 2 F JJ'..v{{}=>;;
'):):)<e Ir   N)	__name__
__module____qualname____doc__detailed_helpstaticmethodr   r%   rF    r   r   r   r   "   s6    
 = %- 
 
#r   r   N)rJ   
__future__r   r   r   googlecloudsdk.api_lib.alloydbr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.alloydbr	   r
   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr-   GAALPHABETASilentCommandr   rM   r   r   <module>rY      s    $ &  ' 3 > ( 4 > # * ) $++1143D3D3I3ICd   C Cr   