o
    i                     @   sD   d dl Z d dlmZ d dlmZ d dlmZmZ G dd deZ	dS )    N)pretty_json)api)report_errorsreport_warningsc                   @   s`   e Zd Zedd Zedd Zedd Zedd Zed	d
 Zedd Z	edd Z
dS )DowntimeClientc           
      C   s  |j ddd}|jddddd |jd	d
d}d|_|j ddd}|jddd |jddd d |jddd d |jddd d |j| jd |j ddd}|jddd |jddd |jddd d |jddd d |jddd d |j| jd |j dd d}|jdd!d |j| jd |j d"d#d}|jd$d%d d |j| jd |j d&d'd}|jdd(d |j| j	d |j d)d*d}	|	jdd+d |	j| j
d d S ),Ndowntimez"Create, edit, and delete downtimes)helpz--string_ids
store_true
string_idsz9Represent downtime IDs as strings instead of ints in JSON)actiondestr   Verbsverb)titler   TpostzCreate a downtimescopezscope to apply downtime tostartz%POSIX timestamp to start the downtime)r   defaultz--endz#POSIX timestamp to end the downtimez	--messagez7message to include with notifications for this downtime)funcupdatezUpdate existing downtimedowntime_idz+downtime to replace with the new definitionz--scopez--startshowzShow a downtime definitionzdowntime to showshow_allzShow a list of all downtimesz--current_onlyz>only return downtimes that are active when the request is madedeletezDelete a downtimezdowntime to deletecancel_by_scopez'Cancel all downtimes with a given scopez$The scope of the downtimes to cancel)
add_parseradd_argumentadd_subparsersrequiredset_defaults_schedule_downtime_update_downtime_show_downtime_show_all_downtime_cancel_downtime_cancel_downtime_by_scope)
cls
subparsersparserverb_parserspost_parserupdate_parsershow_parsershow_all_parserdelete_parsercancel_parser r0   M/home/ubuntu/.local/lib/python3.10/site-packages/datadog/dogshell/downtime.pysetup_parser   sP   zDowntimeClient.setup_parserc                 C   sd   |j t_|j}tjj|j|j|j|j	d}t
| t| |dkr)tt| d S tt| d S N)r   r   endmessagepretty)timeoutr   _timeoutformatDowntimecreater   r   r4   r5   r   r   printr   jsondumpsr&   argsr9   resr0   r0   r1   r    B   s   z!DowntimeClient._schedule_downtimec                 C   sh   |j t_|j}tjj|j|j|j|j	|j
d}t| t| |dkr+tt| d S tt| d S r3   )r7   r   r8   r9   r:   r   r   r   r   r4   r5   r   r   r<   r   r=   r>   r?   r0   r0   r1   r!   N   s   zDowntimeClient._update_downtimec                 C   s6   |j t_tj|j}|d urt| t| d S d S )N)r7   r   r8   r:   r   r   r   r   )r&   r@   rA   r0   r0   r1   r$   \   s   zDowntimeClient._cancel_downtimec                 C   sV   |j t_|j}tj|j}t| t| |dkr"t	t
| d S t	t| d S )Nr6   )r7   r   r8   r9   r:   getr   r   r   r<   r   r=   r>   r?   r0   r0   r1   r"   d   s   zDowntimeClient._show_downtimec                 C   sX   |j t_|j}tjj|jd}t| t| |dkr#t	t
| d S t	t| d S )N)current_onlyr6   )r7   r   r8   r9   r:   get_allrC   r   r   r<   r   r=   r>   r?   r0   r0   r1   r#   p   s   z!DowntimeClient._show_all_downtimec                 C   sH   |j t_|j}tjj|jd}|dkrtt| d S tt	
| d S )N)r   r6   )r7   r   r8   r9   r:   cancel_downtime_by_scoper   r<   r   r=   r>   r?   r0   r0   r1   r%   |   s   z(DowntimeClient._cancel_downtime_by_scopeN)__name__
__module____qualname__classmethodr2   r    r!   r$   r"   r#   r%   r0   r0   r0   r1   r      s    
1




r   )
r=   datadog.util.formatr   datadogr   datadog.dogshell.commonr   r   objectr   r0   r0   r0   r1   <module>   s
   