
    4)                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr   " S S	\R                  5      rg)
Cloud Backup Plans client.    )absolute_import)division)unicode_literalsN)util)
exceptionsc                   P   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
rU =r$ )BackupPlansClient   r   c                 `   > [         [        U ]  5         U R                  R                  U l        g )N)superr
   __init__clientprojects_locations_backupPlansservice)self	__class__s    3lib/googlecloudsdk/api_lib/backupdr/backup_plans.pyr   BackupPlansClient.__init__!   s"    	
T+-;;==DL    c                    / nU GH  nU R                   R                  5       nSU;  a  SOUS   Ul        U R                   R                  US   US   S9Ul        U R                   R                  R                  US   5      Ul        SU;   a
  US   Ul        SU;   a>  US    Vs/ s H(  nU R                   R                  R                  U5      PM*     snUl	        S	U;   a  US	   R                  S
5      nU R                   R                  U R                   R                  R                  US   5      U R                   R                  R                  US   5      S9Ul        SU;   a
  US   Ul        SU;   a>  US    Vs/ s H(  nU R                   R                  R!                  U5      PM*     snUl        U R                   R%                  US   US   US9nUR'                  U5        GM     U$ s  snf s  snf )Nz	time-zoneUTCzbackup-window-startzbackup-window-end)startHourOfDayendHourOfDay
recurrencezhourly-frequencyzdays-of-weekzweek-day-of-month-r      )weekOfMonth	dayOfWeekzdays-of-monthmonthsrule-idzretention-days)ruleIdbackupRetentionDaysstandardSchedule)messagesStandardScheduletimeZoneBackupWindowbackupWindowRecurrenceTypeValueValuesEnumrecurrenceTypehourlyFrequency"DaysOfWeekValueListEntryValuesEnum
daysOfWeeksplitWeekDayOfMonthWeekOfMonthValueValuesEnumDayOfWeekValueValuesEnumweekDayOfMonthdaysOfMonthMonthsValueListEntryValuesEnumr    
BackupRuleappend)	r   backup_rulesbackup_rules_messagebackup_rulestandard_scheduledayweek_day_of_monthmonthbackup_rule_messages	            r   _ParseBackupRules#BackupPlansClient._ParseBackupRules%   s2   #--88:k1%{;7O   (,}}'A'A$%:;"#67 (B ($
 --
(
(
F
F,' &
 
{	*,78J,K)	;	&
 #>2	(
 3 MM**MM 3	(
$ 
	+'(;<BB3G+/==+G+G44OO!!$ mm22KK!!$	 ,H ,
( 
K	'(3O(D%	[	  %X.$
. MM**II%P.$
  !MM44Y')*:;, 5 
 !!"56[ $\  ;(
&$
s   $/G-=/G2c	                 r   UR                  5       R                  5       n	UR                  5       n
U R                  R	                  UUS9nUb  Xkl        Ubv  U R                  R                  R                  UR                  5        VVs/ s H2  u  pU R                  R                  R                  R                  XS9PM4     snnS9Ul	        U R                  U5      Ul        Ub  X[l        Ub  [        U5      Ul        U R                  R                  U	UU
S9nU R                   R#                  U5      $ s  snnf )a  Creates a Backup Plan.

Args:
  resource: The Backup Plan resource.
  backup_vault: The Backup Vault resource.
  resource_type: The resource type of the Backup Plan.
  backup_rules: The backup rules of the Backup Plan.
  log_retention_days: The log retention days of the Backup Plan.
  description: The description of the Backup Plan.
  labels: The labels of the Backup Plan.
  max_custom_on_demand_retention_days: The custom on demand retention days
    limit of the Backup Plan.

Returns:
  The created Backup Plan.
)resourceTypebackupVault)keyvalue)additionalProperties)parent
backupPlanbackupPlanId)ParentRelativeNameNamer%   
BackupPlandescriptionLabelsValueitemsAdditionalPropertylabelsr@   backupRuleslogRetentionDaysintmaxCustomOnDemandRetentionDays1BackupdrProjectsLocationsBackupPlansCreateRequestr   Create)r   resourcebackup_vaultresource_typer8   log_retention_daysrO   rS   #max_custom_on_demand_retention_daysrH   backup_plan_idbackup_planrE   rF   requests                  r   rY   BackupPlansClient.CreateW   s@   6 __++-F]]_N--**"  + K  +==33??
 !'	  !/*# mm&&22EE F  !/	  @ k #44\BK%%7"*6
1
2 0 mmMM# N G
 <<w''' s   9D3
c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zmDescribes a Backup Plan.

Args:
  resource: The Backup Plan resource.

Returns:
  The described Backup Plan.
name)r%   .BackupdrProjectsLocationsBackupPlansGetRequestrL   r   Getr   rZ   ra   s      r   DescribeBackupPlansClient.Describe   sA     mmJJ""$ K G <<G$$r   c	           	         Uc  [        S5      eU R                  R                  UR                  S9n	Ub  Xl        Ub  Xyl        Ub  [        U5      U	l        UR                   V
s1 s H  oR                  iM     nn
Ub  U R                  U5      U	l        U	$ UGb?  [        R                  " U V
s/ s H  oS   PM	     sn
5      nUR                  5        VVs/ s H  u  pUS:  d  M  UPM     nnnU(       a  [        R                  " SSU S35      e[!        [#        U V
s/ s H  n
U
S   U;  d  M  U
S   PM     sn
5      5      nU(       a  [        R                  " SSU S35      eU V
s/ s H  oS   PM	     nn
UR                   V
s/ s H  n
U
R                  U;  d  M  U
PM     sn
U	l        U	R                  R%                  U R                  U5      5        OUR                  U	l        Ub*  U	R                  R%                  U R                  U5      5        Ub  [!        [#        U Vs/ s H  nX;  d  M
  UPM     sn5      5      nU(       a  [        R                  " SSU S35      eU	R                   V
s/ s H  n
U
R                  U;  d  M  U
PM     sn
U	l        U	$ s  sn
f s  sn
f s  snnf s  sn
f s  sn
f s  sn
f s  snf s  sn
f )	a  Parses the update request for a Backup Plan.

Args:
  description: The description of the Backup Plan.
  new_backup_rules_from_file: The backup rules to update from file in the
    Backup Plan.
  update_backup_rules: The backup rules to update in the Backup Plan.
  add_backup_rules: The backup rules to add to the Backup Plan.
  remove_backup_rules: The backup rules to remove from the Backup Plan.
  current_backup_plan: The current Backup Plan.
  log_retention_days: The log retention days of the Backup Plan.
  max_custom_on_demand_retention_days: The custom on demand retention days
    limit of the Backup Plan.

Returns:
  The updated Backup Plan.

Raises:
  InvalidArgumentException: If the backup rules are invalid.
  ValueError: If the backup plan is not found.
zCould not find the backup plan.)rC   r!   r   zRules z+ found in more than one --backup-rule flag.z` not found in the backup plan. The --backup-rule flag can only be used to modify existing rules.z not found in the backup plan.)
ValueErrorr%   rN   rC   rO   rU   rV   rW   rT   r"   r@   collectionsCounterrQ   r   InvalidArgumentExceptionlistsetextend)r   rO   new_backup_rules_from_fileupdate_backup_rulesadd_backup_rulesremove_backup_rulescurrent_backup_planr]   r^   updated_backup_planrulecurrent_rule_idsrule_idsrule_idcountduplicate_rule_idsnot_found_rule_idsupdate_rule_idss                     r   ParseUpdateBackupPlansClient.ParseUpdate   s'   @ "899--22(55 3  (3%%-?**6
1
2 8 1D0O0OP0O0OP!-(,(>(>
$)% ! &$$':
;':t	?':
;h )1(8(8ngEAI'(8   
11'( )# #
 	

  )%)d)_$44 $y/)% !	 

 
11'( ) 
 	
 6II5HTi5HoI *55)5d[[/ 5)%
 %%,,

 
 !4
5 )<(G(G%#%%,,

 
 !1
2 &,%,g, ,% !	 

 
11'((FG
 	

 /::):4[[ 33 :)% { Q <% J)%)sN   %J/J$J)'J) J/1	J/+J4	J9!J9)	J>6J>7KKc                     [         R                  " 5       nU R                  R                  UUR	                  5       UUS9nU R
                  R                  U5      $ )zUpdates a Backup Plan.

