
    iQA                     f    d dl Z d dlZd dlZd dlmZ d dlmZ  G d de      Zh dZ G d d      Z	y)	    N)PineconeApiValueError)	TypedDictc                   "    e Zd ZU eed<   eed<   y)HostSettingurldescriptionN)__name__
__module____qualname__str__annotations__     w/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/config/openapi_configuration.pyr   r   	   s    	Hr   r   >
   maximumminimumpatternmaxItemsminItems	maxLength	minLength
multipleOfexclusiveMaximumexclusiveMinimumc                   N   e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 ddZd Zd Zed        Z	ed        Z
ed        Zej                  d	        Zed
        Zej                  d        Zed        Zej                  d        ZddZd Zd ZddZed        Zej                  d        Zd Zy)Configurationa  Class to hold the configuration of the API client.

        :param host: Base url
        :param api_key: Dict to store API key(s).
          Each entry in the dict specifies an API key.
          The dict key is the name of the security scheme in the OAS specification.
          The dict value is the API key secret.
        :param api_key_prefix: Dict to store API prefix (e.g. Bearer)
          The dict key is the name of the security scheme in the OAS specification.
          The dict value is an API key prefix when generating the auth data.
        :param discard_unknown_keys: Boolean value indicating whether to discard
          unknown properties. A server may send a response that includes additional
          properties that are not known by the client in the following scenarios:
          1. The OpenAPI document is incomplete, i.e. it does not match the server
             implementation.
          2. The client was generated using an older version of the OpenAPI document
             and the server has been upgraded since then.
          If a schema in the OpenAPI document defines the additionalProperties attribute,
          then all undeclared properties received by the server are injected into the
          additional properties map. In that case, there are undeclared properties, and
          nothing to discard.
        :param disabled_client_side_validations (string): Comma-separated list of
          JSON schema validation keywords to disable JSON schema structural validation
          rules. The following keywords may be specified: multipleOf, maximum,
          exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern,
          maxItems, minItems.
          By default, the validation is performed for data generated locally by the client
          and data received from the server, independent of any validation performed by
          the server side. If the input data does not satisfy the JSON schema validation
          rules specified in the OpenAPI document, an exception is raised.
          If disabled_client_side_validations is set, structural validation is
          disabled. This can be useful to troubleshoot data validation problem, such as
          when the OpenAPI document validation rules do not match the actual API data
          received by the server.
        :param server_operation_index: Mapping from operation ID to an index to server
          configuration.
        :param server_operation_variables: Mapping from operation ID to a mapping with
          string values to replace variables in templated server configuration.
          The validation of enums is performed for variables with defined enum values before.
        :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
          in PEM format

        :Example:

        API Key Authentication Example.
        Given the following security scheme in the OpenAPI specification:
          components:
            securitySchemes:
              cookieAuth:         # name for the security scheme
                type: apiKey
                in: cookie
                name: JSESSIONID  # cookie name

        You can programmatically set the cookie:

    conf = pinecone.config.openapi_configuration.Configuration(
        api_key={'cookieAuth': 'abc123'}
        api_key_prefix={'cookieAuth': 'JSESSIONID'}
    )

        The following cookie will be added to the HTTP request:
           Cookie: JSESSIONID abc123
    Nc                    |dn|| _         	 ||dn|| _        |xs i | _        	 |xs i | _        |	xs i | _        	 d| _        	 i | _        |r|| _        	 i | _        |r|| _        	 d| _        	 || _	        || _
        i | _        	 t        j                  d      | j                  d<   t        j                  d      | j                  d<   d| _        	 d| _        	 d| _        	 d| _        	 d	| _        	 d
