
    o                        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 e	j$                   e	j&                  e	j(                  j*                         G d de	j,                                      Z e	j&                  e	j(                  j0                  e	j(                  j2                         G d de             Zy)zUpdates a AlloyDB cluster.    )absolute_import)division)unicode_literals)api_util)cluster_operations)base)
exceptions)cluster_helper)flags)log)
properties)	resourcesc                   H     e Zd ZdZdddZ fdZed        Zd Zd Z	 xZ
S )	Update<Update an AlloyDB cluster within a given project and region.z{description}z        To update a cluster, run:

          $ {command} my-cluster --region=us-central1 --automated-backup-start-times=12:00 --automated-backup-days-of-week=MONDAY --automated-backup-retention-count=10
        )DESCRIPTIONEXAMPLESc                 >    t        t        | 
  |i | ddg| _        y )NzL--automated-backup-* | --disable-automated-backup | --clear-automated-backupz]--enable-continuous-backup | --continuous-backup-* | --clear-continuous-backup-encryption-key)superr   __init__
parameters)selfargskwargs	__class__s      &lib/surface/alloydb/clusters/update.pyr   zUpdate.__init__3   s+    	&$ $1&1'O	DO    c                    t        j                  | j                               }t        j                  j                  |       t        j                  |       t        j                  |       t        j                  ||| j                         d       t        j                  || j                         d       t        j                  ||d       t        j                  ||d       t        j                  ||       y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    T)updateN)r   GetMessagesModuleReleaseTrackr   
ASYNC_FLAGAddToParserr   	AddRegion
AddClusterAddAutomatedBackupFlagsAddContinuousBackupConfigFlagsAddMaintenanceWindowAddDenyMaintenancePeriodAddSubscriptionType)clsparseralloydb_messagess      r   ArgszUpdate.Args@   s      11#2B2B2DEOO'	OOF	V	!! #"2"2"4T 
((  "4 
v'7E	""6+;DI	f&67r   c                 0    t        j                  |||      S N)r
   ConstructPatchRequestFromArgsGAr   r-   cluster_refr   s       r   ConstructPatchRequestFromArgsz$Update.ConstructPatchRequestFromArgsU   s    99+t- -r   c                     t        j                  | j                               }|j                  }|j                  }|j
                  j                  dt        j                  j                  j                  j                  |j                  |j                        }| j                  |||      }|j                  s t!        j"                  | j$                  d      |j&                  j)                  |      }t*        j,                  j/                  |j0                  d      }t2        j4                  j7                  dj9                  |j;                                      |j<                  s&t?        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)
projectsIdlocationsId
clustersIdz.Please specify at least one property to updatez%alloydb.projects.locations.operations)
collectionzOperation ID: {}zUpdating clusterF)!r   AlloyDBClientr!   alloydb_clientr-   resource_parserCreater   VALUEScoreproject	GetOrFailregionclusterr4   
updateMaskr	   MinimumArgumentExceptionr   projects_locations_clustersPatchr   REGISTRYParseRelativeNamenamer   statusPrintformatNameasync_r   Await)	r   r   clientr;   r-   r3   reqopop_refs	            r   Runz
Update.RunY   sH    ##D$5$5$78F**N..((//-$$))11;;KK<<	 0 !K
 
,
,-={-13C>>//
//KM M		3	3	9	9#	>B11
C 2 EFJJ'..v{{}=>;;v'94;L;L;N$&Ir   )__name__
__module____qualname____doc__detailed_helpr   classmethodr.   r4   rU   __classcell__r   s   @r   r   r   #   s=     E 		- 8 8(-r   r   c                   2     e Zd ZdZe fd       Zd Z xZS )
UpdateBetar   c                 ^    t         t        t          |       t        j                  |       y r0   )r   r_   r.   r   AddMaintenanceVersion)r+   r,   r   s     r   r.   zUpdateBeta.Args~   s     	*j&v.	'r   c                 0    t        j                  |||      S r0   )r
   !ConstructPatchRequestFromArgsBetar2   s       r   r4   z(UpdateBeta.ConstructPatchRequestFromArgs   s    ;;+t r   )rV   rW   rX   rY   r[   r.   r4   r\   r]   s   @r   r_   r_   z   s    D( (r   r_   N)rY   
__future__r   r   r   googlecloudsdk.api_lib.alloydbr   r   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.alloydbr
   r   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr!   GAUpdateCommandr   ALPHABETAr_    r   r   <module>rp      s    ! &  ' 3 = ( . = 4 # * ) D%%(()RT R * Rj D%%++T->->-C-CD  Er   