
    i?1iwE                        d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	m
Z
mZ d dlmZmZ d dlmZmZ d dlmZmZ d dlmZmZ d d	lmZmZ  G d
 de      Z G d de      Zy)    )annotations)Any)"filter_out_none_values_recursivelyignore_docsparse_date_fields)#encode_key_value_store_record_value
pluck_data
to_safe_id)ActorJobBaseClientActorJobBaseClientAsync)DatasetClientDatasetClientAsync)KeyValueStoreClientKeyValueStoreClientAsync)	LogClientLogClientAsync)RequestQueueClientRequestQueueClientAsyncc                       e Zd ZdZed fd       ZddZdddddZddZdddd	Z	dd
ddZ
dddd	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 ddZddZddZddZd dZd!dZ xZS )"	RunClientz/Sub-client for manipulating a single actor run.c                L    |j                  dd      }t        |   |d|i| y)zInitialize the RunClient.resource_path
actor-runsN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/run.pyr   zRunClient.__init__   ,     

?LA$FmFvF    c                "    | j                         S )Return information about the actor run.

        https://docs.apify.com/api/v2#/reference/actor-runs/run-object/get-run

        Returns:
            dict: The retrieved actor run data
        _getr   s    r#   getzRunClient.get   s     yy{r%   Nstatus_messageis_status_message_terminalc               @    ||d}| j                  t        |            S )  Update the run with the specified fields.

        https://docs.apify.com/api/v2#/reference/actor-runs/run-object/update-run

        Args:
            status_message (str, optional): The new status message for the run
            is_status_message_terminal (bool, optional): Set this flag to True if this is the final status message of the Actor run.

        Returns:
            dict: The updated run
        statusMessageisStatusMessageTerminal_updater   r   r-   r.   updated_fieldss       r#   updatezRunClient.update"   s(     ,'A

 ||>~NOOr%   c                "    | j                         S )kDelete the run.

        https://docs.apify.com/api/v2#/reference/actor-runs/delete-run/delete-run
        _deleter*   s    r#   deletezRunClient.delete5   s    
 ||~r%   
gracefullyc               &    | j                  |      S )'  Abort the actor run which is starting or currently running and return its details.

        https://docs.apify.com/api/v2#/reference/actor-runs/abort-run/abort-run

        Args:
            gracefully (bool, optional): If True, the actor run will abort gracefully.
                It will send ``aborting`` and ``persistStates`` events into the run and force-stop the run after 30 seconds.
                It is helpful in cases where you plan to resurrect the run later.

        Returns:
            dict: The data of the aborted actor run
        r>   _abortr   r?   s     r#   abortzRunClient.abort<   s     {{j{11r%   	wait_secsc               &    | j                  |      S )  Wait synchronously until the run finishes or the server times out.

        Args:
            wait_secs (int, optional): how long does the client wait for run to finish. None for indefinite.

        Returns:
            dict, optional: The actor run data. If the status on the object is not one of the terminal statuses
                (SUCEEDED, FAILED, TIMED_OUT, ABORTED), then the run has not yet finished.
        rF   _wait_for_finishr   rG   s     r#   wait_for_finishzRunClient.wait_for_finishK   s     $$y$99r%   target_actor_build	run_inputcontent_typec                  t        ||      \  }}t        |      }| j                  ||      }| j                  j	                  | j                  d      dd|i||      }t        t        |j                                     S )  Transform an actor run into a run of another actor with a new input.

        https://docs.apify.com/api/v2#/reference/actor-runs/metamorph-run/metamorph-run

        Args:
            target_actor_id (str): ID of the target actor that the run should be transformed into
            target_actor_build (str, optional): The build of the target actor. It can be either a build tag or build number.
                By default, the run uses the build specified in the default run configuration for the target actor (typically the latest build).
            run_input (Any, optional): The input to pass to the new run.
            content_type (str, optional): The content type of the input.

        Returns:
            dict: The actor run data.
        targetActorIdbuild	metamorphPOSTcontent-typeurlmethodheadersdataparams	r   r
   _paramshttp_clientcall_urlr   r	   jsonr   target_actor_idrO   rP   rQ   safe_target_actor_idrequest_paramsresponses           r#   rW   zRunClient.metamorphW   s    , #FiQ]"^	<)/:.$ & 

 ##((		+&#\2! ) 
 !HMMO!<==r%   rV   memory_mbytestimeout_secsc                   | j                  |||      }| j                  j                  | j                  d      d|      }t	        t        |j                                     S ))  Resurrect a finished actor run.

        Only finished runs, i.e. runs with status FINISHED, FAILED, ABORTED and TIMED-OUT can be resurrected.
        Run status will be updated to RUNNING and its container will be restarted with the same default storages.

        https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run

        Args:
            build (str, optional): Which actor build the resurrected run should use. It can be either a build tag or build number.
                                   By default, the resurrected run uses the same build as before.
            memory_mbytes (int, optional): New memory limit for the resurrected run, in megabytes.
                                           By default, the resurrected run uses the same memory limit as before.
            timeout_secs (int, optional): New timeout for the resurrected run, in seconds.
                                           By default, the resurrected run uses the same timeout as before.

        Returns:
            dict: The actor run data.
        rV   memorytimeout	resurrectrX   r[   r\   r_   ra   rb   rc   rd   r   r	   re   r   rV   rl   rm   ri   rj   s         r#   rs   zRunClient.resurrect   sg    2    & 
 ##((		+&! ) 
 !HMMO!<==r%   c                    | j                   j                  | j                  d      d      }t        t	        |j                                     S )Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted.

        https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run

        Returns:
            dict: The Actor run data.
        rebootrX   r[   r\   rb   rc   rd   r   r	   re   r   rj   s     r#   ry   zRunClient.reboot   sF     ##((		(# ) 
 !HMMO!<==r%   c                8    t        di | j                  d      S )a  Get the client for the default dataset of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            DatasetClient: A client allowing access to the default dataset of this actor run.
        datasetr    )r   _sub_resource_init_optionsr*   s    r#   r~   zRunClient.dataset   s'      
