o
    "`^h                     @   s  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 ddlm Z 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+m,Z,m-Z-m.Z.m/Z/ ddl
m0Z0 ddl
m1Z1 ddlm2Z2 ddlm3Z3 ddl)m4Z4 ddl)m5Z5 ddl)m6Z6 e7e8Z9e: Z;e: Z<e=dZ>dZ?dZ@e=dAe?e@gZBdZCe=dZDdd ZEdd ZFdd ZGdd  ZHd!d" ZId#d$ ZJd%d& ZKd'd( ZLd)d* ZMd+d, ZNd-d. ZOd/d0 ZPd1d2 ZQd3d4 ZRdd6d7ZSd8d9 ZTd:d; ZUd<d= ZVG d>d? d?ZWd@dA ZXdBdC ZYdDdE ZZdFdG Z[dHdI Z\dJdK Z]dLdM Z^dNdO Z_dPdQ Z`dRdS ZadTdU ZbdVdW ZcdXdY ZddZd[ Zed\d] Zfd^d_ Zgd`da Zhdbdc Ziddde Zjdfdg Zkdhdi Zldjdk Zmdldm Zndndo Zodpdq Zpdrds Zqdtdu Zrdvdw Zsdxdy Ztdzd{ Zud|d} ZvG d~d dZwG dd dZxG dd dZydd Zzdd Z{dd Z|dd Z}dd Z~dd Zdd Zdd Zdd Zdd Zdd Zdd Zg deEfdexdfdeue<fdeue<fde(fde'fdenfde{fde|fde`fdeLfdeOfdebfdefdeMfdePfde~fdepfdepfdepfdeYfdeYfdeefdeefdeefdefdeXfdeXfdefdefdefdeFfdeVfdehfdeifde,fde-fdeGfde,fdeGfdejfdejfde^fde}fdemfdeHe;fdeHe;fdeHe;fdeUfdeUfdeUfdeUfdeUfdeUfdeJfdeQfdeQfdeQfdeQfdeRfdeQfdeQfdeQfdeRfdeQfdeQfdecfdecfdeffdegfdefdefdeqfderfdesfdeofdeddjfdedjfdedjfdek fdelfdeddfdeddfdedjfdedjfdedjfdedjfdeddfdeddg djfde&fde_fde_fde_fde_fde_fdedjfdedjfdedjfdedjfdedjfd e_fde_fdedjfdedjfde_fde_fdedjfdedjfdezfZeve 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)VALID_HOST_LABEL_RE)AliasConflictParameterErrorParamValidationErrorUnsupportedTLSVersionWarning)EndpointResolverBuiltins)add_generate_db_auth_tokenadd_generate_presigned_postadd_generate_presigned_url)
SAFE_CHARS	ArnParser conditionally_calculate_checksumconditionally_calculate_md5percent_encodeswitch_host_with_param)retryhandler)	translate)MD5_AVAILABLE)MissingServiceIdError)hyphenize_service_id)is_global_accesspoint)SERVICE_NAME_ALIASESz^[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}$|)s3zs3-outpostszs3-object-lambda	s3expressz\?versionId=[^\s]+$c                 K   s   t | | S N)r&   get)service_namekwargs r.   O/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/botocore/handlers.pyhandle_service_name_aliasi      r0   c                 K   sN   dt jv }t jd}|r!|r#| d }d|vr%t|dd|d< d S d S d S d S )NAWS_LAMBDA_FUNCTION_NAME_X_AMZN_TRACE_IDheaderszX-Amzn-Trace-Idz-=;:+&[]{}"',safe)osenvironr+   r
   )paramsr-   has_lambda_nametrace_idr4   r.   r.   r/   add_recursion_detection_headerm   s   
r<   c                 K   s<   | d }d|v r| dd}d|v r| dd}|| d< d S )Nbody   s   &#xD;   
s   &#xA;)replace)r9   r-   r=   r.   r.   r/   escape_xml_payloadv   s   rA   c                 K   s6   | d u rd S | \}}t |rtd| d|_d S 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   
rI   c                 C   s\   | j dkr,ztjt dd}|| j | }W n
 ty$   Y dS w |jdkr,dS dS )N   utf-8targetencodingTErrorF)	rE   r   	XMLParserTreeBuilderfeedcontentcloser   tag)rG   parserrootr.   r.   r/   rB      s   

