§
    7xÅj¨ˆ  ã                   ó4  — 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mZ d dl	m
Z
mZ d dlmZmZmZmZ d dlmZ d dlmZmZmZ  G d„ d¦  «        Z G d	„ d
¦  «        Zd„ Zd„ Zdd„Z	 dd„Z	 dd„Z	 dd„Z G d„ d¦  «        Zd„ Z 	 dd„Z!d„ Z"	 dd„Z#d„ Z$dS )é    N)Úcreate_request_objectÚprepare_request_dict)ÚOrderedDictÚget_current_datetime)ÚParamValidationErrorÚUnknownClientMethodErrorÚUnknownSignatureVersionErrorÚ UnsupportedSignatureVersionError)ÚFrozenAuthToken)Ú	ArnParserÚdatetime2timestampÚfix_s3_hostc                   ó    — e Zd ZdZ	 dd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zdd„Z		 	 	 	 dd	„Z
d
„ Zd„ Z	 	 dd„ZeZ	 	 	 dd„ZdS )ÚRequestSignera0  
    An object to sign requests before they go out over the wire using
    one of the authentication mechanisms defined in ``auth.py``. This
    class fires two events scoped to a service and operation name:

    * choose-signer: Allows overriding the auth signer name.
    * before-sign: Allows mutating the request before signing.

    Together these events allow for customization of the request
    signing pipeline, including overrides, request path manipulation,
    and disabling signing per operation.


    :type service_id: botocore.model.ServiceId
    :param service_id: The service id for the service, e.g. ``S3``

    :type region_name: string
    :param region_name: Name of the service region, e.g. ``us-east-1``

    :type signing_name: string
    :param signing_name: Service signing name. This is usually the
                         same as the service name, but can differ. E.g.
                         ``emr`` vs. ``elasticmapreduce``.

    :type signature_version: string
    :param signature_version: Signature name like ``v4``.

    :type credentials: :py:class:`~botocore.credentials.Credentials`
    :param credentials: User credentials with which to sign requests.

    :type event_emitter: :py:class:`~botocore.hooks.BaseEventHooks`
    :param event_emitter: Extension mechanism to fire events.
    Nc                 óŒ   — || _         || _        || _        || _        || _        || _        t          j        |¦  «        | _        d S ©N)	Ú_region_nameÚ_signing_nameÚ_signature_versionÚ_credentialsÚ_auth_tokenÚ_service_idÚweakrefÚproxyÚ_event_emitter)ÚselfÚ
service_idÚregion_nameÚsigning_nameÚsignature_versionÚcredentialsÚevent_emitterÚ
auth_tokens           úAC:\Projects\Historical\venv\Lib\site-packages\botocore/signers.pyÚ__init__zRequestSigner.__init__G   sN   € ð (ˆÔØ)ˆÔØ"3ˆÔØ'ˆÔØ%ˆÔØ%ˆÔõ &œm¨MÑ:Ô:ˆÔÐÐó    c                 ó   — | j         S r   )r   ©r   s    r$   r   zRequestSigner.region_name[   s   € àÔ Ð r&   c                 ó   — | j         S r   )r   r(   s    r$   r    zRequestSigner.signature_version_   s   € àÔ&Ð&r&   c                 ó   — | j         S r   )r   r(   s    r$   r   zRequestSigner.signing_namec   s   € àÔ!Ð!r&   c                 ó.   — |                       ||¦  «        S r   )Úsign)r   Úoperation_nameÚrequestÚkwargss       r$   ÚhandlerzRequestSigner.handlerg   s   € ð
 �yŠy˜¨Ñ1Ô1Ð1r&   Ústandardc           	      ó2  — |}|€| j         }|€| j        }|                      |||j        ¦  «        }| j                             d| j                             ¦   «         › d|› �||| j         || |¬¦  «         |t          j	        k    �r|||dœ}	|�||	d<   |j         
                    di ¦  «        }
|s |
 
                    d¦  «        r|
d         |	d	<   |
 
                    d
¦  «        r|
d
         |	d
<   |
 
                    d¦  «        r|
d         |	d<   |
 
                    d¦  «        �#|                      |	|
d         |
d         ¦  «         	  | j        di |	¤Ž}n*# t          $ r}|dk    rt          |¬¦  «        ‚|‚d}~ww xY w|                     |¦  «         dS dS )a<  Sign a request before it goes out over the wire.

        :type operation_name: string
        :param operation_name: The name of the current operation, e.g.
                               ``ListBuckets``.
        :type request: AWSRequest
        :param request: The request object to be sent over the wire.

        :type region_name: str
        :param region_name: The region to sign the request for.

        :type signing_type: str
        :param signing_type: The type of signing to perform. This can be one of
            three possible values:

            * 'standard'     - This should be used for most requests.
            * 'presign-url'  - This should be used when pre-signing a request.
            * 'presign-post' - This should be used when pre-signing an S3 post.

        :type expires_in: int
        :param expires_in: The number of seconds the presigned url is valid
            for. This parameter is only valid for signing type 'presign-url'.

        :type signing_name: str
        :param signing_name: The name to use for the service when signing.
        Nzbefore-sign.ú.)r.   r   r   r    Úrequest_signerr-   )r   r   r    ÚexpiresÚsigningÚregionr   r   Úrequest_credentialsÚidentity_cacheÚ	cache_keyr1   ©r    © )r   r   Ú_choose_signerÚcontextr   Úemitr   Ú	hyphenizeÚbotocoreÚUNSIGNEDÚgetÚ_resolve_identity_cacheÚget_auth_instancer	   r
   Úadd_auth)r   r-   r.   r   Úsigning_typeÚ
