
    Oj                       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ZE G d de      ZF G d de      ZG G d d      ZH G d d       ZI G d! d"      ZJ G d# d$      ZKy)%    )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dd       Zedd       Zedd       Zddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZ	e
e
e
ddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Ze
e
ddded
	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZe
ddded	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 	 	 d dZy)!r2   c                ,    t        | j                        S N)r   _clientselfs    y/var/www/origus_pro_usr/data/www/origus.pro/core/.venv/lib/python3.12/site-packages/openai/resources/webhooks/webhooks.pyevent_typeszWebhooks.event_types/   s    $,,''    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
        )WebhooksWithRawResponser8   s    r:   with_raw_responsezWebhooks.with_raw_response3   s     't,,r<   c                    t        |       S 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
        )WebhooksWithStreamingResponser8   s    r:   with_streaming_responsez Webhooks.with_streaming_response=   s     -T22r<   Nextra_headersextra_query
extra_bodytimeoutc                   | j                  dt        |||dt        j                        t	        ||||ddi      t
              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;   nameurlbearer_authTrF   rG   rH   rI   securitybodyoptionscast_to)_postr   r*   WebhookCreateParamsr&   r1   r9   r;   rN   rO   rF   rG   rH   rI   s           r:   createzWebhooks.createF   sb    h zz  #. 
 &99 )+'%'. .#  
 	
r<   c                   |st        d|      | j                  t        d|      t        ||||ddi      t              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}webhook_endpoint_idrP   TrQ   rU   rV   
ValueError_getr   r&   r-   r9   r`   rF   rG   rH   rI   s         r:   retrievezWebhooks.retrieve   se    . #TUhTkl  yyDZmn(+'%'. $  

 
	
r<   r;   rN   rO   rF   rG   rH   rI   c                   |st        d|      | j                  t        d|      t        |||dt        j
                        t        ||||ddi      t              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
        r]   r^   r_   rM   rP   TrQ   rS   )rc   rW   r   r   r+   WebhookUpdateParamsr&   r-   	r9   r`   r;   rN   rO   rF   rG   rH   rI   s	            r:   updatezWebhooks.update   s    l #TUhTkl  zzDZmn #. 
 &99 )+'%'. $#  
 	
r<   afterlimitrF   rG   rH   rI   c                   | j                  dt        t           t        ||||t	        ||dt
        j                        ddi      t              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
        rL   )rn   ro   rP   T)rF   rG   rH   rI   queryrR   )pagerU   model)_get_api_listr"   r-   r&   r   r(   WebhookListParamsr9   rn   ro   rF   rG   rH   rI   s          r:   listzWebhooks.list  sh    8 !! 0(+'%%!&!& (99 (. "# " 
 	
r<   c                   |st        d|      | j                  t        d|      t        ||||ddi      t              S )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
        r]   r^   r_   rP   TrQ   ra   rc   _deleter   r&   r/   re   s         r:   deletezWebhooks.delete3  se    . #TUhTkl  ||DZmn(+'%'. +  

 
	
r<   #keep_old_secret_active_for_24_hoursrF   rG   rH   rI   c                   |st        d|      | j                  t        d|      t        d|it        j
                        t        ||||ddi      t              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
        r]   6/webhook_endpoints/{webhook_endpoint_id}/rotate_secretr_   r   rP   TrQ   rS   )rc   rW   r   r   r,   WebhookRotateSecretParamsr&   r1   r9   r`   r   rF   rG   rH   rI   s          r:   rotate_secretzWebhooks.rotate_secretZ  s    6 #TUhTkl  zzH^q !68[\,FF )+'%'. .  
 	
r<   c                   |st        d|      | j                  t        d|      t        d|it        j
                        t        ||||ddi      t              S )	  
        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
        r]   -/webhook_endpoints/{webhook_endpoint_id}/testr_   
event_typerP   TrQ   rS   )rc   rW   r   r   r)   WebhookTestParamsr&   r0   r9   r`   r   rF   rG   rH   rI   s          r:   testzWebhooks.test  s|    Z #TUhTkl  zzI_rs ,
!;=P=b=bc(+'%'. .  
 	
r<   secretc          	         || j                   j                  }| j                  |||       t        t        t        t        t        j                  |                  S )KValidates that the given payload was sent by OpenAI and parses the payload.payloadheadersr   type_value)r7   webhook_secretverify_signaturer   r.   r   jsonloads)r9   r   r   r   s       r:   unwrapzWebhooks.unwrap  sT     >\\00FgwvN(jj)
 	
r<   ,  r   	tolerancec                   || j                   j                  }|t        d      t        ||||      st	        d      dy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)
        NzThe 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   rc   _webhook_signature_matchesr$   r9   r   r   r   r   s        r:   r   zWebhooks.verify_signature  sZ      >\\00F>` 
 *'76U^_.S `r<   )returnr   )r   r?   )r   rC   r;   a  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']]rN   strrO   r   rF   Headers | NonerG   Query | NonerH   Body | NonerI   (float | httpx2.Timeout | None | NotGivenr   r1   r`   r   rF   r   rG   r   rH   r   rI   r   r   r-   r`   r   r;   a  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']] | OmitrN   