rB   c                 K   s   |  d}|s	dS |dkrtjS |dkrdS |  ds|dkr#d| d< |d	r[|d
kr.|S |dkrNt| }||d}d| v rG| d | n|| d< d}nd	}|tv rYd| }|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nonebearerunsigned_payloadzv4-unsigned-bodyFpayload_signing_enabledv4zv4-s3expressv4a)regionsigning_namesigningr(   )r+   botocoreUNSIGNED
startswith_resolve_sigv4a_regionupdateS3_SIGNING_NAMES)contextr`   r-   rX   r_   ra   signature_versionr.   r.   r/   set_operation_specific_signer   s0   



rj   c                 C   s@   d }d| v r| d j }|s| di dr| d d }|pdS )Nclient_configra   r_   *)sigv4a_signing_region_setr+   )rh   r_   r.   r.   r/   re      s   
re   c              
   K   s`   d| v r.zt t| d ddd}|| d< W d S  tttfy-   tjddd Y d S w d S )NOutputzlatin-1rK   r@   zError decoding base64Texc_info)	base64	b64decodebytesdecode
ValueError	TypeErrorAttributeErrorrC   rD   rH   r-   valuer.   r.   r/   decode_console_output   s   rz   c                 K   sD   |j D ]}|| vrtt | |< td| |  d| d qd S )Nzinjecting idempotency token (z) into param 'z'.)idempotent_membersstruuiduuid4rC   rD   )r9   modelr-   namer.   r.   r/   generate_idempotent_uuid  s   
r   c              	   C   s<   z
t t| } W | S  ttfy   tjddd Y | S w )NzError loading quoted JSONTro   )r	   loadsr   ru   rv   rC   rD   )ry   r.   r.   r/   decode_quoted_jsondoc  s   r   c              	   K   sT   d| v r(zt j| d td}|| d< W d S  ttfy'   tjddd Y d S w d S )NTemplateBody)object_pairs_hookzerror loading JSONTro   )r	   r   r   ru   rv   rC   rD   rx   r.   r.   r/   json_decode_template_body  s   r   c                 K   sV   d| vrd S | d }t |s't|s)d| dt j dtj d}t|dd S 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   )r9   r-   bucket	error_msgr.   r.   r/   validate_bucket_name  s   
r   c                 K      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r9   r-   r.   r.   r/   sse_md5,     r   c                 K   r   )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.
    CopySourceSSECustomerNr   r   r.   r.   r/   copy_source_sse_md56  r   r   r   c                 C   sv   t | |sd S |d }|d }| | }t|tr|d}tt| d}t|d}|| |< || |< d S )NKeyKeyMD5rK   )	_needs_s3_sse_customization
isinstancer|   encoderq   	b64encoder   digestrt   )r9   sse_member_prefixsse_key_membersse_md5_memberkey_as_byteskey_md5_strkey_b64_encodedr.   r.   r/   r   @  s   


r   c                 C   s   |  |d d uo|d | vS )Nr   r   r+   )r9   r   r.   r.   r/   r   Q  s   
r   c                  K   s   t jS )zk
    This handler disables request signing by setting the signer
    name to a special sentinel value.
    )rb   rc   )r-   r.   r.   r/   disable_signingX  s   r   c                 K   s|   | j dddvrd S d|v r:|d }t|dr<ttjdd}|r-t|dkr-d S t	d	 d
