o
    rMfe  ã                   @   st   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 G dd„ dej
jƒZG dd„ dejjƒZdS )é    )Úprint_functionN)Úawsqueryrequestc                       s   e Zd Z‡ fdd„Z‡  ZS )ÚNoCredentialsErrorc                    s   d}t t| ƒ |¡ d S )NzUnable to find credentials)Úsuperr   Ú__init__)ÚselfÚs©Ú	__class__© ú]/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/boto/roboto/awsqueryservice.pyr      s   zNoCredentialsError.__init__)Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__r   r   r	   r   r   
   s    r   c                       sX   e Zd ZdZdZdZdZdZdZdZ	dZ
g Z‡ fdd„Zd	d
„ Zdd„ Zdd„ Z‡  ZS )ÚAWSQueryServiceÚ zsign-v2ú/i»  ÚawsÚAWS_URLc                    sÎ   || _ |  ¡  |  ¡  d| j vr2| jr2| j  d| jd d ¡}| jD ]}|d |kr1|d | j d< q"d| j vr=| j| j d< d| j vrH| j| j d< ztt| ƒj	di | j ¤Ž d | _
W d S  tjjyf   tƒ ‚w )	NÚhostÚregion_namer   ÚnameÚendpointÚpathÚportr   )ÚargsÚcheck_for_credential_fileÚcheck_for_env_urlÚRegionsÚgetÚPathÚPortr   r   r   Úaws_responseÚbotoÚ	exceptionÚNoAuthHandlerFoundr   )r   r   r   Úregionr	   r   r   r      s,   
ÿ
€

ÿzAWSQueryService.__init__c                 C   sä   dt jv rpt jd }t j |¡}t j |¡}t j |¡rjt|ƒ}| ¡ }| ¡  |D ]=}|d dkrgd|v rg| 	dd¡\}}| 
¡ dkrSd| jvrR| 
¡ }|| jd< q*| 
¡ dkrgd	| jvrg| 
¡ }|| jd	< q*dS td
ƒ dS dS )aq  
        Checks for the existence of an AWS credential file.
        If the environment variable AWS_CREDENTIAL_FILE is
        set and points to a file, that file will be read and
        will be searched credentials.
        Note that if credentials have been explicitelypassed
        into the class constructor, those values always take
        precedence.
        ÚAWS_CREDENTIAL_FILEr   ú#ú=é   ÚAWSAccessKeyIdÚaws_access_key_idÚAWSSecretKeyÚaws_secret_access_keyz+Warning: unable to read AWS_CREDENTIAL_FILEN)ÚosÚenvironr   Ú
expanduserÚ
expandvarsÚisfileÚopenÚ	readlinesÚcloseÚsplitÚstripr   Úprint)r   r   ÚfpÚlinesÚliner   Úvaluer   r   r   r   2   s2   




€

€õëz)AWSQueryService.check_for_credential_filec                 C   sú   | j  dd¡}|r| j d= |s| jtjv rtj| j }|rwt |¡}d| j vr7|jdkr2d| j d< nd| j d< |j}d}| d¡}t	|ƒdkrQ|d	 }t
|d ƒ}d
| j vr[|| j d
< |rgd| j vrg|| j d< |jryd| j vr{|j| j d< dS dS dS dS )a¡  
        First checks to see if a url argument was explicitly passed
        in.  If so, that will be used.  If not, it checks for the
        existence of the environment variable specified in ENV_URL.
        If this is set, it should contain a fully qualified URL to the
        service you want to use.
        Note that any values passed explicitly to the class constructor
        will take precedence.
        ÚurlNÚ	is_secureÚhttpsTFú:r+   r   r   r   r   )r   r    ÚEnvURLr0   r1   ÚurlparseÚschemeÚnetlocr8   ÚlenÚintr   )r   r?   Úrsltr   r   Úlr   r   r   r   S   s2   








ìz!AWSQueryService.check_for_env_urlc                 C   s   | j gS )N)ÚAuthentication)r   r   r   r   Ú_required_auth_capabilityx   s   z)AWSQueryService._required_auth_capability)r   r   r   ÚNameÚDescriptionÚ
APIVersionrK   r!   r"   ÚProviderrC   r   r   r   r   rL   r   r   r   r	   r   r      s    !%r   )Ú
__future__r   r0   rD   r$   Úboto.connectionÚboto.jsonresponseÚboto.exceptionÚboto.robotor   r%   ÚBotoClientErrorr   Ú
connectionÚAWSQueryConnectionr   r   r   r   r   Ú<module>   s    