U 3_,[@sdZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZmZmZmZmZmZmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lm Z dd 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/e0Z1e0Z2e3dZ4e3dZ5e3dZ6ddiZ7ddZ8ddZ9ddZ:d d!Z;d"d#Zd(d)Z?d*d+Z@d,d-ZAd.d/ZBdd1d2ZCd3d4ZDd5d6ZEd7d8ZFGd9d:d:e0ZGd;d<ZHd=d>ZId?d@ZJdAdBZKdCdDZLdEdFZMdGdHZNdIdJZOdKdLZPdMdNZQdOdPZRdQdRZSdSdTZTdUdVZUdWdXZVdYdZZWd[d\ZXd]d^ZYd_d`ZZdadbZ[dcddZ\dedfZ]dgdhZ^didjZ_dkdlZ`dmdnZadodpZbdqdrZcdsdtZddudvZedwdxZfGdydzdze0ZgGd{d|d|e0ZhGd}d~d~e0ZiddZjde8fdehdfdeee2fdeee2fdefdefde^fdePfde|jD]2}||krtt||<td|||fqdS)Nz1injecting idempotency token (%s) into param '%s'.)Zidempotent_membersstruuiduuid4r(r))paramsmodelr#namer$r$r%generate_idempotent_uuids   r[c Cs>ztt|}Wn&ttfk r8tjdddYnX|S)NzError loading quoted JSONTrI)rloadsrrOrPr(r))rSr$r$r%decode_quoted_jsondocs r]c KsRd|krNztj|dtd}||d<Wn&ttfk rLtjdddYnXdS)N TemplateBody)object_pairs_hookzerror loading JSONTrI)rr\r rOrPr(r)rRr$r$r%json_decode_template_bodys r`cKsHd|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)rXr#bucket error_msgr$r$r%validate_bucket_namesrjcKst|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_md5rXr#r$r$r%sse_md5srocKst|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. ZCopySourceSSECustomerNrlrnr$r$r%copy_source_sse_md5srprkcCsxt||sdS|d}|d}||}t|tjr<|d}tt| d}t| d}|||<|||<dS)NKeyKeyMD5r0) _needs_s3_sse_customization isinstancer text_typeencoderK b64encoderdigestrN)rXsse_member_prefixZsse_key_memberZsse_md5_memberZ key_as_bytesZ key_md5_strZkey_b64_encodedr$r$r%rms    rmcCs||ddk o|d|kS)Nrqrrr")rXryr$r$r%rss rscKstjS)zk This handler disables request signing by setting the signer name to a special sentinel value. )rCrD)r#r$r$r%disable_signingsr{cKsJ|jdddkrdSd|krF|d}t|drFtdd|dd <dS) Nmethod)PUTPOSTbodyreadz-Adding expect 100 continue header to request.z 100-continueheadersZExpect)httpr"hasattrr(r))rYrXr#rr$r$r%add_expect_headers  rc@seZdZddZddZdS)DeprecatedServiceDocumentercCs ||_dSr )_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_importantwriterefrZ end_important)rsection event_namer#r$r$r%inject_deprecation_notices   z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__ __module__ __qualname__rrr$r$r$r%r src Ksd|kr:|d}|d}|d}||dnJd|kr|d}|d}||d|d }||d dS) Nzrequest-examplestructure-value CopySource member-valuezH'string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'}zrequest-params 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_forms         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"rtr string_types_quote_source_headerdict_quote_source_header_from_dict)rXr#sourcer$r$r%handle_copy_source_param?s   rc CszB|d}|d}|d}t|r4d||f}n d||f}Wn4tk rv}ztdt|dW5d}~XYnXt|tdd }|dk r|d |7}|S) NrarqZ VersionIdz %s/object/%sz%s/%szMissing required parameter: %srb/safez ?versionId=%s)r"rfreKeyErrorrrUrr)Z source_dictrhkey version_idfinaler$r$r%rZs    rcCs\t|}|dkr"t|tddS|d|||d}}t|tdd|SdS)Nrr)VERSION_ID_SUFFIXrerrstart)rSresultfirstrr$r$r%rls  "rcCsLt|}||dd<|d|||d<d|d<i|d<|j|||jdS)NrDestinationRegionurlGETr|r)Z region_nameZoperation_name)copydeepcopyrHZgenerate_presigned_urlrZ)request_signer request_dictrY source_regiondestination_regionZrequest_dict_copyr$r$r%_get_cross_region_presigned_urlus  rcCs|j}|d}||fS)N SourceRegion)Z _region_namer")rrXrrr$r$r%1_get_presigned_url_source_and_destination_regionss rcKsNd|dkrdSt||d\}}t|||||}||dd<||dd<dS)N PresignedUrlrrrrrXrrYr#srcdestrr$r$r%inject_presigned_url_ec2s  rcKs\d|dkrdSt||d\}}|dd=d|dkrr?Zregionr$r$r%parse_get_bucket_locations   rcKsFd|krBt|dtjr*|dd|d<t|dd|d<dS)NUserDatar0)rtrrurvrKrwrNrnr$r$r%base64_encode_user_datasrcCsd}t||}|jS)Nzw**This value will be base64 encoded automatically. Do not base64 encode this value prior to performing the operation.**rZappend_documentation)param descriptionappendr$r$r%document_base64_encodings rc Ks|d}|rt|tsdS|D]Z\}}z|d|dWq$tk r|}zd||f}t|dW5d}~XYq$Xq$dS)aEVerify 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." ZMetadataNasciizvNon ascii characters found in S3 metadata for key "%s", value: "%s". S3 metadata can only contain ASCII characters. rb)r"rtrrrvUnicodeEncodeErrorr)rXr#metadatarrSrrir$r$r%validate_ascii_metadatas  rcKsp|j}|rt|dsdSdd|jD}|D]:}||kr0||}|dd||<td||||q0dS)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'``). rNcSsg|]\}}|jdkr|qS))Z ResourceIdZDelegationSetId)rZ).0rZrr$r$r% "s z#fix_route53_ids..rz %s %s -> %s) input_shaperrrsplitr(r))rXrYr#rrrZZ orig_valuer$r$r%fix_route53_idssrcKs|ddkrd|d<dS)N accountId-rzrnr$r$r%inject_account_id,srcKs|}|jd|dd<dS)NZ apiVersionrzx-amz-glacier-version)rrYrXr#rr$r$r%add_glacier_version5srcKs(|ddddkr$|}d|dd<dS)NrAcceptzapplication/jsonrzrr$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. rrzx-amz-content-sha256T)Zas_hexzx-amz-sha256-tree-hashN) rtr binary_typeBytesIOtellrZcalculate_sha256seekZcalculate_tree_hash)rXr#rrrZstarting_positionr$r$r%add_glacier_checksumsAs     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')) checksumr)docr$r$r%#document_glacier_tree_hash_checksumas rcKsld|kr0|d}|d}||dn8d|krh|d}|d}|d}||ddS) Nzresponse-paramsr^rz (*dict*) --zresponse-examplerrz{}r)rrr#Ztemplate_body_sectionrrrrr$r$r%0document_cloudformation_get_template_return_typers      rcKst|ddS)NZPredictEndpointrrequestr#r$r$r%switch_host_machinelearningsrcKsFddl}z$|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_VERSIONrrQ)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)r|rrrdatarr$r$r%change_get_to_posts rcKsd|krd|d<d|d<dS)N EncodingTypeTencoding_type_auto_setrr$)rXrFr#r$r$r%"set_list_objects_encoding_type_urlsrcKstdddgddg||ddS)N DelimiterMarkerZ NextMarkerZContentsrqZCommonPrefixesPrefixtop_level_keys nested_keysr-rF_decode_list_objectr-rFr#r$r$r%decode_list_objects rcKstdddgddg||ddS)Nrr Z StartAfterrrr r rr$r$r%decode_list_object_v2s rcKs"tddddgdddg||ddS) NZ KeyMarkerZ NextKeyMarkerr r)ZVersionsrq)Z DeleteMarkersrqrr r rr$r$r%decode_list_object_versionssrcCsr|ddkrn|drn|D]}||krt||||<q|D].\}}||kr>||D]}t||||<qVq>dS)Nrrr)r"r)r r r-rFrZtop_keyZ child_keyrr$r$r%rs  rcKsVd|krRt|dtjr0tt|d|d<n"t|dtjrRt|d|d<dS)NZBody)rtrrrrrrnr$r$r% convert_body_to_file_like_objects rc Csrdddd}|D]X\}}|dd\}}t||}d||jtf}d|d |jf}||||qdS) 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||_||_dSr )_original_name _alias_name)rrZ alias_namer$r$r%rszParameterAlias.__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}(?rrVZbotocore.compatrrrrrrrr r r r Zbotocore.docs.utilsr rrZbotocore.signersrrrZbotocore.exceptionsrrrrZbotocore.utilsrrrrrrCrrrZ botocore.auth getLoggerrr(objectrZ REGISTER_LASTr?rdrfrr!r&r.r'rGrTr[r]r`rjrorprmrsr{rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr%r*rBZdocument_auto_populated_paramZ hide_paramr2rZBUILTIN_HANDLERSr$r$r$r%s@4                   !      #         1 /   >