
                         D   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  \R$                  \R&                  " \R(                  R*                  \R(                  R,                  5       " S S\R.                  5      5       5       rg)Creates a new Backup Plan.    )absolute_import)division)unicode_literals)
exceptions)backup_plans)util)base)flags)logc                   :    \ rS rSrSrSSSS.r\S 5       rS rS	r	g
)Create   r   zCreates a new backup planz          Create a new backup plan in the project. It can only be created in
          locations where Backup and DR is available.
      a\          To create a new backup plan ``sample-backup-plan''
        in project ``sample-project'',
        at location ``us-central1'',
        with resource-type ``compute.<UNIVERSE_DOMAIN>.com/Instance'' and
        backup-vault ``backup-vault''
        with 2 backup-rules:

        run:

          $ {command} sample-backup-plan --project=sample-project --location=us-central1
            --resource-type 'compute.<UNIVERSE_DOMAIN>.com/Instance'
            --backup-vault <BACKUP-VAULT>
            --backup-rule <BACKUP-RULE>
            --backup-rule <BACKUP-RULE>

        Backup Rule Examples:

        1. Hourly backup rule with hourly backup frequency of 6 hours and store it for 30 days, and expect the backups to run only between 10:00 to 20:00 UTC

        <BACKUP-RULE>: rule-id=sample-hourly-rule,retention-days=30,recurrence=HOURLY,hourly-frequency=6,time-zone=UTC,backup-window-start=10,backup-window-end=20

        Properties:
          -- rule-id = "sample-hourly-rule"
          -- retention-days = 30
          -- recurrence = HOURLY
          -- hourly-frequency = 6
          -- time-zone = UTC
          -- backup-window-start = 10
          -- backup-window-end = 20

        2. Daily backup rule with daily backup frequency of 6 hours and store it for 7 days

        <BACKUP-RULE>: rule-id=sample-daily-rule,retention-days=7,recurrence=DAILY,backup-window-start=1,backup-window-end=14

        Properties:
          -- rule-id = "sample-daily-rule"
          -- retention-days = 7
          -- recurrence = DAILY
          -- backup-window-start = 1
          -- backup-window-end = 14

        3. Weekly backup rule with weekly backup frequency on every MONDAY & FRIDAY and store it for 21 days

        <BACKUP-RULE>: rule-id=sample-weekly-rule,retention-days=21,recurrence=WEEKLY,days-of-week="MONDAY FRIDAY",backup-window-start=10,backup-window-end=20

        Properties:
          -- rule-id = "sample-weekly-rule"
          -- retention-days: 21
          -- recurrence = WEEKLY
          -- days-of-week = "MONDAY FRIDAY"
          -- backup-window-start = 10
          -- backup-window-end = 20
        )BRIEFDESCRIPTIONEXAMPLESc                    [         R                  R                  U 5        [         R                  R                  U S5        [        R
                  " U S5        [        R                  " U S5        [        R                  " U 5        [        R                  " U 5        Sn[        R                  " X5        Sn[        R                  " X5        [        R                  " U 5        g)zmSpecifies additional command flags.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
TzName of the backup plan to be created.
        Once the backup plan is created, this name can't be changed.
        The name must be unique for a project and location.
        zvType of resource to which the backup plan should be applied.
          E.g., `compute.<UNIVERSE_DOMAIN>.com/Instance` a          Provide a description of the backup plan, such as specific use cases and
        relevant details, in 2048 characters or less.

        E.g., This is a backup plan that performs a daily backup at 6 p.m. and
        retains data for 3 months.
        a          If you have assigned labels to your resources for grouping, you can
        provide the label using this flag.A label is a key-value pair.

        Keys must start with a lowercase character and contain only hyphens (-),
        underscores (_), lowercase characters, and numbers. Values must contain
        only hyphens (-), underscores (_), lowercase characters, and numbers.
        N)r
   
ASYNC_FLAGAddToParser
SetDefaultr   'AddBackupPlanResourceArgWithBackupVaultAddResourceTypeAddBackupRule!AddMaxCustomOnDemandRetentionDaysAddDescription	AddLabelsAddLogRetentionDays)parserdescription_helplabels_helps      ,lib/surface/backup_dr/backup_plans/create.pyArgsCreate.Argsb   s     	OO'OOvt,	11	 
	=
 
	++F3 
2K 
OOF(	f%    c           
         [         R                  " 5       nUR                  nUR                  R                  R                  5       nUR                  R                  R                  5       nUR                  nUR                  nUR                  nUR                  n	UR                  n
UR                  n UR                  UUR                  5       UUUU	U
U5      nU(       aN  [*        R,                  " UR                  5       SS[&        R.                  R1                  UR2                  5      S9  U$ UR5                  UR7                  U5      SR1                  UR                  5       5      S9n[*        R,                  " UR                  5       SS9  U$ ! [        R                    a*  n["        R$                  " U[&        R(                  5      eSnAff = f)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.
Nzbackup planT)kindis_asyncdetailszGCreating backup plan [{}]. (This operation could take up to 2 minutes.))operation_refmessage)r&   )r   BackupPlansClientasync_CONCEPTSbackup_planParsebackup_vaultresource_typebackup_rulelog_retention_daysdescriptionlabels#max_custom_on_demand_retention_daysr   RelativeNameapitools_exceptions	HttpErrorr   HttpExceptionr	   HTTP_ERROR_FORMATr   CreatedResourceASYNC_OPERATION_MESSAGEformatnameWaitForOperationGetOperationRef)selfargsclientr'   r.   r0   r1   backup_rulesr3   r4   r5   r6   	operationeresources                  r!   Run
Create.Run   s    ++-F{{H--++113K==--335L&&M##L00""K[[F00 (@--


#
#
%





-	i 	

"
"
$..55innE	 &&,,Y7&&,f[-E-E-G&H	 ' H 002GO+ (( @$$Q(>(>??@s   3&F G#%GG N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr"   rI   __static_attributes__rK   r$   r!   r   r      s8     # +
5<-| )& )&V8r$   r   N)rP   
__future__r   r   r   apitools.base.pyr   r8   googlecloudsdk.api_lib.backupdrr   r	   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper
   #googlecloudsdk.command_lib.backupdrr   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAGACreateCommandr   rK   r$   r!   <module>ra      s    ! '  ' > 8 0 2 ( 5 # D%%++T->->-A-ABeT e C er$   