str | OmitrO   r   rF   r   rG   r   rH   r   rI   r   r   r-   )rn   Optional[str] | Omitro   
int | OmitrF   r   rG   r   rH   r   rI   r   r   zSyncCursorPage[WebhookEndpoint]r`   r   rF   r   rG   r   rH   r   rI   r   r   r/   r`   r   r   zbool | OmitrF   r   rG   r   rH   r   rI   r   r   r1   r`   r   r   a  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']rF   r   rG   r   rH   r   rI   r   r   r0   r   str | bytesr   r   r   
str | Noner   r.   
r   r   r   r   r   r   r   intr   None__name__
__module____qualname__r   r;   r@   rD   r   rZ   rf   r   rl   rx   r}   r   r   r   r    r<   r:   r2   r2   .   sZ   ( ( - - 3 3J )-$("&<EAF

F
2 3F
4 5F
: &;F
< "=F
>  ?F
@ :AF
B 
#CF
\ )-$("&<E%
 %
 &%
 "%
  %
 :%
 
%
B  )-$("&<EEL
 L
	L
6 7L
8 9L
> &?L
@ "AL
B  CL
D :EL
F 
GL
b '+  )-$("&<E.
 $.
 	.
 &.
 ".
  .
 :.
 
).
l )-$("&<E%
 %
 &%
 "%
  %
 :%
 
 %
V <@ )-$("&<E/
 /
 .9	/
 &/
 "/
  /
 :/
 
#/
V )-$("&<E;<
 <

	<
4 &5<
6 "7<
8  9<
: :;<
< 
#=<
F "

 

 
 

4 " 
   
r<   c                     e Zd Zedd       Zedd       Zedd       Zddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZ	e
e
e
ddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Ze
e
ddded
	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZe
ddded	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 	 	 d dZy)!r3   c                ,    t        | j                        S r6   )r   r7   r8   s    r:   r;   zAsyncWebhooks.event_types  s    t||,,r<   c                    t        |       S r>   )AsyncWebhooksWithRawResponser8   s    r:   r@   zAsyncWebhooks.with_raw_response  s     ,D11r<   c                    t        |       S rB   )"AsyncWebhooksWithStreamingResponser8   s    r:   rD   z%AsyncWebhooks.with_streaming_response  s     2$77r<   NrE   c                  K   | j                  dt        |||dt        j                         d{   t	        ||||ddi      t
               d{   S 7 '7 w)rK   rL   rM   NrP   TrQ   rS   )rW   r   r*   rX   r&   r1   rY   s           r:   rZ   zAsyncWebhooks.create  s{     h ZZ ,#. 
 &99  )+'%'. .#   
 
 	

s!   .AA
"AAAAc                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	r\   r]   r^   r_   rP   TrQ   ra   Nrb   re   s         r:   rf   zAsyncWebhooks.retrieve]  ss     . #TUhTkl  YYDZmn(+'%'. $  

 

 
	
 

   AA	A
Arg   c                  K   |st        d|      | j                  t        d|      t        |||dt        j
                         d{   t        ||||ddi      t        	       d{   S 7 '7 w)
ri   r]   r^   r_   rM   NrP   TrQ   rS   )rc   rW   r   r   r+   rj   r&   r-   rk   s	            r:   rl   zAsyncWebhooks.update  s     l #TUhTkl  ZZDZmn,#. 
 &99  )+'%'. $#   
 
 	

s$   A	A7A3
"A7.A5/A75A7rm   c                   | j                  dt        t           t        ||||t	        ||dt
        j                        ddi      t              S rq   )ru   r#   r-   r&   r   r(   rv   rw   s          r:   rx   zAsyncWebhooks.list  sh    8 !!  1(+'%%!&!& (99 (. "# " 
 	
r<   c                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	rz   r]   r^   r_   rP   TrQ   ra   Nr{   re   s         r:   r}   zAsyncWebhooks.delete  ss     . #TUhTkl  \\DZmn(+'%'. + " 

 

 
	
 

r   r~   c                  K   |st        d|      | j                  t        d|      t        d|it        j
                         d{   t        ||||ddi      t        	       d{   S 7 '7 w)
r   r]   r   r_   r   NrP   TrQ   rS   )rc   rW   r   r   r,   r   r&   r1   r   s          r:   r   zAsyncWebhooks.rotate_secret)  s     6 #TUhTkl  ZZH^q -68[\,FF  )+'%'. .   
 
 	
	
$   AA5	A1

"A5,A3-A53A5c                  K   |st        d|      | j                  t        d|      t        d|it        j
                         d{   t        ||||ddi      t        	       d{   S 7 '7 w)
r   r]   r   r_   r   NrP   TrQ   rS   )rc   rW   r   r   r)   r   r&   r0   r   s          r:   r   zAsyncWebhooks.testZ  s     Z #TUhTkl  ZZI_rs,lJ-GI\InInoo(+'%'. .   
 
 	
o
r   r   c          	        || j                   j                  }| j                  |||       t        |t              r|j                  d      n|}t        t        t        t        t        j                  |                  S )r   r   zutf-8r   )r7   r   r   
isinstancebytesdecoder   r.   r   r   r   )r9   r   r   r   rT   s        r:   r   zAsyncWebhooks.unwrap  sm     >\\00FgwvN*4We*Dw~~g&'(jj&
 	
r<   r   r   c                   || j                   j                  }|t        d      dt        ||||      st	        d      yr   r   r   s        r:   r   zAsyncWebhooks.verify_signature  sX      >\\00F>` 
 *'76U^_./rss `r<   )r   r   )r   r   )r   r   r   r   r   )rn   r   ro   r   rF   r   rG   r   rH   r   rI   r   r   zAAsyncPaginator[WebhookEndpoint, AsyncCursorPage[WebhookEndpoint]]r   r   r   r   r   r   r   r<   r:   r3   r3     sa   - - 2 2 8 8J )-$("&<EAF

