U
    ³.¬b±¼  ã                c   @   sP  d 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Zddlm	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mZmZmZmZmZmZ ddlmZmZmZ ddlmZmZm Z  ddl!m"Z"m#Z#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- ddlm.Z. ddl%m/Z/ e 0e1¡Z2e3ƒ Z4e3ƒ Z5e 6d¡Z7dZ8dZ9e 6d :e8e9g¡¡Z;e 6d¡Z<ddiZ=dd„ Z>dd„ Z?dd„ Z@dd„ ZAdd„ ZBd d!„ ZCd"d#„ ZDd$d%„ ZEd&d'„ ZFd(d)„ ZGd*d+„ ZHd,d-„ ZId.d/„ ZJdõd1d2„ZKd3d4„ ZLd5d6„ ZMd7d8„ ZNG d9d:„ d:ƒZOd;d<„ ZPd=d>„ ZQd?d@„ ZRdAdB„ ZSdCdD„ ZTdEdF„ ZUdGdH„ ZVdIdJ„ ZWdKdL„ ZXdMdN„ ZYdOdP„ ZZdQdR„ Z[dSdT„ Z\dUdV„ Z]dWdX„ Z^dYdZ„ Z_d[d\„ Z`d]d^„ Zad_d`„ Zbdadb„ Zcdcdd„ Zddedf„ Zedgdh„ Zfdidj„ Zgdkdl„ Zhdmdn„ Zidodp„ Zjdqdr„ Zkdsdt„ Zldudv„ Zmdwdx„ ZnG dydz„ dzƒZoG d{d|„ d|ƒZpG d}d~„ d~ƒZqdd€„ Zrd�d‚„ Zsdƒd„„ Ztd…e>fd†epd‡ƒfdˆeme5fd‰eme5fdŠe$fd‹e#fdŒeffd�esfdŽeXfd�eDfd�eGfd‘eZfd’eEfd“eHfd”ehfd•ehfd–ehfd—eQfd˜eQfd—e]fd‰e]fd™e]fdšePfd›ePfdœe?fd�eNfdže`fdŸeafd e'fd¡e'fd¢e@fd£e@fd¤ebfd¥ebfd¦eVfd§etfd¨eefd©eAe4fdªeAe4fd«eAe4fd¬eMfd­eMfd®eMfd¯eMfd°eMfd±eMfd²eCfd³eIfd´eIfd‰eIfd—eIfd—eJfd™eIfdˆeIfd˜eIfd˜eJfdµe[fd¶e[fd·e^fd¸e_fd¹eifdºejfd»ekfd¼egfd½ed¾d¿ƒjufdÀedÁƒjufdÂedÁƒjufdÃecƒ fdÄedfdÅe\dÆƒfdÇe\dÆƒfdÈedÉƒjufdÈedÊƒjufdËedÌƒjufdËedÍƒjufdÎe\dÏƒfdËedÐdÑdÒdÓdÔdÕdÖd×dØdÙdÚdÛdÜdÝdÞgƒjvfdße"fdàeWfdáeWfdâeWfdãeWfdäeWfdåedæƒjufdçedæƒjufdèedæƒjufdéedæƒjufdêedæƒjufdëeWfdìeWfdíedæƒjufdîedæƒjufdïeWfdðeWfdñedæƒjufdòedæƒjufdóeOdôƒjwfdœerfgbZxenexƒ dS )öz_Builtin event handlers.

