o .&aŵ@sdZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z m!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddl%m&Z&ddl%Z%ddl'Z%ddl%m(Z(ddl%m)Z)ddlm*Z*ddlm+Z+ddlm,Z,e-e.Z/e0Z1e0Z2e3dZ4dZ5dZ6e3d7e5e6gZ8e3dZ9ddiZ:ddZ;d d!Zd&d'Z?d(d)Z@d*d+ZAd,d-ZBd.d/ZCd0d1ZDd2d3ZEd4d5ZFdd7d8ZGd9d:ZHd;d<ZId=d>ZJGd?d@d@e0ZKdAdBZLdCdDZMdEdFZNdGdHZOdIdJZPdKdLZQdMdNZRdOdPZSdQdRZTdSdTZUdUdVZVdWdXZWdYdZZXd[d\ZYd]d^ZZd_d`Z[dadbZ\dcddZ]dedfZ^dgdhZ_didjZ`dkdlZadmdnZbdodpZcdqdrZddsdtZedudvZfdwdxZgdydzZhd{d|Zid}d~ZjGddde0ZkGddde0ZlGddde0ZmddZnddZogde;fdeldfdeie2fdeie2fdefdefdebfdeofdeTfde@fdeCfdeVfdeAfdeDfdedfdedfdedfdeMfdeMfdeYfdeYfdeYfdeLfdeLfdeJfde\fde]fde#fde#fde|jD]}||vrtt||<td|||fqdS)Nz1injecting idempotency token (%s) into param '%s'.)idempotent_membersstruuiduuid4r5r6)r1modelr'namer(r(r)generate_idempotent_uuids  rkc Cs<z tt|}W|SttfytjdddY|Sw)NzError loading quoted JSONTrY)rloadsrr_r`r5r6)rcr(r(r)decode_quoted_jsondocsrmc KsTd|vr(ztj|dtd}||d<WdSttfy'tjdddYdSwdS)N TemplateBody)object_pairs_hookzerror loading JSONTrY)rrlrr_r`r5r6rbr(r(r)json_decode_template_bodysrpcKsLd|vrdS|d}t|s"t|s$d|tjtjf}t|ddSdS)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)r1r'bucket error_msgr(r(r)validate_bucket_names  rzcKt|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_md5r1r'r(r(r)sse_md5rcKr{)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}rr(r(r)copy_source_sse_md5rrr|cCsxt||sdS|d}|d}||}t|tjr|d}tt| d}t| d}|||<|||<dS)NKeyKeyMD5r=) _needs_s3_sse_customization isinstancer text_typeencoder[ b64encoderdigestr^)r1sse_member_prefixsse_key_membersse_md5_member key_as_bytes key_md5_strkey_b64_encodedr(r(r)r~ s     r~cCs||dduo|d|vS)Nrrr%)r1rr(r(r)rs rcKstjS)zk This handler disables request signing by setting the signer name to a special sentinel value. )rQrR)r'r(r(r)disable_signing!srcKsR|jdddvr dSd|vr%|d}t|dr'tdd|dd <dSdSdS) Nmethod)PUTPOSTr,readz-Adding expect 100 continue header to request.z 100-continuer/Expect)httpr%hasattrr5r6)rir1r'r,r(r(r)add_expect_header)s  rc@eZdZddZddZdS)DeprecatedServiceDocumentercC ||_dSr#)_replacement_service_name)selfreplacement_service_namer(r(r)__init__6 z$DeprecatedServiceDocumenter.__init__cKs>|j|d|j|j|j|d|jdS)Nz.This service client is deprecated. Please use z instead.)stylestart_importantwriterefr end_important)rsection event_namer'r(r(r)inject_deprecation_notice9s   z5DeprecatedServiceDocumenter.inject_deprecation_noticeN)__name__ __module__ __qualname__rrr(r(r(r)r5s rc Ksd|vr|d}|d}|d}||ddSd|vrE|d}|d}||d|d }||d dSdS) 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_section doc_sectionr(r(r)document_copy_source_formDs"       rcKsP|d}|dur dSt|tjrt||d<dSt|tr&t||d<dSdS)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%rr string_types_quote_source_headerdict_quote_source_header_from_dict)r1r'sourcer(r(r)handle_copy_source_paramgs   rc Csz!|d}|d}|d}t|rd||f}nd||f}Wnty6}z tdt|dd}~wwt|tdd }|durI|d |7}|S) Nrqr VersionIdz %s/object/%sz%s/%szMissing required parameter: %srr/safez ?versionId=%s)r%rvruKeyErrorrrfrr) source_dictrxkey version_idfinaler(r(r)rs$     rcCsXt|}|durt|tddS|d|||d}}t|tdd|S)Nrr)VERSION_ID_SUFFIXrurrstart)rcresultfirstrr(r(r)rs "rcCsLt|}||dd<|d|||d<d|d<i|d<|j|||jdS)Nr,DestinationRegionurlGETrr/) region_nameoperation_name)copydeepcopyr0generate_presigned_urlrj)request_signer request_dictri source_regiondestination_regionrequest_dict_copyr(r(r)_get_cross_region_presigned_urls rcCs|j}|d}||fS)N SourceRegion) _region_namer%)rr1rrr(r(r)1_get_presigned_url_source_and_destination_regionss rcKsNd|dvrdSt||d\}}t|||||}||dd<||dd<dS)N PresignedUrlr,rrrr1rrir'srcdestrr(r(r)inject_presigned_url_ec2s   rcKs\d|dvrdSt||d\}}|dd=d|dvrdSt|||||}||dd<dS)Nrr, PreSignedUrlrrr(r(r)inject_presigned_url_rdss    rcKs"|j}|durt||jdSdSr#) output_shape_decode_policy_types)r:rir'rr(r(r)json_decode_policiessrcCsd}|jdkr3|jD]&\}}|jdkr'|j|kr'||vr't||||<q ||vr2t|||q |jdkrE|j}|D] }t||q=dSdS)NpolicyDocumentType structurestringlist) type_namemembersitemsrjrmrmember)r:shape shape_name member_name member_shape shape_memberitemr(r(r)rs$      rcKsJ|jdurdS|j}tjtdd}|||}|j}||d<dS)Nr=r>LocationConstraint)rawrEr rBrCrDrFtext)r:r9r' response_bodyrHrIregionr(r(r)parse_get_bucket_locations   rcKsJd|vr#t|dtjr|dd|d<t|dd|d<dSdS)NUserDatar=)rrrrr[rr^rr(r(r)base64_encode_user_datas rcCsd}t||}|jS)Nzw**This value will be base64 encoded automatically. Do not base64 encode this value prior to performing the operation.**rappend_documentation)param descriptionappendr(r(r)document_base64_encodings r c Ksn|d}|r t|tsdS|D]"\}}z |d|dWqty4d||f}t|dwdS)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." MetadataNasciizvNon ascii characters found in S3 metadata for key "%s", value: "%s". S3 metadata can only contain ASCII characters. rr)r%rrrrUnicodeEncodeErrorr)r1r'metadatarrcryr(r(r)validate_ascii_metadatas"   rcKsp|j}|r t|ds dSdd|jD}|D]}||vr5||}|dd||<td||||qdS)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|] \}}|jdvr|qS)) ResourceIdDelegationSetId)rj).0rjrr(r(r) Js z#fix_route53_ids..rz %s %s -> %s) input_shaperrrsplitr5r6)r1rir'rrrj orig_valuer(r(r)fix_route53_ids?srcKs|ddur d|d<dSdS)N accountId-rrr(r(r)inject_account_idTs rcKs|}|jd|dd<dS)N apiVersionr/zx-amz-glacier-version)r rir1r'rr(r(r)add_glacier_version]srcKs,|ddddur|}d|dd<dSdS)Nr/Acceptzapplication/jsonrrr(r(r)add_accept_headercsrcKsz|}|d}|d}t|tjrt|}|}d|vr&tj|dd|d<||d|vr6t||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)as_hexzx-amz-sha256-tree-hashN) rr binary_typeBytesIOtellrcalculate_sha256seekcalculate_tree_hash)r1r'rr/r,starting_positionr(r(r)add_glacier_checksumsis    r(cCsd}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 r+cKsrd|vr|d}|d}||ddSd|vr7|d}|d}|d}||ddSdS) Nzresponse-paramsrnrz (*dict*) --zresponse-examplerrz{}r)rrr'template_body_sectionrrrrr(r(r)0document_cloudformation_get_template_return_types     r-cKst|ddS)NPredictEndpointrrequestr'r(r(r)switch_host_machinelearningsr1cKsJddl}z|j}|dkrtd|jtWdSWdSty$YdSw)Nr)rr2zCurrently 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_VERSIONrra)r'r3openssl_version_tupler(r(r)&check_openssl_supports_tls_version_1_2s  r9cKsF|jdkrd|jvr!d|jd<d|_|jdd\|_|_dSdSdS)Nr?z!application/x-www-form-urlencodedz Content-Typerr2)rrr/rdatar/r(r(r)change_get_to_posts  r<cKs d|vrd|d<d|d<dSdS)N EncodingTypeTencoding_type_auto_setrr()r1rTr'r(r(r)"set_list_objects_encoding_type_urls r?cKtgdddg||ddS)N) DelimiterMarker NextMarkerContentsrCommonPrefixesPrefixtop_level_keys nested_keysr:rT_decode_list_objectr:rTr'r(r(r)decode_list_objects   rOcKr@)N)rArH StartAfterrDrFrIrLrNr(r(r)decode_list_object_v2s  rQcKstgdgd||ddS)N) KeyMarker NextKeyMarkerrHrA))Versionsr) DeleteMarkersrrFrIrLrNr(r(r)decode_list_object_versionss  rVcCsz|ddkr7|dr9|D]}||vrt||||<q|D]\}}||vr6||D] }t||||<q+qdSdSdS)Nr=rr>)r%r)rJrKr:rTrtop_key child_keyrr(r(r)rMs  rMcKs`d|vr,t|dtjrtt|d|d<dSt|dtjr.t|d|d<dSdSdS)NBody)rrrr"rr!rr(r(r) convert_body_to_file_like_objectsrZc Csrdddd}|D],\}}|dd\}}t||}d||jtf}d|d |jf}||||q dS) NFiltersfromTime returnFields)z ec2.*.Filterzlogs.CreateExportTask.fromzcloudsearchdomain.Search.return.r2zbefore-parameter-build.zdocs.*.z.complete-section)rrsplitParameterAliasalias_parameter_in_callREGISTER_FIRST alias_parameter_in_documentationr) handler_listaliasesoriginalnew_name event_portion original_nameparameter_alias#parameter_build_event_handler_tupledocs_event_handler_tupler(r(r)_add_parameter_aliasess"    rmc@s,eZdZddZddZddZddZd S) r`cCs||_||_dSr#)_original_name _alias_name)rri alias_namer(r(r)r9s zParameterAlias.__init__cKs^|jr)|j|jjvr+|j|vr-|j|vrt|j|j|jd||j||j<dSdSdSdS)N)rfalias operation)rrnrrorrjpop)rr1rir'r(r(r)ra=s  z&ParameterAlias.alias_parameter_in_callcKs|dr)|j|jvr dS||j}|d}|||d}||dS|drH|d}|j|jvr;dS||j}||dSdS)Nzdocs.request-paramsrz param-namezdocs.request-exampler)rSrnavailable_sectionsr_replace_content)rrrr'rparam_type_sectionparam_name_sectionr(r(r)rcMs          z/ParameterAlias.alias_parameter_in_documentationcCs4|d}||j|j}|||dS)Nr=)getvaluer^r0rnrorr)rrrEupdated_contentr(r(r)ruas zParameterAlias._replace_contentN)rrrrrarcrur(r(r(r)r`8s  r`c@r)ClientMethodAliascCs ||_dS)z Aliases 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)rjs zClientMethodAlias.__init__cKs t||jSr#)getattrr{)rclientr'r(r(r)__call__rr+zClientMethodAlias.__call__N)rrrrrr(r(r(r)rzis rzc@s>eZdZdZedejZddZddZ 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 Pythonstart_conversationNr()class_attributesr'r(r(r) remove_lex_v2_start_conversations rzchoose-service-namez/getattr.mturk.list_hi_ts_for_qualification_type 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.RunInstanceszsT 4                     $     #          1/      !"$%'()*+,-./012346789;<=>?@ABCDEFGHJKLMNQTXZ\_ceiknqtw   "&(.046<> A