|d d< d S d S d S )Nmethod )PUTPOSTr=   read$BOTO_EXPERIMENTAL__NO_EMPTY_CONTINUEFr   z-Adding expect 100 continue header to request.z100-continuer4   Expect)
httpr+   hasattrr   ensure_booleanr7   r8   determine_content_lengthrC   rD   )r   r9   r-   r=   
check_bodyr.   r.   r/   add_expect_header`  s"   

r   c                   @      e Zd Zdd Zdd ZdS )DeprecatedServiceDocumenterc                 C   
   || _ d S r*   )_replacement_service_name)selfreplacement_service_namer.   r.   r/   __init__u     
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.)stylestart_importantwriterefr   end_important)r   section
event_namer-   r.   r.   r/   inject_deprecation_noticex  s   


z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__
__module____qualname__r   r   r.   r.   r.   r/   r   t  s    r   c           	      K   s   d|v r|  d}| d}| d}|  |d d S d|v rE|  d}| d}|  |d | d	}|  |d
 d S 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 dict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_sectiondoc_sectionr.   r.   r/   document_copy_source_form  s&   






r   c                 K   sN   |  d}|du rdS t|trt|| d< dS t|tr%t|| d< dS 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   r|   _quote_source_headerdict_quote_source_header_from_dict)r9   r-   sourcer.   r.   r/   handle_copy_source_param  s   


r   c              
   C   s   z#| d }| d }|  d}t|r| d| }n| d| }W n ty9 } z
tdt| dd }~ww t|td d}|d urM|d	| 7 }|S )
Nr   r   	VersionIdz/object//zMissing required parameter: r   r5   z?versionId=)r+   r   r   KeyErrorr   r|   r   r   )source_dictr   key
version_idfinaler.   r.   r/   r     s$   

r   c                 C   sX   t | }|d u rt| td dS | d |  | | d  }}t|td d| S )Nr   r5   )VERSION_ID_SUFFIXr   r   r   start)ry   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   r4   )region_nameoperation_name)copydeepcopyr@   generate_presigned_urlr   )request_signerrequest_dictr   source_regiondestination_regionrequest_dict_copyr.   r.   r/   _get_cross_region_presigned_url  s   
r   c                 C   s   | j }|d}||fS )NSourceRegion)_region_namer+   )r   r9   r   r   r.   r.   r/   1_get_presigned_url_source_and_destination_regions  s   
r   c                 K   sN   d| d v rd S t || d \}}t|| |||}|| d d< || d d< d S )NPresignedUrlr=   r   r   r   r9   r   r   r-   srcdestr   r.   r.   r/   inject_presigned_url_ec2  s   
r   c                 K   s\   d| d vrd S t || d \}}| d d= d| d v 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 urt| |j  d S d S r*   )output_shape_decode_policy_types)rH   r   r-   r  r.   r.   r/   json_decode_policies%  s   r  c                 C   s   d}|j dkr3|j D ]&\}}|j dkr'|j|kr'|| v r't| | | |< q|| v r2t| | | q|j dkrE|j}| D ]	}t|| q=d S d S )NpolicyDocumentType	structurestringlist)	type_namemembersitemsr   r   r  member)rH   shape
shape_namemember_namemember_shapeshape_memberitemr.   r.   r/   r  1  s$   




r  c                 K   sJ   |j d u rd S |j}tjt dd}|| | }|j}|| d< d S )NrK   rL   LocationConstraint)rawrS   r   rP   rQ   rR   rT   text)rH   rG   r-   response_bodyrV   rW   r_   r.   r.   r/   parse_get_bucket_locationG  s   

r  c                 K   sH   d| v r"t | d tr| d d| d< t| d d| d< d S d S )NUserDatarK   )r   r|   r   rq   r   rt   r   r.   r.   r/   base64_encode_user_dataW  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   append_documentation)paramdescriptionappendr.   r.   r/   document_base64_encodinga  s   
r   c              	   K   st   |  d}|rt|tsdS | D ]%\}}z|d |d W q ty7   d| d| d}t|dw 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."

    MetadataNasciiz3Non ascii characters found in S3 metadata for key "z", value: "z4".  
S3 metadata can only contain ASCII characters. r   )r+   r   r   r  r   UnicodeEncodeErrorr   )r9   r-   metadatar   ry   r   r.   r.   r/   validate_ascii_metadatak  s"   



r%  c                 K   sp   |j }|r
t|dsdS dd |j D }|D ]}|| v r5| | }|dd | |< td||| |  qd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 v r|qS ))
ResourceIdDelegationSetIdChangeId)r   ).0r   r  r.   r.   r/   
<listcomp>  s
    
z#fix_route53_ids.<locals>.<listcomp>r   z%s %s -> %s)input_shaper   r  r  splitrC   rD   )r9   r   r-   r,  r  r   
orig_valuer.   r.   r/   fix_route53_ids  s   r/  c                 K   s   |  dd u rd| d< d S d S )N	accountId-r   r   r.   r.   r/   inject_account_id  s   r2  c                 K   s   |}| j d |d d< d S )N
apiVersionr4   zx-amz-glacier-version)r$  r   r9   r-   r   r.   r.   r/   add_glacier_version  s   r5  c                 K   s,   |d  dd d u r|}d|d d< d S d S )Nr4   Acceptzapplication/jsonr   r4  r.   r.   r/   add_accept_header  s   r7  c                 K   sv   | }|d }|d }t |trt|}| }d|vr$tj|dd|d< || d|vr4t||d< || dS )zAdd 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.

    r4   r=   zx-amz-content-sha256T)as_hexzx-amz-sha256-tree-hashN)r   rs   r   tellr   calculate_sha256seekcalculate_tree_hash)r9   r-   r   r4   r=   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   rA  c                 K   sr   d|v r|  d}| d}|  |d d S d|v r7|  d}| d}| d}|  |d d S d S )	Nresponse-paramsr   r   z(*dict*) --response-exampler   r   z{}r   )r   r   r-   template_body_sectionr   r   r   r   r.   r.   r/   0document_cloudformation_get_template_return_type  s   




rE  c                 K   s   t | d d S )NPredictEndpoint)r   requestr-   r.   r.   r/   switch_host_machinelearning  s   rI  c                  K   sN   dd l }z|j}|dk rtd|j dt W d S W d S  ty&   Y d S w )Nr   )   r   rJ  z%Currently installed openssl version: z 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   rw   )r-   rK  openssl_version_tupler.   r.   r/   &check_openssl_supports_tls_version_1_2  s   

rQ  c                 K   sF   | j dkrd| jv r!d| jd< d| _ | jdd\| _| _d S d S d S )Nr   ?z!application/x-www-form-urlencodedContent-Typer   rJ  )r   r   r4   r-  datarG  r.   r.   r/   change_get_to_post  s
   
rU  c                 K   s    d| vrd|d< d| d< d S d S )NEncodingTypeTencoding_type_auto_setr   r.   )r9   rh   r-   r.   r.   r/   "set_list_objects_encoding_type_url  s   rX  c                 K      t g dddg| |d d S )N)	DelimiterMarker
NextMarkerContentsr   CommonPrefixesPrefixtop_level_keysnested_keysrH   rh   _decode_list_objectrH   rh   r-   r.   r.   r/   decode_list_object"  s   	
rh  c                 K   rY  )N)rZ  ra  
StartAfterr]  r_  rb  re  rg  r.   r.   r/   decode_list_object_v23  s   
rj  c                 K   s   t g dg d| |d d S )N)	KeyMarkerNextKeyMarkerra  rZ  ))Versionsr   )DeleteMarkersr   r_  rb  re  rg  r.   r.   r/   decode_list_object_versions@  s   
ro  c                 C   sz   | ddkr7| dr9| D ]}||v rt|| ||< q|D ]\}}||v r6|| D ]
}t|| ||< q+qd S d S d S )NrV  r   rW  )r+   r   )rc  rd  rH   rh   r   top_key	child_keyr  r.   r.   r/   rf  V  s   rf  c                 K   sX   d| v r(t | d trtt| d | d< d S t | d tr*t| d | d< d S d S d S )NBody)r   r|   r   r   rs   r   r.   r.   r/    convert_body_to_file_like_objecte  s   rs  c           	      C   sr   dddd}|  D ],\}}|dd\}}t||}d| |jtf}d| d	 |jf}| | | | q
d S )
NFiltersfromTimereturnFields)zec2.*.Filterzlogs.CreateExportTask.fromzcloudsearchdomain.Search.return.rJ  zbefore-parameter-build.zdocs.*.z.complete-section)r  rsplitParameterAliasalias_parameter_in_callREGISTER_FIRST alias_parameter_in_documentationr  )	handler_listaliasesoriginalnew_nameevent_portionoriginal_nameparameter_alias#parameter_build_event_handler_tupledocs_event_handler_tupler.   r.   r/   _add_parameter_aliasesm  s"   


r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ry  c                 C   s   || _ || _d S r*   )_original_name_alias_name)r   r  
alias_namer.   r.   r/   r     s   
zParameterAlias.__init__c                 K   s^   |j r)| j|j jv r+| j|v r-| j|v rt| j| j|jd|| j|| j< d S d S d S d S )N)r  alias	operation)r,  r  r  r  r   r   pop)r   r9   r   r-   r.   r.   r/   rz    s   

z&ParameterAlias.alias_parameter_in_callc                 K   s   | dr)| j|jvrd S || j}|d}| | |d}| | d S | drH|d}| j|jvr;d S || j}| | d S d S )Nzdocs.request-paramsr   z
param-namezdocs.request-exampler   )rd   r  available_sectionsr   _replace_content)r   r   r   r-   r   param_type_sectionparam_name_sectionr.   r.   r/   r|    s   





z/ParameterAlias.alias_parameter_in_documentationc                 C   s4   |  d}|| j| j}|  || d S )NrK   )getvaluert   r@   r  r  r   r   )r   r   rS   updated_contentr.   r.   r/   r    s   zParameterAlias._replace_contentN)r   r   r   r   rz  r|  r  r.   r.   r.   r/   ry    s
    ry  c                   @   r   )ClientMethodAliasc                 C   s
   || _ dS )zAliases 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   actual_namer.   r.   r/   r     s   
zClientMethodAlias.__init__c                 K   s   t || jS r*   )getattrr  )r   clientr-   r.   r.   r/   __call__  r1   zClientMethodAlias.__call__N)r   r   r   r   r  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   r   r*   )_header_name)r   header_namer.   r.   r/   r     r   zHeaderToHostHoister.__init__c                 K   sJ   | j |d v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.
        r4   Nr   )r  _ensure_header_is_valid_host_prepend_to_host)r   r9   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.r   )_VALID_HOSTNAMEmatchr   )r   headerr  r.   r.   r/   r    s   z0HeaderToHostHoister._ensure_header_is_valid_hostc                 C   sH   t |}|jd}|g| }d|}|j||j|jdf}t|}|S )Nrw  r   )r   netlocr-  joinschemepathqueryr   )r   r   prefixurl_componentsparts
new_netlocnew_componentsr  r.   r.   r/   r    s   

z$HeaderToHostHoister._prepend_to_hostN)r   r   r   __doc__recompile
IGNORECASEr  r   r  r  r  r.   r.   r.   r/   r    s    
r  c                 K   s   | j sd S | jj|d d< d S )Nr4   zx-amz-api-version)is_endpoint_discovery_operationservice_modelapi_version)r   r9   r-   r.   r.   r/   #inject_api_version_header_if_needed  s   r  c                 K      d| v r	| d= dS dS )>Operation requires h2 which is currently unsupported in Pythonstart_conversationNr.   class_attributesr-   r.   r.   r/    remove_lex_v2_start_conversation     
r  c                 K   r  )r  chatNr.   r  r.   r.   r/   remove_qbusiness_chat  r  r  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)ttlattemptmaxc                    s&   g | ]}| v r| d  |  qS )=r.   )r)  r   retries_contextr.   r/   r*    s
    z%add_retry_headers.<locals>.<listcomp>z; zamz-sdk-request)rh   r+   r4   r  )rH  r-   r4   sdk_retry_keyssdk_request_headersr.   r  r/   add_retry_headers  s   
r  c                 K   sd   |j d }d}||r0|t|d |j d< |dd }||k}|r)| dn||j d< dS dS )a  Strips leading `{Bucket}/` from any operations that have it.

    The original value is retained in a separate "authPath" field. This is
    used in the HmacV1Auth signer. See HmacV1Auth.canonical_resource in
    botocore/auth.py for details.

    This change is applied to the operation model during the first time the
    operation is invoked and then stays in effect for the lifetime of the
    client object.

    When the ruleset based endpoint resolver is in effect, both the endpoint
    ruleset AND the service model place the bucket name in the final URL.
    The result is an invalid URL. This handler modifies the operation model to
    no longer place the bucket name. Previous versions of botocore fixed the
    URL after the fact when necessary. Since the introduction of ruleset based
    endpoint resolution, the problem exists in ALL URLs that contain a bucket
    name and can therefore be addressed before the URL gets assembled.
    
requestUriz	/{Bucket}NrR  r   r   authPath)r   rd   lenr-  )r9   r   rh   r-   req_uribucket_pathneeds_slashr.   r.   r/   'remove_bucket_from_url_paths_from_model   s   

r  c                 K   sJ   t dd |jD }|jdur|jddkr!|r#|jd= dS dS dS dS )aP  Removes the `{AccountId}.` prefix from the operation model.

    This change is applied to the operation model during the first time the
    operation is invoked and then stays in effect for the lifetime of the
    client object.

    When the ruleset based endpoint resolver is in effect, both the endpoint
    ruleset AND the service model place the {AccountId}. prefix in the URL.
    The result is an invalid endpoint. This handler modifies the operation
    model to remove the `endpoint.hostPrefix` field while leaving the
    `RequiresAccountId` static context parameter in place.
    c                 s   s$    | ]}|j d ko|jdu V  qdS )RequiresAccountIdTN)r   ry   )r)  	ctx_paramr.   r.   r/   	<genexpr>O  s
    
z6remove_accid_host_prefix_from_model.<locals>.<genexpr>N
hostPrefixz{AccountId}.)anystatic_context_parametersendpointr+   )r9   r   rh   r-   has_ctx_paramr.   r.   r/   #remove_accid_host_prefix_from_modelB  s   
r  c                 K   sp   | j }t|tr0|dr2|d}t|dkr4tt|d r6d	dg|dd  | _ d S d S d S d S d S )Nz/arn%3Ar   rJ  r      )
	auth_pathr   r|   rd   r-  r  r   is_arnr   r  )rH  r-   r  auth_path_partsr.   r.   r/   remove_arn_from_signing_path[  s   

r  c           	      K   s   | d}|duot|}|jdkrd| tj< n|r d| tj< |duo)t| }| tj }| drK|sM|sO|sQt	|sSd| tj
< d| tj< dS dS dS dS dS dS )a  Modify builtin parameter values for endpoint resolver

    Modifies the builtins dict in place. Changes are in effect for one call.
    The corresponding event is emitted only if at least one builtin parameter
    value is required for endpoint resolution for the operation.
    r   NGetBucketLocationTFuse_global_endpointz
aws-global)r+   r   r  r   r   AWS_S3_FORCE_PATH_STYLEr   r  r   is_s3express_bucket
AWS_REGIONAWS_S3_USE_GLOBAL_ENDPOINT)	builtinsr   r9   rh   r-   bucket_namebucket_is_arnpath_style_requiredpath_style_requestedr.   r.   r/   $customize_endpoint_resolver_builtinse  s0   
	


r  c                 K   s.   | j ddu rd| jv r| jd= d S d S d S )Nis_presign_requestTrS  )rh   r+   r4   rG  r.   r.   r/   )remove_content_type_header_for_presigning  s
   
r  c              	   K   sv   t | jr7|di d }r9||d< zt| W d S  ttfy6   td| d |d d= Y d S w d S d S )Nr4   ExpiresExpiresStringz5Failed to parse the "Expires" member as a timestamp: zH. The unparsed value is available in the response under "ExpiresString".)	_has_expires_shaper  r+   r   parse_timestampru   RuntimeErrorrC   warning)operation_modelresponse_dictcustomized_response_dictr-   expires_valuer.   r.   r/   handle_expires_header  s   

r  c                 C   s    | sdS t dd | j D S )NFc                 s   s*    | ]}|j d ko|jdd kV  qdS )r  r   N)r   serializationr+   )r)  r  r.   r.   r/   r    s    

z%_has_expires_shape.<locals>.<genexpr>)r  r  values)r  r.   r.   r/   r    s
   r  c           	      K   s   d|v r2|  dsd S | d}| dsd S |d}|d |d}|d |j  d S d|v rv|  ds=d S | d}|d}|j  |d |j  |d}|j  |d	 |j	  |j  |d
 d S d S )NrC  r   r  r  z'ExpiresString': 'string',rB  r   zFThis member has been deprecated. Please use ``ExpiresString`` instead.z!- **ExpiresString** *(string) --*z1The raw, unparsed value of the ``Expires`` field.)
has_sectionr   add_new_sectionr   r   new_line
start_noteend_notenew_paragraphindent)	r   r   r-   r   r   new_param_liner   r   new_param_sectionr.   r.   r/   document_expires_shape  s<   
















r  zchoose-service-namez/getattr.mturk.list_hi_ts_for_qualification_type 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creating-client-class.qbusinesszafter-call.iamzafter-call.ec2.GetConsoleOutputz%after-call.cloudformation.GetTemplatezafter-call.s3.GetBucketLocationzbefore-parse.s3.*z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!before-parameter-build.s3-controlz%docs.*.s3.CopyObject.complete-sectionz)docs.*.s3.UploadPartCopy.complete-sectionz+docs.response-example.s3.*.complete-sectionz*docs.response-params.s3.*.complete-sectionzbefore-endpoint-resolution.s3z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.GetObjectz1before-parameter-build.s3.CompleteMultipartUploadz-before-parameter-build.s3.SelectObjectContentz'before-parameter-build.ec2.RunInstancesz<before-parameter-build.autoscaling.CreateLaunchConfigurationzbefore-parameter-build.route53zbefore-parameter-build.glacierzbefore-sign.s3z"before-sign.polly.SynthesizeSpeechzafter-call.s3.ListObjectszafter-call.s3.ListObjectsV2z after-call.s3.ListObjectVersionsz(request-created.cloudsearchdomain.Searchz!docs.*.glacier.*.complete-sectionr0  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-sectionSSECustomerKeyMD5CopySourceSSECustomerKeyMD5z1docs.*.lambda.UpdateFunctionCode.complete-sectionZipFiler(   
ContentMD5)DeleteObjectsPutBucketAclPutBucketCorsPutBucketLifecyclePutBucketLoggingPutBucketNotificationPutBucketPolicyPutBucketReplicationPutBucketRequestPaymentPutBucketTaggingPutBucketVersioningPutBucketWebsite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-section)r   )r  rq   r   loggingr7   r  r}   rM  ior   rb   botocore.authr   botocore.compatr   r   r   r   r   r	   r
   r   r   r   r   botocore.docs.utilsr   r   r   botocore.endpoint_providerr   botocore.exceptionsr   r   r   botocore.regionsr   botocore.signersr   r   r   botocore.utilsr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   	getLoggerr   rC   objectr{  REGISTER_LASTr  r   _ACCESSPOINT_ARN_OUTPOST_ARNr  r   rg   r   r0   r<   rA   rI   rB   rj   re   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/  r2  r5  r7  r>  rA  rE  rI  rQ  rU  rX  rh  rj  ro  rf  rs  r  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  document_auto_populated_param
hide_paramBUILTIN_HANDLERSr.   r.   r.   r/   <module>   s  4 



	5		

%	

	!	!21"
.
)"&)*+,.123456789:;<=>?@ABCDEFHLMNPSTUVWXYZ[\]^_`acfghjmnoqt|    
          !  &  -  2  J  K  L  M  N  P  U  Y  ]  a  e  k  l  o  s  y  z  }           