This module contains builtin handlers for events emitted by botocore.
é    N)ÚBytesIO)Úutils)ÚETreeÚOrderedDictÚXMLParseErrorÚensure_bytesÚget_md5ÚjsonÚquoteÚunquoteÚunquote_strÚurlsplitÚ
urlunsplit)ÚAppendParamDocumentationÚAutoPopulatedParamÚHideParamFromOperations)ÚAliasConflictParameterErrorÚParamValidationErrorÚUnsupportedTLSVersionWarning)Úadd_generate_db_auth_tokenÚadd_generate_presigned_postÚadd_generate_presigned_url)Ú
SAFE_CHARSÚconditionally_calculate_md5Úis_global_accesspointÚpercent_encodeÚswitch_host_with_param)Úretryhandler)Ú	translate)ÚMD5_AVAILABLE)ÚMissingServiceIdError)Úhyphenize_service_idz^[a-zA-Z0-9.\-_]{1,255}$z]^arn:(aws).*:(s3|s3-object-lambda):[a-z\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-.]{1,63}$zt^arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63}$ú|z\?versionId=[^\s]+$zruntime.sagemakerzsagemaker-runtimec                 K   s   t  | | ¡S ©N)ÚSERVICE_NAME_ALIASESÚget)Zservice_nameÚkwargs© r'   ú5/tmp/pip-unpacked-wheel-7df6wvge/botocore/handlers.pyÚhandle_service_name_aliasc   s    r)   c                 K   s>   dt jk}t j d¡}|r:|r:| d }d|kr:t|ƒ|d< d S )NZAWS_LAMBDA_FUNCTION_NAMEZ_X_AMZ_TRACE_IDÚheaderszX-Amzn-Trace-Id)ÚosÚenvironr%   r
   )Úparamsr&   Zhas_lambda_nameZtrace_idr*   r'   r'   r(   Úadd_recursion_detection_headerg   s    
r.   c                 K   s<   | d }d|kr|  dd¡}d|kr0|  dd¡}|| d< d S )NÚbodyó   s   &#xD;ó   
s   &#xA;)Úreplace)r-   r&   r/   r'   r'   r(   Úescape_xml_payloadp   s    r3   c                 K   s2   | d krd S | \}}t |ƒr.t d|¡ d|_d S )NzWError found for response with 200 status code, errors: %s, changing status code to 500.iô  )Ú_looks_like_special_case_errorÚloggerÚdebugÚstatus_code)Úresponser&   Úhttp_responseÚparsedr'   r'   r(   Úcheck_for_200_error€   s    ür;   c                 C   s^   | j dkrZz*tjt ¡ dd�}| | j¡ | ¡ }W n tk
rJ   Y dS X |jdkrZdS dS )NéÈ   úutf-8©ÚtargetÚencodingTÚErrorF)	r7   r   Ú	XMLParserÚTreeBuilderÚfeedÚcontentÚcloser   Útag)r9   ÚparserÚrootr'   r'   r(   r4   Ÿ   s    
 ÿ
r4   c                 K   s–   |   d¡}|sdS |dkr tjS |dkrVd|dœ}d| krJ| d  |¡ n|| d< dS | d¡r’d}|d	kr~t| ƒrzd
}nd}|dkrŽd| d< |S dS )a'  Choose the operation-specific signer.

    Individual operations may have a different auth type than the service as a
    whole. This will most often manifest as operations that should not be
    authenticated at all, but can include other auth modes such as sigv4
    without body signing.
    Ú	auth_typeNÚnoneZv4aÚ*)ÚregionÚsigning_nameÚsigningZv4Ús3Zs3v4aZs3v4zv4-unsigned-bodyFZpayload_signing_enabled)r%   ÚbotocoreÚUNSIGNEDÚupdateÚ
startswithr   )ÚcontextrN   r&   rJ   rO   Zsignature_versionr'   r'   r(   Úset_operation_specific_signer±   s(    


rV   c              
   K   s^   d| krZz(t  t| d dƒ¡ dd¡}|| d< W n( tttfk
rX   tjddd� Y nX d S )NZOutputzlatin-1r=   r2   zError decoding base64T©Úexc_info)	Úbase64Ú	b64decodeÚbytesÚdecodeÚ
ValueErrorÚ	TypeErrorÚAttributeErrorr5   r6   ©r:   r&   Úvaluer'   r'   r(   Údecode_console_outputß   s    ÿ þrb   c                 K   s>   |j D ]2}|| krtt ¡ ƒ| |< t d| | |f ¡ qd S )Nz1injecting idempotency token (%s) into param '%s'.)Zidempotent_membersÚstrÚuuidZuuid4r5   r6   )r-   Úmodelr&   Únamer'   r'   r(   Úgenerate_idempotent_uuidí   s    

ÿÿrg   c              	   C   s>   zt  t| ƒ¡} W n& ttfk
r8   tjddd� Y nX | S )NzError loading quoted JSONTrW   )r	   Úloadsr   r]   r^   r5   r6   )ra   r'   r'   r(   Údecode_quoted_jsondoc÷   s
    ri   c              	   K   sR   d| krNzt j| d td�}|| d< W n& ttfk
