
    b\jv                       S SK Jr  S SKJr  S SKrSSKJr  SSKJrJ	r	J
r
JrJrJrJr  SSKJrJrJrJr  SSKJr  SS	KJrJr  SS
KJrJr  SSKJrJr  SSKJ r   SSK!J"r"J#r#  SSK$J%r%J&r&  SSK'J(r(J)r)  SSK*J+r+  SSK,J-r-  SSK.J/r/  SS/r0 " S S\5      r1 " S S\5      r2 " S S5      r3 " S S5      r4 " S S5      r5 " S S5      r6g)    )annotations)IterableN   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_given)path_templatemaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncPage	AsyncPage)AnthropicError)AsyncPaginatormake_request_options)batch_list_paramsbatch_create_params)JSONLDecoderAsyncJSONLDecoder)MessageBatch)DeletedMessageBatch)MessageBatchIndividualResponseBatchesAsyncBatchesc                  d   \ rS rSr\SS j5       r\SS j5       r\SSS\S.             SS jjr	SSS\S.           SS jjr
\\\SSS\S	.               SS
 jjrSSS\S.           SS jjrSSS\S.           SS jjrSSS\S.           SS jjrSrg)r#      c                    [        U 5      $ z
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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
)BatchesWithRawResponseselfs    Z/var/www/website/venv/lib/python3.13/site-packages/anthropic/resources/messages/batches.pywith_raw_responseBatches.with_raw_response   s     &d++    c                    [        U 5      $ z
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
)BatchesWithStreamingResponser*   s    r,   with_streaming_responseBatches.with_streaming_response&   s     ,D11r/   Nuser_profile_idextra_headersextra_query
extra_bodytimeoutc                   0 [        SU05      EU=(       d    0 EnU R                  S[        SU0[        R                  5      [        X4XVS9[        S9$ )<  
Send a batch of Message creation requests.

The Message Batches API can be used to process multiple Messages API requests at
once. Once a Message Batch is created, it begins processing immediately. Batches
can take up to 24 hours to complete.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  requests: List of requests for prompt completion. Each is an individual request to create
      a Message.

  user_profile_id: The user profile ID to attribute the requests in this batch to. Use when acting
      on behalf of a party other than your organization. Requires the `user-profiles`
      beta header. Applies to every request in the batch; an individual request whose
      `user_profile_id` body field conflicts with this header is errored.

  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
anthropic-user-profile-id/v1/messages/batchesrequestsr7   r8   r9   r:   bodyoptionscast_to)r   _postr   r   BatchCreateParamsr   r    r+   r?   r6   r7   r8   r9   r:   s          r,   createBatches.create/   si    N u?,G+YZt_l_rprtzz" *h!79L9^9^_(+Q[ !  
 	
r/   r@   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )f  This endpoint is idempotent and can be used to poll for Message Batch
completion.

To access the results of a Message Batch, make a request to the
`results_url` field in the response.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  message_batch_id: ID of the Message Batch.

  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
?Expected a non-empty value for `message_batch_id` but received '/v1/messages/batches/{message_batch_id}message_batch_idr@   rC   rD   
ValueError_getr   r   r    r+   rO   r7   r8   r9   r:   s         r,   retrieveBatches.retrieve`   sQ    >  ^_o^rsttyyCVfg(+Q[ !  
 	
r/   after_id	before_idlimitr7   r8   r9   r:   c                   U R                  S[        [           [        UUUU[	        UUUS.[
        R                  5      S9[        S9$ af  List all Message Batches within a Workspace.

Most recently created batches are
returned first.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  after_id: ID of the object to use as a cursor for pagination. When provided, returns the
      page of results immediately after this object.

  before_id: ID of the object to use as a cursor for pagination. When provided, returns the
      page of results immediately before this object.

  limit: Number of items to return per page.

      Defaults to `20`. Ranges from `1` to `1000`.

  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>   )rX   rY   rZ   )r7   r8   r9   r:   query)pagerC   model)_get_api_listr   r    r   r   r   BatchListParamsr+   rX   rY   rZ   r7   r8   r9   r:   s           r,   listBatches.list   sb    P !!",'(+'%%$,%.!&
 &55 # " 
 	
r/   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )V  
Delete a Message Batch.

Message Batches can only be deleted once they've finished processing. If you'd
like to delete an in-progress batch, you must first cancel it.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  message_batch_id: ID of the Message Batch.

  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   rM   rN   r@   rP   rR   _deleter   r   r!   rT   s         r,   deleteBatches.delete   sQ    >  ^_o^rstt||CVfg(+Q[ (  
 	
r/   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )  Batches may be canceled any time before processing ends.

Once cancellation is
initiated, the batch enters a `canceling` state, at which time the system may
complete any in-progress, non-interruptible requests before finalizing
cancellation.

The number of canceled requests is specified in `request_counts`. To determine
which requests were canceled, check the individual results within the batch.
Note that cancellation may not result in any canceled requests if they were
non-interruptible.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  message_batch_id: ID of the Message Batch.

  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   ./v1/messages/batches/{message_batch_id}/cancelrN   r@   rP   rR   rE   r   r   r    rT   s         r,   cancelBatches.cancel   sR    J  ^_o^rsttzzJ]mn(+Q[ !  
 	
r/   c          
     *   U(       d  [        SU< 35      eU R                  US9nUR                  (       d  [        SUR                   35      eSS0U=(       d    0 EnU R                  [        UR                  US9[        X#XES9[        [           SS9$ )	  
Streams the results of a Message Batch as a `.jsonl` file.

Each line in the file is a JSON object containing the result of a single request
in the Message Batch. Results are not guaranteed to be in the same order as
requests. Use the `custom_id` field to match results to requests.

Learn more about the Message Batches API in our
[user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)

Args:
  message_batch_id: ID of the Message Batch.

  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   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr@   TrC   rD   stream)
rR   rU   results_urlr   processing_statusrS   r   r   r   r"   r+   rO   r7   r8   r9   r:   batchs          r,   resultsBatches.results  s    @  ^_o^rstt/?@   TUZUlUlTmn  "#7QM<ORQyy%++>NO(+Q[ !!?@  
 	
r/    )returnr)   )r   r2   r?   z%Iterable[batch_create_params.Request]r6   
str | Omitr7   Headers | Noner8   Query | Noner9   Body | Noner:   'float | httpx.Timeout | None | NotGivenr   r    rO   strr7   r   r8   r   r9   r   r:   r   r   r    )rX   r   rY   r   rZ   
int | Omitr7   r   r8   r   r9   r   r:   r   r   zSyncPage[MessageBatch]rO   r   r7   r   r8   r   r9   r   r:   r   r   r!   )rO   r   r7   r   r8   r   r9   r   r:   r   r   z,JSONLDecoder[MessageBatchIndividualResponse]__name__
__module____qualname____firstlineno__r   r-   r3   r   r   rH   rU   rc   ri   ro   r|   __static_attributes__r~   r/   r,   r#   r#      s2   , , 2 2 '+ )-$("&;D/
 8/
 $	/
 &/
 "/
  /
 9/
 
/
n )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
X  $ $  )-$("&;D:
 :
 	:

 :
 &:
 ":
  :
 9:
 
 :
D )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
^ )-$("&;D-
-
 &-
 "-
  -
 9-
 
-
j )-$("&;D1
1
 &1
 "1
  1
 91
 
61
 1
r/   c                  d   \ rS rSr\SS j5       r\SS j5       r\SSS\S.             SS jjr	SSS\S.           SS jjr
\\\SSS\S	.               SS
 jjrSSS\S.           SS jjrSSS\S.           SS jjrSSS\S.           SS jjrSrg)r$   iQ  c                    [        U 5      $ r(   )AsyncBatchesWithRawResponser*   s    r,   r-   AsyncBatches.with_raw_responseR  s     +400r/   c                    [        U 5      $ r1   )!AsyncBatchesWithStreamingResponser*   s    r,   r3   $AsyncBatches.with_streaming_response\  s     166r/   Nr5   c                  #    0 [        SU05      EU=(       d    0 EnU R                  S[        SU0[        R                  5      I Sh  vN [        X4XVS9[        S9I Sh  vN $  N N7f)r<   r=   r>   r?   Nr@   rA   )r   rE   r   r   rF   r   r    rG   s          r,   rH   AsyncBatches.createe  s|     N u?,G+YZt_l_rprtZZ",j(-CEXEjEjkk(+Q[ !   
 
 	
k
s$   AA)A%
	A) A'!A)'A)r@   c          
        #    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9I Sh  vN $  N7f)rK   rL   rM   rN   r@   rP   NrQ   rT   s         r,   rU   AsyncBatches.retrieve  s^     >  ^_o^rsttYYCVfg(+Q[ !  
 
 	
 
   ?AAArW   c                   U R                  S[        [           [        UUUU[	        UUUS.[
        R                  5      S9[        S9$ r\   )r`   r   r    r   r   r   ra   rb   s           r,   rc   AsyncBatches.list  sb    P !!"<((+'%%$,%.!&
 &55 # " 
 	
r/   c          
        #    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9I Sh  vN $  N7f)rf   rL   rM   rN   r@   rP   Nrg   rT   s         r,   ri   AsyncBatches.delete  s^     >  ^_o^rstt\\CVfg(+Q[ ( " 
 
 	
 
r   c          
        #    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9I Sh  vN $  N7f)rl   rL   rm   rN   r@   rP   Nrn   rT   s         r,   ro   AsyncBatches.cancel$  s_     J  ^_o^rsttZZJ]mn(+Q[ !   
 
 	
 
r   c          
     Z  #    U(       d  [        SU< 35      eU R                  US9I Sh  vN nUR                  (       d  [        SUR                   35      eSS0U=(       d    0 EnU R                  [        UR                  US9[        X#XES9[        [           SS	9I Sh  vN $  N{ N7f)
rr   rL   rN   Nrs   rt   ru   r@   Trv   )
rR   rU   rx   r   ry   rS   r   r   r   r"   rz   s          r,   r|   AsyncBatches.resultsS  s     @  ^_o^rsttmm5EmFF   TUZUlUlTmn  "#7QM<ORQYY%++>NO(+Q[ &&DE  
 
 	
 G
s"   )B+B'A6B+"B)#B+)B+r~   )r   r   )r   r   r   r   )rX   r   rY   r   rZ   r   r7   r   r8   r   r9   r   r:   r   r   z5AsyncPaginator[MessageBatch, AsyncPage[MessageBatch]]r   )rO   r   r7   r   r8   r   r9   r   r:   r   r   z1AsyncJSONLDecoder[MessageBatchIndividualResponse]r   r~   r/   r,   r$   r$   Q  s2   1 1 7 7 '+ )-$("&;D/
 8/
 $	/
 &/
 "/
  /
 9/
 
/
n )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
X  $ $  )-$("&;D:
 :
 	:

 :
 &:
 ":
  :
 9:
 
?:
D )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
^ )-$("&;D-
-
 &-
 "-
  -
 9-
 
-
j )-$("&;D1
1
 &1
 "1
  1
 91
 
;1
 1
r/   c                      \ rS rSrSS jrSrg)r)   i  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g N)_batchesr   to_raw_response_wrapperrH   rU   rc   ri   ro   r+   batchess     r,   __init__BatchesWithRawResponse.__init__  s    &>>NN
 )@@
 %<<LL
	 '>>NN
 '>>NN
