
    }                     R   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KJr  SSKJr  SSKJr  SSKr\R0                  \R2                  " \R4                  R6                  5       " S S\R8                  5      5       5       rg)9Performs a storage size decrease of a Cloud SQL instance.    )absolute_import)division)unicode_literals)
exceptions)api_util)	constants)
operations)validate)base)flags)
properties)
console_ioNc                   .    \ rS rSrSr\S 5       rS rSrg)PerformStorageShrink$   r   c                     [         R                  R                  U 5        U R                  S[        R
                  SS9  [        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.
instancezCloud SQL instance ID.)	completerhelpN)r   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleterAddStorageSizeForStorageShrink)parsers    3lib/surface/sql/instances/perform_storage_shrink.pyArgsPerformStorageShrink.Args)   sH     	OO'
))%  ' 
((0    c           
         [         R                  " [         R                  5      nUR                  nUR                  n[
        R                  " UR                  5        UR                  R                  UR                  S[        R                  R                  R                  R                  0SS9n[        R                   " S5      (       d  g UR#                  UR                  UR                  UR%                  ['        UR(                  [*        R,                  -  5      S9S9nUR.                  R1                  U5      nUR                  R3                  SUR4                  UR                  S	9nUR6                  (       a/  UR                  UR                  UR4                  UR8                  S
.$ [:        R<                  R?                  UUSS5        UR@                  RC                  URE                  UR                  UR                  S95      n	UR                  UR                  U	RF                  RH                  S.$ ! [J        RL                   a  n
U
RN                  [P        RR                  RT                  RV                  :X  a3  [X        RZ                  " SR]                  UR_                  5       5      5      e[`        Rb                  " U
5      eSn
A
ff = f)aJ  Performs a storage size decrease of a Cloud SQL instance.

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

Returns:
  A dict object representing the operations resource describing the perform
  storage shrink operation if the decrease was successful.

Raises:
  HttpException: A http error response was received while executing api
      request.
  ResourceNotFoundError: The SQL instance wasn't found.
  RequiredArgumentException: A required argument was not supplied by the
  user, such as omitting --root-password on a SQL Server instance.
projectzsql.instances)params
collectionzConfirm that you have already run `gcloud alpha sql instances get-storage-shrink-config $instance_name` and understand that this operation will restart your database and might take a long time to complete (y/n)N)targetSizeGb)r   r"   performDiskShrinkContextzsql.operations)	operationr"   )NameProjectOperationIdStatusz;Performing a storage size decrease on a Cloud SQL instance.i)r"   r   )r(   r)   StorageSizeGbzFThere's no instance found at {} or you're not authorized to access it.)2r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer   resource_parserParser   VALUEScorer"   	GetOrFailr   PromptContinue,SqlProjectsInstancesPerformDiskShrinkRequestPerformDiskShrinkContextintstorage_sizer	   BYTES_TO_GBprojects_instancesPerformDiskShrink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/   r0   instance_refrequestresult_operationoperation_refchanged_instance_resourceerrors              r   RunPerformStorageShrink.Run9   s   $  < <=F""J&&L!!$--0))//:,,1199CCD" 0 L $$	  +5II((&&#/#H#Ht0093H3HHI $I $ J g $66HH
 ,,33
$))&& 4 (m
 
$--,:N:N/44*113 	3 ""33


G
	 #-"6"6":":

-
-"**\5J5J . L#M
 ''!))4==LL 
 (( 5			cii33==	=.. 9 9 ;<> 	>  --e445s!   CH: -BH: :KA;K		K N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r_   __static_attributes__ra   r    r   r   r   $   s      B1 1P5r    r   )rf   
__future__r   r   r   apitools.base.pyr   rJ   googlecloudsdk.api_lib.sqlr   r	   r
   r   googlecloudsdk.callioper   rT   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   googlecloudsdk.core.consoler   six.moves.http_clientrM   HiddenReleaseTracksReleaseTrackALPHACommandr   ra   r    r   <module>rv      s}    @ &  ' > / 0 1 1 / ( E 0 * 2  D%%++,c54<< c5 - c5r    