
    ;                         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 dd	lmZ dd
lmZ  G d dej                         Zy)z+`gcloud monitoring snoozes cancel` command.    )absolute_import)division)unicode_literals)snoozes)base)resource_args)util)log)timesc                   0    e Zd ZdZdddZed        Zd Zy)CancelzCancels a snooze.a            Cancel a snooze.

          If the start time is in the future, then
          this command is equivalent to:

            * update --start-time="+PT1S" --end-time="+PT1S

          Otherwise, if the start time is past and the ending time is in the
          future, then this command is equivalent to:

            * update --end-time="+PT1S

          For information about the JSON/YAML format of a snooze:
          https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.snoozes
       aQ            To cancel a snooze, run:

            $ {command} MY-SNOOZE

          To cancel a snooze contained within a specific project, run:

            $ {command} MY-SNOOZE --project=MY-PROJECT

          To cancel a snooze with a fully qualified snooze ID, run:

            $ {command} projects/MY-PROJECT/snoozes/MY-SNOOZE
       )DESCRIPTIONEXAMPLESc                 \    t        j                  d      g}t        j                  | |       y )Nzto be canceled.)r   CreateSnoozeResourceArgAddResourceArgs)parser	resourcess     (lib/surface/monitoring/snoozes/cancel.pyArgszCancel.Args@   s+     	--.?@BI!!&)4    c                    t        j                         }|j                  }|j                  j                  j                         }|j                  |      }t        j                  |j                  j                        }t        j                  d      }|t        j                         kD  r|}t        j                  ||||       |j                  ||d       }t        j                   |j"                  d       |S )Nz+PT1S)
start_timeend_timesnooze)r   SnoozeClientmessagesCONCEPTSr   ParseGetr   ParseDateTimeinterval	startTimeNowr	   ModifySnoozeUpdater
   UpdatedResourcename)	selfargsclientr   
snooze_refr   r   r   results	            r   Runz
Cancel.RunF   s    !!#FH%%++-J ZZ
#F$$V__%>%>?J""7+HEIIKj	 ]]:vt4FX.Mr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r.    r   r   r   r      s0     #-@ 5 5
r   r   N)r2   
__future__r   r   r   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r	   googlecloudsdk.corer
   googlecloudsdk.core.utilr   UpdateCommandr   r5   r   r   <module>r=      s7    2 &  ' 5 ( ? 6 # *?T ?r   