a 97aha@sRdZddlZddlZddlZddlZddlZddlZddlmZm 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(m+Z+ddl(Z(ddl,Z(e-e.Z/e0Z1e0Z2e3dZ4dZ5dZ6e3d7e5e6gZ8e3dZ9ddiZ:ddZ;dd Zd%d&Z?d'd(Z@d)d*ZAd+d,ZBd-d.ZCd/d0ZDd1d2ZEd3d4ZFdd6d7ZGd8d9ZHd:d;ZIdd?d?e0ZKd@dAZLdBdCZMdDdEZNdFdGZOdHdIZPdJdKZQdLdMZRdNdOZSdPdQZTdRdSZUdTdUZVdVdWZWdXdYZXdZd[ZYd\d]ZZd^d_Z[d`daZ\dbdcZ]dddeZ^dfdgZ_dhdiZ`djdkZadldmZbdndoZcdpdqZddrdsZedtduZfdvdwZgdxdyZhdzd{Zid|d}ZjGd~dde0ZkGddde0ZlGddde0ZmddZnddZode;fdeldfdeie2fdeie2fdefdefdebfdeofdeTfde@fdeCfdeVfdeAfdeDfdedfdedfdedfdeMfdeMfdeYfdeYfdeYfdeLfdeLfdeJfde\fde]fde&fde&fde|jD]2}||vrtt||<td|||fqdS)Nz1injecting idempotency token (%s) into param '%s'.)Zidempotent_membersstruuiduuid4r2r3)r/modelr&namer'r'r(generate_idempotent_uuids   r`c Cs<ztt|}Wn$ttfy6tjdddYn0|S)NzError loading quoted JSONTrO)rloadsrrUrVr2r3)rYr'r'r(decode_quoted_jsondocs rbc KsPd|vrLztj|dtd}||d<Wn$ttfyJtjdddYn0dS)N TemplateBody)object_pairs_hookzerror loading JSONTrO)rrar rUrVr2r3rXr'r'r(json_decode_template_bodys recKsHd|vr 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)r/r&bucket error_msgr'r'r(validate_bucket_names rocKst|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_md5r/r&r'r'r(sse_md5srtcKst|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. ZCopySourceSSECustomerNrqrsr'r'r(copy_source_sse_md5srurpcCsxt||sdS|d}|d}||}t|tjr<|d}tt| d}t| d}|||<|||<dS)NKeyKeyMD5r:) _needs_s3_sse_customization isinstancer text_typeencoderQ b64encoderdigestrT)r/sse_member_prefixZsse_key_memberZsse_md5_memberZ key_as_bytesZ key_md5_strZkey_b64_encodedr'r'r(rrs    rrcCs||dduo|d|vS)Nrvrwr%)r/r~r'r'r(rxs rxcKstjS)zk This handler disables request signing by setting the signer name to a special sentinel value. )rJrK)r&r'r'r(disable_signingsrcKsJ|jdddvrdSd|vrF|d}t|drFtdd|dd <dS) Nmethod)PUTPOSTr*readz-Adding expect 100 continue header to request.z 100-continuer-ZExpect)httpr%hasattrr2r3)r^r/r&r*r'r'r(add_expect_header$s  rc@seZdZddZddZdS)DeprecatedServiceDocumentercCs ||_dSr#)_replacement_service_name)selfZreplacement_service_namer'r'r(__init__1sz$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_notice4s   z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__ __module__ __qualname__rrr'r'r'r(r0src Ksd|vr:|d}|d}|d}||dnJd|vr|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_form?s         rcKsJ|d}|durdSt|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%ryr string_types_quote_source_headerdict_quote_source_header_from_dict)r/r&sourcer'r'r(handle_copy_source_parambs   rc CszB|d}|d}|d}t|r4d||f}n d||f}Wn6tyx}ztdt|dWYd}~n d}~00t|tdd }|dur|d |7}|S) NrfrvZ VersionIdz %s/object/%sz%s/%szMissing required parameter: %srg/safez ?versionId=%s)r%rkrjKeyErrorrr[rr)Z source_dictrmkey version_idfinaler'r'r(r}s    rcCs\t|}|dur"t|tddS|d|||d}}t|tdd|SdS)Nrr)VERSION_ID_SUFFIXrjrrstart)rYresultfirstrr'r'r(rs  "rcCsLt|}||dd<|d|||d<d|d<i|d<|j|||jdS)Nr*DestinationRegionurlGETrr-)Z region_nameZoperation_name)copydeepcopyr.Zgenerate_presigned_urlr_)request_signer request_dictr^ source_regiondestination_regionZrequest_dict_copyr'r'r(_get_cross_region_presigned_urls  rcCs|j}|d}||fS)N SourceRegion)Z _region_namer%)rr/rrr'r'r(1_get_presigned_url_source_and_destination_regionss rcKsNd|dvrdSt||d\}}t|||||}||dd<||dd<dS)N PresignedUrlr*rrrr/rr^r&srcdestrr'r'r(inject_presigned_url_ec2s   rcKs\d|dvrdSt||d\}}|dd=d|dvrEs  z#fix_route53_ids..rz %s %s -> %s) input_shaperrrsplitr2r3)r/r^r&rrr_Z orig_valuer'r'r(fix_route53_ids:srcKs|ddurd|d<dS)N accountId-rrsr'r'r(inject_account_idOsrcKs|}|jd|dd<dS)NZ apiVersionr-zx-amz-glacier-version)rr^r/r&rr'r'r(add_glacier_versionXsrcKs(|ddddur$|}d|dd<dS)Nr-Acceptzapplication/jsonrrr'r'r(add_accept_header^srcKsz|}|d}|d}t|tjr*t|}|}d|vrLtj|dd|d<||d|vrlt||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. r-r*zx-amz-content-sha256T)Zas_hexzx-amz-sha256-tree-hashN) ryr binary_typeBytesIOtellr Zcalculate_sha256seekZcalculate_tree_hash)r/r&rr-r*Zstarting_positionr'r'r(add_glacier_checksumsds     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_checksums rcKsld|vr0|d}|d}||dn8d|vrh|d}|d}|d}||ddS) Nzresponse-paramsrcrz (*dict*) --zresponse-examplerrz{}r)rrr&Ztemplate_body_sectionrrrrr'r'r(0document_cloudformation_get_template_return_types      rcKst|ddS)NZPredictEndpointrrequestr&r'r'r(switch_host_machinelearningsrcKsDddl}z$|j}|dkr*td|jtWnty>Yn0dS)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_VERSIONrrW)r&rZopenssl_version_tupler'r'r(&check_openssl_supports_tls_version_1_2s rcKs>|jdkr:d|jvr:d|jd<d|_|jdd\|_|_dS)Nr?z!application/x-www-form-urlencodedz Content-Typerr)rrr-rdatarr'r'r(change_get_to_posts rcKsd|vrd|d<d|d<dS)N EncodingTypeTencoding_type_auto_setrr')r/rMr&r'r'r("set_list_objects_encoding_type_urlsrcKstgdddg||ddS)N) DelimiterMarkerZ NextMarkerZContentsrvZCommonPrefixesPrefixtop_level_keys nested_keysr7rM_decode_list_objectr7rMr&r'r'r(decode_list_objects rcKstgdddg||ddS)N)r r Z StartAfterr r rrrr'r'r(decode_list_object_v2s rcKstgdgd||ddS)N)Z KeyMarkerZ NextKeyMarkerr r ))ZVersionsrv)Z DeleteMarkersrvr rrrr'r'r(decode_list_object_versionss rcCsr|ddkrn|drn|D]}||vrt||||<q|D].\}}||vr>||D]}t||||<qVq>dS)Nrrr)r%r)rrr7rMrZtop_keyZ child_keyrr'r'r(rs  rcKsVd|vrRt|dtjr0tt|d|d<n"t|dtjrRt|d|d<dS)NZBody)ryrrrrrrsr'r'r( convert_body_to_file_like_object s 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    r"c@s,eZdZddZddZddZddZd S) rcCs||_||_dSr#)_original_name _alias_name)rr!Z alias_namer'r'r(r5szParameterAlias.__init__cKsR|jrN|j|jjvrN|j|vrN|j|vreZdZdZedejZddZddZ 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}(?Operation requires h2 which is currently unsupported in PythonZstart_conversationNr')Zclass_attributesr&r'r'r( remove_lex_v2_start_conversationsrGzchoose-service-namez/getattr.mturk.list_hi_ts_for_qualification_typeZ list_hits_for_qualification_typez$before-parameter-build.s3.UploadPartz#before-parameter-build.s3.PutObjectzcreating-client-classzcreating-client-class.s3zcreating-client-class.iot-dataz$creating-client-class.lex-runtime-v2zafter-call.iamzafter-call.ec2.GetConsoleOutputz%after-call.cloudformation.GetTemplatezafter-call.s3.GetBucketLocationzbefore-parameter-buildzbefore-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-sectionzbefore-call.s3zbefore-call.glacierzbefore-call.apigatewayzbefore-call.s3.PutObjectzbefore-call.s3.UploadPartzbefore-call.s3.DeleteObjectsz.before-call.s3.PutBucketLifecycleConfigurationz!before-call.glacier.UploadArchivez'before-call.glacier.UploadMultipartPartzbefore-call.ec2.CopySnapshotz'request-created.machinelearning.Predictzneeds-retry.s3.UploadPartCopyzneeds-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.RunInstanceszsB8                    $      #         1/   C