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                   @   s0   e Zd Zedd Zedd Zedd ZdS )HostsClientc                 C   s   |j ddd}|jddd}d|_|j dd	d}|jd
dtd |jddtd |jddddgdd |jddtd |jddtdd |jddtdd |jddd d! |j| jd" |j d#d$d}|jdd%tdd |j| jd" d S )&NhostszGet information about hosts)helpVerbsverb)titledestTlistzList all hostsz--filterzString to filter search results)r   typez--sort_fieldzSort hosts by this fieldz
--sort_dirz"Direction of sort. 'asc' or 'desc'ascdesc)r   choicesdefaultz--starta5  Specify the starting point for the host search results.                                     For example, if you set count to 100 and the first 100 results                                      have already been returned,                                     you can set start to 101 to get the next 100 results.z--countz#Number of hosts to return. Max 1000d   )r   r   r   z--fromzLNumber of seconds since UNIX epoch from which you want to search your hosts.from_)r   r   r   z--include_hosts_metadatazxInclude metadata from the hosts                                     (agent_version, machine, platform, processor, etc.).
store_true)r   action)functotalszGet the total number of hostszpNumber of seconds since UNIX epoch                                     from which you want to search your hosts.)	
add_parseradd_subparsersrequiredadd_argumentstrintset_defaults_list_totals)cls
subparsersparserverb_parserslist_parsertotals_parser r(   J/home/ubuntu/.local/lib/python3.10/site-packages/datadog/dogshell/hosts.pysetup_parser   sJ   zHostsClient.setup_parserc              	   C   sp   |j t_|j}tjj|j|j|j|j	|j
|j|jd}t| t| |dkr/tt| d S tt| d S )N)filter
sort_fieldsort_dirstartcountr   include_hosts_metadatapretty)timeoutr   _timeoutformatHostsget_allr+   r,   r-   r.   r/   r   r0   r   r   printr   jsondumpsr"   argsr4   resr(   r(   r)   r    D   s    zHostsClient._listc                 C   sX   |j t_|j}tjj|jd}t| t| |dkr#t	t
| d S t	t| d S )N)r   r1   )r2   r   r3   r4   r5   r   r   r   r   r7   r   r8   r9   r:   r(   r(   r)   r!   Z   s   zHostsClient._totalsN)__name__
__module____qualname__classmethodr*   r    r!   r(   r(   r(   r)   r      s    
2
r   )
r8   datadog.util.formatr   datadogr   datadog.dogshell.commonr   r   objectr   r(   r(   r(   r)   <module>   s
   