o
    ùT·j¤   ã                   @  sÐ  d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	Z	ddl
mZ ddlmZmZmZmZmZmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZmZ ddl m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1 ddl2m3Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddgZEG dd„ deƒZFG dd„ deƒZGG dd„ dƒZHG dd „ d ƒZIG d!d"„ d"ƒZJG d#d$„ d$ƒZKdS )%é    )ÚannotationsN)ÚListÚOptionalÚcast)ÚLiteralé   )Ú_legacy_response)ÚBodyÚOmitÚQueryÚHeadersÚNotGivenÚHeadersLikeÚomitÚ	not_given)Úpath_templateÚmaybe_transformÚasync_maybe_transform)Úcached_property)Úconstruct_type)ÚSyncAPIResourceÚAsyncAPIResource)Úto_streamed_response_wrapperÚ"async_to_streamed_response_wrapperé   )Ú
EventTypesÚAsyncEventTypesÚEventTypesWithRawResponseÚAsyncEventTypesWithRawResponseÚEventTypesWithStreamingResponseÚ$AsyncEventTypesWithStreamingResponse)ÚSyncCursorPageÚAsyncCursorPage)ÚInvalidWebhookSignatureError)ÚAsyncPaginatorÚmake_request_options)Úwebhook_signature_matches)Úwebhook_list_paramsÚwebhook_test_paramsÚwebhook_create_paramsÚwebhook_update_paramsÚwebhook_rotate_secret_params)ÚWebhookEndpoint)ÚUnwrapWebhookEvent)ÚDeletedWebhookEndpoint)ÚWebhookEndpointTestResult)ÚWebhookEndpointWithSecretÚWebhooksÚAsyncWebhooksc                   @  óþ   e Zd ZedLdd„ƒZedMdd„ƒZedNd	d
„ƒZdddedœdOdd„ZdddedœdPdd „Z	e
e
e
ddded!œdQd$d%„Ze
e
ddded&œdRd,d-„ZdddedœdSd/d0„Ze
ddded1œdTd4d5„ZdddedœdUd9d:„Zdd;œdVdCdD„ZddEdFœdWdJdK„ZdS )Xr1   Úreturnr   c                 C  ó
   t | jƒS ©N)r   Ú_client©Úself© r:   úe/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/openai/resources/webhooks/webhooks.pyÚevent_types/   ó   
zWebhooks.event_typesÚWebhooksWithRawResponsec                 C  ó   t | ƒS ©a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r>   r8   r:   r:   r;   Úwith_raw_response3   ó   zWebhooks.with_raw_responseÚWebhooksWithStreamingResponsec                 C  r?   ©zÌ
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )rC   r8   r:   r:   r;   Úwith_streaming_response=   ó   z Webhooks.with_streaming_responseN©Úextra_headersÚextra_queryÚ
extra_bodyÚtimeoutr<   á‘  List[Literal['batch.completed', 'batch.failed', 'batch.expired', 'batch.cancelled', 'response.completed', 'response.failed', 'response.cancelled', 'response.incomplete', 'eval.run.succeeded', 'eval.run.failed', 'eval.run.canceled', 'fine_tuning.job.succeeded', 'fine_tuning.job.failed', 'fine_tuning.job.cancelled', 'realtime.call.incoming', 'video.completed', 'video.failed', 'safety.alert.created']]ÚnameÚstrÚurlrH   úHeaders | NonerI   úQuery | NonerJ   úBody | NonerK   ú(float | httpx2.Timeout | None | NotGivenr0   c             
   C  s4   | j dt|||dœtjƒt||||ddid�td�S )á@  
        Creates a webhook endpoint for the authenticated project.

        Args:
          event_types: The event types that trigger deliveries to this endpoint.

          name: A human-readable name for the webhook endpoint.

          url: The HTTPS URL that receives webhook deliveries.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        ú/webhook_endpoints©r<   rM   rO   Úbearer_authT©rH   rI   rJ   rK   Úsecurity©ÚbodyÚoptionsÚcast_to)Ú_postr   r)   ÚWebhookCreateParamsr%   r0   ©r9   r<   rM   rO   rH   rI   rJ   rK   r:   r:   r;   ÚcreateF   s$   4ýúûïzWebhooks.createÚwebhook_endpoint_idr,   c             	   C  ó<   |s	t d|›�ƒ‚| jtd|d�t||||ddid�td�S )áo  
        Retrieves a webhook endpoint for the authenticated project.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        úBExpected a non-empty value for `webhook_endpoint_id` but received ú(/webhook_endpoints/{webhook_endpoint_id}©rb   rW   TrX   ©r\   r]   ©Ú
