o
    i                  	   @   sJ   d dl mZ d dlmZmZmZmZmZmZ G dd deeeeeeZ	dS )    )ApiError)CreateableAPIResourceGetableAPIResourceActionAPIResourceUpdatableAPISyntheticsResource!UpdatableAPISyntheticsSubResourceActionAPISyntheticsResourcec                       s   e Zd ZdZdZdZe fddZe fddZe fdd	Z	e fd
dZ
e fddZe fddZe fddZe fddZe fddZe fddZ  ZS )
Syntheticsz.
    A wrapper around Sythetics HTTP API.
    
syntheticsstatusc                    s   d}t t| jd|||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__ J/home/ubuntu/.local/lib/python3.10/site-packages/datadog/api/synthetics.pyget_test   s   zSynthetics.get_testc                    sF   dD ]}||v rt || trd|| ||< qtt| jd|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   r   r   get_all_tests/   s
   zSynthetics.get_all_testsc                       d}t t| jd||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   r   r   get_devices?   s   
zSynthetics.get_devicesc                    r#   )zy
        Get a list of all available locations

        :return: Dictionary representing the API's JSON response
        r   r   r$   r   r%   r   r   r   get_locationsM   s   zSynthetics.get_locationsc                    s    d |}tt| jd||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   r   r   get_results[   s   
zSynthetics.get_resultsc                    s"   d ||}tt| jd||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   r+   r   r   r   
get_resultl   s   zSynthetics.get_resultc                    s   t t| j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   Nr   )r   r	   create)r   r   r   r   r   create_test   s   #zSynthetics.create_testc                       t t| j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   Nr   )r   r	   update_synthetics)r   r   r   r   r   r   	edit_test   s   zSynthetics.edit_testc                    r1   )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   Nr   )r   r	   update_synthetics_items)r   r   bodyr   r   r   start_or_pause_test   s   zSynthetics.start_or_pause_testc                    s2   t |d tstdtt| j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 listPOSTr
   ztests/delete)r   r   N)r8   )r   r   r   r   r	   _trigger_action)r   r5   r   r   r   delete_test   s   zSynthetics.delete_test)__name__
__module____qualname____doc___resource_name_sub_resource_nameclassmethodr   r"   r&   r'   r,   r.   r0   r3   r6   r:   __classcell__r   r   r   r   r	      s0    $r	   N)
datadog.api.exceptionsr   datadog.api.resourcesr   r   r   r   r   r   r	   r   r   r   r   <module>   s    

