
                         p   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  e
j                  d	d
d      Z e
j                  de	j                  j                  d      Z e
j                  de	j                  j                  d      Z e
j                  ded      ZdZd Zd Zd Zd Zy)z"Command utilities for maintenance.    )absolute_import)division)unicode_literals)
datafusion)arg_parsers)base)
exceptionsz--clear-maintenance-window
store_truezD    Clear the maintenance window for this Data Fusion instance.
    )actionhelp--maintenance-window-starta      The start time of the maintenance window. Only the time of the day is
    used as a reference for a starting time of the window with a provided
    recurrence. This flag must be specified if any of the other arguments in
    this group are specified. For example:
      --maintenance_window_start=2024-01-01T01:00:00Z.
    See $ gcloud topic datetimes for information on time formats.
    )typer   --maintenance-window-enda      The end time of the maintenance window. Only the time of the day is
    used as a reference for an ending time of the window with a provided
    recurrence. This will be used in conjunction with start time, and
    the difference will determine the length of a single maintenance
    window. This flag must be specified if any of the other arguments in this
    group are specified. For example:
      --maintenance_window_end=2024-01-02T01:00:00Z.
    See $ gcloud topic datetimes for information on time formats.
    --maintenance-window-recurrencea#      An RFC 5545 RRULE, specifying how the maintenance window will recur.
    Only FREQ=WEEKLY format is supported. This flag must be specified if
    any of the other arguments in this group are specified. For example:
      --maintenance_window_recurrence="FREQ=WEEKLY;BYDAY=FR,SA,SU".
    z<Group of arguments for setting the maintenance window value.c                     | j                  t              }t        j                  |       t        j                  |       t
        j                  |       y)zAdds argument group for creating maintenance window.

  Args:
    parser: parser to which the group of flags should be added.
  N)	add_group$MAINTENANCE_WINDOW_GROUP_DESCRIPTIONMAINTENANCE_WINDOW_STARTAddToParserMAINTENANCE_WINDOW_ENDMAINTENANCE_WINDOW_RECURRENCE)parsergroups     ?lib/googlecloudsdk/command_lib/data_fusion/maintenance_utils.pyCreateArgumentsGroupr   I   s?     

?
@%&&u-$$U+++E2    c                     | j                         }|j                  t              }t        j	                  |       t
        j	                  |       t        j	                  |       t        j	                  |       y)zAdds argument group for updating maintenance window.

  Args:
    parser: parser to which the group of flags should be added.
  N)add_mutually_exclusive_groupr   r   r   r   r   r   CLEAR_MAINTENANCE_WINDOW_FLAG)r   update_groupmaintenance_window_groups      r   UpdateArgumentsGroupr"   U   sa     446,)33*,&&'?@$$%=>++,DE++L9r   c                 n   | j                   }| j                  }| j                  }|s|s|r
|st        j                  dd      |st        j                  dd      |st        j                  dd      t        j                         }|j                  j                  |j                  j                  |j                  j                  |j                  j                  |j                         j                  dd      |j                         j                  dd            |      	      
      |_        yy)LValidates maintenance window flags and sets the maintenance window value.
  r   zmust be specified.r   r   z+00:00Z)	startTimeendTime)window
recurrence)recurringTimeWindow)maintenanceWindowN)maintenance_window_startmaintenance_window_endmaintenance_window_recurrencer	   RequiredArgumentExceptiondf
DatafusionmessagesMaintenancePolicyMaintenanceWindowRecurringTimeWindow
TimeWindow	isoformatreplacemaintenancePolicy)argsinstancer,   r-   r.   r   s         r   SetMaintenanceWindowr<   d   s<    "::66"&"D"D##00
&
    "00
$
    )00
+
    J!+!4!4!F!F$--?? * 3 3 G G!**556@@BGHc*2<<>GHc*	 6  9 !H ! @ 

 "G "H $r   c                 D    | j                   rd|_        yt        | |       y)r$   N)clear_maintenance_windowr9   r<   )r:   r;   s     r   UpdateMaintenanceWindowr?      s     
""!%Hx(r   N)__doc__
__future__r   r   r   "googlecloudsdk.api_lib.data_fusionr   r0   googlecloudsdk.callioper   r   r	   Argumentr   DatetimeParser   r   strr   r   r   r"   r<   r?    r   r   <module>rI      s    ) &  ' ? / ( . - 
!	  )4== 				#	#

	  '				#	#	
	  !.%	
!	  C %	3:#L)r   