B w\Gi@sdZddlZddlZddlZddlZddlZddlZddlZddl 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&Z&ddl*Z&e+e,Z-e.Z/e.Z0e1dZ2e1dZ3ddiZ4ddZ5ddZ6ddZ7ddZ8d d!Z9d"d#Z:d$d%Z;d&d'Zd,d-Z?d.d/Z@d0d1ZAd2d3ZBd4d5ZCdd7d8ZDd9d:ZEd;d<ZFd=d>ZGd?d@ZHdAdBZIdCdDZJGdEdFdFe.ZKdGdHZLdIdJZMdKdLZNdMdNZOdOdPZPdQdRZQdSdTZRdUdVZSdWdXZTdYdZZUd[d\ZVd]d^ZWd_d`ZXdadbZYdcddZZdedfZ[dgdhZ\didjZ]dkdlZ^dmdnZ_dodpZ`dqdrZadsdtZbdudvZcdwdxZddydzZed{d|Zfd}d~ZgddZhddZiGddde.ZjGddde.ZkGddde.ZlddZmde5fdekdfdehe0fdehe0fdefdefdebfdeTfde9fdeytt|}Wn&ttfk r8tjdddYnX|S)NzError loading quoted JSONT)rD)rloadsrrIrJr%r&)rLr!r!r"decode_quoted_jsondocs rUc KsRd|krNytj|dtd}||d<Wn&ttfk rLtjdddYnXdS)N TemplateBody)object_pairs_hookzerror loading JSONT)rD)rrTr rIrJr%r&)r*r rLr!r!r"json_decode_template_bodys rXcKs`|}|dr\d|dkr\|d}t|ttfr8t|}nt|}t|d}||dd<dS)Nbodyz Content-MD5headersascii) isinstancebytes bytearray_calculate_md5_from_bytes_calculate_md5_from_filerE b64encoderH)rPr request_dictrYZ binary_md5Z base64_md5r!r!r" calculate_md5s rccCst|}|S)N)rdigest)Z body_bytesmd5r!r!r"r_sr_csF}t}x$tfdddD]}||q"W||S)Ncs dS)Ni)readr!)fileobjr!r"sz*_calculate_md5_from_file..)tellriterupdateseekrd)rgZstart_positionrechunkr!)rgr"r`s  r`cKstrt|f|dS)z1Only add a Content-MD5 if the system supports it.N)rrc)rPrArequest_signerr r!r!r"conditionally_calculate_md5srpcKs>d|kr dS|d}t|dkr:d|tjf}t|ddS)NBucketz?Invalid bucket name "%s": Bucket name must match the regex "%s")report) VALID_BUCKETsearchpatternr)rPr bucket error_msgr!r!r"validate_bucket_names rxcKst|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)rPr r!r!r"sse_md5sr{cKst|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)rz)rPr r!r!r"copy_source_sse_md5sr|rycCsxt||sdS|d}|d}||}t|tjr<|d}tt| d}t| d}|||<|||<dS)NKeyKeyMD5zutf-8) _needs_s3_sse_customizationr\r text_typeencoderErarrdrH)rPsse_member_prefixZsse_key_memberZsse_md5_memberZ key_as_bytesZ key_md5_strZkey_b64_encodedr!r!r"rzs   rzcCs||ddk o|d|kS)Nr}r~)r)rPrr!r!r"rsrc Ks|d}|did}|dkr4td|dS|did}|dkrXt|dt|}t||}|srdStd|t||} d|} |j d || | d t |||dS) NZ data_loadermetadataZendpointPrefixzSNot registering retry handlers, could not endpoint prefix from model for service %sZ serviceId)rz*Registering retry handlers for service: %szretry-config-%szneeds-retry.%s) unique_id) Z get_componentrr%r&rr_load_retry_configrcreate_retry_handlerregister_register_for_operations) Z service_datasessionrr loaderendpoint_prefixZ service_idservice_event_nameconfighandlerrr!r!r"register_retries_for_services(      rcCs(|d}t||d|di}|S)NZ_retryretryZ definitions)Z load_datarZbuild_retry_configr)rrZoriginal_configZ retry_configr!r!r"r+s  rcCsLxF|D]>}|dkrqt||}d||f}|jd||f||dqWdS)NZ __default__zretry-config-%s-%szneeds-retry.%s.%s)r)rrr)rrrkeyrrr!r!r"r3s   rcKstjS)zk This handler disables request signing by setting the signer name to a special sentinel value. )r>r?)r r!r!r"disable_signingAsrcKsJ|jdddkrdSd|krF|d}t|drFtdd|dd <dS) Nmethod)PUTPOSTrYrfz-Adding expect 100 continue header to request.z 100-continuerZZExpect)httprhasattrr%r&)rQrPr rYr!r!r"add_expect_headerIs  rc@seZdZddZddZdS)DeprecatedServiceDocumentercCs ||_dS)N)_replacement_service_name)selfZreplacement_service_namer!r!r"__init__Vsz$DeprecatedServiceDocumenter.__init__cKs>|j|d|j|j|j|d|jdS)Nz.This service client is deprecated. Please use z instead.)styleZstart_importantwriterefrZ end_important)rsection event_namer r!r!r"inject_deprecation_noticeYs   z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__ __module__ __qualname__rrr!r!r!r"rUsrc 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-documentationa9The 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.) get_section clear_textr) rrr parent param_line value_portion param_section type_sectionZ doc_sectionr!r!r"document_copy_source_formds        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)rr\r string_types_quote_source_headerdict_quote_source_header_from_dict)rPr sourcer!r!r"handle_copy_source_params   rc Csy*|d}t|dtdd}|d}Wn4tk r^}ztdt|dWdd}~XYnXd||f}|dk r|d |7}|S) Nrqr}/)safeZ VersionIdzMissing required parameter: %s)rrz%s/%sz ?versionId=%s)rrrKeyErrorrrN)Z source_dictrvr version_idefinalr!r!r"rs"  rcCs\t|}|dkr"t|tddS|d|||d}}t|tdd|SdS)Nr)r)VERSION_ID_SUFFIXrtrrstart)rLresultfirstrr!r!r"rs  "rcCsLt|}||dd<|d|||d<d|d<i|d<|j|||jdS)NrYDestinationRegionurlGETrrZ)Z region_nameZoperation_name)copydeepcopyrCZgenerate_presigned_urlrR)rorbrQ source_regiondestination_regionZrequest_dict_copyr!r!r"_get_cross_region_presigned_urls   rcCs|j}|d}||fS)N SourceRegion)Z _region_namer)rorPrrr!r!r"1_get_presigned_url_source_and_destination_regionss rcKsNd|dkrdSt||d\}}t|||||}||dd<||dd<dS)N PresignedUrlrYr)rr)rProrQr srcdestrr!r!r"inject_presigned_url_ec2s  rcKs\d|dkrdSt||d\}}|dd=d|dkrasz#fix_route53_ids..rz %s %s -> %s) input_shaperrrsplitr%r&)rPrQr rrrRZ orig_valuer!r!r"fix_route53_idsVs rcKs|ddkrd|d<dS)N accountId-)r)rPr r!r!r"inject_account_idksrcKs|}|jd|dd<dS)NZ apiVersionrZzx-amz-glacier-version)r)rQrPr rbr!r!r"add_glacier_versiontsrcKs(|ddddkr$|}d|dd<dS)NrZAcceptzapplication/json)r)rQrPr rbr!r!r"add_accept_headerzsrcKsz|}|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. rZrYzx-amz-content-sha256T)Zas_hexzx-amz-sha256-tree-hashN) r\r binary_typeBytesIOrjrZcalculate_sha256rmZcalculate_tree_hash)rPr rbrZrYZstarting_positionr!r!r"add_glacier_checksumss    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_checksums rcKsld|kr0|d}|d}||dn8d|krh|d}|d}|d}||ddS) Nzresponse-paramsrVz param-typez (*dict*) --zresponse-examplezstructure-valuez member-valuez{})rrr)rrr Ztemplate_body_sectionrrrrr!r!r"0document_cloudformation_get_template_return_types      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-Typerr)rrrZrdata)rr r!r!r"change_get_to_posts rcKsd|krd|d<d|d<dS)N EncodingTypeTencoding_type_auto_setrr!)rPrAr r!r!r""set_list_objects_encoding_type_urlsrcKstdddgddg||ddS)N DelimiterMarkerZ NextMarker)Contentsr})CommonPrefixesPrefix)top_level_keys nested_keysr*rA)_decode_list_object)r*rAr r!r!r"decode_list_objects rcKstdddgddg||ddS)Nrr Z StartAfter)r r})r r )r rr*rA)r)r*rAr r!r!r"decode_list_object_v2s rcCs~|ddkrz|drzx$|D]}||krt||||<qWx:|D]2\}}||krDx ||D]}t||||<q^WqDWdS)Nrrr)rr)r rr*rArZtop_keyZ child_keyrr!r!r"rs  rcKsVd|krRt|dtjr0tt|d|d<n"t|dtjrRt|d|d<dS)NZBody)r\rrrrr)rPr 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)rrZ alias_namer!r!r"r;szParameterAlias.__init__cKsR|jrN|j|jjkrN|j|krN|j|krrrrZ botocore.auth getLoggerrr%objectrZ REGISTER_LASTcompilersrrr#r+r$rBrMrSrUrXrcr_r`rprxr{r|rzrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr$r)r9Zdocument_auto_populated_paramZ hide_paramr/rZBUILTIN_HANDLERSr!r!r!r"s0                   !                  1 $