Ë
    £ªðiV  ã                   ó  — d Z ddlZddlZddlZddlmZ ddlmZm	Z	m
Z
mZmZ ddlmZ ddlmZ ddlmZ  ej&                  e«      Zdada ej0                  «       ZdZh d	£Zd
„ Zd„ Zd„ Zd„ Zd„ Z  G d„ d«      Z!d„ Z"d„ Z#d„ Z$d„ Z%y)a6  
This file contains private functionality for interacting with the AWS
Common Runtime library (awscrt) in boto3.

All code contained within this file is for internal usage within this
project and is not intended for external consumption. All interfaces
contained within are subject to abrupt breaking changes.
é    N)ÚSession)ÚBotocoreCRTCredentialsWrapperÚBotocoreCRTRequestSerializerÚCRTTransferManagerÚacquire_crt_s3_process_lockÚcreate_s3_crt_client)ÚTRANSFER_CONFIG_SUPPORTS_CRT)ÚInvalidCrtTransferConfigError)ÚCRT_TRANSFER_CLIENTÚboto3>   Úmax_concurrencyÚmultipart_chunksizeÚmultipart_thresholdÚmax_request_concurrencyÚpreferred_transfer_clientc                 ó$   — |d|dœ}t        di |¤ŽS )z“Create a CRT S3 Client for file transfer.

    Instantiating many of these may lead to degraded performance or
    system resource exhaustion.
    T)ÚregionÚuse_sslÚcrt_credentials_provider© )r   )ÚsessionÚconfigÚregion_nameÚcred_providerÚcreate_crt_client_kwargss        ú`/var/www/acinvestment.org/public_html/aci/backend/venv/lib/python3.12/site-packages/boto3/crt.pyÚ_create_crt_clientr   :   s&   € ð ØØ$1ñ Ðô
  Ñ;Ð":Ñ;Ð;ó    c                 ó    — t        | |d dœ«      S )N)r   Úendpoint_url)r   )r   r   s     r   Ú_create_crt_request_serializerr!   H   s   € Ü'Ø ¸dÑCóð r   c                 ól   — t        |«      }|j                  «       }t        t        | |||«      |||«      S )zFCreate boto3 wrapper class to manage crt lock reference and S3 client.)r   Úto_crt_credentials_providerÚCRTS3Clientr   )r   r   r   ÚcredentialsÚlockÚkwargsÚcred_wrapperr   s           r   Ú_create_crt_s3_clientr)   N   s@   € ô 1°Ó=€LØ ×<Ñ<Ó>€MÜÜ˜7 F¨K¸ÓGØØØó	ð r   c                 óÄ   — t        t        «      }|€yt        «       }| j                  j                  }| j                  «       }t        ||«      }t        |||||«      }||fS )N)NN)r   ÚPROCESS_LOCK_NAMEr   Úmetar   Ú_get_credentialsr!   r)   )Úclientr   r&   r   r   r%   Ú
serializerÚ	s3_clients           r   Ú#_initialize_crt_transfer_primativesr1   \   si   € Ü&Ô'8Ó9€DØ€|ð ä‹i€GØ—+‘+×)Ñ)€KØ×)Ñ)Ó+€Kä/°¸ÓE€JÜ%Ø�˜ k°4ó€Ið �yÐ Ð r   c                 ó€   — t         5  t        €t        | |«      \  }}|a|ad d d «       t        S # 1 sw Y   t        S xY w©N)ÚCLIENT_CREATION_LOCKÚCRT_S3_CLIENTr1   ÚBOTOCORE_CRT_SERIALIZER)r.   r   r/   r0   s       r   Úget_crt_s3_clientr7   o   sN   € ô 
ñ &ÜÐ Ü$GØ˜ó%Ñ!ˆJ˜	ð '1Ð#Ø%ˆM÷&ô Ð÷&ô Ðús   ‡/¯=c                   ó   — e Zd ZdZd„ Zy)r$   aƒ  
    This wrapper keeps track of our underlying CRT client, the lock used to
    acquire it and the region we've used to instantiate the client.

    Due to limitations in the existing CRT interfaces, we can only make calls
    in a single region and does not support redirects. We track the region to
    ensure we don't use the CRT client when a successful request cannot be made.
    c                 ó<   — || _         || _        || _        || _        y r3   )Ú
crt_clientÚprocess_lockr   r   )Úselfr:   r;   r   r   s        r   Ú__init__zCRTS3Client.__init__ˆ   s    € Ø$ˆŒØ(ˆÔØˆŒØ*ˆÕr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r=   r   r   r   r$   r$   ~   s   „ ñó+r   r$   c                 óÈ   — |€y| j                  «       }|€yt        |j                  «       |j                  «      }| j                  j
                  |j                  k(  }|xr |S )z†
    Boto3 client must use same signing region and credentials
    as the CRT_S3_CLIENT singleton. Otherwise fallback to classic.
    F)r-   Úcompare_identityÚget_frozen_credentialsr   r,   r   r   )r.   Úcrt_s3_clientÚboto3_credsÚis_same_identityÚis_same_regions        r   Úis_crt_compatible_requestrI   �   sk   € ð
 ÐØà×)Ñ)Ó+€KØÐØä'Ø×*Ñ*Ó,¨m×.IÑ.IóÐð —[‘[×,Ñ,°×0DÑ0DÑD€NØÒ.Ð.Ð.r   c                 óú   — 	  |«       }| j                  |j                  k(  xr4 | j
                  |j                  k(  xr | j                  |j                  k(  }|S # t         j                  j                  $ r Y yw xY w)NF)	ÚbotocoreÚ
exceptionsÚNoCredentialsErrorÚ
access_keyÚaccess_key_idÚ
secret_keyÚsecret_access_keyÚtokenÚsession_token)rF   Úcrt_s3_credsÚ	crt_credsÚis_matching_identitys       r   rC   rC   ¢   sƒ   € ðÙ “Nˆ	ð
 	×Ñ )×"9Ñ"9Ñ9ò 	9Ø×"Ñ" i×&AÑ&AÑAò	9à×Ñ ×!8Ñ!8Ñ8ð ð
  Ðøô ×Ñ×1Ñ1ò Ùðús   ‚A ÁA:Á9A:c                 ó@  — | €y | j                   t        k7  ry g }| j                  j                  «       D ]<  }| j	                  |«      }|t
        vsŒ|| j                  usŒ,|j                  |«       Œ> t        |«      dkD  rt        ddj                  |«      › d�«      ‚y )Nr   z`The following transfer config options are invalid when preferred_transfer_client is set to crt: z, ú`)r   r   ÚDEFAULTSÚkeysÚget_deep_attrÚ$_ALLOWED_CRT_TRANSFER_CONFIG_OPTIONSÚUNSET_DEFAULTÚappendÚlenr
   Újoin)r   Úinvalid_crt_argsÚparamÚvals       r   Ú_validate_crt_transfer_configrd   °   s³   € Ø€~Øð ×'Ñ'Ô+>Ò>ØØÐØ—‘×%Ñ%Ó'ò +ˆØ×"Ñ" 5Ó)ˆàÔ=Ò=Ø˜6×/Ñ/Ò/à×#Ñ# EÕ*ð+ô ÐÓ˜qÒ Ü+ð=à�y‰yÐ)Ó*Ð+¨1ð.ó
ð 	
ð !r   c                 óÖ   — t        | |«      }t        | |«      rQ|j                  t        dœ}t        rt        |«       ||d<   t        s|rt        j                  d«       t        di |¤ŽS y)z8Create a CRTTransferManager for optimized data transfer.)rE   Úcrt_request_serializerr   zfUsing TransferConfig with CRT client requires s3transfer >= 0.16.0, configured values will be ignored.Nr   )	r7   rI   r:   r6   r	   rd   ÚloggerÚwarningr   )r.   r   rE   Úcrt_transfer_manager_kwargss       r   Úcreate_crt_transfer_managerrj   È   so   € ä% f¨fÓ5€MÜ  ¨Ô7à*×5Ñ5Ü&=ñ'
Ð#õ (Ü)¨&Ô1Ø4:Ð'¨Ñ1Ý+±Ü�N‰NðKôô "Ñ@Ð$?Ñ@Ð@Ør   )&rA   ÚloggingÚ	threadingÚbotocore.exceptionsrK   Úbotocore.sessionr   Ús3transfer.crtr   r   r   r   r   Úboto3.compatr	   Úboto3.exceptionsr
   Úboto3.s3.constantsr   Ú	getLoggerr>   rg   r5   r6   ÚLockr4   r+   r\   r   r!   r)   r1   r7   r$   rI   rC   rd   rj   r   r   r   ú<module>ru      s    ðñó Û ã Ý $÷õ õ 6Ý :Ý 2à	ˆ×	Ñ	˜8Ó	$€ð €ØÐ à%�y—~‘~Ó'Ð ØÐ ò(Ð $ò<òòò!ò&÷+ñ +ò"/ò& ò
ó0r   