Ë
    P÷Ôeãw  ã                   óð   — 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
 d dlmZmZmZ d dlmZmZ d dlmZ  G d„ d«      Z G d	„ d
«      Zd„ Zdd„Z G d„ d«      Zd„ Z	 dd„Zd„ Z	 dd„Zd„ Zy)é    N)Úcreate_request_objectÚprepare_request_dict)ÚOrderedDict)ÚUnknownClientMethodErrorÚUnknownSignatureVersionErrorÚ UnsupportedSignatureVersionError)Ú	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y)Ú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                  |«      | _        y ©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           ú2/usr/lib/python3/dist-packages/botocore/signers.pyÚ__init__zRequestSigner.__init__D   sG   € ð (ˆÔØ)ˆÔØ"3ˆÔØ'ˆÔØ%ˆÔØ%ˆÔô &Ÿm™m¨MÓ:ˆÕó    c                 ó   — | j                   S r   )r   ©r   s    r!   r   zRequestSigner.region_nameX   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_name`   s   € à×!Ñ!Ð!r#   c                 ó&   — | j                  ||«      S r   )Úsign)r   Úoperation_nameÚrequestÚkwargss       r!   ÚhandlerzRequestSigner.handlerd   s   € ð
 �y‰y˜¨Ó1Ð1r#   c           	      óè  — |}|€| j                   }|€| j                  }| j                  |||j                  «      }| j                  j                  dj                  | j                  j                  «       |«      ||| j                   || |¬«       |t        j                  k7  r¬|||dœ}	|�||	d<   |j                  j                  di «      }
|s|
j                  d«      r|
d   |	d<   |
j                  d	«      r|
d	   |	d	<   |
j                  d
«      �| j                  |	|
d
   |
d   «       	  | j                  di |	¤Ž}|j!                  |«       yy# t        $ r}|dk7  rt        |¬«      ‚|‚d}~ww xY w)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   Úidentity_cacheÚ	cache_keyÚstandard©r   © )r   r   Ú_choose_signerÚcontextr   ÚemitÚformatr   Ú	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.signk   s¶  € ðF  +ÐØÐØ×+Ñ+ˆKàÐØ×-Ñ-ˆLà ×/Ñ/Ø˜L¨'¯/©/ó
Ðð
 	×Ñ× Ñ Ø×&Ñ&Ø× Ñ ×*Ñ*Ó,¨nóð Ø%Ø×)Ñ)Ø/ØØ)ð 	!ô 
	
ð ¤× 1Ñ 1Ò1à ,Ø*Ø%6ñˆFð
 Ð%Ø$.��yÑ!Ø%Ÿo™o×1Ñ1°)¸RÓ@ˆOÙ'¨O×,?Ñ,?ÀÔ,IØ(7¸Ñ(A��}Ñ%Ø×"Ñ" >Ô2Ø)8¸Ñ)H��~Ñ&Ø×"Ñ"Ð#3Ó4Ð@Ø×,Ñ,ØØ#Ð$4Ñ5Ø# KÑ0ôð
Ø-�t×-Ñ-Ñ7°Ñ7�ð �M‰M˜'Õ"ð; 2øô* 0ò Ø :Ò-Ü:Ø*;ôð ð �Gûðús   Ä+E Å	E1ÅE,Å,E1c                 ó   — ||d<   ||d<   y )Nr3   r4   r7   )r   r,   Úcacher4   s       r!   r@   z%RequestSigner._resolve_identity_cacheÅ   s   € Ø#(ˆÐÑ Ø'ˆˆ{Òr#   c                 óD  — dddœ}|j                  |d«      }|j                  d«      xs | j                  }|j                  di «      }|j                  d| j                  «      }|j                  d| j                  «      }	|t        j
                  ur|j                  |«      s||z  }| j                  j                  d	j                  | j                  j                  «       |«      ||	||¬
«      \  }
}|�*|}|t        j
                  ur|j                  |«      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_typer1   r   r2   zchoose-signer.{}.{})r   r   r   r9   )r?   r   r   r   r=   r>   Úendswithr   Úemit_until_responser;   r   r<   )r   r*   rC   r9   Úsigning_type_suffix_mapÚsuffixr   r1   r   r   r-   Úresponses               r!   r8   zRequestSigner._choose_signerÉ   s3  € ð ,Ø#ñ#