F
2 3F
4 5F
: &;F
< "=F
>  ?F
@ :AF
B 
#CF
\ )-$("&<E%
 %
 &%
 "%
  %
 :%
 
%
B  )-$("&<EEL
 L
	L
6 7L
8 9L
> &?L
@ "AL
B  CL
D :EL
F 
GL
b '+  )-$("&<E.
 $.
 	.
 &.
 ".
  .
 :.
 
K.
l )-$("&<E%
 %
 &%
 "%
  %
 :%
 
 %
V <@ )-$("&<E/
 /
 .9	/
 &/
 "/
  /
 :/
 
#/
V )-$("&<E;<
 <

	<
4 &5<
6 "7<
8  9<
: :;<
< 
#=<
F "

 

 
 

6 "tt t
 t t 
tr<   c                  &    e Zd ZddZedd       Zy)r?   c                
   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _	        y r6   )
	_webhooksr	   to_raw_response_wrapperrZ   rf   rl   rx   r}   r   r   r9   webhookss     r:   __init__z WebhooksWithRawResponse.__init__  s    !&>>OO
 )@@
 '>>OO
 %<<MM
	 '>>OO
 .EE""
 %<<MM
	r<   c                @    t        | j                  j                        S r6   )r   r   r;   r8   s    r:   r;   z#WebhooksWithRawResponse.event_types  s    ()C)CDDr<   Nr   r2   r   r   )r   r   r   r   r   r   r   r;   r   r<   r:   r?   r?     s    
2 E Er<   r?   c                  &    e Zd ZddZedd       Zy)r   c                
   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _	        y r6   )
r   r	   async_to_raw_response_wrapperrZ   rf   rl   rx   r}   r   r   r   s     r:   r   z%AsyncWebhooksWithRawResponse.__init__  s    !&DDOO
 )FF
 'DDOO
 %BBMM
	 'DDOO
 .KK""
 %BBMM
	r<   c                @    t        | j                  j                        S r6   )r   r   r;   r8   s    r:   r;   z(AsyncWebhooksWithRawResponse.event_types  s    -dnn.H.HIIr<   Nr   r3   r   r   )r   r   r   r   r<   r:   r   r     s    
2 J Jr<   r   c                  &    e Zd ZddZedd       Zy)rC   c                ~   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        y r6   )	r   r   rZ   rf   rl   rx   r}   r   r   r   s     r:   r   z&WebhooksWithStreamingResponse.__init__
  s    !2OO
 5
 3OO
 1MM
	 3OO
 :""
 1MM
	r<   c                @    t        | j                  j                        S r6   )r    r   r;   r8   s    r:   r;   z)WebhooksWithStreamingResponse.event_types#  s    .t~~/I/IJJr<   Nr   )r   r    r   r   r<   r:   rC   rC   	  s    
2 K Kr<   rC   c                  &    e Zd ZddZedd       Zy)r   c                ~   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        y r6   )	r   r   rZ   rf   rl   rx   r}   r   r   r   s     r:   r   z+AsyncWebhooksWithStreamingResponse.__init__)  s    !8OO
 ;
 9OO
 7MM
	 9OO
 @""
 7MM
	r<   c                @    t        | j                  j                        S r6   )r!   r   r;   r8   s    r:   r;   z.AsyncWebhooksWithStreamingResponse.event_typesB  s    3DNN4N4NOOr<   Nr   )r   r!   r   r   r<   r:   r   r   (  s    
2 P P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_resultr0   +types.webhooks.webhook_endpoint_with_secretr1   __all__r2   r3   r?   r   rC   r   r   r<   r:   <module>r      s    #  ' ' %    X X X K K & % : Y  : 7 @ T  ? E M T T
'L L^Kt$ Kt\E E>J J>K K>P Pr<   