z]c@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlmZmZddlZddlZddlZddlmZmZmZmZmZddlmZmZmZddlmZmZddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ej*e+Z,dZ-dZ.d Z/ej0d Z1e'e&e(e)fZ2d gZ3iId d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dEdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dTdV6d+dW6d-dX6d5dY6dZd[6d\d]6d^d_6d`da6dbdc6ddde6dfdg6dPdh6didj6dkdl6dkdm6dndo6d`dp6dqdr6dsdt6dudv6dZdw6dxdy6dzd{6d|d}6dbd~6dd6dd6dd6dd6dd6dd6dd6dd6d?d6dxd6Z4dZ5dZ6dZ7dZ8dZ9dZ:e;dZ<de=fdYZ>de?fdYZ@de@fdYZAeBdZCdZDeEdZFdZGe/dZHe/dZIdZJdZKddZMeBdZNdZOdZPde?fdYZQde?fdYZRdZSdZTddZUddZVdZWdZXdZYdZZe;dZ[e;dZ\dZ]dZ^de?fdYZ_de?fdYZ`dZadZbddZcde?fdYZddS(iN(ttzlocalttzutc(tjsontquotet zip_longestturlsplitt urlunsplit(t OrderedDicttsixturlparse(t getproxiest proxy_bypass( tInvalidExpressionErrortConfigNotFoundtInvalidDNSNameErrort ClientErrortMetadataRetrievalErrortEndpointConnectionErrortReadTimeoutErrortConnectionClosedErrortConnectTimeoutErrorishttp://169.254.169.254/s-._~s-z0-9][a-z0-9\-]*[a-z0-9]t dualstacksalexa-for-businessta4btalexaforbusinesst mediatailorsapi.mediatailortpricings api.pricingt sagemakers api.sagemakers api-gatewayt apigatewaysapplication-auto-scalingsapplication-autoscalingt appstreamt appstream2s auto-scalingt autoscalingsauto-scaling-planssautoscaling-planss cost-explorertces cloudhsm-v2t cloudhsmv2scloudsearch-domaintcloudsearchdomainscognito-identity-providers cognito-idpsconfig-servicetconfigscost-and-usage-report-servicetcursiot-data-planesdata.iotsiot-jobs-data-planes data.jobs.iotsmediastore-datasdata.mediastores data-pipelinet datapipelines device-farmt devicefarmsiot-1click-devices-servicesdevices.iot1clicksdirect-connectt directconnectsapplication-discovery-servicet discoverysdatabase-migration-servicetdmssdirectory-servicetdssdynamodb-streamstdynamodbstreamsselastic-beanstalktelasticbeanstalktefstelasticfilesystemselastic-load-balancingtelasticloadbalancingtemrtelasticmapreduceselastic-transcodertelastictranscodertelbselastic-load-balancing-v2telbv2tsestemailsmarketplace-entitlement-servicesentitlement.marketplaceselasticsearch-servicetest eventbridgeteventsscloudwatch-eventssiot-datas iot-jobs-datasiot1click-devicessiot-1click-projectssiot1click-projectsskinesis-analyticstkinesisanalyticss kinesis-videot kinesisvideoslex-model-building-services lex-modelsslex-runtime-services lex-runtimescloudwatch-logstlogssmachine-learningtmachinelearningsmarketplace-entitlementsmarketplace-commerce-analyticstmarketplacecommerceanalyticssmarketplace-meteringsmetering.marketplacetmeteringmarketplaces migration-hubtmghs models.lext cloudwatcht monitoringtmturksmturk-requestert opsworkscms opsworks-cmsprojects.iot1clicksresource-groups-tagging-apitresourcegroupstaggingapisroute-53troute53sroute-53-domainstroute53domainss runtime.lexssagemaker-runtimesruntime.sagemakertsimpledbtsdbssecrets-managertsecretsmanagertserverlessapplicationrepositorytserverlessreposservice-catalogtservicecatalogtsfntstatest stepfunctionssstorage-gatewaytstoragegatewaysstreams.dynamodbttaggingcCs't|tr|S|jdkSdS(s~Ensures a boolean value if a string or boolean is provided For strings, the value for True/False is case insensitive ttrueN(t isinstancetbooltlower(tval((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytensure_booleanscCsIt|doH|jjdtoH|jjddkoH|jdkS(sDetermines if the provided shape is the special header type jsonvalue. :type shape: botocore.shape :param shape: Shape to be inspected for the jsonvalue trait. :return: True if this type is a jsonvalue, False otherwise :rtype: Bool t serializationt jsonvaluetlocationtheadertstring(thasattrRXtgettFalset type_name(tshape((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytis_json_value_headers cCsd|jjd|jjd|j}|jdd}|jdd}tjdd|}|S(svReturns the module name for a service This is the value used in both the documentation and client class name tserviceAbbreviationtserviceFullNametAmazonttAWSs\W+(tmetadataR^t service_nametreplacetretsub(t service_modeltname((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytget_service_module_names  cCs|s dSt|S(Nt/(tremove_dot_segments(tpath((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytnormalize_url_pathscCs|s dS|jd}g}xR|D]J}|r&|dkr&|dkr`|rm|jqmqp|j|q&q&W|ddkrd}nd}|ddkr|rd}nd}|dj||S(NRfRpt.s..ii(tsplittpoptappendtjoin(turlt input_urlt output_listtxtfirsttlast((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRqs"    cCsa| s|dkr%td|nx5dddgD]$}||kr5td|q5q5WdS(NRtt expressiont[t]t*(R (Rtinvalid((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytvalidate_jmespath_for_sets  cCs|rt|n|jdd}|dt|dkrH|dnd}}|sjtd|n|r||kri|||d7}|j|jntj||dS(NsHMetadata service returned %s response with status code of %s for url: %ss, content body: %s(RRyRwRRR(RRt reason_to_logRt statementt logger_args((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRKs  N(RRRRt DEFAULT_METADATA_SERVICE_TIMEOUTtMETADATA_BASE_URLRRRRRRR_R(((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRs $   tInstanceMetadataFetchercBs_eZdZddddgZdZdZdZdZd Zd Z d Z RS( s*latest/meta-data/iam/security-credentials/t AccessKeyIdtSecretAccessKeytTokent ExpirationcCsy|j}|j|}|j|rdi|d6|dd6|dd6|dd6|dd 6Sd |krd |krtjd |niSWn'|jk rtjd |jnXiS(Nt role_nameRt access_keyRt secret_keyRttokenRt expiry_timetCodetMessages7Error response received when retrievingcredentials: %s.s\Max number of attempts exceeded (%s) when attempting to retrieve data from metadata service.(t _get_iam_rolet_get_credentialst_contains_all_credential_fieldsRRRR(RRt credentials((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytretrieve_iam_role_credentials_s$        cCs|jd|jd|jjS(NRR(Rt _URL_PATHt_needs_retry_for_role_namettext(R((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR~s  cCs2|jd|j|d|j}tj|jS(NRR(RRt_needs_retry_for_credentialsRtloadsR(RRtr((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRs   cCsAytj|jtSWn"tk r<|j|dtSXdS(Ns invalid json(RRRR_t ValueErrorRR(RR((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyt_is_invalid_jsons  cCs|j|p|j|S(N(RR(RR((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRscCs+|j|p*|j|p*|j|S(N(RRR(RR((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRscCs8x1|jD]&}||kr tjd|tSq WtS(Ns3Retrieved credentials is missing required field: %s(t_REQUIRED_CREDENTIAL_FIELDSRRR_R(RRtfield((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRs ( RRRRRRRRRRR(((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRYs      cCsx|D]}t||tra||krP||krPt||||q||||RfRfN(thashlibtsha256titertupdatet hexdigesttdigest(R#tas_hextchecksumtchunk((R#s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytcalculate_sha256s   csg}dtj}x<tfddD]}|j||jq1W|sj|djSxxt|dkrg}xSt|D]E\}}|dk r|j|||jq|j|qW|}qmWt j |dj dS( s\Calculate a tree hash checksum. For more information see: http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html :param body: Any file like object. This has the same constraints as the ``body`` param in calculate_sha256 :rtype: str :returns: The hex version of the calculated tree hash ics jS(N(R((R#trequired_chunk_size(s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR$RfRfiitasciiiN( R%R&R'RwR*R)Rt _in_pairsRtbinasciithexlifytdecode(R#tchunksR&R-t new_chunksR}tsecond((R#R/s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytcalculate_tree_hashs "   cCst|}t||S(N(R'R(titerablet shared_iter((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR1s tCachedPropertycBs eZdZdZdZRS(sA read only property that caches the initially computed value. This descriptor will only call the provided ``fget`` function once. Subsequent access to this property will return the cached value. cCs ||_dS(N(t_fget(Rtfget((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRscCs:|dkr|S|j|}||j|jj<|SdS(N(RR<t__dict__R(Rtobjtclstcomputed_value((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyt__get__s  (RRRRRB(((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR;s tArgumentGeneratorcBsJeZdZedZdZddZdZdZdZ RS(sGenerate sample input based on a shape model. This class contains a ``generate_skeleton`` method that will take an input/output shape (created from ``botocore.model``) and generate a sample dictionary corresponding to the input/output shape. The specific values used are place holder values. For strings either an empty string or the member name can be used, for numbers 0 or 0.0 is used. The intended usage of this class is to generate the *shape* of the input structure. This can be useful for operations that have complex input shapes. This allows a user to just fill in the necessary data instead of worrying about the specific structure of the input arguments. Example usage:: s = botocore.session.get_session() ddb = s.get_service_model('dynamodb') arg_gen = ArgumentGenerator() sample_input = arg_gen.generate_skeleton( ddb.operation_model('CreateTable').input_shape) print("Sample input for dynamodb.CreateTable: %s" % sample_input) cCs ||_dS(N(t_use_member_names(Rtuse_member_names((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRscCsg}|j||S(sGenerate a sample input. :type shape: ``botocore.model.Shape`` :param shape: The input shape. :return: The generated skeleton input corresponding to the provided input shape. (t_generate_skeleton(RRatstack((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytgenerate_skeletons RfcCs |j|jz|jdkr2|j||S|jdkrQ|j||S|jdkrp|j||S|jdkr|jr|S|jrtj |jSdS|jdkrdS|jd krd S|jd krt S|jd kr t j d dddddSWd|j XdS(Nt structureRtmapR\RftintegertlongiR gtbooleant timestampii(RKRL( RwRnR`t_generate_type_structuret_generate_type_listt_generate_type_mapRDtenumtrandomtchoiceRRRv(RRaRGRn((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRF s.   cCse|j|jdkriSt}x9|jjD](\}}|j||d|||ytt|jrtSWnttjfk r9nXtS(s: Returns whether we should bypass proxies or not. (R R RvRRtsockettgaierrorR_(Ry((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR6s s ISO-8859-1cCs_|jd}|sdStj|\}}d|krK|djdSd|kr[|SdS(sReturns encodings from given HTTP Header Dict. :param headers: dictionary to extract encoding from. :param default: default encoding if the content-type is text s content-typetcharsets'"RN(R^Rtcgit parse_headerR(Rtdefaultt content_typeR((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pytget_encoding_from_headersKs  tFileWebIdentityTokenLoadercBseZedZdZRS(cCs||_||_dS(N(t_web_identity_token_pathR(Rtweb_identity_token_pathR((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyRas cCs)|j|j}|jSWdQXdS(N(RRR(Rt token_file((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyt__call__es(RRtopenRR(((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyR`s (eRkRtloggingRR%R2RRRSRRRtdateutil.parserRt dateutil.tzRRRtbotocore.awsrequesttbotocore.httpsessiontbotocore.compatRRRRRRRR t*botocore.vendored.six.moves.urllib.requestR R tbotocore.exceptionsR R RRRRRRRt getLoggerRRRRt SAFE_CHARSR`RgRRt EVENT_ALIASESRWRbRoRsRqRRRt ExceptionRtobjectRRR_RRRRRRRRRRR"R.R8R1R;RCRfRkRsRnRuRRRRRRRRRRRRR(((s0/tmp/pip-build-kBFYxq/botocore/botocore/utils.pyt s                 (@         !XQ    $   -   ! `    >       d