| _        	 |
| _        	 d| _        	 d| _        	 d| _        	 t1        j2                         dz  | _        	 d| _        	 d| _        	 d| _        	 d| _        	 d
| _        d| _         y)ConstructorNhttps://api.pinecone.ior   zpinecone.openapi_supportpackage_loggerurllib3urllib3_loggerz%%(asctime)s %(levelname)s %(message)sFT    )!
_base_pathserver_indexserver_operation_indexserver_variablesserver_operation_variablestemp_folder_pathapi_keyapi_key_prefixrefresh_api_key_hookdiscard_unknown_keys disabled_client_side_validationsloggerlogging	getLoggerlogger_formatlogger_stream_handlerlogger_file_handlerlogger_filedebug
verify_sslssl_ca_cert	cert_filekey_fileassert_hostnamemultiprocessing	cpu_countconnection_pool_maxsizeproxyproxy_headerssafe_chars_for_path_paramretriesclient_side_validationsocket_options)selfhostr+   r,   r.   r/   r&   r(   r'   r)   r9   s              r   __init__zConfiguration.__init___   s    8<|3	!-!5$,AL&<&B#	 0 6B*D*J'	 $	 "DL	 "0D	$(!	$8!0P-	(/(9(9:T(U$%(/(9(9)(D$%D	%)"	#' 		 
	 	 '			#	 (7'@'@'BQ'F$	 
	!	)+&		 '+# #r   c           	      x   | j                   }|j                  |      }||t        |       <   | j                  j	                         D ]+  \  }}|dvst        ||t        j                  ||             - t        j                  | j                        |_        | j                  |_	        | j                  |_
        |S )N)r0   r5   )	__class____new__id__dict__itemssetattrcopydeepcopyr0   r6   r7   )rF   memoclsresultkvs         r   __deepcopy__zConfiguration.__deepcopy__   s    nnS!RXMM'') 	;DAq994==D#9:	; 		$++.!--zzr   c                     t         j                  | ||       |dk(  rUt        t        d |j	                  d                  }|D ]$  }|t
        vst        dj                  |             || _        y y )Nr/   ,zInvalid keyword: '{0}'')	object__setattr__setfiltersplitJSON_SCHEMA_VALIDATION_KEYWORDSr   format!_disabled_client_side_validations)rF   namevaluesrV   s        r   r[   zConfiguration.__setattr__   sx    4u-55F4S!123A U;;/0I0P0PQR0STTU 67D2 6r   c                 8    t        j                  |      | _        y)zSet default instance of configuration.

        It stores default configuration, which can be
        returned by get_default_copy method.

        :param default: object of Configuration
        N)rP   rQ   _default)rS   defaults     r   set_defaultzConfiguration.set_default   s     }}W-r   c                 l    | j                   t        j                  | j                         S t               S )a  Return new instance of configuration.

        This method returns newly created, based on default constructor,
        object of Configuration class or returns a copy of default
        configuration passed by the set_default method.

        :return: The configuration object.
        )rf   rP   rQ   r   )rS   s    r   get_default_copyzConfiguration.get_default_copy   s)     <<#==..r   c                     | j                   S )The logger file.

        If the logger_file is None, then add stream handler and remove file
        handler. Otherwise, add file handler and remove stream handler.

        :param value: The logger_file path.
        :type: str
        )_Configuration__logger_filerF   s    r   r6   zConfiguration.logger_file   s     !!!r   c                 8   || _         | j                   rt        j                  | j                         | _        | j                  j	                  | j
                         | j                  j                         D ]   \  }}|j                  | j                         " yy)rl   N)	rm   r1   FileHandlerr5   setFormatterlogger_formatterr0   rN   
addHandler)rF   rc   _r0   s       r   r6   zConfiguration.logger_file	  s     # (/':':4;M;M'ND$$$11$2G2GH![[..0 <	6!!$":":;< r   c                     | j                   S )aDebug status

        :param value: The debug status, True or False.
        :type: bool
        )_debugrn   s    r   r7   zConfiguration.debug  s     {{r   c                 X   t        | d      r| j                  }nd}|| _        d }d }d }| j                  rI| j                  j                         D ]$  \  }}|j	                  t
        j                         &  |        y|du r| j                  du r ||         |        y ||        y)rv   rw   Nc                  2    ddl m}  d| j                  _        y )Nr   client   httpr{   HTTPConnection
debuglevelhttp_clients    r   enable_http_loggingz0Configuration.debug.<locals>.enable_http_logging2      245K&&1r   c                  2    ddl m}  d| j                  _        y )Nr   rz   r}   r   s    r   disable_http_loggingz1Configuration.debug.<locals>.disable_http_logging7  r   r   c                     | j                   j                         D ]$  \  }}|j                  t        j                         & y N)r0   rN   setLevelr1   WARNING)crt   r0   s      r   set_default_log_levelz2Configuration.debug.<locals>.set_default_log_level<  s0    XX^^- 1	601r   TF)hasattrrw   r0   rN   r   r1   DEBUG)rF   rc   previous_debugr   r   r   rt   r0   s           r   r7   zConfiguration.debug%  s     4"![[N!N	6
	6
	1 ;;![[..0 /	6./!t#u(<!$' " "$'r   c                     | j                   S )The logger format.

        The logger_formatter will be updated when sets logger_format.

        :param value: The format string.
        :type: str
        )_Configuration__logger_formatrn   s    r   r3   zConfiguration.logger_formatL  s     ###r   c                 Z    || _         t        j                  | j                         | _        y)r   N)r   r1   	Formatterrr   rF   rc   s     r   r3   zConfiguration.logger_formatW  s%      % ' 1 1$2F2F Gr   c                     | j                   | j                  |        | j                  j                  ||| j                  j                  |      nd      }|r&| j                  j                  |      }|r|d|S |S y)zGets API key (with prefix if set).

        :param identifier: The identifier of apiKey.
        :param alias: The alternative identifier of apiKey.
        :return: The token for api key authentication.
        N )r-   r+   getr,   )rF   