--I-F
 	
r%   c                8    t        di | j                  d      S )a!  Get the client for the default key-value store of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            KeyValueStoreClient: A client allowing access to the default key-value store of this actor run.
        key-value-storer   r   )r   r   r*   s    r#   key_value_storezRunClient.key_value_store   s(     # 
--<M-N
 	
r%   c                8    t        di | j                  d      S )a  Get the client for the default request queue of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            RequestQueueClient: A client allowing access to the default request_queue of this actor run.
        request-queuer   r   )r   r   r*   s    r#   request_queuezRunClient.request_queue   s'     " 
--O-L
 	
r%   c                8    t        di | j                  d      S )zGet the client for the log of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            LogClient: A client allowing access to the log of this actor run.
        logr   r   )r   r   r*   s    r#   r   zRunClient.log   s'      
--E-B
 	
r%   )r   r   r    r   r!   r   returnNone)r   r   r   dict | None)r   r   r-   
str | Noner.   bool | Noner   dict)r   r   r   r   )r   r   r?   r   r   r   )r   r   rG   
int | Noner   r   )r   r   rg   strrO   r   rP   r   rQ   r   r   r   )
r   r   rV   r   rl   r   rm   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r   r   r+   r8   r=   rE   rM   rW   rs   ry   r~   r   r   r   __classcell__r"   s   @r#   r   r      s    9G G
 AEpt P& =A 2 EI 
:  *.#''>'> '> '	'>
 '> !'> 
'>X !$(#'%>%> %> "	%>
 !%> 
%>N>