ValueErrorÚ_getr   r%   r,   ©r9   rb   rH   rI   rJ   rK   r:   r:   r;   ÚretrieveŽ   ó   ÿ
û÷zWebhooks.retrieve©r<   rM   rO   rH   rI   rJ   rK   á˜  List[Literal['batch.completed', 'batch.failed', 'batch.expired', 'batch.cancelled', 'response.completed', 'response.failed', 'response.cancelled', 'response.incomplete', 'eval.run.succeeded', 'eval.run.failed', 'eval.run.canceled', 'fine_tuning.job.succeeded', 'fine_tuning.job.failed', 'fine_tuning.job.cancelled', 'realtime.call.incoming', 'video.completed', 'video.failed', 'safety.alert.created']] | Omitú
str | Omitc          	   
   C  sN   |s	t d|›�ƒ‚| jtd|d�t|||dœtjƒt||||ddid�td�S )	áL  
        Updates a webhook endpoint for the authenticated project.

        Args:
          event_types: The complete set of event types that should trigger deliveries.

          name: A new human-readable name for the webhook endpoint.

          url: A new HTTPS URL that receives webhook deliveries.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        re   rf   rg   rV   rW   TrX   rZ   )rj   r^   r   r   r*   ÚWebhookUpdateParamsr%   r,   ©	r9   rb   r<   rM   rO   rH   rI   rJ   rK   r:   r:   r;   Úupdateµ   s,   6ÿ
ýúûïzWebhooks.update©ÚafterÚlimitrH   rI   rJ   rK   rw   úOptional[str] | Omitrx   ú
int | OmitúSyncCursorPage[WebhookEndpoint]c                C  ó8   | j dtt t||||t||dœtjƒddid�td�S ©a  
        Returns webhook endpoints for the authenticated project in newest-first order.

        Args:
          after: ID of the last webhook endpoint from the previous page.

          limit: Maximum number of webhook endpoints to return. Defaults to 20.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rU   )rw   rx   rW   T)rH   rI   rJ   rK   ÚqueryrY   )Úpager\   Úmodel)Ú_get_api_listr!   r,   r%   r   r'   ÚWebhookListParams©r9   rw   rx   rH   rI   rJ   rK   r:   r:   r;   Úlist  ó$   þûôïzWebhooks.listr.   c             	   C  rc   )ám  
        Deletes a webhook endpoint for the authenticated project.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        re   rf   rg   rW   TrX   rh   ©rj   Ú_deleter   r%   r.   rl   r:   r:   r;   Údelete3  rn   zWebhooks.delete©Ú#keep_old_secret_active_for_24_hoursrH   rI   rJ   rK   r‹   úbool | Omitc             
   C  óJ   |s	t d|›�ƒ‚| jtd|d�td|itjƒt||||ddid�td�S )	áV  
        Rotates the signing secret for a webhook endpoint in the authenticated project.

        Args:
          keep_old_secret_active_for_24_hours: Whether to keep the previous signing secret valid for 24 hours after rotation.
              Defaults to false, which invalidates the previous secret immediately.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        re   ú6/webhook_endpoints/{webhook_endpoint_id}/rotate_secretrg   r‹   rW   TrX   rZ   )rj   r^   r   r   r+   ÚWebhookRotateSecretParamsr%   r0   ©r9   rb   r‹   rH   rI   rJ   rK   r:   r:   r;   Úrotate_secretZ  s*   ÿÿþûñzWebhooks.rotate_secretÚ
