
    9Yf                     J    d dl Z d dlmZ d dlmZ d dlmZmZ  G d de      Z	y)    N)pretty_json)api)report_errorsreport_warningsc                   |    e Zd Zed        Zed        Zed        Zed        Zed        Zed        Z	ed        Z
y)	DowntimeClientc                    |j                  dd      }|j                  dddd       |j                  d	d
      }d|_        |j                  dd      }|j                  dd       |j                  ddd        |j                  ddd        |j                  ddd        |j	                  | j
                         |j                  dd      }|j                  dd       |j                  dd       |j                  ddd        |j                  ddd        |j                  ddd        |j	                  | j                         |j                  dd       }|j                  dd!       |j	                  | j                         |j                  d"d#      }|j                  d$d%d        |j	                  | j                         |j                  d&d'      }|j                  dd(       |j	                  | j                         |j                  d)d*      }	|	j                  dd+       |	j	                  | j                         y ),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_parsers
             Y/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/datadog/dogshell/downtime.pysetup_parserzDowntimeClient.setup_parser   s   &&z8\&]L	 	 	
 ,,7,H $"--f;N-O  /K L  /V`d e  /T^b c  Zdh 	! 	
 	  c&<&< =$//?Y/Z""=7g"h""93O"P""93]gk"l""71Ycg"h""Zdh 	# 	
 	""(<(<"="--f;W-X  5G H  c&8&8 9&11*Ca1b$$#fpt 	% 	
 	$$#*@*@$A$//?R/S""=7K"L""(<(<"=$//0AHq/r""71W"X""(E(E"F    c                 x   |j                   t        _        |j                  }t        j                  j                  |j                  |j                  |j                  |j                        }t        |       t        |       |dk(  rt        t        |             y t        t        j                  |             y N)r   r   endmessagepretty)timeoutr   _timeoutformatDowntimecreater   r   r8   r9   r   r   printr   jsondumpsr)   argsr=   ress       r3   r#   z!DowntimeClient._schedule_downtimeB   s{    ||ll!!

$**$((\`\h\h!icX+c"#$**S/"r5   c                    |j                   t        _        |j                  }t        j                  j                  |j                  |j                  |j                  |j                  |j                        }t        |       t        |       |dk(  rt        t        |             y t        t        j                   |             y r7   )r;   r   r<   r=   r>   r   r   r   r   r8   r9   r   r   r@   r   rA   rB   rC   s       r3   r$   zDowntimeClient._update_downtimeN   s    ||ll!!DJJdjjdhhX\XdXd " 
 	cX+c"#$**S/"r5   c                     |j                   t        _        t        j                  j	                  |j
                        }|t        |       t        |       y y )N)r;   r   r<   r>   r   r   r   r   )r)   rD   rE   s      r3   r'   zDowntimeClient._cancel_downtime\   sA    ||ll!!$"2"23?C # r5   c                 4   |j                   t        _        |j                  }t        j                  j                  |j                        }t        |       t        |       |dk(  rt        t        |             y t        t        j                  |             y )Nr:   )r;   r   r<   r=   r>   getr   r   r   r@   r   rA   rB   rC   s       r3   r%   zDowntimeClient._show_downtimed   se    ||llt//0cX+c"#$**S/"r5   c                 6   |j                   t        _        |j                  }t        j                  j                  |j                        }t        |       t        |       |dk(  rt        t        |             y t        t        j                  |             y )N)current_onlyr:   )r;   r   r<   r=   r>   get_allrK   r   r   r@   r   rA   rB   rC   s       r3   r&   z!DowntimeClient._show_all_downtimep   sh    ||ll""0A0A"BcX+c"#$**S/"r5   c                 
   |j                   t        _        |j                  }t        j                  j                  |j                        }|dk(  rt        t        |             y t        t        j                  |             y )N)r   r:   )r;   r   r<   r=   r>   cancel_downtime_by_scoper   r@   r   rA   rB   rC   s       r3   r(   z(DowntimeClient._cancel_downtime_by_scope|   sV    ||ll33$**3EX+c"#$**S/"r5   N)__name__
__module____qualname__classmethodr4   r#   r$   r'   r%   r&   r(    r5   r3   r   r      s    /G /Gb 	# 	# # #   	# 	# 	# 	# # #r5   r   )
rA   datadog.util.formatr   datadogr   datadog.dogshell.commonr   r   objectr   rS   r5   r3   <module>rX      s%   
  ,  Bu#V u#r5   