
    9Yf ?                     t   d Z ddlmZ  G d de      Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Zy#)$z
Datadog API resources.
    )	APIClientc                   "    e Zd ZdZedd       Zy)CreateableAPIResourcez 
    Creatable API Resource
    Nc                     |i }| j                   }t        | dd      }|dk(  rt        j                  d||fi |S |t        j                  d|||fd|i|S dj	                  | j                   |      }t        j                  d|||fd|i|S )ac  
        Create a new API resource object

        :param attach_host_name: link the new resource object to the host name
        :type attach_host_name: bool

        :param method: HTTP method to use to contact API endpoint
        :type method: HTTP method string

        :param id: create a new resource object as a child of the given object
        :type id: id

        :param params: new resource object source
        :type params: dictionary

        :param body: new resource object attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        N_api_versionGETPOSTattach_host_name{resource_name}/{resource_id}resource_nameresource_id)_resource_namegetattrr   submitformat)clsr
   methodidparamsbodypathapi_versions           U/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/datadog/api/resources.pycreatezCreateableAPIResource.create   s    , >F!!c>48U?##E4EEE:##FD+tqVfqjpqq.55CDVDVdf5gk4mRbmflmm    )Fr	   NN)__name__
__module____qualname____doc__classmethodr    r   r   r   r      s     !n !nr   r   c                   "    e Zd ZdZedd       Zy)SendableAPIResourcezI
    Fork of CreateableAPIResource class with different method names
    Nc                     t        | dd      }|%t        j                  d| j                  ||||      S dj	                  | j                  |      }t        j                  d|||||      S )a  
        Create an API resource object

        :param attach_host_name: link the new resource object to the host name
        :type attach_host_name: bool

        :param id: create a new resource object as a child of the given object
        :type id: id

        :param compress_payload: compress the payload using zlib
        :type compress_payload: bool

        :param body: new resource object attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        r   Nr	   )r
   compress_payloadr   r   )r   r   r   r   r   )r   r
   r   r&   r   r   r   s          r   sendzSendableAPIResource.send:   s    & c>48:##""!1!1  /55CDVDVdf5gD+t>Naq
 	
r   )FNF)r   r   r   r    r!   r'   r"   r   r   r$   r$   5   s     !
 !