rL   tjddd� Y nX d S )NÚTemplateBody)Úobject_pairs_hookzerror loading JSONTrW   )r	   rh   r   r]   r^   r5   r6   r`   r'   r'   r(   Újson_decode_template_bodyÿ   s     ÿrl   c                 K   sR   d| krd S | d }t  |¡sNt |¡sNd|› dt j› dtj› d�}t|d�‚d S )NÚBucketzInvalid bucket name "z%": Bucket name must match the regex "z#" or be an ARN matching the regex "ú"©Úreport)ÚVALID_BUCKETÚsearchÚVALID_S3_ARNÚpatternr   )r-   r&   ÚbucketÚ	error_msgr'   r'   r(   Úvalidate_bucket_name
  s    ÿrw   c                 K   s   t | dƒ dS )zò
    S3 server-side encryption requires the encryption key to be sent to the
    server base64 encoded, as well as a base64-encoded MD5 hash of the
    encryption key. This handler does both if the MD5 has not been set by
    the caller.
    ÚSSECustomerN©Ú_sse_md5©r-   r&   r'   r'   r(   Ússe_md5  s    r|   c                 K   s   t | dƒ dS )a1  
    S3 server-side encryption requires the encryption key to be sent to the
    server base64 encoded, as well as a base64-encoded MD5 hash of the
    encryption key. This handler does both if the MD5 has not been set by
    the caller specifically if the parameter is for the copy-source sse-c key.
    ZCopySourceSSECustomerNry   r{   r'   r'   r(   Úcopy_source_sse_md5!  s    r}   rx   c                 C   sv   t | |ƒsd S |d }|d }| | }t|tƒr:| d¡}t t|ƒ ¡ ¡ d¡}t |¡ d¡}|| |< || |< d S )NÚKeyÚKeyMD5r=   )	Ú_needs_s3_sse_customizationÚ
isinstancerc   ÚencoderY   Ú	b64encoder   Údigestr\   )r-   Ússe_member_prefixZsse_key_memberZsse_md5_memberZkey_as_bytesZkey_md5_strZkey_b64_encodedr'   r'   r(   rz   +  s    


ÿrz   c                 C   s   |   |d ¡d k	o|d | kS )Nr~   r   ©r%   )r-   r…   r'   r'   r(   r€   <  s    
þr€   c                  K   s   t jS )zk
    This handler disables request signing by setting the signer
    name to a special sentinel value.
    )rQ   rR   )r&   r'   r'   r(   Údisable_signingC  s    r‡   c                 K   sJ   | j  dd¡dkrd S d|krF|d }t|dƒrFt d¡ d|d d	< d S )
NÚmethodÚ )ÚPUTÚPOSTr/   Úreadz-Adding expect 100 continue header to request.z100-continuer*   ZExpect)Úhttpr%   Úhasattrr5   r6   )re   r-   r&   r/   r'   r'   r(   Úadd_expect_headerK  s    

r�   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚDeprecatedServiceDocumenterc                 C   s
   || _ d S r#   )Ú_replacement_service_name)ÚselfZreplacement_service_namer'   r'   r(   Ú__init__X  s    z$DeprecatedServiceDocumenter.__init__c                 K   s>   |j  ¡  | d¡ |j  | j| j¡ | d¡ |j  ¡  d S )Nz.This service client is deprecated. Please use z	 instead.)ÚstyleZstart_importantÚwriteÚrefr‘   Zend_important)r’   ÚsectionÚ
event_namer&   r'   r'   r(   Úinject_deprecation_notice[  s    

þ
z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)Ú__name__Ú
__module__Ú__qualname__r“   r™   r'   r'   r'   r(   r�   W  s   r�   c           	      K   sˆ   d|kr:|   d¡}|  d¡}|  d¡}| ¡  | d¡ nJd|kr„|   d¡}|  d¡}| ¡  | d¡ |  d	¡}| ¡  | d
¡ d S )Nzrequest-exampleústructure-valueÚ
CopySourceúmember-valuezH'string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'}zrequest-paramsú
param-typez:type CopySource: str or dictzparam-documentationaq  The name of the source bucket, key name of the source object, and optional version ID of the source object.  You can either provide this value as a string or a dictionary.  The string form is {bucket}/{key} or {bucket}/{key}?versionId={versionId} if you want to copy a specific version.  You can also provide this value as a dictionary.  The dictionary format is recommended over the string format because it is more explicit.  The dictionary format is: {'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}.  Note that the VersionId key is optional and may be omitted. To specify an S3 access point, provide the access point ARN for the ``Bucket`` key in the copy source dictionary. If you want to provide the copy source for an S3 access point as a string instead of a dictionary, the ARN provided must be the full S3 access point object ARN (i.e. {accesspoint_arn}/object/{key})©Úget_sectionÚ
clear_textr•   )	r—   r˜   r&   ÚparentÚ
param_lineÚvalue_portionÚparam_sectionÚtype_sectionZdoc_sectionr'   r'   r(   Údocument_copy_source_formf  s$    


ÿ



ÿr©   c                 K   sH   |   d¡}|dkrdS t|tƒr.t|ƒ| d< nt|tƒrDt|ƒ| d< dS )aH  Convert CopySource param for CopyObject/UploadPartCopy.

    This handler will deal with two cases:

        * CopySource provided as a string.  We'll make a best effort
          to URL encode the key name as required.  This will require
          parsing the bucket and version id from the CopySource value
          and only encoding the key.
        * CopySource provided as a dict.  In this case we're
          explicitly given the Bucket, Key, and VersionId so we're
          able to encode the key and ensure this value is serialized
          and correctly sent to S3.

    rž   N)r%   r�   rc   Ú_quote_source_headerÚdictÚ_quote_source_header_from_dict)r-   r&   Úsourcer'   r'   r(   Úhandle_copy_source_param‹  s    


r®   c              
   C   s¦   zF| d }| d }|   d¡}t |¡r6|› d|› �}n|› d|› �}W n6 tk
r| } ztdt|ƒ› �d�‚W 5 d }~X Y nX t|td d�}|d k	r¢|d	| 7 }|S )
Nrm   r~   Z	VersionIdz/object/ú/zMissing required parameter: ro   ©Úsafez?versionId=%s)r%   rs   rr   ÚKeyErrorr   rc   r   r   )Zsource_dictru   ÚkeyÚ
version_idÚfinalÚer'   r'   r(   r¬   ¦  s    

ÿr¬   c                 C   s\   t  | ¡}|d kr"t| td d�S | d | ¡ … | | ¡ d …  }}t|td d�| S d S )Nr¯   r°   )ÚVERSION_ID_SUFFIXrr   r   r   Ústart)ra   ÚresultÚfirstr´   r'   r'   r(   rª   ¹  s
    
"rª   c                 C   sL   t  |¡}||d d< |d  ||¡|d< d|d< i |d< | j|||jd�S )Nr/   ÚDestinationRegionÚurlÚGETrˆ   r*   )Zregion_nameZoperation_name)ÚcopyÚdeepcopyr2   Zgenerate_presigned_urlrf   )Úrequest_signerÚrequest_dictre   Úsource_regionÚdestination_regionZrequest_dict_copyr'   r'   r(   Ú_get_cross_region_presigned_urlÂ  s    
 ÿ  ÿrÄ   c                 C   s   | j }| d¡}||fS )NÚSourceRegion)Z_region_namer%   )rÀ   r-   rÃ   rÂ   r'   r'   r(   Ú1_get_presigned_url_source_and_destination_regionsÙ  s    
rÆ   c                 K   sN   d| d krd S t || d ƒ\}}t|| |||ƒ}|| d d< || d d< d S )NÚPresignedUrlr/   r»   ©rÆ   rÄ   ©r-   rÀ   re   r&   ÚsrcÚdestr¼   r'   r'   r(   Úinject_presigned_url_ec2à  s     ÿ    ÿrÌ   c                 K   s\   d| d krd S t || d ƒ\}}| d d= d| d kr<d S t|| |||ƒ}|| d d< d S )NrÅ   r/   ÚPreSignedUrlrÈ   rÉ   r'   r'   r(   Úinject_presigned_url_rdsð  s"     ÿ
    ÿrÎ   c                 K   s   |j }|d k	rt| |j ƒ d S r#   )Úoutput_shapeÚ_decode_policy_types)r:   re   r&   rÏ   r'   r'   r(   Újson_decode_policies  s    rÑ   c                 C   sŽ   d}|j dkrf|j ¡ D ]L\}}|j dkrN|j|krN|| krNt| | ƒ| |< q|| krt| | |ƒ q|j dkrŠ|j}| D ]}t||ƒ qzd S )NZpolicyDocumentTypeZ	structureÚstringÚlist)Ú	type_nameÚmembersÚitemsrf   ri   rÐ   Úmember)r:   ÚshapeZ
shape_nameÚmember_nameZmember_shapeZshape_memberÚitemr'   r'   r(   rÐ     s$    
ÿþýÿ

rÐ   c                 K   sJ   |j d krd S |j}tjt ¡ dd�}| |¡ | ¡ }|j}|| d< d S )Nr=   r>   ZLocationConstraint)ÚrawrE   r   rB   rC   rD   rF   Útext)r:   r9   r&   Zresponse_bodyrH   rI   rM   r'   r'   r(   Úparse_get_bucket_location*  s    

rÝ   c                 K   sD   d| kr@t | d tƒr(| d  d¡| d< t | d ¡ d¡| d< d S )NÚUserDatar=   )r�   rc   r‚   rY   rƒ   r\   r{   r'   r'   r(   Úbase64_encode_user_data:  s    ÿrß   c                 C   s   d}t | |ƒ}|jS )Nzw**This value will be base64 encoded automatically. Do not base64 encode this value prior to performing the operation.**©r   Zappend_documentation)ÚparamÚdescriptionÚappendr'   r'   r(   Údocument_base64_encodingD  s    ÿ
rä   c              	   K   sv   |   d¡}|rt|tƒsdS | ¡ D ]L\}}z| d¡ | d¡ W q$ tk
rn   d||f }t|d�‚Y q$X q$dS )aE  Verify S3 Metadata only contains ascii characters.

    From: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html

    "Amazon S3 stores user-defined metadata in lowercase. Each name, value pair
    must conform to US-ASCII when using REST and UTF-8 when using SOAP or
    browser-based uploads via POST."

    ZMetadataNÚasciizvNon ascii characters found in S3 metadata for key "%s", value: "%s".  
S3 metadata can only contain ASCII characters. ro   )r%   r�   r«   rÖ   r‚   ÚUnicodeEncodeErrorr   )r-   r&   Úmetadatar³   ra   rv   r'   r'   r(   Úvalidate_ascii_metadataN  s    


þÿrè   c                 K   sp   |j }|rt|dƒsdS dd„ |j ¡ D ƒ}|D ]:}|| kr0| | }| d¡d | |< t d||| | ¡ q0dS )zì
    Check for and split apart Route53 resource IDs, setting
    only the last piece. This allows the output of one operation
    (e.g. ``'foo/1234'``) to be used as input in another
    operation (e.g. it expects just ``'1234'``).
    rÕ   Nc                 S   s   g | ]\}}|j d kr|‘qS ))Z
ResourceIdZDelegationSetIdZChangeId)rf   )Ú.0rf   rØ   r'   r'   r(   Ú
<listcomp>x  s   
þz#fix_route53_ids.<locals>.<listcomp>r¯   éÿÿÿÿz%s %s -> %s)Úinput_shaperŽ   rÕ   rÖ   Úsplitr5   r6   )r-   re   r&   rì   rÕ   rf   Z
orig_valuer'   r'   r(   Úfix_route53_idsm  s    þrî   c                 K   s   |   d¡d krd| d< d S )NÚ	accountIdú-r†   r{   r'   r'   r(   Úinject_account_id…  s    rñ   c                 K   s   |}| j d |d d< d S )NZ
apiVersionr*   zx-amz-glacier-version)rç   ©re   r-   r&   rÁ   r'   r'   r(   Úadd_glacier_versionŽ  s    ÿró   c                 K   s(   |d   dd ¡d kr$|}d|d d< d S )Nr*   ÚAcceptzapplication/jsonr†   rò   r'   r'   r(   Úadd_accept_header•  s    rõ   c                 K   sv   | }|d }|d }t |tƒr&t|ƒ}| ¡ }d|krHtj|dd�|d< | |¡ d|krht |¡|d< | |¡ dS )zûAdd glacier checksums to the http request.

    This will add two headers to the http request:

        * x-amz-content-sha256
        * x-amz-sha256-tree-hash

    These values will only be added if they are not present
    in the HTTP request.

    r*   r/   zx-amz-content-sha256T)Zas_hexzx-amz-sha256-tree-hashN)r�   r[   r   Útellr   Zcalculate_sha256ÚseekZcalculate_tree_hash)r-   r&   rÁ   r*   r/   Zstarting_positionr'   r'   r(   Úadd_glacier_checksums›  s    
 ÿ

rø   c                  C   s   d} t d| ƒjS )Naî  
        This is a required field.

        Ideally you will want to compute this value with checksums from
        previous uploaded parts, using the algorithm described in
        `Glacier documentation <http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html>`_.

        But if you prefer, you can also use botocore.utils.calculate_tree_hash()
        to compute it from raw file by::

            checksum = calculate_tree_hash(open('your_file.txt', 'rb'))

        Úchecksumrà   )Údocr'   r'   r(   Ú#document_glacier_tree_hash_checksum¼  s    rû   c                 K   sl   d|kr0|   d¡}|  d¡}| ¡  | d¡ n8d|krh|   d¡}|  d¡}|  d¡}| ¡  | d¡ d S )	Nzresponse-paramsrj   r    z(*dict*) --zresponse-exampler�   rŸ   z{}r¡   )r—   r˜   r&   Ztemplate_body_sectionr¨   r¤   r¥   r¦   r'   r'   r(   Ú0document_cloudformation_get_template_return_typeÍ  s    




rü   c                 K   s   t | dƒ d S )NZPredictEndpoint)r   ©Úrequestr&   r'   r'   r(   Úswitch_host_machinelearningÝ  s    rÿ   c                  K   sF   dd l }z$|j}|dk r*t d|j t¡ W n tk
r@   Y nX d S )Nr   )é   r   r   zªCurrently installed openssl version: %s does not support TLS 1.2, which is required for use of iot-data. Please use python installed with openssl version 1.0.1 or higher.)ÚsslÚOPENSSL_VERSION_INFOÚwarningsÚwarnÚOPENSSL_VERSIONr   r_   )r&   r  Zopenssl_version_tupler'   r'   r(   Ú&check_openssl_supports_tls_version_1_2á  s    ýû	r  c                 K   s>   | j dkr:d| jkr:d| jd< d| _ | j dd¡\| _| _d S )Nr½   ú?z!application/x-www-form-urlencodedzContent-Typer‹   r   )rˆ   r¼   r*   rí   Údatarý   r'   r'   r(   Úchange_get_to_postô  s    
r	  c                 K   s   d| krd|d< d| d< d S )NÚEncodingTypeTÚencoding_type_auto_setr¼   r'   )r-   rU   r&   r'   r'   r(   Ú"set_list_objects_encoding_type_urlý  s    r  c                 K   s   t dddgddg| |d� d S )NÚ	DelimiterÚMarkerZ
NextMarker©ZContentsr~   ©ZCommonPrefixesÚPrefix©Útop_level_keysÚnested_keysr:   rU   ©Ú_decode_list_object©r:   rU   r&   r'   r'   r(   Údecode_list_object  s    	ür  c                 K   s   t dddgddg| |d� d S )Nr  r  Z
StartAfterr  r  r  r  r  r'   r'   r(   Údecode_list_object_v2  s    ür  c                 K   s"   t ddddgdddg| |d� d S )	NZ	KeyMarkerZNextKeyMarkerr  r  )ZVersionsr~   )ZDeleteMarkersr~   r  r  r  r  r'   r'   r(   Údecode_list_object_versions#  s    üýór  c                 C   sr   |  d¡dkrn|  d¡rn| D ]}||krt|| ƒ||< q|D ].\}}||kr>|| D ]}t|| ƒ||< qVq>d S )Nr
  r¼   r  )r%   r   )r  r  r:   rU   r³   Ztop_keyZ	child_keyr×   r'   r'   r(   r  9  s    ÿr  c                 K   sN   d| krJt | d tƒr,tt| d ƒƒ| d< nt | d tƒrJt| d ƒ| d< d S )NZBody)r�   rc   r   r   r[   r{   r'   r'   r(   Ú convert_body_to_file_like_objectH  s
    r  c           	      C   sr   ddddœ}|  ¡ D ]X\}}| dd¡\}}t||ƒ}d| |jtf}d| d	 |jf}|  |¡ |  |¡ qd S )
NZFiltersZfromTimeZreturnFields)zec2.*.Filterzlogs.CreateExportTask.fromzcloudsearchdomain.Search.returnÚ.r   zbefore-parameter-build.zdocs.*.z.complete-section)rÖ   ÚrsplitÚParameterAliasÚalias_parameter_in_callÚREGISTER_FIRSTÚ alias_parameter_in_documentationrã   )	Zhandler_listÚaliasesÚoriginalÚnew_nameZevent_portionÚoriginal_nameZparameter_aliasZ#parameter_build_event_handler_tupleZdocs_event_handler_tupler'   r'   r(   Ú_add_parameter_aliasesP  s     ý
ý
þ
r&  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
r  c                 C   s   || _ || _d S r#   )Ú_original_nameÚ_alias_name)r’   r%  Z
alias_namer'   r'   r(   r“   r  s    zParameterAlias.__init__c                 K   sR   |j rN| j|j jkrN| j|krN| j|kr<t| j| j|jd�‚| | j¡|| j< d S )N)r#  ÚaliasZ	operation)rì   r'  rÕ   r(  r   rf   Úpop)r’   r-   re   r&   r'   r'   r(   r  v  s    

ýz&ParameterAlias.alias_parameter_in_callc                 K   sŽ   |  d¡rP| j|jkrd S | | j¡}| d¡}|  |¡ | d¡}|  |¡ n:|  d¡rŠ| d¡}| j|jkrtd S | | j¡}|  |¡ d S )Nzdocs.request-paramsr    z
param-namezdocs.request-exampler�   )rT   r'  Zavailable_sectionsr¢   Ú_replace_content)r’   r˜   r—   r&   r§   Zparam_type_sectionZparam_name_sectionr'   r'   r(   r!  †  s    





z/ParameterAlias.alias_parameter_in_documentationc                 C   s4   |  ¡  d¡}| | j| j¡}| ¡  | |¡ d S )Nr=   )Úgetvaluer\   r2   r'  r(  r£   r•   )r’   r—   rE   Zupdated_contentr'   r'   r(   r+  š  s     ÿzParameterAlias._replace_contentN)rš   r›   rœ   r“   r  r!  r+  r'   r'   r'   r(   r  q  s   r  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚClientMethodAliasc                 C   s
   || _ dS )zŸAliases a non-extant method to an existing method.

        :param actual_name: The name of the method that actually exists on
            the client.
        N)Ú_actual)r’   Zactual_namer'   r'   r(   r“   ¤  s    zClientMethodAlias.__init__c                 K   s   t || jƒS r#   )Úgetattrr.  )r’   Úclientr&   r'   r'   r(   Ú__call__¬  s    zClientMethodAlias.__call__N)rš   r›   rœ   r“   r1  r'   r'   r'   r(   r-  £  s   r-  c                   @   s>   e Zd ZdZe dej¡Zdd„ Zdd„ Z	dd„ Z
d	d
„ ZdS )ÚHeaderToHostHoisterz;Takes a header and moves it to the front of the hoststring.z(?!-)[a-z\d-]{1,63}(?<!-)$c                 C   s
   || _ d S r#   )Ú_header_name)r’   Úheader_namer'   r'   r(   r“   ¶  s    zHeaderToHostHoister.__init__c                 K   sJ   | j |d krdS |d | j  }|  |¡ |d }|  ||¡}||d< dS )a  Hoist a header to the hostname.

        Hoist a header to the beginning of the hostname with a suffix "." after
        it. The original header should be removed from the header map. This
        method is intended to be used as a target for the before-call event.
        r*   Nr¼   )r3  Ú_ensure_header_is_valid_hostÚ_prepend_to_host)r’   r-   r&   Úheader_valueÚoriginal_urlÚnew_urlr'   r'   r(   Úhoist¹  s    
zHeaderToHostHoister.hoistc                 C   s   | j  |¡}|stdd�‚d S )Nz`Hostnames must contain only - and alphanumeric characters, and between 1 and 63 characters long.ro   )Ú_VALID_HOSTNAMEÚmatchr   )r’   Úheaderr<  r'   r'   r(   r5  È  s
    þz0HeaderToHostHoister._ensure_header_is_valid_hostc                 C   sH   t |ƒ}|j d¡}|g| }d |¡}|j||j|jdf}t|ƒ}|S )Nr  r‰   )r   Únetlocrí   ÚjoinÚschemeÚpathÚqueryr   )r’   r¼   ÚprefixZurl_componentsÚpartsZ
