
    ~iG                         d dl mZ d dlZd dlmZ d dlmZ d dlZd dlm	Z	 d dl
mZ d dlmZmZmZ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  G d de          Zd ZdS )    )absolute_importN)
ThreadPool)sleep)rest)Configuration)BuildRequestInterceptorSignRequestInterceptorResolveEndpointInterceptorRuntimeOptionsInterceptor)DeserializedResponseInterceptor)InterceptorChainInterceptorContext)RequestResponse)sdk_core_loggerLogLevelc            	       "   e Zd ZdZeeeej        fej	        z   Z
eej        reneeeeej        ej        edZ	 	 ddZd Zed             Zed             Zej        d             Zd	 Z	 	 	 	 	 ddZd Z	 	 	 	 	 ddZ	 	 	 ddZd Zd Zd Z dS )	ApiClienta  Generic API client for Swagger client library builds.

    Swagger generic API client. This client handles the client-
    server communication, and is invariant across implementations. Specifics of
    the methods and models for each application are generated from the Swagger
    templates.

    NOTE: This class is auto generated by the swagger code generator program.
    Ref: https://github.com/swagger-api/swagger-codegen
    Do not edit the class manually.

    :param configuration: .Configuration object for this client
    :param header_name: a header to pass when making calls to the API.
    :param header_value: a header value to pass when making calls to
        the API.
    :param cookie: a cookie to include in the header when making calls
        to the API
    )intlongfloatstrbooldatedatetimeobjectNc                 p   |t                      }|| _        d | _        t          j        |          | _        i | _        |
|| j        |<   || _        d| _        |j	        | _	        t                      | _        | j                            t                                 | j                            t                                 | j                            t                                 | j                            t!                                 | j                            t%                                 d S )Nzvolcstack-python-sdk/5.0.17)r   configuration_poolr   RESTClientObjectrest_clientdefault_headerscookie
user_agentclient_side_validationr   interceptor_chainappend_request_interceptorr   r   r
   r	   append_response_interceptorr   )selfr   header_nameheader_valuer#   s        e/root/.openclaw/workspace/.venvs/ark-sdk/lib/python3.11/site-packages/volcenginesdkcore/api_client.py__init__zApiClient.__init__5   s    )OOM* 
0??!"0<D -7&3&J#!1!3!399:Q:S:STTT99:S:U:UVVV99:T:V:VWWW99:P:R:RSSS::;Z;\;\]]]]]    c                 |    | j         4| j                                          | j                                          d S d S N)r   closejoinr)   s    r,   __del__zApiClient.__del__O   s>    :!JJOO "!r.   c                 D    | j         t                      | _         | j         S r0   )r   r   r3   s    r,   poolzApiClient.poolT   s    :#DJzr.   c                     | j         d         S )zUser agent for this API client
User-Agentr"   r3   s    r,   r$   zApiClient.user_agentZ   s     #L11r.   c                     || j         d<   d S )Nr8   r9   )r)   values     r,   r$   zApiClient.user_agent_   s    -2\***r.   c                     || j         |<   d S r0   r9   )r)   r*   r+   s      r,   set_default_headerzApiClient.set_default_headerc   s    ,8[)))r.   Tc                    |pi }|                     | j                   | j        r
| j        |d<   t          t	          | j        |||||||||	|
||||                    }| j                            |          }|                     |	                                           d}d }d }|j
        j        }|j
        j        }|j        }	 	 | 
                    ||j
        j        |j
        j        |j
        j        |j
        j        |j
        j        |j
        j        |j
        j                  }|| _        nH# t,          $ r;}t/          j        d                    |                     |}||k    r|Y d }~nd }~ww xY w|r|                     ||||          s||n|dz  }d }t7          |          |_        | j                            |          }|j        }|r|j        S |j        |j        j         |j        !                                fS )NCookie)requestr   T)urlquery_paramsheaderspost_paramsbody_preload_content_request_timeoutzrequest error: {}   )"updater"   r#   r   r   r   r&   execute_request_log_configget_requestr@   