Ðð )×,Ñ,¨\¸2Ó>ˆð $ŸK™K¨Ó4ÒO¸×8OÑ8OÐØ—+‘+˜i¨Ó,ˆØ—{‘{ >°4×3EÑ3EÓFˆØ—k‘k (¨D×,=Ñ,=Ó>ˆà¤X×%6Ñ%6Ñ6Ø%×.Ñ.¨vÔ6à Ñ'Ðà ×/Ñ/×CÑCØ!×(Ñ(Ø× Ñ ×*Ñ*Ó,¨nóð &Ø#Ø/Øð Dó 
Ñˆ�ð ÐØ (Ðð "¬×):Ñ):Ñ:Ø)×2Ñ2°6Ô:à! VÑ+Ð!à Ð r#   c                 óD  — |€| j                   }t        j                  j                  j	                  |«      }|€t        |¬«      ‚|j                  du r2d}| j                  �| j                  j                  «       } ||«      }|S | j                  }t        |dd«      du r|d   }	|d   }
|	j                  |
«      }|d= d}|�|j                  «       }||d<   |j                  r4| j                  €t        j                  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.
        Nr6   TÚREQUIRES_IDENTITY_CACHEr3   r4   r   r   Úservice_namer7   )r   r=   rG   ÚAUTH_TYPE_MAPSr?   r   ÚREQUIRES_TOKENr   Úget_frozen_tokenr   ÚgetattrÚget_credentialsÚget_frozen_credentialsÚREQUIRES_REGIONr   Ú
