
    i                     d    d dl Z d dlmZmZmZ d dlZd dlZd dlZd dlm	Z
 dZdZdZ G d d      Zy)	    N)ListOptionalTuple)Configuration<   i,     c                       e Zd Zeddedee   fd       Zededededefd       Zede	e
efd	ed
edededeeeeef      f
d       Zy)OpenApiConfigFactoryNapi_keyhostc                     t               }d|i|_        ||_        t        j                         |_        | j                         |_        d|_        |S )N
ApiKeyAuthT)	OpenApiConfigurationr   r   certifiwheressl_ca_cert_get_socket_optionssocket_optionsdiscard_unknown_keys)clsr   r   kwargsopenapi_configs        x/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/config/openapi_config_factory.pybuildzOpenApiConfigFactory.build   sL    -/".!8"%,]]_"(+(?(?(A%.2+    r   returnc                     t        j                  |      }d|i|_        ||_        |j                  s| j                         |_        |S )aQ  
        Copy a user-supplied openapi configuration and update it with the user's api key and host.
        If they have not specified other socket configuration, we will use the default values.
        We expect these objects are being passed mainly a vehicle for proxy configuration, so
        we don't modify those settings.
        r   )copydeepcopyr   r   r   r   )r   r   r   r   copieds        r   r   zOpenApiConfigFactory.copy   sH     ~.&0 $$$'$;$;$=F! r   Tdo_keep_alivekeep_alive_idle_seckeep_alive_interval_seckeep_alive_triesc                 D   t         j                  t         j                  dfg}|s|S |t         j                  t         j                  dfgz  }t
        j                  }|dk(  rt        t         d      rt        t         d      rt        t         d      rq|t         j                  t         j                  |fgz  }|t         j                  t         j                  |fgz  }|t         j                  t         j                  |fgz  }|S |dk(  rd}|t         j                  ||fgz  }|S )aK  
        Returns the socket options to pass to OpenAPI's Rest client
        Args:
            do_keep_alive: Whether to enable TCP keep alive mechanism
            keep_alive_idle_sec: Time in seconds of connection idleness before starting to send keep alive probes
            keep_alive_interval_sec: Interval time in seconds between keep alive probe messages
            keep_alive_tries: Number of failed keep alive tries (unanswered KA messages) before terminating the connection

        Returns:
            A list of socket options for the Rest client's connection pool
           linuxTCP_KEEPIDLETCP_KEEPINTVLTCP_KEEPCNTdarwin   )socketIPPROTO_TCPTCP_NODELAY
SOL_SOCKETSO_KEEPALIVEsysplatformhasattrr(   r)   r*   )selfr!   r"   r#   r$   socket_paramsr3   TCP_KEEPALIVEs           r   r   z(OpenApiConfigFactory._get_socket_options4   s   , !,,f.@.@!DE  6,,f.A.A1EFF << /0.v1163F3FH[\]]Mv1163G3GI`abbMv1163E3EGWXYYM 	 ! Mv11=BYZ[[Mr   )N)__name__
__module____qualname__classmethodstrr   r   r   r   r(   r)   r*   boolintr   r   r    r   r   r
   r
      s    C x}   1<?GJ	 0  ##/'4 +44 !4 "%	4
 4 
eCcM"	#4 4r   r
   )r2   typingr   r   r   r   r-   r   %pinecone.config.openapi_configurationr   r   r)   r(   r*   r
   r?   r   r   <module>rB      s5    
 ( (    WZ Zr   