auto_retryretryernum_max_retriesrA   rB   header_paramsrD   rE   preload_contentrequest_timeoutlast_response	Exceptionr   warningformatrequest_retryr   responseexecute_responseresulthttp_responsestatus
getheaders)r)   resource_pathmethodpath_paramsrB   rP   rE   rD   filesresponse_typeauth_settings_return_http_data_onlycollection_formatsrF   rG   interceptor_contextretry_countresponse_data	retry_errrM   rN   rO   erX   s                           r,   
__call_apizApiClient.__call_apif   sz    &+T1222; 	2&*kM(#06;-{=-"$6.:
 :
    #4DDEXYY,88::;;;	(0;
%-5!1	 $ 3 ; ?NaNiNv/7E 3 ; GNaNiNn%8%@%P%8%@%P !- !R !R &3""   '(;(B(B1(E(EFFF	/11G 21111  T%7%7{T]_f%g%g (#O1KI+	. (0'>'>$"4EEFYZZ&/! 	9?"OX%;%B*55779 9s   A*D3 3
E8=1E33E8c                 <   |                     |||          r|                    |          }t          |dz             | j        j        rOt          j        dt          |j                  j	        t          |j
                  j	        |j        |dz   |           dS dS )Ni  zoretry backoff strategy:%s, retry condition: %s, max retry count:%d, current retry count: %d, retry delay(ms):%frH   TF)should_retryget_backoff_delayr   r   debugr   debug_configtypebackoff_strategy__name__retry_conditionrO   )r)   rh   rg   ri   rN   delays         r,   rW   zApiClient.request_retry   s    {IFF 	--k::E%$,!' E, F122;T'BY=Z=Z=c+[1_eE E E 4ur.   c                     |s"|                      |||||||||	|
||||          S | j                            | j         |||||||||	|
||||f          }|S )a  Makes the HTTP request (synchronous) and returns deserialized data.

        To make an async request, set the async_req parameter.

        :param resource_path: Path to method endpoint.
        :param method: Method to call.
        :param path_params: Path parameters in the url.
        :param query_params: Query parameters in the url.
        :param header_params: Header parameters to be
            placed in the request header.
        :param body: Request body.
        :param post_params dict: Request post form parameters,
            for `application/x-www-form-urlencoded`, `multipart/form-data`.
        :param auth_settings list: Auth Settings names for the request.
        :param response: Response data type.
        :param files dict: key -> filename, value -> filepath,
            for `multipart/form-data`.
        :param async_req bool: execute request asynchronously
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param collection_formats: dict of collection formats for path, query,
            header, and post parameters.
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return:
            If async_req parameter is True,
            the request will be called asynchronously.
            The method will return the request thread.
            If parameter async_req is False or missing,
            then the method will return the response directly.
        )_ApiClient__call_apir6   apply_async)r)   r^   r_   r`   rB   rP   rE   rD   ra   rb   rc   	async_reqrd   re   rF   rG   threads                    r,   call_apizApiClient.call_api   s    T  	b??=&#.m#'e#0-#9;M#35EG G G Y**4?]=C[R^=JD=H%=JM=S=O=MO_=a b bF r.   c	           	      8   |dk    r| j                             |||||          S |dk    r| j                             |||||          S |dk    r!| j                             |||||||          S |dk    r!| j                             |||||||          S |dk    r!| j                             |||||||          S |dk    r!| j                             |||||||          S |d	k    r | j                             ||||||
          S t          d          )z(Makes the HTTP request using RESTClient.GET)rB   rF   rG   rC   HEADOPTIONS)rB   rC   rD   rF   rG   rE   POSTPUTPATCHDELETE)rB   rC   rF   rG   rE   zQhttp method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.)	r!   r}   r~   r   r   r   r   r   
ValueError)	r)   r_   rA   rB   rC   rD   rE   rF   rG   s	            r,   r@   zApiClient.request   s    U??#''5A9I9I07	 ( 9 9 9
 v#((6B:J:J18	 ) : : :
 y  #++C9E4;8C=M=M15 , 7 7 7 v#((6B185@:J:J.2 ) 4 4 4 u__#''5A074?9I9I-1 ( 3 3 3 w#))#7C296A;K;K/3 * 5 5 5 x#**38D3:<L<L04 + 6 6 6 7  r.   c                 X    |sdS d |D             }d|v rdS d                     |          S )zReturns `Accept` based on an array of accepts provided.

        :param accepts: List of headers.
        :return: Accept (e.g. application/json).
        Nc                 6    g | ]}|                                 S  lower.0xs     r,   
<listcomp>z2ApiClient.select_header_accept.<locals>.<listcomp>7  s     ...17799...r.   application/jsonz, )r2   )r)   acceptss     r,   select_header_acceptzApiClient.select_header_accept.  sG      	F..g...((%%99W%%%r.   c                 F    |sdS d |D             }d|v sd|v rdS |d         S )zReturns `Content-Type` based on an array of content_types provided.

        :param content_types: List of content-types.
        :return: Content-Type (e.g. application/json).
        r   c                 6    g | ]}|                                 S r   r   r   s     r,   r   z8ApiClient.select_header_content_type.<locals>.<listcomp>G  s     :::q:::r.   z*/*r   r   )r)   content_typess     r,   select_header_content_typez$ApiClient.select_header_content_type>  sK      	&%%::M:::..%=2H2H%% ##r.   c                 ^   t          j        t          j                  sd S g }|                    d           |                    | j        dz              |                    d           |                    d           |                    t          | j        j                  dz              |                    d           |                    t          | j        j	                  dz              |                    d           |                    d           |                    t          |j
                  dz              |                    d           |                    d	           |                    t          | j        j                  dz              |                    d
           |                    t          | j        j                  dz              |                    d           |                    d           |                    t          | j        j                  dz              |                    d           |                    t          | j        j                  dz              |                    d           |                    d           |                    t          |j                  dz              |j        r|j        |                    d           |                    t          |j        j                  dz              |                    d           |                    t          |j        j        j                  dz              |                    d           |                    t          |j        j        j                  dz              |                    d           |                    |j        j        t-          |j        j                  j        nd           |                    d           |                    |j        j        t-          |j        j                  j        nd           |                    d           |                    t          |j        j        j                  dz              |                    d           |                    d           |                    t          |j                  dz              |                    d           |                    t          |j                  dz              |                    d           |                    t          |j                  dz              |                    d           |                    t          |j                  dz              |                    d           |                    |j        t-          |j                  j        nd           t          j        d                    |                     d S )NzSDK Version        : 
z[Connection Pool]
z  Number of pools           : z  Connection pool maxsize   : z	[Scheme]
z  Scheme      : z[Proxy]
z  HTTP Proxy       : z  HTTPS Proxy      : z
[Timeout]
z  Connect Timeout(ms)  : z  Read Timeout(ms)     : z[Retry]
z  Auto Retry       : z  Max Retries      : z  Min Delay (ms)   : z  Max Delay (ms)   : z  Retry Condition  : zNone
z  Backoff Strategy : z  Retry ErrorCodes : z[Endpoint Resolver]
z  Region           : z  Endpoint         : z  Use DualStack    : z  Bootstrap Region : z  Resolver Class   :  ) r   is_enabled_for_loglevelr   LOG_DEBUG_WITH_CONFIGappendr$   r   r   	num_poolsconnection_pool_maxsizescheme
http_proxyhttps_proxyconnect_timeoutread_timeoutrM   rN   rO   rr   min_retry_delay_msmax_retry_delay_msrt   rq   rs   retry_error_codesregionhostuse_dual_stackcustom_bootstrap_regionendpoint_providerrp   r2   )r)   r@   sbs      r,   rK   zApiClient._log_configN  sW   6x7UVV 	F
		)***
		$/D())) 			,---
		2333
		#d(233d:;;;
		2333
		#d(@AADHIII 			#$$$
		$%%%
		#gn%%,--- 			"###
		)***
		#d(344t;<<<
		)***
		#d(455<=== 			$%%%
		-...
		#d(899D@AAA
		-...
		#d(566=>>> 			"###
		)***
		#g())D0111 	U'/"=II-...IIc'/9::TABBBII-...IIc'/:MNNQUUVVVII-...IIc'/:MNNQUUVVVII-...IIHgHsd7?:;;DD  zG  H  H  HII-...IIIiIud7?;<<EE  |I  J  J  JII-...IIc'/9KLLtSTTT 			.///
		)***
		#gn%%,---
		)***
		#gl##d*+++
		)***
		#g,--4555
		)***
		#g566=>>>
		)***
		g>W>c$w011::ivwww$RWWR[[11111r.   )NNNN)NNNNNNNNNNTN)NNNNNNNNNNNTN)NNNNTN)!rs   
__module____qualname____doc__r   r   bytessix	text_typeinteger_typesPRIMITIVE_TYPESr   PY3r   r   r   r   r   NATIVE_TYPES_MAPPINGr-   r4   propertyr6   r$   setterr=   rw   rW   r{   r@   r   r   rK   r   r.   r,   r   r      s        & dE3=9C<MMOw(D%	 	 KO^ ^ ^ ^4  
   X
 2 2 X2 3 3 39 9 9 6:JN:><@48A9 A9 A9 A9F
 
 
 EI48CGAE9=: : : :x ?C>B!%; ; ; ;z& & & $ $ $ C2 C2 C2 C2 C2r.   r   c                     | j         S r0   )	_metadatar3   s    r,   metadatar     s
    >r.   )
__future__r   r   multiprocessing.poolr   timer   r   volcenginesdkcorer   volcenginesdkcore.configurationr   volcenginesdkcore.interceptorr   r	   r
   r   r   r   r   r   r   (volcenginesdkcore.observability.debuggerr   r   r   r   r   r   r.   r,   <module>r      sW   ' & & & & &  + + + + + +       


 " " " " " " 9 9 9 9 9 9: : : : : : : : : : : : I I I I I I N N N N N N N N ; ; ; ; ; ; ; ; N N N N N N N N|2 |2 |2 |2 |2 |2 |2 |2|    r.   