expires_inr   Úexplicit_region_namer    r/   Úsigning_contextÚauthÚes                r$   r,   zRequestSigner.signn   s;  € ðF  +ÐØÐØÔ+ˆKàÐØÔ-ˆLà ×/Ò/Ø˜L¨'¬/ñ
ô 
Ðð
 	Ô× Ò ØJ˜4Ô+×5Ò5Ñ7Ô7ÐJÐJ¸.ÐJÐJØØ%ØÔ)Ø/ØØ)ð 	!ñ 	
ô 	
ð 	
ð ¥Ô 1Ò1Ñ1à ,Ø*Ø%6ðð ˆFð
 Ð%Ø$.��yÑ!Ø%œo×1Ò1°)¸RÑ@Ô@ˆOØ'ð B¨O×,?Ò,?ÀÑ,IÔ,Ið BØ(7¸Ô(A��}Ñ%Ø×"Ò" >Ñ2Ô2ð IØ)8¸Ô)H��~Ñ&Ø×"Ò"Ð#8Ñ9Ô9ð Ø0?Ø)ô1�Ð,Ñ-ð ×"Ò"Ð#3Ñ4Ô4Ð@Ø×,Ò,ØØ#Ð$4Ô5Ø# KÔ0ñô ð ð
Ø-�tÔ-Ð7Ð7°Ð7Ð7��øÝ/ð ð ð Ø :Ò-Ð-Ý:Ø*;ðñ ô ð ð �Gøøøøðøøøð �MŠM˜'Ñ"Ô"Ð"Ð"Ð"ðC 2Ð1s   ÅE Å
E=Å E8Å8E=c                 ó   — ||d<   ||d<   d S )Nr9   r:   r<   )r   r/   Úcacher:   s       r$   rD   z%RequestSigner._resolve_identity_cacheÊ   s   € Ø#(ˆÐÑ Ø'ˆˆ{ÑÐÐr&   c                 ó2  — dddœ}|                      |d¦  «        }|                      d¦  «        p| j        }|                      di ¦  «        }|                      d| j        ¦  «        }|                      d| j        ¦  «        }	|t          j        ur|                     |¦  «        s||z  }| j                             d	| j	         
                    ¦   «         › d
|› �||	||¬¦  «        \  }
}|�*|}|t          j        ur|                     |¦  «        s||z  }|S )ai  
        Allow setting the signature version via the choose-signer event.
        A value of `botocore.UNSIGNED` means no signing will be performed.

        :param operation_name: The operation to sign.
        :param signing_type: The type of signing that the signer is to be used
            for.
        :return: The signature version to sign with.
        z-presign-postz-query)úpresign-postúpresign-urlÚ Ú	auth_typer6   r   r7   zchoose-signer.r3   )r   r   r    r>   )rC   r   r   r   rA   rB   Úendswithr   Úemit_until_responser   r@   )r   r-   rG   r>   Úsigning_type_suffix_mapÚsuffixr    r6   r   r   r0   Úresponses               r$   r=   zRequestSigner._choose_signerÎ   sR  € ð ,Ø#ð#
ð #
Ðð )×,Ò,¨\¸2Ñ>Ô>ˆð $ŸKšK¨Ñ4Ô4ÐO¸Ô8OÐØ—+’+˜i¨Ñ,Ô,ˆØ—{’{ >°4Ô3EÑFÔFˆØ—k’k (¨DÔ,=Ñ>Ô>ˆà¥XÔ%6Ð6Ð6Ø%×.Ò.¨vÑ6Ô6ð 7ð  Ñ'Ðà Ô/×CÒCØL˜TÔ-×7Ò7Ñ9Ô9ÐLÐL¸NÐLÐLØ%Ø#Ø/Øð Dñ 
ô 
Ñˆ�ð ÐØ (Ðð "­Ô):Ð:Ð:Ø)×2Ò2°6Ñ:Ô:ð ;ð " VÑ+Ð!à Ð r&   c                 ór  — |€| j         }t          j        j                             |¦  «        }|€t          |¬¦  «        ‚|j        du rO| j        r4t          | j        t          ¦  «        s| j         
                    ¦   «         }n| j        } ||¦  «        }|S |p| j        }	t          |dd¦  «        du r(|d         }