r/   r   ro   rH   ri   rc   rU   Nr   r#   r   Noner   r   r   r   r   r   r~   r/   r,   r)   r)         
r/   r)   c                      \ rS rSrSS jrSrg)r   i  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g r   )r   r   async_to_raw_response_wrapperrH   rU   rc   ri   ro   r   s     r,   r   $AsyncBatchesWithRawResponse.__init__  s    &DDNN
 )FF
 %BBLL
	 'DDNN
 'DDNN
r/   r   Nr   r$   r   r   r   r~   r/   r,   r   r     r   r/   r   c                      \ rS rSrSS jrSrg)r2   i  c                   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        g r   )r   r   rH   rU   rc   ri   ro   r   s     r,   r   %BatchesWithStreamingResponse.__init__  sp    2NN
 5
 1LL
	 3NN
 3NN
r/   r   Nr   r   r~   r/   r,   r2   r2     r   r/   r2   c                      \ rS rSrSS jrSrg)r   i  c                   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        g r   )r   r   rH   rU   rc   ri   ro   r   s     r,   r   *AsyncBatchesWithStreamingResponse.__init__  sp    8NN
 ;
 7LL
	 9NN
 9NN
r/   r   Nr   r   r~   r/   r,   r   r     r   r/   r   )7
__future__r   typingr   httpx r   _typesr   r   r	   r
   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   _exceptionsr   _base_clientr   r   types.messagesr   r   _decoders.jsonlr   r   types.messages.message_batchr    $types.messages.deleted_message_batchr!   0types.messages.message_batch_individual_responser"   __all__r#   r$   r)   r   r2   r   r~   r/   r,   <module>r      s    #     K K K \ \ & : Y - ) @ D > 8 G ^n
%s
o s
l	s
# s
l	
 
*
 
*
 
*
 
r/   