
    i?1i                        d dl mZ d dlmZmZ d dlmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ erd dlZ G d	 d
e      Z G d de      Zy)    )annotations)asynccontextmanagercontextmanager)TYPE_CHECKINGAnyAsyncIteratorIterator)ignore_docs)ApifyApiError)catch_not_found_or_throw)ResourceClientResourceClientAsyncNc                  P     e Zd ZdZed fd       ZddZddZed	d       Z	 xZ
S )
	LogClientz!Sub-client for manipulating logs.c                L    |j                  dd      }t        |   |d|i| y)zInitialize the LogClient.resource_pathlogsNpopsuper__init__selfargskwargsr   	__class__s       s/home/www/therecruiter.miabetepe.com/venv/lib/python3.12/site-packages/apify_client/clients/resource_clients/log.pyr   zLogClient.__init__   ,     

?F;$FmFvF    c                    	 | j                   j                  | j                  d| j                               }|j                  S # t
        $ r}t        |       Y d}~yd}~ww xY wzRetrieve the log as text.

        https://docs.apify.com/api/v2#/reference/logs/log/get-log

        Returns:
            str, optional: The retrieved log, or None, if it does not exist.
        GET)urlmethodparamsNhttp_clientcallr#   _paramstextr   r   r   responseexcs      r   getzLogClient.get   s_    
	*'',,HH||~ - H ==  	*$S))	*s   AA 	A"AA"c                    	 | j                   j                  | j                  d| j                         d      }|j                  S # t
        $ r}t        |       Y d}~yd}~ww xY wzRetrieve the log as raw bytes.

        https://docs.apify.com/api/v2#/reference/logs/log/get-log

        Returns:
            bytes, optional: The retrieved log as raw bytes, or None, if it does not exist.
        r"   F)r#   r$   r%   parse_responseNr'   r(   r#   r)   contentr   r   r+   s      r   get_as_byteszLogClient.get_as_bytes/   sd    	*'',,HH||~$	 - H ### 	*$S))	*s   AA 	A#AA#c              #  .  K   d}	 | j                   j                  | j                  d| j                  d      dd      }| |r|j                          yy# t        $ r}t        |       d Y d}~1d}~ww xY w# |r|j                          w w xY wwzRetrieve the log as a stream.

        https://docs.apify.com/api/v2#/reference/logs/log/get-log

        Returns:
            httpx.Response, optional: The retrieved log as a context-managed streaming Response, or None, if it does not exist.
        Nr"   T)streamF)r#   r$   r%   r7   r1   )r'   r(   r#   r)   r   r   closer+   s      r   r7   zLogClient.streamF   s      	!'',,HH||4|0$ - H N
   	  	$S)J	   s:   B>A B	A:!A50A= 5A::A= =BB)r   r   r   r   r   r   returnNone)r   r   r9   
str | None)r   r   r9   bytes | None)r   r   r9   zIterator[httpx.Response | None])__name__
__module____qualname____doc__r
   r   r.   r4   r   r7   __classcell__r   s   @r   r   r      s8    +G G
,. ! !r   r   c                  P     e Zd ZdZed fd       ZddZddZed	d       Z	 xZ
S )
LogClientAsyncz'Async sub-client for manipulating logs.c                L    |j                  dd      }t        |   |d|i| y)zInitialize the LogClientAsync.r   r   Nr   r   s       r   r   zLogClientAsync.__init__e   r   r   c                   K   	 | j                   j                  | j                  d| j                                d{   }|j                  S 7 # t
        $ r}t        |       Y d}~yd}~ww xY wwr!   r&   r+   s      r   r.   zLogClientAsync.getk   sn     
	*!--22HH||~ 3  H ==   	*$S))	*s>   A19A AA A1A 	A.A)$A1)A..A1c                   K   	 | j                   j                  | j                  d| j                         d       d{   }|j                  S 7 # t
        $ r}t        |       Y d}~yd}~ww xY wwr0   r2   r+   s      r   r4   zLogClientAsync.get_as_bytes   ss     	*!--22HH||~$	 3  H ###  	*$S))	*s>   A2:A AA A2A 	A/A*%A2*A//A2c               l  K   d}	 | j                   j                  | j                  d| j                  d      dd       d{   }| |r|j                          d{    yy7 %# t        $ r}t        |       d Y d}~<d}~ww xY w7 .# |r|j                          d{  7   w w xY wwr6   )r'   r(   r#   r)   r   r   acloser+   s      r   r7   zLogClientAsync.stream   s      	(!--22HH||4|0$ 3  H N
 oo'''   	$S)JJ	
 ( oo''' sj   B4=A+ A)	A+ B4"B#B4)A+ +	B4B	B 	BB B4B1)B,*B11B4)r   rD   r   r   r   r   r9   r:   )r   rD   r9   r;   )r   rD   r9   r<   )r   rD   r9   z$AsyncIterator[httpx.Response | None])r=   r>   r?   r@   r
   r   r.   r4   r   r7   rA   rB   s   @r   rD   rD   b   s8    1G G
,. ( (r   rD   )
__future__r   
contextlibr   r   typingr   r   r   r	   apify_shared.utilsr
   apify_client._errorsr   apify_client._utilsr   apify_client.clients.baser   r   httpxr   rD    r   r   <module>rS      sA    " : > > * . 8 IO! O!dO(( O(r   