event_typeá‹  Literal['batch.completed', 'batch.failed', 'batch.expired', 'batch.cancelled', 'response.completed', 'response.failed', 'response.cancelled', 'response.incomplete', 'eval.run.succeeded', 'eval.run.failed', 'eval.run.canceled', 'fine_tuning.job.succeeded', 'fine_tuning.job.failed', 'fine_tuning.job.cancelled', 'realtime.call.incoming', 'video.completed', 'video.failed', 'safety.alert.created']r/   c             
   C  r�   )	áÁ  
        Sends a sample event to a webhook endpoint for the authenticated project.

        Args:
          event_type: The event type to send as a sample delivery.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        re   ú-/webhook_endpoints/{webhook_endpoint_id}/testrg   r“   rW   TrX   rZ   )rj   r^   r   r   r(   ÚWebhookTestParamsr%   r/   ©r9   rb   r“   rH   rI   rJ   rK   r:   r:   r;   Útest‹  s    -ÿ
ûözWebhooks.test©ÚsecretÚpayloadústr | bytesÚheadersr   r›   ú
str | Noner-   c                C  s8   |du r| j j}| j|||d� ttttt |¡d�ƒS )úKValidates that the given payload was sent by OpenAI and parses the payload.N©rœ   rž   r›   ©Útype_Úvalue)r7   Úwebhook_secretÚverify_signaturer   r-   r   ÚjsonÚloads)r9   rœ   rž   r›   r:   r:   r;   ÚunwrapÉ  s   þþzWebhooks.unwrapé,  ©r›   Ú	tolerancer¬   ÚintÚNonec                C  s>   |du r| j j}|du rtdƒ‚t||||d�stdƒd‚dS ©a\  Validates whether or not the webhook payload was sent by OpenAI.

        Args:
            payload: The webhook payload
            headers: The webhook headers
            secret: The webhook secret (optional, will use client secret if not provided)
            tolerance: Maximum age of the webhook in seconds (default: 300 = 5 minutes)
        Nz�The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI(webhook_secret='123'), or passed to this functionr«   zAThe given webhook signature does not match the expected signature©r7   r¥   rj   Ú_webhook_signature_matchesr#   ©r9   rœ   rž   r›   r¬   r:   r:   r;   r¦   Þ  s   ÿÿþÿzWebhooks.verify_signature)r4   r   )r4   r>   )r4   rC   ©r<   rL   rM   rN   rO   rN   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r0   ©rb   rN   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r,   ©rb   rN   r<   rp   rM   rq   rO   rq   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r,   )rw   ry   rx   rz   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r{   ©rb   rN   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r.   ©rb   rN   r‹   rŒ   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r0   ©rb   rN   r“   r”   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   r/   ©rœ   r�   rž   r   r›   rŸ   r4   r-   ©