new_netlocZnew_componentsr9  r'   r'   r(   r6  Ò  s    

ûz$HeaderToHostHoister._prepend_to_hostN)rš   r›   rœ   Ú__doc__ÚreÚcompileÚ
IGNORECASEr;  r“   r:  r5  r6  r'   r'   r'   r(   r2  ±  s   
r2  c                 K   s   | j s
d S | jj|d d< d S )Nr*   zx-amz-api-version)Zis_endpoint_discovery_operationZservice_modelÚapi_version)re   r-   r&   r'   r'   r(   Ú#inject_api_version_header_if_neededâ  s    rJ  c                 K   s   d| kr| d= dS )z>Operation requires h2 which is currently unsupported in PythonZstart_conversationNr'   )Zclass_attributesr&   r'   r'   r(   Ú remove_lex_v2_start_conversationè  s    rK  c                    sN   | j  d¡‰ ˆ sd S | j}ˆ d |d< d}‡ fdd„|D ƒ}d |¡|d< d S )	NÚretrieszinvocation-idzamz-sdk-invocation-id)ZttlÚattemptÚmaxc                    s&   g | ]}|ˆ kr|› d ˆ | › �‘qS )ú=r'   )ré   r³   ©Zretries_contextr'   r(   rê   õ  s   þz%add_retry_headers.<locals>.<listcomp>z; zamz-sdk-request)rU   r%   r*   r?  )rþ   r&   r*   Zsdk_retry_keysZsdk_request_headersr'   rP  r(   Úadd_retry_headersî  s    
þrQ  zchoose-service-namez/getattr.mturk.list_hi_ts_for_qualification_typeZ list_hits_for_qualification_typez$before-parameter-build.s3.UploadPartz#before-parameter-build.s3.PutObjectzcreating-client-classzcreating-client-class.s3zcreating-client-class.iot-dataz$creating-client-class.lex-runtime-v2zafter-call.iamzafter-call.ec2.GetConsoleOutputz%after-call.cloudformation.GetTemplatezafter-call.s3.GetBucketLocationzbefore-parameter-buildzbefore-parameter-build.s3z%before-parameter-build.s3.ListObjectsz'before-parameter-build.s3.ListObjectsV2z,before-parameter-build.s3.ListObjectVersionsz$before-parameter-build.s3.CopyObjectz(before-parameter-build.s3.UploadPartCopyz/before-parameter-build.s3.CreateMultipartUploadz%docs.*.s3.CopyObject.complete-sectionz)docs.*.s3.UploadPartCopy.complete-sectionzbefore-callzbefore-call.s3zbefore-call.glacierzbefore-call.apigatewayzbefore-call.s3.PutObjectzbefore-call.s3.UploadPartzbefore-call.s3.DeleteObjectsz.before-call.s3.PutBucketLifecycleConfigurationz!before-call.glacier.UploadArchivez'before-call.glacier.UploadMultipartPartzbefore-call.ec2.CopySnapshotzrequest-createdz'request-created.machinelearning.Predictzneeds-retry.s3.UploadPartCopyzneeds-retry.s3.CopyObjectz&needs-retry.s3.CompleteMultipartUploadz$choose-signer.cognito-identity.GetIdz-choose-signer.cognito-identity.GetOpenIdTokenz-choose-signer.cognito-identity.UnlinkIdentityz8choose-signer.cognito-identity.GetCredentialsForIdentityz$choose-signer.sts.AssumeRoleWithSAMLz+choose-signer.sts.AssumeRoleWithWebIdentityzchoose-signerz$before-parameter-build.s3.HeadObjectz#before-parameter-build.s3.GetObjectz'before-parameter-build.ec2.RunInstancesz<before-parameter-build.autoscaling.CreateLaunchConfigurationzbefore-parameter-build.route53zbefore-parameter-build.glacierzafter-call.s3.ListObjectszafter-call.s3.ListObjectsV2z after-call.s3.ListObjectVersionsz(request-created.cloudsearchdomain.Searchz!docs.*.glacier.*.complete-sectionrï   zJNote: this parameter is set to "-" bydefault if no value is not specified.z-docs.*.glacier.UploadArchive.complete-sectionrù   z3docs.*.glacier.UploadMultipartPart.complete-sectionzDdocs.request-params.glacier.CompleteMultipartUpload.complete-sectionz2docs.*.cloudformation.GetTemplate.complete-sectionz(docs.*.ec2.RunInstances.complete-sectionrÞ   z=docs.*.autoscaling.CreateLaunchConfiguration.complete-sectionz(docs.*.ec2.CopySnapshot.complete-sectionrÇ   r»   zdocs.*.s3.*.complete-sectionZSSECustomerKeyMD5ZCopySourceSSECustomerKeyMD5z1docs.*.lambda.UpdateFunctionCode.complete-sectionÚZipFilerP   Z
ContentMD5ZDeleteObjectsZPutBucketAclZPutBucketCorsZPutBucketLifecycleZPutBucketLoggingZPutBucketNotificationZPutBucketPolicyZPutBucketReplicationZPutBucketRequestPaymentZPutBucketTaggingZPutBucketVersioningZPutBucketWebsiteZPutObjectAclzcreating-client-class.rdsz%before-call.rds.CopyDBClusterSnapshotzbefore-call.rds.CreateDBClusterzbefore-call.rds.CopyDBSnapshotz+before-call.rds.CreateDBInstanceReadReplicaz:before-call.rds.StartDBInstanceAutomatedBackupsReplicationz1docs.*.rds.CopyDBClusterSnapshot.complete-sectionrÍ   z+docs.*.rds.CreateDBCluster.complete-sectionz*docs.*.rds.CopyDBSnapshot.complete-sectionz7docs.*.rds.CreateDBInstanceReadReplica.complete-sectionzFdocs.*.rds.StartDBInstanceAutomatedBackupsReplication.complete-sectionz)before-call.neptune.CopyDBClusterSnapshotz#before-call.neptune.CreateDBClusterz5docs.*.neptune.CopyDBClusterSnapshot.complete-sectionz/docs.*.neptune.CreateDBCluster.complete-sectionz'before-call.docdb.CopyDBClusterSnapshotz!before-call.docdb.CreateDBClusterz3docs.*.docdb.CopyDBClusterSnapshot.complete-sectionz-docs.*.docdb.CreateDBCluster.complete-sectionzdocs.title.sms-voicezpinpoint-sms-voice)rx   )yrE  rY   r¾   Úloggingr+   rF  rd   r  Úior   rQ   Zbotocore.authr   Zbotocore.compatr   r   r   r   r   r	   r
   r   r   r   r   Zbotocore.docs.utilsr   r   r   Zbotocore.exceptionsr   r   r   Zbotocore.signersr   r   r   Zbotocore.utilsr   r   r   r   r   r   r   r   r    r!   Ú	getLoggerrš   r5   Úobjectr   ZREGISTER_LASTrG  rq   Z_ACCESSPOINT_ARNZ_OUTPOST_ARNr?  rs   r·   r$   r)   r.   r3   r;   r4   rV   rb   rg   ri   rl   rw   r|   r}   rz   r€   r‡   r�   r�   r©   r®   r¬   rª   rÄ   rÆ   rÌ   rÎ   rÑ   rÐ   rÝ   rß   rä   rè   rî   rñ   ró   rõ   rø   rû   rü   rÿ   r  r	  r  r  r  r  r  r  r&  r  r-  r2  rJ  rK  rQ  Zdocument_auto_populated_paramZ
hide_paramr™   ZBUILTIN_HANDLERSr'   r'   r'   r(   Ú<module>   s:  4	

ÿÿ
	.



%	

	!	!21þýýþþþþýþþþþ	þþþþþþþþþÿþþóýþþþþþþþþþþþÿþ€ ƒ  