
    9Yf              
       P    d dl mZ d dlmZmZmZmZmZmZ  G d deeeeee      Z	y)    )ApiError)CreateableAPIResourceGetableAPIResourceActionAPIResourceUpdatableAPISyntheticsResource!UpdatableAPISyntheticsSubResourceActionAPISyntheticsResourcec                        e Zd ZdZdZdZe fd       Ze fd       Ze fd       Z	e fd       Z
e fd       Ze fd	       Ze fd
       Ze fd       Ze fd       Ze fd       Z xZS )
Syntheticsz.
    A wrapper around Sythetics HTTP API.
    
syntheticsstatusc                 6    d}t         t        |   d|||      S )z
        Get test's details.

        :param id: public id of the test to retrieve
        :type id: string

        :returns: Dictionary representing the API's JSON response
        testsGET)idnameparamssuperr    _trigger_synthetics_class_action)clsr   r   r   	__class__s       V/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/datadog/api/synthetics.pyget_testzSynthetics.get_test   s(     ZFuQSZ^gmFnn    c                     dD ]2  }||v st        ||   t              sdj                  ||         ||<   4 t        t        |   d|      S )zl
        Get all tests' details.

        :returns: Dictionary representing the API's JSON response
        )	locationstags,r   )r   r   )
isinstancelistjoinr   r   get)r   r   pr   s      r   get_all_testszSynthetics.get_all_tests/   sW     ' 	0AF{z&)T:HHVAY/q		0 Z)WV)DDr   c                 4    d}t         t        |   d||      S )z}
        Get a list of devices for browser checks

        :returns: Dictionary representing the API's JSON response
        zbrowser/devicesr   r   r   r   r   r   r   r   s      r   get_deviceszSynthetics.get_devices?   s%     !ZFuSW`fFggr   c                 4    d}t         t        |   d||      S )zy
        Get a list of all available locations

        :return: Dictionary representing the API's JSON response
        r   r   r'   r   r(   s      r   get_locationszSynthetics.get_locationsM   s'      ZFuSW`fFggr   c                 R    dj                  |      }t        t        |   d||      S )z
        Get the most recent results for a test

        :param id: public id of the test to retrieve results for
        :type id: id

        :return: Dictionary representing the API's JSON response
        ztests/{}/resultsr   r   formatr   r   r   )r   r   r   pathr   s       r   get_resultszSynthetics.get_results[   s/     "((,ZFud[aFbbr   c                 T    dj                  ||      }t        t        |   d||      S )aV  
        Get a specific result for a given test.

        :param id: public ID of the test to retrieve the most recent result for
        :type id: id

        :param result_id: result ID of the test to retrieve the most recent result for
        :type result_id: id

        :returns: Dictionary representing the API's JSON response
        ztests/{}/results/{}r   r-   r.   )r   r   	result_idr   r0   r   s        r   
get_resultzSynthetics.get_resultl   s1      %++B	:ZFud[aFbbr   c                 .    t        t        | 
  dddi|S )a  
        Create a test

        :param name: A unique name for the test
        :type name: string

        :param type: The type of test. Valid values are api and browser
        :type type: string

        :param subtype: required for SSL test - For a SSL API test, specify ssl as the value.
        :Otherwise, you should omit this argument.
        :type subtype: string

        :param config: The test configuration, contains the request specification and the assertions.
        :type config: dict

        :param options: List of options to customize the test
        :type options: dict

        :param message: A description of the test
        :type message: string

        :param locations: A list of the locations to send the tests from
        :type locations: list

        :param tags: A list of tags used to filter the test
        :type tags: list

        :return: Dictionary representing the API's JSON response
        r   r    )r   r   create)r   r   r   s     r   create_testzSynthetics.create_test   s     F Z,BB6BBr   c                 .    t        t        | 
  dd|i|S )z
        Edit a test

        :param id: Public id of the test to edit
        :type id: string

        :return: Dictionary representing the API's JSON response
        r   r6   )r   r   update_synthetics)r   r   r   r   s      r   	edit_testzSynthetics.edit_test   s     Z7H2HHHr   c                 .    t        t        | 
  dd|i|S )a   
        Pause a given test

        :param id: public id of the test to pause
        :type id: string

        :param new_status: mew status for the test
        :type id: string

        :returns: Dictionary representing the API's JSON response
        r   r6   )r   r   update_synthetics_items)r   r   bodyr   s      r   start_or_pause_testzSynthetics.start_or_pause_test   s      Z=LLtLLr   c                 l    t        |d   t              st        d      t        t        |   dddd|S )z
        Delete a test

        :param public_ids: list of public IDs to delete corresponding tests
        :type public_ids: list of strings

        :return: Dictionary representing the API's JSON response
        
public_idsz%Parameter 'public_ids' must be a listr   ztests/delete)r   r   )POST)r    r!   r   r   r   _trigger_action)r   r>   r   s     r   delete_testzSynthetics.delete_test   s@     $|,d3BCC Z5k<Tbkfjkkr   )__name__
__module____qualname____doc___resource_name_sub_resource_nameclassmethodr   r%   r)   r+   r1   r4   r8   r;   r?   rD   __classcell__)r   s   @r   r   r      s     "N!o o  E E h h h h c c  c c& "C "CH I I M M" l lr   r   N)
datadog.api.exceptionsr   datadog.api.resourcesr   r   r   r   r   r	   r   r6   r   r   <module>rO      s4    , Gl"%Glr   