|d         }|
                     |¦  «        }	|d= d}|	�|	                     ¦   «         }||d<   |j        r/| j        €t          j                             ¦   «         ‚||d<   ||d	<    |d
i |¤Ž}|S )a©  
        Get an auth instance which can be used to sign a request
        using the given signature version.

        :type signing_name: string
        :param signing_name: Service signing name. This is usually the
                             same as the service name, but can differ. E.g.
                             ``emr`` vs. ``elasticmapreduce``.

        :type region_name: string
        :param region_name: Name of the service region, e.g. ``us-east-1``

        :type signature_version: string
        :param signature_version: Signature name like ``v4``.

        :rtype: :py:class:`~botocore.auth.BaseSigner`
        :return: Auth instance to sign a request.
        Nr;   TÚREQUIRES_IDENTITY_CACHEr9   r:   r!   r   Úservice_namer<   )r   rA   rK   ÚAUTH_TYPE_MAPSrC   r	   ÚREQUIRES_TOKENr   Ú
isinstancer   Úget_frozen_tokenr   ÚgetattrÚget_credentialsÚget_frozen_credentialsÚREQUIRES_REGIONr   Ú
exceptionsÚNoRegionError)r   r   r   r    r8   r/   ÚclsÚfrozen_tokenrK   r!   rN   ÚkeyÚfrozen_credentialss                r$   rE   zRequestSigner.get_auth_instanceþ   s…  € ð4 Ð$Ø $Ô 7ÐåŒmÔ*×.Ò.Ð/@ÑAÔAˆØˆ;Ý.Ø"3ðñ ô ð ð Ô Ð%Ð%ØÔð 0­
ØÔ ¥/ñ)ô )ð 0ð  $Ô/×@Ò@ÑBÔB��à#Ô/�Ø�3�|Ñ$Ô$ˆDØˆKà)Ð>¨TÔ->ˆÝ�3Ð1°4Ñ8Ô8¸DÐ@Ð@ØÐ+Ô,ˆEØ˜Ô%ˆCØ×/Ò/°Ñ4Ô4ˆKØ�{Ð#ð "ÐØÐ"Ø!,×!CÒ!CÑ!EÔ!EÐØ 2ˆˆ}ÑØÔð 	2ØÔ Ð(ÝÔ)×7Ò7Ñ9Ô9Ð9Ø$/ˆF�=Ñ!Ø%1ˆF�>Ñ"Øˆsˆ}ˆ}�Vˆ}ˆ}ˆØˆr&   é  c                 óŠ   — t          |¦  «        }|                      |||d||¦  «         |                     ¦   «          |j        S )aÍ  Generates a presigned url

        :type request_dict: dict
        :param request_dict: The prepared request dictionary returned by
            ``botocore.awsrequest.prepare_request_dict()``

        :type operation_name: str
        :param operation_name: The operation being signed.

        :type expires_in: int
        :param expires_in: The number of seconds the presigned url is valid
            for. By default it expires in an hour (3600 seconds)

        :type region_name: string
        :param region_name: The region name to sign the presigned url.

        :type signing_name: str
        :param signing_name: The name to use for the service when signing.

        :returns: The presigned url
        rQ   )r   r,   ÚprepareÚurl)r   Úrequest_dictr-   rH   r   r   r.   s          r$   Úgenerate_presigned_urlz$RequestSigner.generate_presigned_urlE  sS   € õ: (¨Ñ5Ô5ˆØ�	Š	ØØØØØØñ	
ô 	
ð 	
ð 	�ŠÑÔÐØŒ{Ðr&   r   ©NN)Nr1   NN)rj   NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   Úpropertyr   r    r   r0   r,   rD   r=   rE   Úget_authro   r<   r&   r$   r   r   $   s*  € € € € € ð ð  ðT ð;ð ;ð ;ð ;ð( ð!ð !ñ „Xð!ð ð'ð 'ñ „Xð'ð ð"ð "ñ „Xð"ð2ð 2ð 2ð 2ð ØØØðZ#ð Z#ð Z#ð Z#ðx(ð (ð (ð.!ð .!ð .!ðh Ø ðBð Bð Bð BðJ !€Hð ØØð(ð (ð (ð (ð (ð (r&   r   c                   ó6   — e Zd ZdZd„ Zdd„Zd„ Z	 dd„Zd„ ZdS )	ÚCloudFrontSigneraà  A signer to create a signed CloudFront URL.

    First you create a cloudfront signer based on a normalized RSA signer::

        import rsa
        def rsa_signer(message):
            private_key = open('private_key.pem', 'r').read()
            return rsa.sign(
                message,
                rsa.PrivateKey.load_pkcs1(private_key.encode('utf8')),
                'SHA-1')  # CloudFront requires SHA-1 hash
        cf_signer = CloudFrontSigner(key_id, rsa_signer)

    To sign with a canned policy::

        signed_url = cf_signer.generate_signed_url(
            url, date_less_than=datetime(2015, 12, 1))

    To sign with a custom policy::

        signed_url = cf_signer.generate_signed_url(url, policy=my_policy)
    c                 ó"   — || _         || _        dS )a–  Create a CloudFrontSigner.

        :type key_id: str
        :param key_id: The CloudFront Key Pair ID

        :type rsa_signer: callable
        :param rsa_signer: An RSA signer.
               Its only input parameter will be the message to be signed,
               and its output will be the signed content as a binary string.
               The hash algorithm needed by CloudFront is SHA-1.
        N)Úkey_idÚ