identifieraliaskeyprefixs        r   get_api_key_with_prefixz%Configuration.get_api_key_with_prefixc  s|     $$0%%d+llzeFW4<<+;+;E+B]ab((,,Z8F"(#..
 r   c                     i }d| j                   v rddd| j                  d      d|d<   |S d| j                   v rddd| j                  d      d|d<   |S )zfGets Auth Settings dict for api client.

        :return: The Auth Settings information dict.
        
ApiKeyAuthr+   headerzApi-Key)typeinr   rc   
BearerAuthAuthorization)r+   r   )rF   auths     r   auth_settingszConfiguration.auth_settingst  sw    
 4<<'! 55lC	"D  T\\)!&55lC	"D r   c                     dddgS )zSGets an array of host settings

        :return: An array of host settings
        r   zProduction API endpoints)r   r   r   rn   s    r   get_host_settingszConfiguration.get_host_settings  s    
 2B\]^^r   c           	         || j                   S |i n|}|| j                         n|}	 ||   }|d   }|j                  di       j                         D ]_  \  }}|j                  ||d         }d|v r)||d   vr"t        dj	                  |||   |d               |j                  d|z   dz   |      }a |S # t        $ r% t        dj	                  |t        |                  w xY w)	a  Gets host URL based on the index and variables
        :param index: array index of the host settings
        :param variables: hash of variable and the corresponding value
        :param servers: an array of host settings or None
        :return: URL based on host settings
        zIInvalid index {0} when selecting the host settings. Must be less than {1}r   	variablesdefault_valueenum_valueszFThe variable `{0}` in the host URL has invalid value {1}. Must be {2}.{})	r%   r   
IndexError
ValueErrorr`   lenr   rN   replace)	rF   indexr   serversserverr   variable_namevariable
used_values	            r   get_host_from_settingsz$Configuration.get_host_from_settings  s%    =??"#+B	.5o$((*7	U^F Um (.zz+r'B'H'H'J 
	E#M8"}h6OPJ(Zx?V-V \cc%y'?-AX  ++cM1C7DC
	E 
-  	[bb3w< 	s   B8 8.C&c                 P    | j                  | j                  | j                        S )zReturn generated host.)r   )r   r&   r(   rn   s    r   rG   zConfiguration.host  s&     **4+<+<H]H]*^^r   c                      || _         d| _        y)zFix base path.N)r%   r&   r   s     r   rG   zConfiguration.host  s       r   c                 J   d| j                    dd| j                   d| j                   d| j                   d| j                   d| j
                   d| j                   d	| j                   d
| j                   d| j                   g}ddj                  |       dS )Nzhost=zapi_key=***zapi_key_prefix=zconnection_pool_maxsize=zdiscard_unknown_keys=z!disabled_client_side_validations=zserver_index=zserver_variables=zserver_operation_index=zserver_operation_variables=zssl_ca_cert=zConfiguration(z, ))rG   r,   r?   r.   r/   r&   r(   r'   r)   r9   join)rF   attrss     r   __repr__zConfiguration.__repr__  s    DII;d1123&t'C'C&DE#D$=$=#>?/0U0U/VWD--./ 5 567%d&A&A%BC)$*I*I)JK4++,-
  		% 0133r   )
NNNFr$   NNNNNr   )NN)r	   r
   r   __doc__rf   rH   rW   r[   classmethodrh   rj   propertyr6   setterr7   r3   r   r   r   r   rG   r   r   r   r   r   r      s<   >@ H ")+##'l#\7 . .   	" 	" < <$   \\$( $(L $ $ 	H 	H",_%N _ _ 
[[! !
4r   r   )
rP   r1   r=   pinecone.exceptionsr   typingr   r   r_   r   r   r   r   <module>r      s4       5 ) 
# u4 u4r   