exceptionsÚNoRegionError)r   r   r   r   r,   ÚclsÚfrozen_tokenrG   r   rJ   ÚkeyÚfrozen_credentialss               r!   rA   zRequestSigner.get_auth_instanceû   sI  € ð* Ð$Ø $× 7Ñ 7Ðä�m‰m×*Ñ*×.Ñ.Ð/@ÓAˆØˆ;Ü.Ø"3ôð ð ×Ñ Ñ%ØˆLØ×ÑÐ+Ø#×/Ñ/×@Ñ@ÓB�Ù�|Ó$ˆDØˆKà×'Ñ'ˆÜ�3Ð1°4Ó8¸DÑ@ØÐ+Ñ,ˆEØ˜Ñ%ˆCØ×/Ñ/°Ó4ˆKØ�{Ð#ð "ÐØÐ"Ø!,×!CÑ!CÓ!EÐØ 2ˆˆ}ÑØ×ÒØ× Ñ Ð(Ü×)Ñ)×7Ñ7Ó9Ð9Ø$/ˆF�=Ñ!Ø%1ˆF�>Ñ"Ù‰}�V‰}ˆØˆr#   c                 ó|   — t        |«      }| j                  |||d||«       |j                  «        |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
        rM   )r   r)   ÚprepareÚurl)r   Úrequest_dictr*   rD   r   r   r+   s          r!   Úgenerate_presigned_urlz$RequestSigner.generate_presigned_url:  sB   € ô: (¨Ó5ˆØ�	‰	ØØØØØØô	
ð 	�‰ÔØ�{‰{Ðr#   r   ©NN)Nr5   NN)é  NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   Úpropertyr   r   r   r-   r)   r@   r8   rA   Úget_authri   r7   r#   r!   r   r   !   s–   „ ñ ðT ó;ð( ñ!ó ð!ð ñ'ó ð'ð ñ"ó ð"ó2ð ØØØóX#òt(ò0!ðf <@ó:ðz !€Hð ØØô(r#   r   c                   ó4   — e Zd ZdZd„ Zdd„Zd„ Z	 dd„Zd„ Zy)	Ú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                 ó    — || _         || _        y)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   ru   rv   s      r!   r"   zCloudFrontSigner.__init__}  s   € ð ˆŒØ$ˆ�r#   Nc                 óü  — |duxr |du}|du xr |du }|s|rd}t        |«      ‚|�| j                  ||«      }t        |t        «      r|j	                  d«      }|�dt        t        |«      «      z  g}n$d| j                  |«      j                  d«      z  g}| j                  |«      }|j                  d| j                  |«      j                  d«      › �d| j                  › �g«       | j                  ||«      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=%sz	Policy=%sz
Signature=zKey-Pair-Id=)Ú
ValueErrorÚbuild_policyÚ
isinstanceÚstrÚencodeÚintr
   Ú_url_b64encodeÚdecoderv   Úextendru   Ú
_build_url)	r   rg   Údate_less_thanÚpolicyÚboth_args_suppliedÚneither_arg_suppliedrH   ÚparamsÚ	signatures	            r!   ri   z'CloudFrontSigner.generate_presigned_urlŒ  s  € ð ,°4Ð7ÒN¸FÈ$Ð<NÐØ-°Ð5ÒH¸&ÀD¸.ÐÙÑ!5ØOˆAÜ˜Q“-ÐØÐ%à×&Ñ& s¨NÓ;ˆFÜ�fœcÔ"Ø—]‘] 6Ó*ˆFØÐ%Ø"¤SÔ);¸NÓ)KÓ%LÑLÐM‰Fà! D×$7Ñ$7¸Ó$?×$FÑ$FÀvÓ$NÑNÐOˆFØ—O‘O FÓ+ˆ	Ø�‰à˜T×0Ñ0°Ó;×BÑBÀ6ÓJÐKÐLØ˜tŸ{™{˜mÐ,ðô	
ð �‰˜s FÓ+Ð+r#   c                 ó@   — d|v rdnd}||z   dj                  |«      z   S )Nú?ú&)Újoin)r   Úbase_urlÚextra_paramsÚ	separators       r!   r‚   zCloudFrontSigner._build_url²  s(   € Ø (™?‘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!   rz   zCloudFrontSigner.build_policy¶  s§   € ô: Ô'¨Ó7Ó8ˆÜ °/À6Ð1JÐ KÓLˆ	ÙØ˜*Ñ$Ø˜eÑ#�
Ø&4°jÐ%AˆI�kÑ"ÙÜÔ+Ð,=Ó>Ó?ˆFØ,;¸VÐ+DˆIÐ'Ñ(Ø&¨Ð1°KÀÐ3KÐLˆØ$¤{°?Ó'CÐ&DÐEˆÜ�z‰z˜-°JÔ?Ð?r#   c                 óŒ   — t        j                  |«      j                  dd«      j                  dd«      j                  dd«      S )Nó   +ó   -ó   =ó   _ó   /ó   ~)Úbase64Ú	b64encodeÚreplace)r   Údatas     r!   r   zCloudFrontSigner._url_b64encodeà  s;   € ô ×Ñ˜TÓ"ß‰W�T˜4Ó ß‰W�T˜4Ó ß‰W�T˜4Ó ð		
r#   rj   )	rl   rm   rn   ro   r"   ri   r‚   rz   r   r7   r#   r!   rs   rs   e  s*   „ ñò.%ó$,òL=ð
 LPó(@óT
r#   rs   c                 ó   — t         | d<   y )NÚgenerate_db_auth_token)r°   ©Úclass_attributesr,   s     r!   Úadd_generate_db_auth_tokenr³   ë  ó   € Ü1GÐÐ-Ò.r#   c                 óÚ   — |}|€| j                   j                  }d|dœ}ddi |ddœ}d}|› |› d	|› �}	t        ||	«       | j                  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’   rN   ÚGET)Úurl_pathÚquery_stringÚheadersÚbodyÚmethodzhttps://r™   i„  zrds-db)r*   rh   r   rD   r   )Úmetar   r   Ú_request_signerri   Úlen)r   Ú
DBHostnameÚPortÚ
DBUsernameÚRegionr2   r‡   rh   ÚschemeÚendpoint_urlÚpresigned_urls              r!   r°   r°   ï  s§   € ð$ €FØ€~Ø—‘×&Ñ&ˆð Øñ€Fð ØØØØñ€Lð €FØ�X˜j˜\¨¨4¨&Ð1€LÜ˜ |Ô4Ø×(Ñ(×?Ñ?Ø Ø!ØØØð @ó €Mð œ˜V›˜Ð'Ð'r#   c                   ó"   — e Zd Zd„ Z	 	 	 	 dd„Zy)ÚS3PostPresignerc                 ó   — || _         y r   )rÀ   )r   r/   s     r!   r"   zS3PostPresigner.__init__&  s
   € Ø-ˆÕr#   Nc                 óÈ  — |€i }|€g }i }t         j                   j                  «       }|t        j                  |¬«      z   }|j                  t        j
                  j                  «      |d<   g |d<   |D ]  }	|d   j                  |	«       Œ t        |«      }
||
j                  d<   ||
j                  d<   | j                  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:
            [
             {"acl": "public-read"},
             {"bucket": "mybucket"},
             ["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:

            {'url': 'https://mybucket.s3.amazonaws.com
             'fields': {'acl': 'public-read',
                        'key': 'mykey',
                        'signature': 'mysignature',
                        'policy': 'mybase64 encoded policy'}
            }
        )ÚsecondsÚ
expirationÚ
conditionszs3-presign-post-fieldszs3-presign-post-policyÚ	PutObjectrL   )rg   Úfields)ÚdatetimeÚutcnowÚ	timedeltaÚstrftimer=   rG   ÚISO8601Úappendr   r9   rÀ   r)   rg   )r   rh   rÑ   rÏ   rD   r   r„   Údatetime_nowÚexpire_dater¡   r+   s              r!   Úgenerate_presigned_postz'S3PostPresigner.generate_presigned_post)  sñ   € ð^ ˆ>ØˆFàÐØˆJð ˆô  ×(Ñ(×/Ñ/Ó1ˆØ"¤X×%7Ñ%7À
Ô%KÑKˆØ*×3Ñ3´H·M±M×4IÑ4IÓJˆˆ|Ñð  "ˆˆ|ÑØ#ò 	3ˆIØ�<Ñ ×'Ñ'¨	Õ2ð	3ô (¨Ó5ˆØ4:ˆ�‰Ð0Ñ1Ø4:ˆ�‰Ð0Ñ1à×Ñ×!Ñ!Ø˜ +¨~ô	
ð —{‘{¨fÑ5Ð5r#   )NNrk   N)rl   rm   rn   r"   rÚ   r7   r#   r!   rÊ   rÊ   %  s   „ ò.ð ØØØôK6r#   rÊ   c                 ó   — t         | d<   y )Nri   )ri   r±   s     r!   Úadd_generate_presigned_urlrÜ   w  r´   r#   c                 óô  — |}|}|€i }|}|}dt        | «      dœ}	| j                  }
	 | j                  |   }| j
                  j                  j                  |«      }| j                  |||	¬«      }t        j                  |j                  dd«      «      }| j                  |||	| ¬«      \  }}}| j                  ||||	|d¬	«      }|�||d