rsa_signer)r   rz   r{   s      r$   r%   zCloudFrontSigner.__init__ˆ  s   € ð ˆŒØ$ˆŒˆˆr&   Nc                 óT  — |duo|du}|du o|du }|s|rd}t          |¦  «        ‚|�|                      ||¦  «        }t          |t          ¦  «        r|                     d¦  «        }|�!dt          t          |¦  «        ¦  «        › �g}n,d|                      |¦  «                             d¦  «        › �g}|  	                    |¦  «        }| 
                    d|                      |¦  «                             d¦  «        › �d| j        › �g¦  «         |                      ||¦  «        S )a¤  Creates a signed CloudFront URL based on given parameters.

        :type url: str
        :param url: The URL of the protected object

        :type date_less_than: datetime
        :param date_less_than: The URL will expire after that date and time

        :type policy: str
        :param policy: The custom policy, possibly built by self.build_policy()

        :rtype: str
        :return: The signed URL.
        Nz=Need to provide either date_less_than or policy, but not bothÚutf8zExpires=zPolicy=z
Signature=zKey-Pair-Id=)Ú
ValueErrorÚbuild_policyr^   ÚstrÚencodeÚintr   Ú_url_b64encodeÚdecoder{   Úextendrz   Ú
_build_url)	r   rm   Údate_less_thanÚpolicyÚboth_args_suppliedÚneither_arg_suppliedrL   ÚparamsÚ	signatures	            r$   ro   z'CloudFrontSigner.generate_presigned_url—  sW  € ð ,°4Ð7ÐN¸FÈ$Ð<NÐØ-°Ð5ÐH¸&ÀD¸.ÐØð 	 Ð!5ð 	 ØOˆAÝ˜Q‘-”-ÐØÐ%à×&Ò& s¨NÑ;Ô;ˆFÝ�f�cÑ"Ô"ð 	+Ø—]’] 6Ñ*Ô*ˆFØÐ%ØJ¥Õ%7¸Ñ%GÔ%GÑ!HÔ!HÐJÐJÐKˆFˆFàL × 3Ò 3°FÑ ;Ô ;× BÒ BÀ6Ñ JÔ JÐLÐLÐMˆFØ—O’O FÑ+Ô+ˆ	Ø�ŠàL˜T×0Ò0°Ñ;Ô;×BÒBÀ6ÑJÔJÐLÐLØ,˜tœ{Ð,Ð,ðñ	
ô 	
ð 	
ð �Š˜s FÑ+Ô+Ð+r&   c                 óH   — d|v rdnd}||z   d                      |¦  «        z   S )Nú?ú&)Újoin)r   Úbase_urlÚextra_paramsÚ	separators       r$   r†   zCloudFrontSigner._build_url½  s/   € Ø (˜?˜?�C�C°ˆ	Ø˜)Ñ# c§h¢h¨|Ñ&<Ô&<Ñ<Ð<r&   c                 ó.  — t          t          |¦  «        ¦  «        }t          dd|ii¦  «        }|rd|vr|dz  }d|i|d<   |r#t          t          |¦  «        ¦  «        }d|i|d<   d|fd	|fg}d
t          |¦  «        gi}t          j        |d¬¦  «        S )a0  A helper to build policy.

        :type resource: str
        :param resource: The URL or the stream filename of the protected object

        :type date_less_than: datetime
        :param date_less_than: The URL will expire after the time has passed

        :type date_greater_than: datetime
        :param date_greater_than: The URL will not be valid until this time

        :type ip_address: str
        :param ip_address: Use 'x.x.x.x' for an IP, or 'x.x.x.x/x' for a subnet

        :rtype: str
        :return: The policy in a compact string.
        ÚDateLessThanzAWS:EpochTimeú/z/32zAWS:SourceIpÚ	IpAddressÚDateGreaterThanÚResourceÚ	ConditionÚ	Statement)ú,ú:)Ú