r   r$   c                   "    e Zd ZdZedd       Zy)UpdatableAPIResourcez 
    Updatable API Resource
    Nc                     |i }dj                  | j                  |      }t        | dd      }t        j                  d|||fi |S )"  
        Update an API resource object

        :param params: updated resource object source
        :type params: dictionary

        :param body: updated resource object attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        Nr   r   r   PUTr   r   r   r   r   r   r   r   r   r   r   s         r   updatezUpdatableAPIResource.updated   sT     >F.55CDVDVdf5gc>48t[$I&IIr   Nr   r   r   r    r!   r/   r"   r   r   r)   r)   _        J Jr   r)   c                   "    e Zd ZdZedd       Zy)CustomUpdatableAPIResourcez6
    Updatable API Resource with custom HTTP Verb
    Nc                     |d}|i }dj                  | j                  |      }t        | dd      }t        j                  ||||fi |S )a  
        Update an API resource object

        :param method: HTTP method, defaults to PUT
        :type params: string

        :param params: updatable resource id
        :type params: string

        :param params: updated resource object source
        :type params: dictionary

        :param body: updated resource object attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        Nr,   r   r   r   r-   )r   r   r   r   r   r   r   s          r   r/   z!CustomUpdatableAPIResource.update   s^    ( >F>F.55CDVDVdf5gc>48k4J6JJr   )NNNr1   r"   r   r   r4   r4   z   s     K Kr   r4   c                        e Zd ZdZed        Zy)DeletableAPIResourcez 
    Deletable API Resource
    c                     dj                  | j                  |      }t        | dd      }t        j                  d||fi |S )z
        Delete an API resource object

        :param id: resource object to delete
        :type id: id

        :returns: Dictionary representing the API's JSON response
        r   r   r   NDELETEr-   r   r   r   r   r   s        r   deletezDeletableAPIResource.delete   sH     /55CDVDVdf5gc>48$FvFFr   N)r   r   r   r    r!   r;   r"   r   r   r7   r7      s     G Gr   r7   c                        e Zd ZdZed        Zy)GetableAPIResourcez
    Getable API Resource
    c                     dj                  | j                  |      }t        | dd      }t        j                  d||fi |S )a+  
        Get information about an API resource object

        :param id: resource object id to retrieve
        :type id: id

        :param params: parameters to filter API resource stream
        :type params: dictionary

        :returns: Dictionary representing the API's JSON response
        r   r   r   Nr   r-   r:   s        r   getzGetableAPIResource.get   sH     /55CDVDVdf5gc>48t[CFCCr   N)r   r   r   r    r!   r?   r"   r   r   r=   r=      s     D Dr   r=   c                        e Zd ZdZed        Zy)ListableAPIResourcez
    Listable API Resource
    c                 `    t        | dd      }t        j                  d| j                  |fi |S )z
        List API resource objects

        :param params: parameters to filter API resource stream
        :type params: dictionary

        :returns: Dictionary representing the API's JSON response
        r   Nr   r   r   r   r   r   r   r   s      r   get_allzListableAPIResource.get_all   2     c>48s'9'9;Q&QQr   N)r   r   r   r    r!   rE   r"   r   r   rA   rA           R Rr   rA   c                        e Zd ZdZed        Zy)ListableAPISubResourcez#
    Listable API Sub-Resource
    c                     dj                  | j                  || j                        }t        | dd      }t	        j
                  d||fi |S )aC  
        List API sub-resource objects from a resource

        :param id: resource id to retrieve sub-resource objects from
        :type id: id

        :param params: parameters to filter API sub-resource stream
        :type params: dictionary

        :returns: Dictionary representing the API's JSON response
        1{resource_name}/{resource_id}/{sub_resource_name}r   r   sub_resource_namer   Nr   r   r   _sub_resource_namer   r   r   r:   s        r   	get_itemsz ListableAPISubResource.get_items   sY     CII,,"PSPfPf J 
 c>48t[CFCCr   N)r   r   r   r    r!   rP   r"   r   r   rI   rI      s     D Dr   rI   c                   "    e Zd ZdZedd       Zy)AddableAPISubResourcez"
    Addable API Sub-Resource
    Nc                     |i }dj                  | j                  || j                        }t        | dd      }t	        j
                  d|||fi |S )a|  
        Add new API sub-resource objects to a resource

        :param id: resource id to add sub-resource objects to
        :type id: id

        :param params: request parameters
        :type params: dictionary

        :param body: new sub-resource objects attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        NrK   rL   r   r	   rN   r.   s         r   	add_itemszAddableAPISubResource.add_items   sd      >FBII,,"PSPfPf J 
 c>48k4J6JJr   r0   )r   r   r   r    r!   rT   r"   r   r   rR   rR      s     K Kr   rR   c                   "    e Zd ZdZedd       Zy)UpdatableAPISubResourcez$
    Updatable API Sub-Resource
    Nc                     |i }dj                  | j                  || j                        }t        | dd      }t	        j
                  d|||fi |S )  
        Update API sub-resource objects of a resource

        :param id: resource id to update sub-resource objects from
        :type id: id

        :param params: request parameters
        :type params: dictionary

        :param body: updated sub-resource objects attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        NrK   rL   r   r,   rN   r.   s         r   update_itemsz$UpdatableAPISubResource.update_items  sd      >FBII,,"PSPfPf J 
 c>48t[$I&IIr   r0   )r   r   r   r    r!   rY   r"   r   r   rV   rV          J Jr   rV   c                   "    e Zd ZdZedd       Zy)DeletableAPISubResourcez$
    Deletable API Sub-Resource
    Nc                     |i }dj                  | j                  || j                        }t        | dd      }t	        j
                  d|||fi |S )a  
        Delete API sub-resource objects from a resource

        :param id: resource id to delete sub-resource objects from
        :type id: id

        :param params: request parameters
        :type params: dictionary

        :param body: deleted sub-resource objects attributes
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        NrK   rL   r   r9   rN   r.   s         r   delete_itemsz$DeletableAPISubResource.delete_items?  sd      >FBII,,"PSPfPf J 
 c>48$TLVLLr   r0   )r   r   r   r    r!   r^   r"   r   r   r\   r\   :  s     M Mr   r\   c                        e Zd ZdZed        Zy)SearchableAPIResourcezG
    Fork of ListableAPIResource class with different method names
    c                 `    t        | dd      }t        j                  d| j                  |fi |S )z
        Query an API resource stream

        :param params: parameters to filter API resource stream
        :type params: dictionary

        :returns: Dictionary representing the API's JSON response
        r   Nr   rC   rD   s      r   _searchzSearchableAPIResource._search_  rF   r   N)r   r   r   r    r!   rb   r"   r   r   r`   r`   Z  rG   r   r`   c                   4    e Zd ZdZedd       Zedd       Zy)ActionAPIResourcez!
    Actionable API Resource
    Nc                     |i }t        | dd      }|dj                  | j                  |      }ndj                  | j                  ||      }|dk(  rd}t        j                  ||||fi |S )a  
        Trigger an action

        :param method: HTTP method to use to contact API endpoint
        :type method: HTTP method string

        :param action_name: action name
        :type action_name: string

        :param id: trigger the action for the specified resource object
        :type id: id

        :param params: action parameters
        :type params: dictionary

        :param body: action body
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        Nr   {resource_name}/{action_name}r   action_namez+{resource_name}/{resource_id}/{action_name}r   r   rh   r   r   r   r   r   r   )r   r   rh   r   r   r   r   r   s           r   _trigger_class_actionz'ActionAPIResource._trigger_class_actions  s    , >Fc>48:299HZHZhs9tD@GG!00bk H D U?Dk4J6JJr   c                     t        | dd      }|t        j                  ||||      S dj                  ||      }|dk(  rd}t        j                  ||||      S )a  
        Trigger an action

        :param method: HTTP method to use to contact API endpoint
        :type method: HTTP method string

        :param name: action name
        :type name: string

        :param id: trigger the action for the specified resource object
        :type id: id

        :param body: action body
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        r   Nz{action_name}/{resource_id})rh   r   r   )r   r   r   r   )r   r   namer   r   r   r   s          r   _trigger_actionz!ActionAPIResource._trigger_action  sg    & c>48:##FD+tDD,33RT3UU?Dk4@@r   NNr0   )r   r   r   r    r!   rk   rn   r"   r   r   rd   rd   n  s4     #K #KJ A Ar   rd   c                   "    e Zd ZdZedd       Zy)!UpdatableAPISyntheticsSubResourcez(
    Update Synthetics sub resource
    Nc                     |i }dj                  | j                  || j                        }t        | dd      }t	        j
                  d|||fi |S )rX   Nz7{resource_name}/tests/{resource_id}/{sub_resource_name}rL   r   r,   rN   r.   s         r   update_synthetics_itemsz9UpdatableAPISyntheticsSubResource.update_synthetics_items  sd      >FHOO,,"PSPfPf P 
 c>48t[$I&IIr   r0   )r   r   r   r    r!   rs   r"   r   r   rq   rq     rZ   r   rq   c                   "    e Zd ZdZedd       Zy)UpdatableAPISyntheticsResourcez$
    Update Synthetics resource
    Nc                     |i }dj                  | j                  |      }t        | dd      }t        j                  d|||fi |S )r+   Nz#{resource_name}/tests/{resource_id}r   r   r,   r-   r.   s         r   update_syntheticsz0UpdatableAPISyntheticsResource.update_synthetics  sT     >F4;;#J\J\jl;mc>48t[$I&IIr   r0   )r   r   r   r    r!   rw   r"   r   r   ru   ru     r2   r   ru   c                   "    e Zd ZdZedd       Zy)ActionAPISyntheticsResourcez,
    Actionable Synthetics API Resource
    Nc                     |i }t        | dd      }|dj                  | j                  |      }ndj                  | j                  ||      }|dk(  rd}t        j                  ||||fi |S )a  
        Trigger an action

        :param method: HTTP method to use to contact API endpoint
        :type method: HTTP method string

        :param name: action name
        :type name: string

        :param id: trigger the action for the specified resource object
        :type id: id

        :param params: action parameters
        :type params: dictionary

        :param body: action body
        :type body: dictionary

        :returns: Dictionary representing the API's JSON response
        Nr   rf   rg   z+{resource_name}/{action_name}/{resource_id}ri   r   rj   )r   r   rm   r   r   r   r   r   s           r    _trigger_synthetics_class_actionz<ActionAPISyntheticsResource._trigger_synthetics_class_action  s    , >Fc>48:299HZHZhl9mD@GG!00bd H D U?Dk4J6JJr   ro   )r   r   r   r    r!   r{   r"   r   r   ry   ry     s     #K #Kr   ry   N)r    datadog.api.api_clientr   objectr   r$   r)   r4   r7   r=   rA   rI   rR   rV   r\   r`   rd   rq   ru   ry   r"   r   r   <module>r~      s    -'nF 'nT'
& '
TJ6 J6!K !KHG6 G*D D0R& R(DV D6KF K@Jf J@Mf M@RF R(FA FARJ J@JV J6)K& )Kr   