
    v                     :   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lZej*                   ej,                  ej.                  j0                         G d dej2                                      Zy)zAResets a Cloud SQL read replica size to its primary storage size.    )absolute_import)division)unicode_literals)
exceptions)api_util)
operations)validate)base)flags)
propertiesNc                   &    e Zd ZdZed        Zd Zy)ResetReplicaSizezIResets a Cloud SQL read replica storage size to its primary storage size.c                     t         j                  j                  |        | j                  dt        j
                  d       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.
    replicazCloud SQL read replica ID.)	completerhelpN)r
   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleter)parsers    /lib/surface/sql/instances/reset_replica_size.pyArgszResetReplicaSize.Args(   s8     	OO'
)))      c                    t        j                  t         j                        }|j                  }|j                  }t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }	 |j                  |j                  |j                         }|j"                  j%                  |      }|j                  j'                  d|j(                  |j                        }|j*                  r/|j                   |j                  |j(                  |j,                  dS t.        j0                  j3                  ||d       |j4                  j7                  |j9                  |j                  |j                               }	|j                   |j                  |	j:                  j<                  d	S # t>        j@                  $ r}}
|
jB                  tD        jF                  jH                  jJ                  k(  r2tM        jN                  d
jQ                  |jS                                     tU        jV                  |
      d}
~
ww xY w)a  Resets a Cloud SQL read replica storage size to its primary storage size.

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

    Returns:
      A dict object representing the operations resource describing the reset
      replica size operation if the reset was successful.

    Raises:
      HttpException: A http error response was received while executing an api
          request.
      ResourceNotFoundError: The SQL instance isn't found.
    projectzsql.instances)params
collection)r   instancezsql.operations)	operationr   )NameProjectOperationIdStatusz*Resetting the Cloud SQL read replica size.)r!   r"   StorageSizeGbzFThere's no instance found at {} or you're not authorized to access it.N),r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer   resource_parserParser   VALUEScorer   	GetOrFail+SqlProjectsInstancesResetReplicaSizeRequestr   projects_instancesr   Createnameasync_statusr   OperationsV1Beta4WaitForOperation	instancesGetSqlInstancesGetRequestsettingsdataDiskSizeGbapitools_exceptions	HttpErrorstatus_codesixmoveshttp_client	FORBIDDENr   ResourceNotFoundErrorformatRelativeNamecalliope_exceptionsHttpException)selfargsclientr(   r)   instance_refrequestresult_operationoperation_refchanged_instance_resourceerrors              r   RunzResetReplicaSize.Run7   s0      < <=F""J&&L!!$,,/))//:,,1199CCD" 0 L*5HH&&1F1F I g $66GGP,,33
$))&& 4 m
 
 ))#+++00&--	
 	
 ""33


6 #-"6"6":":

-
-"**\5J5J . # ''!))4==LL 
 (( 5			cii33==	=.. 9 9 ;<> 	>  --e445s!   2B.G0 !BG0 0J A8I;;J N)__name__
__module____qualname____doc__staticmethodr   rR    r   r   r   r   #   s      R E5r   r   )rV   
__future__r   r   r   apitools.base.pyr   r=   googlecloudsdk.api_lib.sqlr   r   r	   googlecloudsdk.callioper
   rG   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   six.moves.http_clientr@   HiddenReleaseTracksReleaseTrackALPHACommandr   rX   r   r   <module>re      sy    H &  ' > / 1 1 / ( E 0 *  D%%++,W5t|| W5 - W5r   