separators)r‚   r   r   ÚjsonÚdumps)	r   Úresourcer‡   Údate_greater_thanÚ
ip_addressÚmomentÚ	conditionÚordered_payloadÚcustom_policys	            r$   r   zCloudFrontSigner.build_policyÁ  sÌ   € õ: Õ'¨Ñ7Ô7Ñ8Ô8ˆÝ °/À6Ð1JÐ KÑLÔLˆ	Øð 	BØ˜*Ð$Ð$Ø˜eÑ#�
Ø&4°jÐ%AˆI�kÑ"Øð 	EÝÕ+Ð,=Ñ>Ô>Ñ?Ô?ˆFØ,;¸VÐ+DˆIÐ'Ñ(Ø&¨Ð1°KÀÐ3KÐLˆØ$¥{°?Ñ'CÔ'CÐ&DÐEˆÝŒz˜-°JÐ?Ñ?Ô?Ð?r&   c                 ó¢   — t          j        |¦  «                             dd¦  «                             dd¦  «                             dd¦  «        S )Nó   +ó   -ó   =ó   _ó   /ó   ~)Úbase64Ú	b64encodeÚreplace)r   Údatas     r$   rƒ   zCloudFrontSigner._url_b64encodeë  sD   € õ Ô˜TÑ"Ô"ßŠW�T˜4Ñ Ô ßŠW�T˜4Ñ Ô ßŠW�T˜4Ñ Ô ð		
r&   rp   )	rq   rr   rs   rt   r%   ro   r†   r   rƒ   r<   r&   r$   rx   rx   p  s€   € € € € € ðð ð.%ð %ð %ð$,ð $,ð $,ð $,ðL=ð =ð =ð
 LPð(@ð (@ð (@ð (@ðT
ð 
ð 
ð 
ð 
r&   rx   c                 ó   — t           | d<   d S )NÚgenerate_db_auth_token)r´   ©Úclass_attributesr/   s     r$   Úadd_generate_db_auth_tokenr·   ö  ó   € Ý1GÐÐ-Ñ.Ð.Ð.r&   c                 ó.   — t           | d<   t          | d<   d S )NÚgenerate_db_connect_auth_tokenÚ$generate_db_connect_admin_auth_token)Ú#dsql_generate_db_connect_auth_tokenÚ)dsql_generate_db_connect_admin_auth_tokenrµ   s     r$   Ú'add_dsql_generate_db_auth_token_methodsr¾   ú  s&   € å+ð Ð5Ñ6õ 	2ð Ð;Ñ<Ð<Ð<r&   c                 óÞ   — |}|€| j         j        }d|dœ}ddi |ddœ}d}|› |› d	|› �}	t          ||	¦  «         | j                             d||d
d¬¦  «        }
|
t          |¦  «        d…         S )a  Generates an auth token used to connect to a db with IAM credentials.

    :type DBHostname: str
    :param DBHostname: The hostname of the database to connect to.

    :type Port: int
    :param Port: The port number the database is listening on.

    :type DBUsername: str
    :param DBUsername: The username to log in as.

    :type Region: str
    :param Region: The region the database is in. If None, the client
        region will be used.

    :return: A presigned url which can be used as an auth token.
    NÚconnect)ÚActionÚDBUserr–   rR   ÚGET©Úurl_pathÚquery_stringÚheadersÚbodyÚmethodúhttps://r�   é„  zrds-db©r-   rn   r   rH   r   )Úmetar   r   Ú_request_signerro   Úlen)r   Ú
DBHostnameÚPortÚ
DBUsernameÚRegionr7   r‹   rn   ÚschemeÚendpoint_urlÚpresigned_urls              r$   r´   r´     s¼   € ð$ €FØ€~Ø”Ô&ˆð Øðð €Fð ØØØØðð €Lð €FØÐ1˜jÐ1Ð1¨4Ð1Ð1€LÝ˜ |Ñ4Ô4Ð4ØÔ(×?Ò?Ø Ø!ØØØð @ñ ô €Mð �˜V™œ˜˜Ô'Ð'r&   rË   c                 ó,  — d}||vr)t          d|› dd                     |¦  «        › �¬¦  «        ‚|€| j        j        }ddi d	|id
dœ}d}|› |› �}t	          ||¦  «         | j                             ||||d¬¦  «        }	|	t          |¦  «        d…         S )a&  Generate a DSQL database token for an arbitrary action.

    :type Hostname: str
    :param Hostname: The DSQL endpoint host name.

    :type Action: str
    :param Action: Action to perform on the cluster (DbConnectAdmin or DbConnect).

    :type Region: str
    :param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.

    :type ExpiresIn: int
    :param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).

    :return: A presigned url which can be used as an auth token.
    )Ú	DbConnectÚDbConnectAdminz	Received z! for action but expected one of: z, )ÚreportNr–   rR   rÁ   rÃ   rÄ   rÊ   ÚdsqlrÌ   )r   r�   rÍ   r   r   rÎ   ro   rÏ   )
r   ÚHostnamerÁ   rÓ   Ú	ExpiresInÚpossible_actionsrn   rÔ   rÕ   rÖ   s
             r$   Ú_dsql_generate_db_auth_tokenrß   9  sï   € ð& 7ÐàÐ%Ð%Ð%Ý"Øe˜vÐeÐeÈÏ	Ê	ÐRbÑHcÔHcÐeÐeð