<   |
j                  |||¬«      S # t        $ r t	        |¬«      ‚w xY w)ax  Generate a presigned url given a client, its method, and arguments

    :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
    T©Úis_presign_requestÚuse_global_endpoint)Úmethod_name©Ú
api_paramsÚoperation_modelr9   ÚBucketrN   ©Úignore_signing_regionF©rã   rä   rÇ   r9   r¼   Úset_user_agent_headerr¾   )rh   rD   r*   )Ú_should_use_global_endpointrÀ   Ú_PY_TO_OP_NAMEÚKeyErrorr   r¿   Úservice_modelrä   Ú_emit_api_paramsr	   Úis_arnr?   Ú_resolve_endpoint_rulesetÚ_convert_to_request_dictri   )r   ÚClientMethodÚParamsÚ	ExpiresInÚ
HttpMethodÚclient_methodr‡   rD   Úhttp_methodr9   r/   r*   rä   Úbucket_is_arnrÇ   Úadditional_headersÚ
propertiesrh   s                     r!   ri   ri   {  s]  € ð, !€MØ€FØ€~ØˆØ€JØ€Kà"Ü:¸4Ó@ñ€Gð
 ×)Ñ)€NðBØ×,Ñ,¨]Ñ;ˆð —i‘i×-Ñ-×=Ñ=¸nÓM€OØ×"Ñ"ØØ'Øð #ó €Fô
 ×$Ñ$ V§Z¡Z°¸"Ó%=Ó>€Mð
 	×&Ñ&ØØØØ#0Ð0ð	 	'ó 	ñ	ØØØð ×0Ñ0ØØ'Ø!ØØ"Ø#ð 1ó €Lð ÐØ!,ˆ�XÑð ×0Ñ0Ø!ØØ%ð 1ó ð øôG ò BÜ&°=ÔAÐAðBús   ¨C! Ã!C7c                 ó   — t         | d<   y )NrÚ   )rÚ   r±   s     r!   Úadd_generate_presigned_postrü   Ê  s   € Ü2IÐÐ.Ò/r#   c           	      ó–  — |}|}|}|}	|}
