o
    di`(                     @   s   d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlZddlmZ ddlmZ ddlmZ G dd	 d	ejjZG d
d deZdS )z_
This class essentially overrides the boto3 session init, passing in
an async botocore session
    N)DataNotFoundErrorUnknownServiceError)ResourceNotExistsErrorUnknownAPIVersionError)	AioConfig)NoCredentialsError)AIOBoto3ResourceFactoryc                   @   sL   e Zd ZdZ							d
ddZ									dddZdd	 ZdS )Sessiona  
    A session stores configuration state and allows you to create service
    clients and resources.

    :type aws_access_key_id: string
    :param aws_access_key_id: AWS access key ID
    :type aws_secret_access_key: string
    :param aws_secret_access_key: AWS secret access key
    :type aws_session_token: string
    :param aws_session_token: AWS temporary session token
    :type region_name: string
    :param region_name: Default region when creating new connections
    :type botocore_session: aiobotocore.session.AioSession
    :param botocore_session: Use this AioBotocore session instead of creating
                             a new default one.
    :type profile_name: string
    :param profile_name: The name of a profile to use. If not given, then
                         the default profile is used.
    :type aws_account_id: string
    :param aws_account_id: AWS account ID
    Nc           
      C   s  |d ur|| _ ntj | _ | j jdkr7d| j j }| j jr*| j  jd| 7  _n|| j _d| j _tj| j _|d urB| j 	d| ||||d}	t
|	 ri| jd
i |	rZt |d u ra|	d= | j j|	   |d urt| j 	d| t| j d	| _|   |   d S )NBotocorez	Botocore/ Boto3profile)aws_access_key_idaws_secret_access_keyaws_session_tokenaws_account_idr   regionevent_emitter )_sessionaiobotocoresessionget_sessionuser_agent_nameuser_agent_versionuser_agent_extraboto3__version__set_config_variableanyvalues#_account_id_set_without_credentialsr   set_credentialsr   get_componentresource_factory_setup_loader_register_default_handlers)
selfr   r   r   region_namebotocore_sessionprofile_namer   botocore_infocredentials_kwargsr   r   D/home/ubuntu/.local/lib/python3.10/site-packages/aioboto3/session.py__init__,   s<   


zSession.__init__Tc                 C   s   z
| j |d|}W n- ty!   |  }||  v }t||| ty7   | j |d}t||d	|w |d u rC| j 
|d}|
d urU|
jd u rTt|
}
d|
_ntdd}
t| |||||||||	|
|S )Nzresources-1z, Resource)r   )_loaderload_service_modelr   get_available_resourcesget_available_servicesr   r   list_api_versionsr   joindetermine_latest_versionr   copydeepcopyr   ResourceCreatorContext)r'   service_namer(   api_versionuse_sslverifyendpoint_urlr   r   r   configresource_model	availablehas_low_level_clientavailable_api_versionsr   r   r-   resourcec   sD   
	



zSession.resourcec                 C   s   | j dtjd | j dtjd | j dtjd | j dtjd | j jd	tjd
dd | j jdtjddd | j dtjd | j dtjjd| jd d S )Nzcreating-client-class.s3z-aioboto3.s3.inject.inject_s3_transfer_methodsz!creating-resource-class.s3.Bucketz(aioboto3.s3.inject.inject_bucket_methodsz!creating-resource-class.s3.Objectz%boto3.s3.inject.inject_object_methodsz(creating-resource-class.s3.ObjectSummaryz0aioboto3.s3.inject.inject_object_summary_methodsz creating-resource-class.dynamodbz6boto3.dynamodb.transform.register_high_level_interfacezhigh-level-dynamodb)	unique_idz&creating-resource-class.dynamodb.Tablez.aioboto3.dynamodb.table.register_table_methodszhigh-level-dynamodb-tablez+creating-resource-class.ec2.ServiceResourcez'boto3.ec2.createtags.inject_create_tagsz$creating-resource-class.ec2.Instancez'boto3.ec2.deletetags.inject_delete_tags)r   )r   registerr   utils	lazy_callevents)r'   r   r   r-   r&      sZ   

	
z"Session._register_default_handlers)NNNNNNN)	NNTNNNNNN)__name__
__module____qualname____doc__r.   rD   r&   r   r   r   r-   r	      s*    
:
Gr	   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )r9   c                 C   sB   || _ || _|| _|| _d | _|j||||||||	|
|d
| _d S )N)	r(   r;   r<   r=   r>   r   r   r   r?   )r:   r@   r   r;   clsclient)r'   r   r:   r(   r;   r<   r=   r>   r   r   r   r?   r@   r   r   r-   r.      s   zResourceCreatorContext.__init__c              	      sz   | j  I d H }|jj}tjj| j|| jd tj	| j
j| j| jd}| j
jj| j| jd |dI d H |d| _| jS )N	resources)r:   service_modelresource_json_definitionsservice_waiter_modelservice)resource_namesingle_resource_json_definitionservice_context)rO   )rO   
__aenter__metarQ   r   rG   ServiceContextr:   r@   LazyLoadedWaiterModelr   r   r;   r$   load_from_definitionrN   )r'   rO   rQ   rW   r   r   r-   rX      s&   

z!ResourceCreatorContext.__aenter__c                    s   | j |||I d H  d S )N)rN   	__aexit__)r'   exc_typeexctbr   r   r-   r]     s   z ResourceCreatorContext.__aexit__N)rJ   rK   rL   r.   rX   r]   r   r   r   r-   r9      s    r9   )rM   r7   boto3.sessionr   boto3.resources.baseboto3.utilsr   r   boto3.exceptionsr   r   aiobotocore.sessionr   aiobotocore.configr   botocore.exceptionsr   aioboto3.resources.factoryr   r   r	   objectr9   r   r   r   r-   <module>   s    K