ñ 
ô 
ð 	
ð €~Ø”Ô&ˆð ØØà�fð
ð ðð €Lð €FØÐ(˜hÐ(Ð(€LÝ˜ |Ñ4Ô4Ð4ØÔ(×?Ò?ØØ!ØØØð @ñ ô €Mð �˜V™œ˜˜Ô'Ð'r&   c                 ó(   — t          | |d||¦  «        S )a¿  Generate a DSQL database token for the "DbConnect" action.

    :type Hostname: str
    :param Hostname: The DSQL endpoint host name.

    :type Region: str
    :param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.

    :type ExpiresIn: int
    :param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).

    :return: A presigned url which can be used as an auth token.
    rØ   ©rß   ©r   rÜ   rÓ   rÝ   s       r$   r¼   r¼   l  s!   € õ  (Øˆh˜ V¨Yñô ð r&   c                 ó(   — t          | |d||¦  «        S )aÄ  Generate a DSQL database token for the "DbConnectAdmin" action.

    :type Hostname: str
    :param Hostname: The DSQL endpoint host name.

    :type Region: str
    :param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.

    :type ExpiresIn: int
    :param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).

    :return: A presigned url which can be used as an auth token.
    rÙ   rá   râ   s       r$   r½   r½   �  s"   € õ  (ØˆhÐ(¨&°)ñô ð r&   c                   ó$   — e Zd Zd„ Z	 	 	 	 dd„ZdS )ÚS3PostPresignerc                 ó   — || _         d S r   )rÎ   )r   r4   s     r$   r%   zS3PostPresigner.__init__—  s   € Ø-ˆÔÐÐr&   Nrj   c                 óŽ  — |€i }|€g }i }t          ¦   «         }|t          j        |¬¦  «        z   }|                     t          j        j        ¦  «        |d<   g |d<   |D ]}	|d                              |	¦  «         Œt          |¦  «        }
||
j	        d<   ||
j	        d<   | j
                             d|
|d¦  «         |
j        |d	œS )
a…  Generates the url and the form fields used for a presigned s3 post

        :type request_dict: dict
        :param request_dict: The prepared request dictionary returned by
            ``botocore.awsrequest.prepare_request_dict()``

        :type fields: dict
        :param fields: A dictionary of prefilled form fields to build on top
            of.

        :type conditions: list
        :param conditions: A list of conditions to include in the policy. Each
            element can be either a list or a structure. For example:

            .. code:: python

                [
                    {"acl": "public-read"},
                    {"bucket": "amzn-s3-demo-bucket"},
                    ["starts-with", "$key", "mykey"]
                ]

        :type expires_in: int
        :param expires_in: The number of seconds the presigned post is valid
            for.

        :type region_name: string
        :param region_name: The region name to sign the presigned post to.

        :rtype: dict
        :returns: A dictionary with two elements: ``url`` and ``fields``.
            Url is the url to post to. Fields is a dictionary filled with
            the form fields and respective values to use when submitting the
            post. For example:

            .. code:: python

                {
                    'url': 'https://amzn-s3-demo-bucket.s3.amazonaws.com',
                    'fields': {
                        'acl': 'public-read',
                        'key': 'mykey',
                        'signature': 'mysignature',
                        'policy': 'mybase64 encoded policy'
                    }
                }
        N)ÚsecondsÚ
expirationÚ
conditionszs3-presign-post-fieldszs3-presign-post-policyÚ	PutObjectrP   )rm   Úfields)r   ÚdatetimeÚ	timedeltaÚstrftimerA   rK   ÚISO8601Úappendr   r>   rÎ   r,   rm   )r   rn   rì   rê   rH   r   rˆ   Údatetime_nowÚexpire_dater¥   r.   s              r$   Úgenerate_presigned_postz'S3PostPresigner.generate_presigned_postš  sù   € ðn ˆ>ØˆFàÐØˆJð ˆõ ,Ñ-Ô-ˆØ"¥XÔ%7À
Ð%KÑ%KÔ%KÑKˆØ*×3Ò3µH´MÔ4IÑJÔJˆˆ|Ñð  "ˆˆ|ÑØ#ð 	3ð 	3ˆIØ�<Ô ×'Ò'¨	Ñ2Ô2Ð2Ð2õ (¨Ñ5Ô5ˆØ4:ˆŒÐ0Ñ1Ø4:ˆŒÐ0Ñ1àÔ×!Ò!Ø˜ +¨~ñ	
ô 	
ð 	
ð ”{¨fÐ5Ð5Ð5r&   )NNrj   N)rq   rr   rs   r%   rô   r<   r&   r$   rå   rå   –  sK   € € € € € ð.ð .ð .ð ØØØðS6ð S6ð S6ð S6ð S6ð S6r&   rå   c                 ó   — t           | d<   d S )Nro   )ro   rµ   s     r$   Úadd_generate_presigned_urlrö   ð  r¸   r&   rj   c                 ó  — |}|}|€i }|}|}dt          | ¦  «        dœ}	| j        }
	 | j        |         }n# t          $ r t	          |¬¦  «        ‚w xY w| j        j                             |¦  «        }|                      |||	¬¦  «        }t          j
        |                     dd¦  «        ¦  «        }|                      |||	| ¬¦  «        \  }}}|                      ||||	|d	¬
