
                            d Z ddl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
ej&                  fdZdej*                  dedefdZ ej0                  ej2                  j4                        ej6                   G d dej8                                      Z ej0                  ej2                  j<                         G d de             Zy)z%Creates a Backup and DR Backup Vault.    N)
exceptions)util)BackupVaultsClient)base)flags)labels_util)logparserc                 0   t        j                  | d       t        j                  |        t        j                  | d       t        j                  |        t        j
                  |        t        j                  |        t        j                  | d       y)zsSpecifies additional command flags.

  Args:
    parser: argparse.Parser: Parser object for command line inputs.
  zName of the backup vault to create.  A vault name cannot be changed after creation. It must be between 3-63 characters long and must be unique within the project and location.TcreateN)r   AddBackupVaultResourceArgAddNoAsyncFlagAddEnforcedRetentionAddDescriptionAddEffectiveTime	AddLabels'AddBackupVaultAccessRestrictionEnumFlagr
   s    -lib/surface/backup_dr/backup_vaults/create.py_add_common_argsr      sr     !!1 vVT*v //&//A    args$support_backup_retention_inheritancesupport_kms_keyc                 <   t               }| j                  j                  j                         }t	        j
                  | j                        }| j                  }t	        j                  | j                  d      }t        j                  | |j                  j                  j                        }| j                  }	| j                   }
d}|r| j"                  }|r2| j$                  r&|j                  j'                  | j$                        nd}	 |j)                  |||||||
||	      }|	rf|j7                  |j9                  |      dj;                  |j=                                     }t?        j@                  |j=                         d       |S t?        j@                  |j=                         dd	t2        jB                  j;                  |jD                        
       |S # t*        j,                  $ r)}t/        j0                  |t2        j4                        d}~ww xY w)a  Constructs and sends request.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the .Args() method.
    support_backup_retention_inheritance: bool, A boolean that indicates if the
      backup vault supports setting the backup_retention_inheritance field.
    support_kms_key: bool, A boolean that indicates if the backup vault
      supports setting the kms_key field.

  Returns:
    ProcessHttpResponse of the request made.
  zeffective-timeN)
kmsKeyName)encryption_configzHCreating backup vault [{}]. (This operation could take up to 2 minutes.))operation_refmessagezbackup vault)kindT)r    is_asyncdetails)#r   CONCEPTSbackup_vaultParsecommand_utilConvertIntToStrbackup_min_enforced_retentiondescriptionVerifyDateInFutureeffective_timer   ParseCreateArgsmessagesBackupVaultLabelsValueno_asyncaccess_restrictionbackup_retention_inheritancekms_keyEncryptionConfigCreateapitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATWaitForOperationGetOperationRefformatRelativeNamer	   CreatedResourceASYNC_OPERATION_MESSAGEname)r   r   r   clientr$   r(   r)   r+   labelsr0   r1   r2   r   	operationeresources                   r   _runrF   2   s   $ &++113,".">">
((#   +22
+. &&
FOO''33& ]](..!%)#'#D#D  
T\\ oo&&$,,&? 
>,%$+  
I &&,,Y7&&,f\-F-F-H&I	 ' H 113.IO!**11)..A	 
) 
	&	& >

"
"1d&<&<
==>s   G H2$HHc                   h    e Zd ZdZdddddZedej                  fd       Zd	ej                  fd
Z
y)r5   $Create a Backup and DR backup vault.z%Creates a Backup and DR backup vault.z{description}zThis command uses the backupdr/v1 API. The full documentation for this API can be found at: https://cloud.google.com/backup-disaster-recoverya          To create a new backup vault ``BACKUP_VAULT'' in location ``MY_LOCATION'' with
        minimum enforced-retention for backups of 1 month and 1 day, run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION             --backup-min-enforced-retention="p1m1d"

        To create a new backup vault ``BACKUP_VAULT'' in location ``MY_LOCATION'' with
        minimum enforced-retention for backups of 1 day and description ``DESCRIPTION'',
        run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION             --backup-min-enforced-retention="1d" --description=DESCRIPTION

        To create a new backup vault ``BACKUP_VAULT'' in location ``MY_LOCATION'' with
        minimum enforced-retention for backups of 1 day and label key1 with value value1,
        run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION             --backup-min-enforced-retention="1d" --labels=key1=value1

        To create a new backup vault ``BACKUP_VAULT'' in location ``MY_LOCATION'' with
        minimum enforced-retention for backups of 1 day and effective-time "2024-03-22",
        run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION             --backup-min-enforced-retention="1d" --effective-time="2024-03-22"
        )BRIEFDESCRIPTIONzAPI REFERENCEEXAMPLESr
   c                     t        |        yzySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    N)r   r   s    r   ArgszCreate.Args   s     Vr   r   c                     t        |dd      S )Constructs 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.
    Fr   r   rF   selfr   s     r   Runz
Create.Run   s     -2 r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodargparseArgumentParserrN   	NamespacerU    r   r   r5   r5      sT     - 7$?$-L 8**  h(( r   r5   c                   @    e Zd ZdZed        Zdej                  fdZy)CreateAlpharH   c                 n    t        |        t        j                  |        t        j                  |        yrM   )r   r   AddBackupRetentionInheritance	AddKmsKeyr   s    r   rN   zCreateAlpha.Args   s&     V	''/	OOFr   r   c                     t        |dd      S )rP   TrQ   rR   rS   s     r   rU   zCreateAlpha.Run   s     4 r   N)	rV   rW   rX   rY   r[   rN   r\   r^   rU   r_   r   r   ra   ra      s)    , h(( r   ra   ) rY   r\   apitools.base.pyr   r6   googlecloudsdk.api_lib.backupdrr   -googlecloudsdk.api_lib.backupdr.backup_vaultsr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   #googlecloudsdk.command_lib.backupdrr   r&   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer	   r]   r   r^   boolrF   ReleaseTracksReleaseTrackGADefaultUniverseOnlyCreateCommandr5   ALPHAra   r_   r   r   <module>ru      s    ,  > 0 L 2 ( 5 D < #BX44 B(J


J*.J JZ D%%(()@T @  *@F D%%++,&  -r   