
    i                        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
 r\R                   \R"                  " \R$                  R&                  5       " S S\R(                  5      5       5       r\R"                  " \R$                  R,                  5       " S S\5      5       r\R"                  " \R$                  R0                  5       " S S\5      5       rg)zCreates a new AlloyDB backup.    )api_util)backup_operations)base)flags)resource_args)log)
properties)	resourcesc                 x    U(       a3  U R                   R                  R                  UR                  5       5      $ g N)BackupTypeValueValuesEnumlookup_by_nameupper)alloydb_messagesbackup_types     %lib/surface/alloydb/backups/create.py_ParseBackupTyper      s3    ""66EE 	    c                   >    \ rS rSrSrSSS.r\S 5       rS rS r	S	r
g
)Create'   z4Creates a new AlloyDB backup within a given project.z{description}a%          To create a new backup, run:

          $ {command} my-backup --cluster=my-cluster --region=us-central1

        To create a new cross-region backup, run:

          $ {command} projects/my-project/locations/us-west1/backups/my-backup --cluster=my-cluster --region=us-central1
        )DESCRIPTIONEXAMPLESc                    [         R                  R                  U5        UR                  SS[        SS9  UR                  S[        SS9  [
        R                  " US5        [
        R                  " U5        [        R                  " USS	S
9  g)zmSpecifies additional command flags.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--regionTz$The region of the cluster to backup.)requiredtypehelpbackupaT  The AlloyDB backup to create. This must either be the backup ID (myBackup) or the full backup path (projects/myProject/locations/us-central1/backups/myBackup). In the first case, the project and location are assumed to be the same as the cluster being backed up. The second form can be used to create cross-region and cross-project backups.)r   r   FzjThe 'AlloyDB Service Agent' service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter')permission_infoN)
r   
ASYNC_FLAGAddToParseradd_argumentstrr   
AddClusterAddTagskms_resource_argsAddKmsKeyResourceArg)clsparsers     r   ArgsCreate.Args9   s     	OO'
3	   F	   
VU#	MM&**9	r   c                 l   UR                  5       nUR                  5       Ul        [        US5      Ul        UR                  5       Ul        [        R                  " XAR                   R                  5      Ul	        [        R                  " U5      nU(       a  UR                  5       nXgl        Xul        U$ )N	ON_DEMAND)r   RelativeNamenamer   r   clusterNamer   GetTagsFromArgs	TagsValuetagsGetAndValidateKmsKeyNameEncryptionConfig
kmsKeyNameencryptionConfig)selfr   cluster_ref
backup_refargsbackup_resourcekms_keyencryption_configs           r   ConstructResourceFromArgs Create.ConstructResourceFromArgs^   s     '--/O%224O+,<kJO"-":":"<O 00%%//1O,,T2G*;;=%,"):&r   c                    [         R                  " U R                  5       5      nUR                  nUR                  nUR
                  R                  S[        R                  R                  R                  R                  UR                  UR                  S9nUR
                  R                  SUR                  [        R                  R                  R                  R                  UR                  S.S9nU R!                  XEXa5      nUR#                  UUR%                  5       UR'                  5       R)                  5       S9nUR*                  R                  U5      n	[,        R.                  R1                  U	R2                  SS9n
[4        R6                  R9                  S	R;                  U
R%                  5       5      5        UR<                  (       d&  [>        R@                  " U
S
U R                  5       5        U	$ )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"alloydb.projects.locations.backups)rC   rD   )
collectionlineparams)r   backupIdparentz%alloydb.projects.locations.operations)rF   zOperation ID: {}zCreating backup)!r   AlloyDBClientReleaseTrackalloydb_clientr   resource_parserr   r	   VALUEScoreproject	GetOrFailregionclusterParser   r@   ,AlloydbProjectsLocationsBackupsCreateRequestNameParentr/   projects_locations_backupsr
   REGISTRYParseRelativeNamer0   r   statusPrintformatasync_r   Await)r9   r<   clientrM   r   r:   r;   r=   reqopop_refs              r   Run
Create.Runn   s    ##D$5$5$78F**N..((//-$$))11;;KK<<	 0 !K
 ''--7[[$++0088BB;;
 . J 44zO 
G
G"  "//1 H C
 
	2	2	9	9#	>B11
C 2 EFJJ'..v{{}=>;;f&79J9J9LMIr    N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr+   r@   re   __static_attributes__rg   r   r   r   r   '   s7     = %- " "H *r   r   c                   B   ^  \ rS rSrSr\U 4S j5       rU 4S jrSrU =r	$ )
CreateBeta   3Create a new AlloyDB backup within a given project.c                 X   > [         [        U ]  U5        [        R                  " U5        g r   )superrq   r+   r   AddEnforcedRetentionr)   r*   	__class__s     r   r+   CreateBeta.Args   s     	*c'	v&r   c                 `   > [         [        U ]  XX45      nUR                  (       a  SUl        U$ )NT)ru   rq   r@   enforced_retentionenforcedRetention)r9   r   r:   r;   r<   r=   rx   s         r   r@   $CreateBeta.ConstructResourceFromArgs   s4     JGzO *.o'r   rg   )
rh   ri   rj   rk   rl   rn   r+   r@   ro   __classcell__rx   s   @r   rq   rq      s"    ;' ' r   rq   c                   6   ^  \ rS rSrSr\U 4S j5       rSrU =r$ )CreateAlpha   rs   c                 ,   > [         [        U ]  U5        g r   )ru   r   r+   rw   s     r   r+   CreateAlpha.Args   s    	+s (r   rg   )	rh   ri   rj   rk   rl   rn   r+   ro   r~   r   s   @r   r   r      s    ;) )r   r   N)rl   googlecloudsdk.api_lib.alloydbr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.alloydbr   googlecloudsdk.command_lib.kmsr   r'   googlecloudsdk.corer   r	   r
   r   DefaultUniverseOnlyReleaseTracksrL   GACreateCommandr   BETArq   ALPHAr   rg   r   r   <module>r      s    $ 4 < ( 4 M # * ) D%%(()oT o * od D%%**+  ,& D%%++,)* ) -)r   