¦  «        }|�||d<   |
                     |||¬¦  «        S )aI  Generate a presigned url given a client, its method, and arguments

    .. warning::

        For backwards compatibility, S3 presigned URLs use Signature
        Version 2 by default in regions where S3 supports it. As a result,
        some ``Params`` entries are not signed. Some headers, including the
        conditionals and ``Range``, are also silently dropped.

        It is recommended to configure the S3 client with Signature
        Version 4 by setting ``signature_version='s3v4'`` in the client's
        ``Config``.

    :type ClientMethod: string
    :param ClientMethod: The client method to presign for

    :type Params: dict
    :param Params: The parameters normally passed to
        ``ClientMethod``.

    :type ExpiresIn: int
    :param ExpiresIn: The number of seconds the presigned url is valid
        for. By default it expires in an hour (3600 seconds)

    :type HttpMethod: string
    :param HttpMethod: The http method to use on the generated url. By
        default, the http method is whatever is used in the method's model.

    :returns: The presigned url
    NT©Úis_presign_requestÚuse_global_endpoint)Úmethod_name©Ú
api_paramsÚoperation_modelr>   ÚBucketrR   ©Úignore_signing_regionF©rý   rþ   rÕ   r>   rÇ   Úset_user_agent_headerrÉ   )rn   rH   r-   )Ú_should_use_global_endpointrÎ   Ú_PY_TO_OP_NAMEÚKeyErrorr   rÍ   Úservice_modelrþ   Ú_emit_api_paramsr   Úis_arnrC   Ú_resolve_endpoint_rulesetÚ_convert_to_request_dictro   )r   ÚClientMethodÚParamsrÝ   Ú
HttpMethodÚclient_methodr‹   rH   Úhttp_methodr>   r4   r-   rþ   Úbucket_is_arnrÕ   Úadditional_headersÚ
propertiesrn   s                     r$   ro   ro   ô  sˆ  € ðB !€MØ€FØ€~ØˆØ€JØ€Kà"Ý:¸4Ñ@Ô@ðð €Gð
 Ô)€NðBØÔ,¨]Ô;ˆˆøÝð Bð Bð BÝ&°=ÐAÑAÔAÐAðBøøøð ”iÔ-×=Ò=¸nÑMÔM€OØ×"Ò"ØØ'Øð #ñ ô €Fõ
 Ô$ V§Z¢Z°¸"Ñ%=Ô%=Ñ>Ô>€Mð
 	×&Ò&ØØØØ#0Ð0ð	 	'ñ 	ô 	ñ	ØØØð ×0Ò0ØØ'Ø!ØØ"Ø#ð 1ñ ô €Lð ÐØ!,ˆ�XÑð ×0Ò0Ø!ØØ%ð 1ñ ô ð s	   §5 µAc                 ó   — t           | d<   d S )Nrô   )rô   rµ   s     r$   Úadd_generate_presigned_postr  N  s   € Ý2IÐÐ.Ñ/Ð/Ð/r&   c           	      óð  — |}|}|}|}	|}
|€i }n|                      ¦   «         }|	€g }	dt          | ¦  «        dœ}t          | j        ¦  «        }| j        j                             d¦  «        }|                      d|i||¬¦  «        }t          j	        | 
                    dd¦  «        ¦  «        }|                      |||| ¬¦  «        \  }}}|                      |||||d	¬
¦  «        }|	                     d|i¦  «         |                     d¦  «        r/|	                     dd|dt          d¦  «         …         g¦  «         n|	                     d|i¦  «         ||d<   |                     |||	|
¬¦  «        S )aw
  Builds the url and the form fields used for a presigned s3 post

    :type Bucket: string
    :param Bucket: The name of the bucket to presign the post to. Note that
        bucket related conditions should not be included in the
        ``conditions`` parameter.

    :type Key: string
    :param Key: Key name, optionally add ${filename} to the end to
        attach the submitted filename. Note that key related conditions and
        fields are filled out for you and should not be included in the
        ``Fields`` or ``Conditions`` parameter.

    :type Fields: dict
    :param Fields: A dictionary of prefilled form fields to build on top
        of. Elements that may be included are acl, Cache-Control,
        Content-Type, Content-Disposition, Content-Encoding, Expires,
        success_action_redirect, redirect, success_action_status,
        and x-amz-meta-.

        Note that if a particular element is included in the fields
        dictionary it will not be automatically added to the conditions
        list. You must specify a condition for the element as well.

    :type Conditions: list
    :param Conditions: A list of conditions to include in the policy. Each
        element can be either a list or a structure. For example:

        .. code:: python

            [
                {"acl": "public-read"},
                ["content-length-range", 2, 5],
                ["starts-with", "$success_action_redirect", ""]
            ]

        Conditions that are included may pertain to acl,
        content-length-range, Cache-Control, Content-Type,
        Content-Disposition, Content-Encoding, Expires,
        success_action_redirect, redirect, success_action_status,
        and/or x-amz-meta-.

        Note that if you include a condition, you must specify
        a valid value in the fields dictionary as well. A value will
        not be added automatically to the fields dictionary based on the
        conditions.

    :type ExpiresIn: int
    :param ExpiresIn: The number of seconds the presigned post
        is valid for.

    :rtype: dict
    :returns: A dictionary with two elements: ``url`` and ``fields``.
        Url is the url to post to. Fields is a dictionary filled with
        the form fields and respective values to use when submitting the
        post. For example:

        .. code:: python

            {
                'url': 'https://amzn-s3-demo-bucket.s3.amazonaws.com',
                'fields': {
                    'acl': 'public-read',
                    'key': 'mykey',
                    'signature': 'mysignature',
                    'policy': 'mybase64 encoded policy'
                }
            }
    NTrø   ÚCreateBucketrÿ   rü   rR   r   Fr  Úbucketz${filename}zstarts-withz$keyrh   )rn   rì   rê   rH   )Úcopyr  rå   rÎ   rÍ   r  rþ   r  r   r	  rC   r
  r  rñ   rT   rÏ   rô   )r   rÿ   ÚKeyÚFieldsÚ