|€i }n|j                  «       }|	€g }	dt        | «      dœ}t        | j                  «      }| j                  j
                  j                  d«      }| j                  d|i||¬«      }t        j                  |j                  dd«      «      }| j                  |||| ¬«      \  }}}| j                  |||||d	¬
«      }|	j                  d|i«       |j                  d«      r"|	j                  dd|dt        d«        g«       n|	j                  d|i«       ||d<   |j!                  |||	|
¬«      S )a×	  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:

        [
         {"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
        the 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:

        {'url': 'https://mybucket.s3.amazonaws.com
         'fields': {'acl': 'public-read',
                    'key': 'mykey',
                    'signature': 'mysignature',
                    'policy': 'mybase64 encoded policy'}
        }
    NTrÞ   ÚCreateBucketrå   râ   rN   ræ   Frè   Úbucketz${filename}zstarts-withz$keyrc   )rh   rÑ   rÏ   rD   )Úcopyrê   rÊ   rÀ   r¿   rí   rä   rî   r	   rï   r?   rð   rñ   r×   rP   rÁ   rÚ   )r   rå   ÚKeyÚFieldsÚ
Conditionsrô   rÿ   rc   rÑ   rÏ   rD   r9   Úpost_presignerrä   r‡   rø   rÇ   rù   rú   rh   s                       r!   rÚ   rÚ   Î  s¤  € ðB €FØ
€CØ€FØ€JØ€Jà€~Ø‰à—‘“ˆàÐØˆ
ð #Ü:¸4Ó@ñ€Gô
 % T×%9Ñ%9Ó:€Nð —i‘i×-Ñ-×=Ñ=¸nÓM€OØ×"Ñ"Ø˜fÐ%Ø'Øð #ó €Fô
 ×$Ñ$ V§Z¡Z°¸"Ó%=Ó>€Mð
 	×&Ñ&ØØØØ#0Ð0ð	 	'ó 	ñ	ØØØð ×0Ñ0ØØ'Ø!ØØ"Ø#ð 1ó €Lð ×Ñ�x Ð(Ô)ð ‡|�|�MÔ"Ø×Ñ˜=¨&°#Ð6K¼¸]Ó9KÐ8KÐ2LÐMÕNà×Ñ˜5 #˜,Ô'ð €Fˆ5�Mà×1Ñ1Ø!ØØØð	 2ó ð r#   c                 ó<  — | j                   j                  dk7  ry| j                   j                  j                  }|r`|j	                  dd«      ry|j	                  d«      dk(  r$| j                   j                  j
                  dk(  ry|j	                  d«      dk(  ryy	)
NÚawsFÚuse_dualstack_endpointÚus_east_1_regional_endpointÚregionalz	us-east-1Úaddressing_styleÚvirtualT)r¿   Ú	partitionÚconfigÚs3r?   r   )ÚclientÚ	s3_configs     r!   rê   rê   V  s†   € Ø‡{�{×Ñ Ò%ØØ—‘×"Ñ"×%Ñ%€IÙØ�=‰=Ð1°5Ô9Øà�M‰MÐ7Ó8¸JÒFØ—‘×"Ñ"×.Ñ.°+Ò=àØ�=‰=Ð+Ó,°	Ò9ØØr#   r   )Nrk   N)NNrk   )r«   rÒ   r›   r   r=   Úbotocore.authÚbotocore.awsrequestr   r   Úbotocore.compatr   Úbotocore.exceptionsr   r   r   Úbotocore.utilsr	   r
   r   r   rs   r³   r°   rÊ   rÜ   ri   rü   rÚ   rê   r7   r#   r!   ú<module>r     s“   ðó Û Û Û ã Û ß KÝ '÷ñ ÷
 9õ '÷Añ A÷H
C
ñ C
òLHó3(÷lO6ñ O6òdHð
 AEóLò^Jð
 @DóEóPr#   