rœ   r�   rž   r   r›   rŸ   r¬   r­   r4   r®   ©Ú__name__Ú
__module__Ú__qualname__r   r<   rA   rE   r   ra   rm   r   ru   r„   r‰   r’   r™   r©   r¦   r:   r:   r:   r;   r1   .   sj    	%àN÷AÞQö6÷+öKãCûúc                   @  r3   )Xr2   r4   r   c                 C  r5   r6   )r   r7   r8   r:   r:   r;   r<   þ  r=   zAsyncWebhooks.event_typesÚAsyncWebhooksWithRawResponsec                 C  r?   r@   )r¿   r8   r:   r:   r;   rA     rB   zAsyncWebhooks.with_raw_responseÚ"AsyncWebhooksWithStreamingResponsec                 C  r?   rD   )rÀ   r8   r:   r:   r;   rE     rF   z%AsyncWebhooks.with_streaming_responseNrG   r<   rL   rM   rN   rO   rH   rP   rI   rQ   rJ   rR   rK   rS   r0   c             
   Ã  sB   �| j dt|||dœtjƒI dH t||||ddid�td�I dH S )rT   rU   rV   NrW   TrX   rZ   )r^   r   r)   r_   r%   r0   r`   r:   r:   r;   ra     s&   €4ýúûïzAsyncWebhooks.createrb   r,   c             	   Ã  óD   �|s
t d|›�ƒ‚| jtd|d�t||||ddid�td�I dH S )	rd   re   rf   rg   rW   TrX   rh   Nri   rl   r:   r:   r;   rm   ]  ó    €ÿ
û÷zAsyncWebhooks.retrievero   rp   rq   c          	   
   Ã  s\   �|s
t d|›�ƒ‚| jtd|d�t|||dœtjƒI dH t||||ddid�td	�I dH S )
rr   re   rf   rg   rV   NrW   TrX   rZ   )rj   r^   r   r   r*   rs   r%   r,   rt   r:   r:   r;   ru   „  s.   €6ÿ
ýúûïzAsyncWebhooks.updaterv   rw   ry   rx   rz   úAAsyncPaginator[WebhookEndpoint, AsyncCursorPage[WebhookEndpoint]]c                C  r|   r}   )r�   r"   r,   r%   r   r'   r‚   rƒ   r:   r:   r;   r„   Ò  r…   zAsyncWebhooks.listr.   c             	   Ã  rÁ   )	r†   re   rf   rg   rW   TrX   rh   Nr‡   rl   r:   r:   r;   r‰     rÂ   zAsyncWebhooks.deleterŠ   r‹   rŒ   c             
   Ã  óX   �|s
t d|›�ƒ‚| jtd|d�td|itjƒI dH t||||ddid�td	�I dH S )
rŽ   re   r�   rg   r‹   NrW   TrX   rZ   )rj   r^   r   r   r+   r�   r%   r0   r‘   r:   r:   r;   r’   )  s,   €ÿÿþûñzAsyncWebhooks.rotate_secretr“   r”   r/   c             
   Ã  rÄ   )
r•   re   r–   rg   r“   NrW   TrX   rZ   )rj   r^   r   r   r(   r—   r%   r/   r˜   r:   r:   r;   r™   Z  s"   €-ÿ
ûözAsyncWebhooks.testrš   rœ   r�   rž   r   r›   rŸ   r-   c                C  sP   |du r| j j}| j|||d� t|tƒr| d¡n|}ttttt	 
|¡d�ƒS )r    Nr¡   zutf-8r¢   )r7   r¥   r¦   Ú
isinstanceÚbytesÚdecoder   r-   r   r§   r¨   )r9   rœ   rž   r›   r[   r:   r:   r;   r©   ˜  s   þþzAsyncWebhooks.unwraprª   r«   r¬   r­   r®   c                C  s>   |du r| j j}|du rtdƒd‚t||||d�stdƒ‚dS r¯   r°   r²   r:   r:   r;   r¦   ®  s   ÿýÿzAsyncWebhooks.verify_signature)r4   r   )r4   r¿   )r4   rÀ   r³   r´   rµ   )rw   ry   rx   rz   rH   rP   rI   rQ   rJ   rR   rK   rS   r4   rÃ   r¶   r·   r¸   r¹   rº   r»   r:   r:   r:   r;   r2   ý  sj    	%àN÷AÞQö6÷+öKãCûúc                   @  ó$   e Zd Zddd„Zeddd	„ƒZd
S )r>   Úwebhooksr1   r4   r®   c                 C  ól   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j	¡| _	d S r6   )
Ú	_webhooksr   Úto_raw_response_wrapperra   rm   ru   r„   r‰   r’   r™   ©r9   rÉ   r:   r:   r;   Ú__init__Ì  ó,   ÿÿÿÿÿÿ
ÿz WebhooksWithRawResponse.__init__r   c                 C  ó   t | jjƒS r6   )r   rË   r<   r8   r:   r:   r;   r<   å  ó   z#WebhooksWithRawResponse.event_typesN©rÉ   r1   r4   r®   )r4   r   ©r¼   r½   r¾   rÎ   r   r<   r:   r:   r:   r;   r>   Ë  ó    
r>   c                   @  rÈ   )r¿   rÉ   r2   r4   r®   c                 C  rÊ   r6   )
rË   r   Úasync_to_raw_response_wrapperra   rm   ru   r„   r‰   r’   r™   rÍ   r:   r:   r;   rÎ   ë  rÏ   z%AsyncWebhooksWithRawResponse.__init__r   c                 C  rÐ   r6   )r   rË   r<   r8   r:   r:   r;   r<     rÑ   z(AsyncWebhooksWithRawResponse.event_typesN©rÉ   r2   r4   r®   )r4   r   rÓ   r:   r:   r:   r;   r¿   ê  rÔ   r¿   c                   @  rÈ   )rC   rÉ   r1   r4   r®   c                 C  ó^   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r6   )	rË   r   ra   rm   ru   r„   r‰   r’   r™   rÍ   r:   r:   r;   rÎ   
  ó,   ÿÿÿÿÿÿ
ÿz&WebhooksWithStreamingResponse.__init__r   c                 C  rÐ   r6   )r   rË   r<   r8   r:   r:   r;   r<   #  rÑ   z)WebhooksWithStreamingResponse.event_typesNrÒ   )r4   r   rÓ   r:   r:   r:   r;   rC   	  rÔ   rC   c                   @  rÈ   )rÀ   rÉ   r2   r4   r®   c                 C  r×   r6   )	rË   r   ra   rm   ru   r„   r‰   r’   r™   rÍ   r:   r:   r;   rÎ   )  rØ   z+AsyncWebhooksWithStreamingResponse.__init__r    c                 C  rÐ   r6   )r    rË   r<   r8   r:   r:   r;   r<   B  rÑ   z.AsyncWebhooksWithStreamingResponse.event_typesNrÖ   )r4   r    rÓ   r:   r:   r:   r;   rÀ   (  rÔ   rÀ   )LÚ
__future__r   r§   Útypingr   r   r   Útyping_extensionsr   Úhttpx2Ú r   Ú_typesr	   r
   r   r   r   r   r   r   Ú_utilsr   r   r   Ú_compatr   Ú_modelsr   Ú	_resourcer   r   Ú	_responser   r   r<   r   r   r   r   r   r    Ú
paginationr!   r"   Ú_exceptionsr#   Ú_base_clientr$   r%   Úlib._webhooksr&   r±   Útypes.webhooksr'   r(   r)   r*   r+   Útypes.webhooks.webhook_endpointr,   Ú#types.webhooks.unwrap_webhook_eventr-   Ú'types.webhooks.deleted_webhook_endpointr.   Ú+types.webhooks.webhook_endpoint_test_resultr/   Ú+types.webhooks.webhook_endpoint_with_secretr0   Ú__all__r1   r2   r>   r¿   rC   rÀ   r:   r:   r:   r;   Ú<module>   sH   (    R   Q