r%   r   c                       e Zd ZdZed fd       ZddZdddddZddddZdd	dd
Z	ddZ
dddd	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 ddZddZddZddZd dZd!dZ xZS )"RunClientAsyncz5Async sub-client for manipulating a single actor run.c                L    |j                  dd      }t        |   |d|i| y)zInitialize the RunClientAsync.r   r   Nr   r   s       r#   r   zRunClientAsync.__init__   r$   r%   c                >   K   | j                          d{   S 7 w)r'   Nr(   r*   s    r#   r+   zRunClientAsync.get   s      YY[      Nr,   c               \   K   ||d}| j                  t        |             d{   S 7 w)r0   r1   Nr4   r6   s       r#   r8   zRunClientAsync.update   s2      ,'A

 \\"D^"TUUUUs   #,*,r>   c               B   K   | j                  |       d{   S 7 w)rA   r>   NrB   rD   s     r#   rE   zRunClientAsync.abort  s      [[J[7777   rF   c               B   K   | j                  |       d{   S 7 w)rI   rF   NrJ   rL   s     r#   rM   zRunClientAsync.wait_for_finish  s"      **Y*????r   c                >   K   | j                          d{   S 7 w)r:   Nr;   r*   s    r#   r=   zRunClientAsync.delete'  s     
 \\^###r   rN   c                 K   t        ||      \  }}t        |      }| j                  ||      }| j                  j	                  | j                  d      dd|i||       d{   }t        t        |j                                     S 7 &w)rS   rT   rW   rX   rY   rZ   Nr`   rf   s           r#   rW   zRunClientAsync.metamorph.  s     , #FiQ]"^	<)/:.$ & 

 ))..		+&#\2! / 
 
 !HMMO!<==
s   A"B$B%'Brk   c                  K   | j                  |||      }| j                  j                  | j                  d      d|       d{   }t	        t        |j                                     S 7 &w)ro   rp   rs   rX   rt   Nru   rv   s         r#   rs   zRunClientAsync.resurrectW  su     2    & 
 ))..		+&! / 
 
 !HMMO!<==
s   AA0A.'A0c                   K   | j                   j                  | j                  d      d       d{   }t        t	        |j                                     S 7 &w)rx   ry   rX   rz   Nr{   r|   s     r#   ry   zRunClientAsync.reboot~  sT      ))..		(# / 
 
 !HMMO!<==	
s   0AA'Ac                8    t        di | j                  d      S )a  Get the client for the default dataset of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            DatasetClientAsync: A client allowing access to the default dataset of this actor run.
        r~   r   r   )r   r   r*   s    r#   r~   zRunClientAsync.dataset  s'     " 
--I-F
 	
r%   c                8    t        di | j                  d      S )a&  Get the client for the default key-value store of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            KeyValueStoreClientAsync: A client allowing access to the default key-value store of this actor run.
        r   r   r   )r   r   r*   s    r#   r   zRunClientAsync.key_value_store  s(     ( 
--<M-N
 	
r%   c                8    t        di | j                  d      S )a!  Get the client for the default request queue of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            RequestQueueClientAsync: A client allowing access to the default request_queue of this actor run.
        r   r   r   )r   r   r*   s    r#   r   zRunClientAsync.request_queue  s'     ' 
--O-L
 	
r%   c                8    t        di | j                  d      S )zGet the client for the log of the actor run.

        https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages

        Returns:
            LogClientAsync: A client allowing access to the log of this actor run.
        r   r   r   )r   r   r*   s    r#   r   zRunClientAsync.log  s'      
--E-B
 	
r%   )r   r   r    r   r!   r   r   r   )r   r   r   r   )r   r   r-   r   r.   r   r   r   )r   r   r?   r   r   r   )r   r   rG   r   r   r   )r   r   r   r   )r   r   rg   r   rO   r   rP   r   rQ   r   r   r   )
r   r   rV   r   rl   r   rm   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r+   r8   rE   rM   r=   rW   rs   ry   r~   r   r   r   r   r   s   @r#   r   r      s    ?G G
! LP{ V& HL 8 PT 
@$ *.#''>'> '> '	'>
 '> !'> 
'>X !$(#'%>%> %> "	%>
 !%> 
%>N>







r%   r   N)
__future__r   typingr   apify_shared.utilsr   r   r   apify_client._utilsr   r	   r
   apify_client.clients.baser   r   -apify_client.clients.resource_clients.datasetr   r   5apify_client.clients.resource_clients.key_value_storer   r   )apify_client.clients.resource_clients.logr   r   3apify_client.clients.resource_clients.request_queuer   r   r   r   r   r%   r#   <module>r      sE    "  a a [ [ Q [ o O kT
" T
nT
, T
r%   