Args:
  resource: The Backup Plan resource.
  backup_plan: The updated Backup Plan.
  update_mask: The update mask to edit the Backup Plan.

Returns:
  The updated Backup Plan.
)rI   re   	requestId
updateMask)command_utilGenerateRequestIdr%   0BackupdrProjectsLocationsBackupPlansPatchRequestrL   r   Patch)r   rZ   r`   update_mask
request_idra   s         r   UpdateBackupPlansClient.Update  sX     //1JmmLL""$	 M G <<g&&r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )ziDeletes a Backup Plan.

Args:
  resource: The Backup Plan resource.

Returns:
  The deleted Backup Plan.
rd   )r%   1BackupdrProjectsLocationsBackupPlansDeleteRequestrL   r   Deleterh   s      r   r   BackupPlansClient.Delete  sA     mmMM""$ N G <<w''r   )r   )__name__
__module____qualname____firstlineno____doc__r   r@   rY   ri   r   r   r   __static_attributes____classcell__)r   s   @r   r
   r
      s2    ">0 d8(t%jX'(( (r   r
   )r   
__future__r   r   r   rm   googlecloudsdk.api_lib.backupdrr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.backupdrr   BackupDrClientBaser
    r   r   <module>r      s3    ! &  '  0 . D
M(// M(r   