ConditionsrÝ   r  rh   rì   rê   rH   r>   Úpost_presignerrþ   r‹   r  rÕ   r  r  rn   s                       r$   rô   rô   R  sè  € ðP €FØ
€CØ€FØ€JØ€Jà€~Øˆˆà—’‘”ˆàÐØˆ
ð #Ý:¸4Ñ@Ô@ðð €Gõ
 % TÔ%9Ñ:Ô:€Nð ”iÔ-×=Ò=¸nÑMÔM€OØ×"Ò"Ø˜fÐ%Ø'Øð #ñ ô €Fõ
 Ô$ V§Z¢Z°¸"Ñ%=Ô%=Ñ>Ô>€Mð
 	×&Ò&ØØØØ#0Ð0ð	 	'ñ 	ô 	ñ	ØØØð ×0Ò0ØØ'Ø!ØØ"Ø#ð 1ñ ô €Lð ×Ò�x Ð(Ñ)Ô)Ð)ð ‡|‚|�MÑ"Ô"ð (Ø×Ò˜=¨&°#Ð6K½¸]Ñ9KÔ9KÐ8KÐ6KÔ2LÐMÑNÔNÐNÐNà×Ò˜5 #˜,Ñ'Ô'Ð'ð €Fˆ5�Mà×1Ò1Ø!ØØØð	 2ñ ô ð r&   c                 ó  — | j         j        dk    rdS | j         j        j        }|rc|                     dd¦  «        rdS |                     d¦  «        dk    r| j         j        j        dk    rdS |                     d¦  «        dk    rdS d	S )
NÚawsFÚuse_dualstack_endpointÚus_east_1_regional_endpointÚregionalz	us-east-1Úaddressing_styleÚvirtualT)rÍ   Ú	partitionÚconfigÚs3rC   r   )ÚclientÚ	s3_configs     r$   r  r  á  sš   € Ø„{Ô Ò%Ð%ØˆuØ”Ô"Ô%€IØð 	Ø�=Š=Ð1°5Ñ9Ô9ð 	Ø�5à�MŠMÐ7Ñ8Ô8¸JÒFÐFØ”Ô"Ô.°+Ò=Ð=à�5Ø�=Š=Ð+Ñ,Ô,°	Ò9Ð9Ø�5Øˆ4r&   r   )NrË   )Nrj   N)NNrj   )%r¯   rí   rŸ   r   rA   Úbotocore.authÚbotocore.awsrequestr   r   Úbotocore.compatr   r   Úbotocore.exceptionsr   r   r	   r
   Úbotocore.tokensr   Úbotocore.utilsr   r   r   r   rx   r·   r¾   r´   rß   r¼   r½   rå   rö   ro   r  rô   r  r<   r&   r$   ú<module>r0     s„  ðð €€€Ø €€€Ø €€€Ø €€€à €€€Ø Ð Ð Ð Ø KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ =Ð =Ð =Ð =Ð =Ð =Ð =Ð =ðð ð ð ð ð ð ð ð ð ð ð ð ,Ð +Ð +Ð +Ð +Ð +ðð ð ð ð ð ð ð ð ð ðIð Ið Ið Ið Iñ Iô Ið IðX
C
ð C
ð C
ð C
ð C
ñ C
ô C
ð C
ðLHð Hð Hðð ð ð3(ð 3(ð 3(ð 3(ðn 47ð0(ð 0(ð 0(ð 0(ðh ,/ðð ð ð ð, ,/ðð ð ð ð*W6ð W6ð W6ð W6ð W6ñ W6ô W6ð W6ðtHð Hð Hð
 AEðWð Wð Wð WðtJð Jð Jð
 @DðLð Lð Lð Lð^ð ð ð ð r&   