B -<`^@s:dZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#ddl!m$Z$ddl!m%Z%ddl!m&Z&ddl'm(Z(ddl'm)Z)ddl'm*Z*ddl'Z'ddl+Z'e,e-Z.e/Z0e/Z1e2dZ3dZ4dZ5e2d6e4e5gZ7e2dZ8ddiZ9ddZ:ddZ;d d!Zd&d'Z?d(d)Z@d*d+ZAd,d-ZBd.d/ZCd0d1ZDdd3d4ZEd5d6ZFd7d8ZGd9d:ZHGd;d<dZJd?d@ZKdAdBZLdCdDZMdEdFZNdGdHZOdIdJZPdKdLZQdMdNZRdOdPZSdQdRZTdSdTZUdUdVZVdWdXZWdYdZZXd[d\ZYd]d^ZZd_d`Z[dadbZ\dcddZ]dedfZ^dgdhZ_didjZ`dkdlZadmdnZbdodpZcdqdrZddsdtZedudvZfdwdxZgdydzZhGd{d|d|e/ZiGd}d~d~e/ZjGddde/ZkddZlde:fdejdfdege1fdege1fdefdefde`fdeRfde>fdeAfdeTfde?fdeBfdebfdebfdebfdeKfdeKfdeWfdeWfdeWfdeJfdeJfdeHfdeZfde[fde&fde&fde\fde\fdePfde_fde;e0fde;e0fde;e0fdeGfdeGfdeGfdeGfdeGfdeGfde=fdeCfdeCfdeCfdeCfdeDfdeCfdeCfdeCfdeDfdeUfdeUfdeXfdeYfdecfdedfdeefdeafdeddjmfdedjmfdedjmfde]fde^fdeVdfdeVdfdedƒjmfdedÃjmfdedŃjmfdedƃjmfdeVdȃfdedddddddddddddddg jnfdefdeQfdeQfdeQfdeQfdeQfded߃jmfded߃jmfded߃jmfded߃jmfded߃jmfdeQfdeQfded߃jmfded߃jmfdeQfdeQfded߃jmfded߃jmfdeIdjofdelfg]ZpehepdS)z_Builtin event handlers. This module contains builtin handlers for events emitted by botocore. N) unquotejsonsix unquote_str ensure_bytesget_md5 MD5_AVAILABLE OrderedDicturlsplit urlunsplit XMLParseErrorETree)AutoPopulatedParam)HideParamFromOperations)AppendParamDocumentation)add_generate_presigned_url)add_generate_presigned_post)add_generate_db_auth_token)ParamValidationError)AliasConflictParameterError)UnsupportedTLSVersionWarning)MissingServiceIdError)percent_encode SAFE_CHARS)switch_host_with_param)hyphenize_service_id)conditionally_calculate_md5) retryhandler)utils) translatez^[a-zA-Z0-9.\-_]{1,255}$zI^arn:(aws).*:s3:[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]+$zruntime.sagemakerzsagemaker-runtimecKs t||S)N)SERVICE_NAME_ALIASESget)Z service_namekwargsr$8/tmp/pip-target-7cdyy134/lib/python/botocore/handlers.pyhandle_service_name_aliasOsr&cKs2|dkr dS|\}}t|r.td|d|_dS)NzWError found for response with 200 status code, errors: %s, changing status code to 500.i)_looks_like_special_case_errorloggerdebug status_code)responser# http_responseparsedr$r$r%check_for_200_errorSsr.cCs\|jdkrXy*tjtdd}||j|}Wntk rHdSX|jdkrXdSdS)Nzutf-8)targetencodingTErrorF) r*r XMLParser TreeBuilderfeedcontentcloser tag)r,parserrootr$r$r%r'os    r'cKsR|d}|sdS|dkr tjS|drNd}|dkr:d}|dkrJd|d <|SdS) 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_typeNnoneZv4s3Zs3v4zv4-unsigned-bodyFZpayload_signing_enabled)r"botocoreUNSIGNED startswith)contextZ signing_namer#r;Zsignature_versionr$r$r%set_operation_specific_signers  rBc Ks^d|krZy(tt|ddd}||d<Wn(tttfk rXtj dddYnXdS)NZOutputzutf-8replacezError decoding base64T)exc_info) base64 b64decoderbdecode ValueError TypeErrorAttributeErrorr(r))r-r#valuer$r$r%decode_console_outputs rMcKsBx<|jD]2}||krtt||<td|||fqWdS)Nz1injecting idempotency token (%s) into param '%s'.)Zidempotent_membersstruuiduuid4r(r))paramsmodelr#namer$r$r%generate_idempotent_uuids  rTc Cs>ytt|}Wn&ttfk r8tjdddYnX|S)NzError loading quoted JSONT)rD)rloadsrrIrJr(r))rLr$r$r%decode_quoted_jsondocs rVc KsRd|krNytj|dtd}||d<Wn&ttfk rLtjdddYnXdS)N TemplateBody)object_pairs_hookzerror loading JSONT)rD)rrUr rIrJr(r))r-r#rLr$r$r%json_decode_template_bodys rYcKsHd|kr dS|d}t|sDt|sDd|tjtjf}t|ddS)NBucketzdInvalid bucket name "%s": Bucket name must match the regex "%s" or be an ARN matching the regex "%s")report) VALID_BUCKETsearch VALID_S3_ARNpatternr)rQr#bucket error_msgr$r$r%validate_bucket_namesrbcKst|ddS)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)rQr#r$r$r%sse_md5srecKst|ddS)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. ZCopySourceSSECustomerN)rd)rQr#r$r$r%copy_source_sse_md5srfrccCsxt||sdS|d}|d}||}t|tjr<|d}tt| d}t| d}|||<|||<dS)NKeyKeyMD5zutf-8) _needs_s3_sse_customization isinstancer text_typeencoderE b64encoderdigestrH)rQsse_member_prefixZsse_key_memberZsse_md5_memberZ key_as_bytesZ key_md5_strZkey_b64_encodedr$r$r%rds   rdcCs||ddk o|d|kS)Nrgrh)r")rQror$r$r%risricKstjS)zk This handler disables request signing by setting the signer name to a special sentinel value. )r>r?)r#r$r$r%disable_signingsrpcKsJ|jdddkrdSd|krF|d}t|drFtdd|dd <dS) Nmethod)PUTPOSTbodyreadz-Adding expect 100 continue header to request.z 100-continueheadersZExpect)httpr"hasattrr(r))rRrQr#rur$r$r%add_expect_headers  rzc@seZdZddZddZdS)DeprecatedServiceDocumentercCs ||_dS)N)_replacement_service_name)selfZreplacement_service_namer$r$r%__init__sz$DeprecatedServiceDocumenter.__init__cKs>|j|d|j|j|j|d|jdS)Nz.This service client is deprecated. Please use z instead.)styleZstart_importantwriterefr|Z end_important)r}section event_namer#r$r$r%inject_deprecation_notices   z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__ __module__ __qualname__r~rr$r$r$r%r{sr{c Ksd|kr:|d}|d}|d}||dnJd|kr|d}|d}||d|d }||d dS) Nzrequest-examplezstructure-value CopySourcez member-valuezH'string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'}zrequest-paramsz param-typez:type CopySource: str or dictzparam-documentationaqThe 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) rrr#parent param_line value_portion param_section type_sectionZ doc_sectionr$r$r%document_copy_source_form!s        rcKsJ|d}|dkrdSt|tjr0t||d<nt|trFt||d<dS)aHConvert 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. rN)r"rjr string_types_quote_source_headerdict_quote_source_header_from_dict)rQr#sourcer$r$r%handle_copy_source_paramDs   rc CsyB|d}|d}|d}t|r4d||f}n d||f}Wn4tk rv}ztdt|dWdd}~XYnXt|tdd }|dk r|d |7}|S) NrZrgZ VersionIdz %s/object/%sz%s/%szMissing required parameter: %s)r[/)safez ?versionId=%s)r"r^r]KeyErrorrrNrr)Z source_dictr`key version_idfinaler$r$r%r_s  " rcCs\t|}|dkr"t|tddS|d|||d}}t|tdd|SdS)Nr)r)VERSION_ID_SUFFIXr]rrstart)rLresultfirstrr$r$r%rqs  "rcCsLt|}||dd<|d|||d<d|d<i|d<|j|||jdS)NruDestinationRegionurlGETrqrw)Z region_nameZoperation_name)copydeepcopyrCZgenerate_presigned_urlrS)request_signer request_dictrR source_regiondestination_regionZrequest_dict_copyr$r$r%_get_cross_region_presigned_urlzs   rcCs|j}|d}||fS)N SourceRegion)Z _region_namer")rrQrrr$r$r%1_get_presigned_url_source_and_destination_regionss rcKsNd|dkrdSt||d\}}t|||||}||dd<||dd<dS)N PresignedUrlrur)rr)rQrrRr#srcdestrr$r$r%inject_presigned_url_ec2s  rcKs\d|dkrdSt||d\}}|dd=d|dkr'sz#fix_route53_ids..rz %s %s -> %s) input_shaperyrrsplitr(r))rQrRr#rrrSZ orig_valuer$r$r%fix_route53_idss rcKs|ddkrd|d<dS)N accountId-)r")rQr#r$r$r%inject_account_id1srcKs|}|jd|dd<dS)NZ apiVersionrwzx-amz-glacier-version)r)rRrQr#rr$r$r%add_glacier_version:srcKs(|ddddkr$|}d|dd<dS)NrwAcceptzapplication/json)r")rRrQr#rr$r$r%add_accept_header@srcKsz|}|d}|d}t|tjr*t|}|}d|krLtj|dd|d<||d|krlt||d<||dS)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. rwruzx-amz-content-sha256T)Zas_hexzx-amz-sha256-tree-hashN) rjr binary_typeBytesIOtellrZcalculate_sha256seekZcalculate_tree_hash)rQr#rrwruZstarting_positionr$r$r%add_glacier_checksumsFs    rcCsd}td|jS)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 `_. 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')) checksum)rr)docr$r$r%#document_glacier_tree_hash_checksumfs rcKsld|kr0|d}|d}||dn8d|krh|d}|d}|d}||ddS) Nzresponse-paramsrWz param-typez (*dict*) --zresponse-examplezstructure-valuez member-valuez{})rrr)rrr#Ztemplate_body_sectionrrrrr$r$r%0document_cloudformation_get_template_return_typews      rcKst|ddS)NZPredictEndpoint)r)requestr#r$r$r%switch_host_machinelearningsrcKsFddl}y$|j}|dkr*td|jtWntk r@YnXdS)Nr)rrzCurrently 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.)sslOPENSSL_VERSION_INFOwarningswarnOPENSSL_VERSIONrrK)r#rZopenssl_version_tupler$r$r%&check_openssl_supports_tls_version_1_2s rcKs>|jdkr:d|jkr:d|jd<d|_|jdd\|_|_dS)Nr?z!application/x-www-form-urlencodedz Content-Typertr)rqrrwrdata)rr#r$r$r%change_get_to_posts rcKsd|krd|d<d|d<dS)N EncodingTypeTencoding_type_auto_setrr$)rQrAr#r$r$r%"set_list_objects_encoding_type_urlsrcKstdddgddg||ddS)N DelimiterMarkerZ NextMarker)Contentsrg)CommonPrefixesPrefix)top_level_keys nested_keysr-rA)_decode_list_object)r-rAr#r$r$r%decode_list_objects rcKstdddgddg||ddS)NrrZ StartAfter)rrg)rr)rrr-rA)r)r-rAr#r$r$r%decode_list_object_v2s rcKs"tddddgdddg||ddS) NZ KeyMarkerZ NextKeyMarkerrr)ZVersionsrg)Z DeleteMarkersrg)rr)rrr-rA)r)r-rAr#r$r$r%decode_list_object_versionssrcCs~|ddkrz|drzx$|D]}||krt||||<qWx:|D]2\}}||krDx ||D]}t||||<q^WqDWdS)Nrrr)r"r)rrr-rArZtop_keyZ child_keyrr$r$r%rs  rcKsVd|krRt|dtjr0tt|d|d<n"t|dtjrRt|d|d<dS)NZBody)rjrrrrr)rQr#r$r$r% convert_body_to_file_like_objects rc Csvdddd}xd|D]X\}}|dd\}}t||}d||jtf}d|d |jf}||||qWdS) NZFiltersZfromTimeZ returnFields)z ec2.*.Filterzlogs.CreateExportTask.fromzcloudsearchdomain.Search.return.rzbefore-parameter-build.zdocs.*.z.complete-section)rrsplitParameterAliasalias_parameter_in_callREGISTER_FIRST alias_parameter_in_documentationr) Z handler_listaliasesoriginalnew_nameZ event_portion original_nameZparameter_aliasZ#parameter_build_event_handler_tupleZdocs_event_handler_tupler$r$r%_add_parameter_aliasess   rc@s,eZdZddZddZddZddZd S) rcCs||_||_dS)N)_original_name _alias_name)r}rZ alias_namer$r$r%r~szParameterAlias.__init__cKsR|jrN|j|jjkrN|j|krN|j|kreZdZdZedejZddZddZ ddZ d d Z d S) HeaderToHostHoisterz@Takes a header and moves it to the front of the hoststring. z(?!-)[a-z\d-]{1,63}(?rrrZ botocore.auth getLoggerrr(objectrZ REGISTER_LASTr)r\Z_ACCESSPOINT_ARNZ _OUTPOST_ARNr!r^rr!r&r.r'rBrMrTrVrYrbrerfrdrirprzr{rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr,Zdocument_auto_populated_paramZ hide_paramrZBUILTIN_HANDLERSr$r$r$r%s8                   !      #         1/