a 97aptãJ@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;ddle?¡Z@dZAdZBd ZCd ZDd ZEe Fd ¡ZGe,e+e-e.fZHd gZIdddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d*d-d.d/d0d1d1ddd"d2d3d4d5d6d7d8d/d9d:d:d;d5dd2d?d@dAd6dBdCdDdEdFdGdGdHd'd?dIœIZJdJZKdKZLdLjMeLeKdMZNeLeNdNœZOgdO¢ZPdPZQdQdR RdSdT„ePDƒ¡dUZSdVeQdWZTdXeSdQeTdYZUe FdZeUd[¡ZVeWd\ƒZXd]d^„ZYd_d`„ZZdadb„Z[dcdd„Z\dedf„Z]dgdh„Z^didj„Z_dkdl„Z`dÚdndo„Zadpdq„ZbGdrds„dsecƒZdGdtdu„duecƒZeGdvdw„dwefƒZgGdxdy„dyegƒZhdÛd{d|„Zid}d~„Zjekfdd€„Zldd‚„ZmeEfdƒd„„ZneEfd…d†„Zod‡dˆ„Zpd‰dŠ„Zqd‹dŒ„ZrdÜddŽ„ZsdÝdd„Ztd‘d’„Zud“d”„ZvGd•d–„d–efƒZwGd—d˜„d˜efƒZxd™dš„Zyd›dœ„Zzddž„Z{dŸd „Z|d¡d¢„Z}dÞd£d¤„Z~dßd¥d¦„Zd§d¨„Z€d©dª„Zd«d¬„Z‚d­d®„Zƒdàd¯d°„Z„dád±d²„Z…d³d´„Z†dµd¶„Z‡Gd·d¸„d¸efƒZˆGd¹dº„dºe‰ƒZŠGd»d¼„d¼efƒZ‹Gd½d¾„d¾efƒZŒGd¿dÀ„dÀefƒZGdÁd„dÂefƒZŽGdÃdÄ„dÄefƒZGdÅdÆ„dÆefƒZdÇdÈ„Z‘dÉdÊ„Z’dâdÌdÍ„Z“dÎdÏ„Z”dÐdÑ„Z•dÒdÓ„Z–dÔdÕ„Z—GdÖdׄd×efƒZ˜GdØdÙ„dÙefƒZ™dS)ãéN)Útzutc) ÚjsonÚquoteÚ zip_longestÚurlsplitÚ urlunsplitÚ OrderedDictÚsixÚurlparseÚget_tzinfo_optionsÚget_md5Ú MD5_AVAILABLEÚHAS_CRT)Ú getproxiesÚ proxy_bypass)ÚInvalidExpressionErrorÚConfigNotFoundÚInvalidDNSNameErrorÚ ClientErrorÚMetadataRetrievalErrorÚEndpointConnectionErrorÚReadTimeoutErrorÚConnectionClosedErrorÚConnectTimeoutErrorÚUnsupportedS3ArnErrorÚ*UnsupportedS3AccesspointConfigurationErrorÚSSOTokenLoadErrorÚInvalidRegionErrorÚInvalidIMDSEndpointErrorÚInvalidIMDSEndpointModeErrorÚUnsupportedOutpostResourceErrorÚ&UnsupportedS3ControlConfigurationErrorÚUnsupportedS3ControlArnErrorÚInvalidHostLabelErrorÚHTTPClientErrorÚUnsupportedS3ConfigurationErrorÚMissingDependencyException)ÚLocationParseErrorézhttp://169.254.169.254/zhttp://[fd00:ec2::254]/)Úipv4Úipv6z-._~z-z0-9][a-z0-9\-]*[a-z0-9]Ú dualstackzalexa-for-businessZ mediatailorZpricingZ sagemakerz api-gatewayzapplication-auto-scalingZ appstreamz auto-scalingzauto-scaling-plansz cost-explorerz cloudhsm-v2zcloudsearch-domainzcognito-identity-providerzconfig-servicezcost-and-usage-report-serviceziot-data-planeziot-jobs-data-planezmediastore-dataz data-pipelinez device-farmziot-1click-devices-servicezdirect-connectzapplication-discovery-servicezdatabase-migration-servicezdirectory-servicezdynamodb-streamszelastic-beanstalkZefszelastic-load-balancingZemrzelastic-transcoderzelastic-load-balancing-v2Zseszmarketplace-entitlement-servicezelasticsearch-serviceZ eventbridgeziot-1click-projectszkinesis-analyticsz kinesis-videozlex-model-building-servicezlex-runtime-servicezcloudwatch-logszmachine-learningzmarketplace-commerce-analyticszmarketplace-meteringz migration-hubZ cloudwatchZmturkZ opsworkscmzresource-groups-tagging-apizroute-53zroute-53-domainszsagemaker-runtimeZsimpledbzsecrets-managerZserverlessapplicationrepositoryzservice-catalogÚsfnzstorage-gateway)IZa4bZalexaforbusinesszapi.mediatailorz api.pricingz api.sagemakerZ apigatewayzapplication-autoscalingZ appstream2Z autoscalingzautoscaling-plansZceZ cloudhsmv2Zcloudsearchdomainz cognito-idpÚconfigÚcurzdata.iotz data.jobs.iotzdata.mediastoreZ datapipelineZ devicefarmzdevices.iot1clickZ directconnectZ discoveryZdmsZdsZdynamodbstreamsZelasticbeanstalkZelasticfilesystemZelasticloadbalancingZelasticmapreduceZelastictranscoderZelbZelbv2Úemailzentitlement.marketplaceÚesÚeventszcloudwatch-eventsziot-dataz iot-jobs-dataziot1click-devicesziot1click-projectsZkinesisanalyticsZ kinesisvideoz lex-modelsz lex-runtimeZlogsZmachinelearningzmarketplace-entitlementZmarketplacecommerceanalyticszmetering.marketplaceZmeteringmarketplaceZmghz models.lexZ monitoringzmturk-requesterz opsworks-cmzprojects.iot1clickZresourcegroupstaggingapiZroute53Zroute53domainsz runtime.lexzruntime.sagemakerZsdbZsecretsmanagerZserverlessrepoZservicecatalogZstatesZ stepfunctionsZstoragegatewayzstreams.dynamodbZtaggingz(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))Úhexr))r2Úls32) z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zDABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~z(?:ú|cCsg|] }|t‘qS©)Ú_subs)Ú.0Úxr5r5úi/private/var/folders/s6/9n5zrl012gv99k63s4q6ccsd4s6mqz/T/pip-target-f5cq3f2q/lib/python/botocore/utils.pyÚ ®ór:ú)z (?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]ú^ú$z cCst|tƒr|S| ¡dkSdS)z~Ensures a boolean value if a string or boolean is provided For strings, the value for True/False is case insensitive ÚtrueN)Ú isinstanceÚboolÚlower©Úvalr5r5r9Úensure_boolean·s rEcCsP| d¡}|dur>| ¡}|tvr:|tdœ}tfi|¤Ž‚|S| d¡rLdSdS)z†Resolving IMDS endpoint mode to either IPv6 or IPv4. ec2_metadata_service_endpoint_mode takes precedence over imds_use_ipv6. Ú"ec2_metadata_service_endpoint_modeN)ÚmodeZ valid_modesZ imds_use_ipv6r*r))Zget_config_variablerBÚMETADATA_ENDPOINT_MODESr)ÚsessionZ endpoint_modeZlendpoint_modeZerror_msg_kwargsr5r5r9Úresolve_imds_endpoint_modeÂsÿþ rJcCs2t|dƒo0|j dd¡o0|j d¡dko0|jdkS)zþDetermines 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 Ú serializationZ jsonvalueFÚlocationÚheaderÚstring)ÚhasattrrKÚgetÚ type_name)Úshaper5r5r9Úis_json_value_header×s  ÿþýrScCsD|j d|j d|j¡¡}| dd¡}| dd¡}t dd|¡}|S)zvReturns the module name for a service This is the value used in both the documentation and client class name ZserviceAbbreviationZserviceFullNameZAmazonÚZAWSz\W+)ÚmetadatarPZ service_nameÚreplaceÚreÚsub)Z service_modelÚnamer5r5r9Úget_service_module_nameæsÿþ  rZcCs|sdSt|ƒS)Nú/)Úremove_dot_segments©Úpathr5r5r9Únormalize_url_pathõsr_cCs|dur |St|ƒSdS)zLReturns None if val is None, otherwise ensure value converted to booleanN)rErCr5r5r9Únormalize_booleanûsr`cCsŽ|sdS| d¡}g}|D]0}|r|dkr|dkr@|rJ| ¡q| |¡q|ddkr^d}nd}|ddkrx|rxd}nd}|d |¡|S)NrTr[Ú.z..réÿÿÿÿ)ÚsplitÚpopÚappendÚjoin)ÚurlZ input_urlZ output_listr8ÚfirstÚlastr5r5r9r\s"     r\cCs6|r |dkrt|d‚dD]}||vrt|d‚qdS)Nra©Ú expression)ú[ú]Ú*)r)rkÚinvalidr5r5r9Úvalidate_jmespath_for_sets   rpTcCs||r t|ƒ| dd¡}|dt|ƒdkr2|dnd}}|sHt|d‚|rp||vr\i||<t||||ddS|||<dS)Nrar(rrTrjF)Úis_first)rprcÚlenrÚset_value_from_jmespath)ÚsourcerkÚvaluerqÚbitsÚ current_keyÚ remainderr5r5r9rs*s  " ürscCs| di¡}| d¡dk}|S)z9Determine if request is intended for an MRAP accesspoint.Ús3_accesspointÚregionrT©rP)ÚcontextryÚ is_globalr5r5r9Úis_global_accesspointKs r~c@seZdZdZdS)Ú_RetriesExceededErrorz@Internal exception used when the number of retries are exceeded.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r5r5r5r9rRsrc@seZdZdd„ZdS)ÚBadIMDSRequestErrorcCs ||_dS©N©Úrequest©Úselfr‡r5r5r9Ú__init__XszBadIMDSRequestError.__init__N)r€rr‚rŠr5r5r5r9r„Wsr„c@s‚eZdZeZdZdZededddfdd„Z dd„Z d d „Z d d „Z dd d„Z dd„Zdd„Zdd„Zdd„Zdd„Zddd„ZdS)Ú IMDSFetcherzlatest/api/tokenZ21600r(NcCsn||_||_| ||¡|_|dur,tj ¡}| dd¡ ¡|_ |j dk|_ ||_ t j j |jt|jƒd|_dS)NZAWS_EC2_METADATA_DISABLEDÚfalser?)ÚtimeoutÚproxies)Ú_timeoutÚ _num_attemptsÚ_select_base_urlÚ _base_urlÚosÚenvironÚcopyrPrBÚ _disabledÚ _user_agentÚbotocoreÚ httpsessionÚURLLib3SessionÚget_environ_proxiesÚ_session)r‰rZ num_attemptsÚbase_urlÚenvÚ user_agentr-r5r5r9rŠbs  þzIMDSFetcher.__init__cCs|jSr…)r’©r‰r5r5r9Ú get_base_urlsszIMDSFetcher.get_base_urlcCs„|dur i}| d¡dk}| d¡}|r6|r6t d¡d}|tkrH|}n|rR|}n|r\t}nt}t d|¡t|ƒs€t|d‚|S)NrFr*Zec2_metadata_service_endpointzFCustom endpoint and IMDS_USE_IPV6 are both set. Using custom endpoint.zIMDS ENDPOINT: %s)Úendpoint)rPÚloggerÚwarnÚMETADATA_BASE_URLÚMETADATA_BASE_URL_IPv6ÚdebugÚ is_valid_urir)r‰rr-Z requires_ipv6Zcustom_metadata_endpointZchosen_base_urlr5r5r9r‘vs,ÿÿ   zIMDSFetcher._select_base_urlc Cs0| ¡|j|j}d|ji}| |¡tjjd||d}t|j ƒD]æ}zN|j   |  ¡¡}|j dkrp|jWS|j dvr‚WdS|j dvr”t|ƒ‚WqDty¬YdStyà}ztjd||dd WYd}~qDd}~0ty(}z0t|j d ¡tƒrt||d ‚n‚WYd}~qDd}~00qDdS) Nz$x-aws-ec2-metadata-token-ttl-secondsÚPUT©ÚmethodrgÚheaderséÈ)i”i“i•)iúOCaught retryable HTTP exception while making metadata service request to %s: %sT©Úexc_infoÚerror)r¢r±)Ú_assert_enabledr’Ú _TOKEN_PATHÚ _TOKEN_TTLÚ_add_user_agentr˜Ú awsrequestÚ AWSRequestÚrangerrœÚsendÚprepareÚ status_codeÚtextr„rÚRETRYABLE_HTTP_ERRORSr£r§r$r@ÚkwargsrPr'r)r‰rgr¬r‡ÚiÚresponseÚer5r5r9Ú_fetch_metadata_token’s: ÿ ÿ      þz!IMDSFetcher._fetch_metadata_tokenc CsÊ| ¡|dur|j}|j|}i}|dur4||d<| |¡t|jƒD]t}z8tjjd||d}|j   |  ¡¡}||ƒs‚|WSWqHt yº} zt jd|| ddWYd} ~ qHd} ~ 00qH| ¡‚dS)aZMake a get request to the Instance Metadata Service. :type url_path: str :param url_path: The path component of the URL to make a get request. This arg is appended to the base_url that was provided in the initializer. :type retry_func: callable :param retry_func: A function that takes the response as an argument and determines if it needs to retry. By default empty and non 200 OK responses are retried. :type token: str :param token: Metadata token to send along with GET requests to IMDS. Nzx-aws-ec2-metadata-tokenÚGETrªr®Tr¯)r²Ú_default_retryr’rµr¸rr˜r¶r·rœr¹rºr½r£r§Ú_RETRIES_EXCEEDED_ERROR_CLS) r‰Úurl_pathÚ retry_funcÚtokenrgr¬r¿r‡rÀrÁr5r5r9Ú _get_request±s,  ÿþzIMDSFetcher._get_requestcCs|jdur|j|d<dS)Nz User-Agent)r—)r‰r¬r5r5r9rµÖs zIMDSFetcher._add_user_agentcCs|jrt d¡| ¡‚dS)Nz)Access to EC2 metadata has been disabled.)r–r£r§rÅr r5r5r9r²Ús zIMDSFetcher._assert_enabledcCs| |¡p| |¡Sr…©Ú_is_non_ok_responseÚ _is_empty©r‰rÀr5r5r9rÄßs þzIMDSFetcher._default_retrycCs"|jdkr|j|ddddSdS)Nr­znon-200T©Úlog_bodyF)r»Ú_log_imds_responserÍr5r5r9rËås zIMDSFetcher._is_non_ok_responsecCs|js|j|ddddSdS)Nzno bodyTrÎF)ÚcontentrÐrÍr5r5r9rÌëszIMDSFetcher._is_emptyFcCs@d}||j|jg}|r*|d7}| |j¡tj|g|¢RŽdS)NzHMetadata service returned %s response with status code of %s for url: %sz, content body: %s)r»rgrerÑr£r§)r‰rÀZ reason_to_logrÏZ statementZ logger_argsr5r5r9rÐñsÿ ÿ zIMDSFetcher._log_imds_response)N)F)r€rr‚rrÅr³r´Ú DEFAULT_METADATA_SERVICE_TIMEOUTr¥rŠr¡r‘rÂrÉrµr²rÄrËrÌrÐr5r5r5r9r‹\s"þ  %r‹c@sTeZdZdZgd¢Zdd„Zddd„Zddd „Zd d „Zd d „Z dd„Z dd„Z dS)ÚInstanceMetadataFetcherz*latest/meta-data/iam/security-credentials/)Ú AccessKeyIdÚSecretAccessKeyÚTokenÚ Expirationc CsÈzp| ¡}| |¡}| ||¡}| |¡rL||d|d|d|ddœWSd|vrhd|vrht d|¡iWSWnR|jy’t d |j¡Yn2tyÂ}zt d |j ¡WYd}~n d}~00iS) NrÔrÕrÖr×)Ú role_nameZ access_keyZ secret_keyrÈZ expiry_timeÚCodeÚMessagez7Error response received when retrievingcredentials: %s.z\Max number of attempts exceeded (%s) when attempting to retrieve data from metadata service.zBad IMDS request: %s) rÂÚ _get_iam_roleÚ_get_credentialsÚ_contains_all_credential_fieldsr£r§rÅrr„r‡)r‰rÈrØÚ credentialsrÁr5r5r9Úretrieve_iam_role_credentialss.   ûÿ þ$z5InstanceMetadataFetcher.retrieve_iam_role_credentialsNcCs|j|j|j|djS©N)rÆrÇrÈ)rÉÚ _URL_PATHÚ_needs_retry_for_role_namer¼)r‰rÈr5r5r9rÛ's ýz%InstanceMetadataFetcher._get_iam_rolecCs$|j|j||j|d}t |j¡Srà)rÉráÚ_needs_retry_for_credentialsrÚloadsr¼)r‰rØrÈÚrr5r5r9rÜ.s ýz(InstanceMetadataFetcher._get_credentialscCs8zt |j¡WdSty2| |d¡YdS0dS)NFz invalid jsonT)rrär¼Ú ValueErrorrÐrÍr5r5r9Ú_is_invalid_json6s    z(InstanceMetadataFetcher._is_invalid_jsoncCs| |¡p| |¡Sr…rÊrÍr5r5r9râ>s þz2InstanceMetadataFetcher._needs_retry_for_role_namecCs| |¡p| |¡p| |¡Sr…)rËrÌrçrÍr5r5r9rãDs  ÿýz4InstanceMetadataFetcher._needs_retry_for_credentialscCs*|jD]}||vrt d|¡dSqdS)Nz3Retrieved credentials is missing required field: %sFT)Ú_REQUIRED_CREDENTIAL_FIELDSr£r§)r‰rÞÚfieldr5r5r9rÝKs þz7InstanceMetadataFetcher._contains_all_credential_fields)N)N) r€rr‚rárèrßrÛrÜrçrârãrÝr5r5r5r9rÓÿs"  rÓFcCs¤|D]š}t||tƒrH||vr:||vr:t||||ƒqž||||<qt||tƒr’|r’||vr„t||tƒr„|| ||¡qž||||<q||||<qdS)zöGiven two dict, merge the second dict into the first. The dicts can have arbitrary nesting. :param append_lists: If true, instead of clobbering a list with the new value, append all of the new values onto the original list. N)r@ÚdictÚ merge_dictsÚlistÚextend)Zdict1Zdict2Z append_listsÚkeyr5r5r9rëUsrëcCs"i}|D]}|||| ¡<q|S)zECopies the given dictionary ensuring all keys are lowercase strings. )rB)Úoriginalr•rîr5r5r9Úlowercase_dictrsrðcCs`z>||ƒ"}| ¡}t|ƒWdƒWS1s20YWntyZt|d‚Yn0dS)Nr])ÚreadÚparse_key_val_file_contentsÚOSErrorr)ÚfilenameÚ_openÚfÚcontentsr5r5r9Úparse_key_val_filezs  , røcCsHi}| ¡D]6}d|vrq | dd¡\}}| ¡}| ¡}|||<q |S)Nú=r()Ú splitlinesrcÚstrip)r÷ÚfinalÚlinerîrDr5r5r9ròƒs  ròcCs~g}t|dƒr| ¡}n|}|D]R\}}t|tƒrX|D]}| dt|ƒt|ƒf¡q6q | dt|ƒt|ƒf¡q d |¡S)afUrlencode a dict or list into a string. This is similar to urllib.urlencode except that: * It uses quote, and not quote_plus * It has a default list of safe chars that don't need to be encoded, which matches what AWS services expect. If any value in the input ``mapping`` is a list type, then each list element wil be serialized. This is the equivalent to ``urlencode``'s ``doseq=True`` argument. This function should be preferred over the stdlib ``urlencode()`` function. :param mapping: Either a dict to urlencode or a list of ``(key, value)`` pairs. Úitemsz%s=%sú&)rOrþr@rìreÚpercent_encoderf)ÚmappingÚsafeZ encoded_pairsÚpairsrîruÚelementr5r5r9Úpercent_encode_sequence’s     ÿ  ÿ rcCs>t|tjtjfƒst |¡}t|tjƒs2| d¡}t||dS)aÂUrlencodes a string. Whereas percent_encode_sequence handles taking a dict/sequence and producing a percent encoded string, this function deals only with taking a string (not a dict/sequence) and percent encoding it. If given the binary type, will simply URL encode it. If given the text type, will produce the binary type by UTF-8 encoding the text. If given something else, will convert it to the text type first. úutf-8)r)r@r Ú binary_typeÚ text_typeÚencoder)Z input_strrr5r5r9r¶s    rc Cs¢t|ttfƒrtj ||ƒ¡Sztj t|ƒ|ƒ¡WSttfyJYn0ztjj |dt ƒidWSttfyœ}ztd||fƒ‚WYd}~n d}~00dS)z.Parse timestamp with pluggable tzinfo options.ÚGMT)ZtzinfoszInvalid timestamp "%s": %sN) r@ÚintÚfloatÚdatetimeÚ fromtimestampÚ TypeErrorræÚdateutilÚparserÚparser©ruÚtzinforÁr5r5r9Ú_parse_timestamp_with_tzinfoËsrc CsdtƒD]L}zt||ƒWStyP}ztjd|j|dWYd}~qd}~00qtd|ƒ‚dS)zÇParse a timestamp into a datetime object. Supported formats: * iso8601 * rfc822 * epoch (value is an integer) This will return a ``datetime.datetime`` object. z2Unable to parse timestamp with "%s" timezone info.r¯Nz4Unable to calculate correct timezone offset for "%s")r rrór£r§r€Ú RuntimeErrorrr5r5r9Úparse_timestampÞs ÿÿrcCsDt|tjƒr|}nt|ƒ}|jdur4|jtƒd}n | tƒ¡}|S)a•Converted the passed in value to a datetime object with tzinfo. This function can be used to normalize all timestamp inputs. This function accepts a number of different types of inputs, but will always return a datetime.datetime object with time zone information. The input param ``value`` can be one of several types: * A datetime object (both naive and aware) * An integer representing the epoch time (can also be a string of the integer, i.e '0', instead of 0). The epoch time is considered to be UTC. * An iso8601 formatted timestamp. This does not need to be a complete timestamp, it can contain just the date portion without the time component. The returned value will be a datetime object that will have tzinfo. If no timezone info was provided in the input value, then UTC is assumed, not local time. N©r)r@r rrrVrÚ astimezone)ruZ datetime_objr5r5r9Úparse_to_aware_datetimeôs   rcCs~t ddd¡}|jdur2|dur&tƒ}|j|d}|jdd| ¡|}t|dƒr\| ¡S|j|j|j ddddS) awCalculate the timestamp based on the given datetime instance. :type dt: datetime :param dt: A datetime object to be converted into timestamp :type default_timezone: tzinfo :param default_timezone: If it is provided as None, we treat it as tzutc(). But it is only used when dt is a naive datetime. :returns: The timestamp é²r(NrÚ total_secondséii@B) r rrrVÚ utcoffsetrOrÚ microsecondsÚsecondsÚdays)ÚdtZdefault_timezoneÚepochÚdr5r5r9Údatetime2timestamp!s    r%csBt ¡}t‡fdd„dƒD]}| |¡q|r6| ¡S| ¡SdS)a²Calculate a sha256 checksum. This method will calculate the sha256 checksum of a file like object. Note that this method will iterate through the entire file contents. The caller is responsible for ensuring the proper starting position of the file and ``seek()``'ing the file back to its starting location if other consumers need to read from the file like object. :param body: Any file like object. The file must be opened in binary mode such that a ``.read()`` call returns bytes. :param as_hex: If True, then the hex digest is returned. If False, then the digest (as binary bytes) is returned. :returns: The sha256 checksum cs ˆ d¡S©Né©rñr5©Úbodyr5r9ÚIr;z"calculate_sha256..r;N)ÚhashlibÚsha256ÚiterÚupdateÚ hexdigestÚdigest)r*Zas_hexZchecksumÚchunkr5r)r9Úcalculate_sha2566s  r3cs°g}d‰tj}t‡‡fdd„dƒD]}| ||ƒ ¡¡q"|sJ|dƒ ¡St|ƒdkrœg}t|ƒD]2\}}|durŠ| |||ƒ ¡¡qb| |¡qb|}qJt  |d¡  d¡S) a\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 r'cs ˆ ˆ¡Sr…r(r5©r*Zrequired_chunk_sizer5r9r+br;z%calculate_tree_hash..r;r(NrÚascii) r,r-r.rer1r0rrÚ _in_pairsÚbinasciiÚhexlifyÚdecode)r*Úchunksr-r2Z new_chunksrhÚsecondr5r4r9Úcalculate_tree_hashQs   r<cCst|ƒ}t||ƒSr…)r.r)ÚiterableZ shared_iterr5r5r9r6rs r6c@s eZdZdZdd„Zdd„ZdS)ÚCachedPropertyzÒA 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 ||_dSr…)Ú_fget)r‰Úfgetr5r5r9rŠ‹szCachedProperty.__init__cCs,|dur |S| |¡}||j|jj<|SdSr…)r?Ú__dict__r€)r‰ÚobjÚclsZcomputed_valuer5r5r9Ú__get__Žs  zCachedProperty.__get__N)r€rr‚rƒrŠrDr5r5r5r9r>ƒsr>c@sDeZdZdZddd„Zdd„Zddd „Zd d „Zd d „Zdd„Z dS)ÚArgumentGeneratoraGenerate 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) FcCs ||_dSr…)Ú_use_member_names)r‰Zuse_member_namesr5r5r9rбszArgumentGenerator.__init__cCsg}| ||¡S)zÞGenerate a sample input. :type shape: ``botocore.model.Shape`` :param shape: The input shape. :return: The generated skeleton input corresponding to the provided input shape. )Ú_generate_skeleton)r‰rRÚstackr5r5r9Úgenerate_skeleton´s z#ArgumentGenerator.generate_skeletonrTcCsF| |j¡z(|jdkr0| ||¡W| ¡S|jdkrP| ||¡W| ¡S|jdkrp| ||¡W| ¡S|jdkr¸|jrŽ|W| ¡S|jrªt   |j¡W| ¡SW| ¡dS|jdvrÐW| ¡dS|jdvrèW| ¡d S|jd krW| ¡d S|jd kr,t   d ddddd¡W| ¡SW| ¡n | ¡0dS)NZ structurerìÚmaprNrT)ÚintegerÚlongr)r ÚdoublegÚbooleanTÚ timestamprr() rerYrQÚ_generate_type_structurerdÚ_generate_type_listÚ_generate_type_maprFÚenumÚrandomÚchoicer ©r‰rRrHrYr5r5r9rGÁsV   ì  î  ð  ó õ ö ø ú ü þz$ArgumentGenerator._generate_skeletoncCsF| |j¡dkriStƒ}|j ¡D]\}}|j|||d||<q$|S)Nr()rY)ÚcountrYrÚmembersrþrG)r‰rRrHZskeletonÚ member_nameZ member_shaper5r5r9rPÛsÿ z*ArgumentGenerator._generate_type_structurecCs$d}|jr|jj}| |j||¡gS)NrT)rFÚmemberrYrGrVr5r5r9rQäs ÿz%ArgumentGenerator._generate_type_listcCs0|j}|j}|jdksJ‚td| ||¡fgƒS)NrNZKeyName)rîrurQrrG)r‰rRrHZ key_shapeZ value_shaper5r5r9rRîs ÿz$ArgumentGenerator._generate_type_mapN)F)rT) r€rr‚rƒrŠrIrGrPrQrRr5r5r5r9rE—s    rEcCs&t |¡rdSt|ƒj}t |¡duS)NF)ÚUNSAFE_URL_CHARSÚ intersectionr ÚnetlocÚ IPV6_ADDRZ_REÚmatch)Ú endpoint_urlr]r5r5r9Úis_valid_ipv6_endpoint_url÷s  racCsht |¡rdSt|ƒ}|j}|dur(dSt|ƒdkr8dS|ddkrP|dd…}t dtj¡}| |¡S)zèVerify the endpoint_url is valid. :type endpoint_url: string :param endpoint_url: An endpoint_url. Must have at least a scheme and a hostname. :return: True if the endpoint url is valid. False otherwise. FNéÿrbraz;^((?!-)[A-Z\d-]{1,63}(?|Sˆ|g|¢Ri|¤Ž}||j|<|Sr…)ÚtupleÚsortedrþZ_instance_cacherP)r‰Úargsr¾Ú cache_keyZ kwarg_itemsÚresult©ÚfuncÚ func_namer5r9Ú _cache_guard¦s   z$instance_cache.._cache_guard)r€Ú functoolsÚwraps)r„r†r5rƒr9Úinstance_cache•s r‰cKsht|jƒj d¡}dd„|Dƒ}d}t|ƒdkrB|d |¡d7}|d7}|dvrVdSt||d d dS) z?Switches the current s3 endpoint with an S3 Accelerate endpointracSsg|]}|tvr|‘qSr5©ÚS3_ACCELERATE_WHITELIST©r7Úpr5r5r9r:½r;z-switch_host_s3_accelerate..zhttps://s3-accelerate.rú amazonaws.com)Z ListBucketsÚ CreateBucketZ DeleteBucketNF)Úuse_new_scheme)rrgr]rcrrrfÚ _switch_hosts)r‡Zoperation_namer¾rfr¢r5r5r9Úswitch_host_s3_accelerateµs r’cCs2t |j d¡¡}| |¡r.||}t||ƒdS)zBSwitches the host using a parameter value from a JSON request bodyrN)rräÚdatar9rPr‘)r‡Ú param_nameZ request_jsonÚ new_endpointr5r5r9Úswitch_host_with_paramÈs r–cCst|j||ƒ}||_dSr…)Ú_get_new_endpointrg)r‡r•rÚfinal_endpointr5r5r9r‘Ðsÿr‘cCsRt|ƒ}t|ƒ}|j}|r |j}||j|j|jdf}t|ƒ}t d||f¡|S©NrTzUpdating URI from %s to %s)rryr]r^rzrr£r§)Zoriginal_endpointr•rZnew_endpoint_componentsZoriginal_endpoint_componentsryZfinal_endpoint_componentsr˜r5r5r9r—Ös ûÿr—cCsR|D]H}||vr@t||tƒr@t||tƒr@t||||ƒq||||<qdS)zõDeeply two dictionaries, overriding existing keys in the base. :param base: The base dictionary which will be merged into. :param extra: The dictionary to merge into the base. Keys from this dictionary will take precedence. N)r@rêÚ deep_merge)ÚbaseÚextrarîr5r5r9ršés ÿršcCs| dd¡ ¡S)zcTranslate the form used for event emitters. :param service_id: The service_id to convert. ú ú-)rVrB)Z service_idr5r5r9Úhyphenize_service_idûsrŸc@sHeZdZddd„Zddd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dS)ÚS3RegionRedirectorNcCs,||_||_|jduri|_t |¡|_dSr…)Ú_endpoint_resolverÚ_cacheÚweakrefÚproxyÚ_client)r‰Zendpoint_bridgeÚclientÚcacher5r5r9rŠs  zS3RegionRedirector.__init__cCs<|p |jjj}| d|j¡| d|j¡| d|j¡dS)Nzneeds-retry.s3zbefore-call.s3úbefore-parameter-build.s3)r¥Úmetar1ÚregisterÚredirect_from_errorÚset_request_urlÚredirect_from_cache)r‰Ú event_emitterZemitterr5r5r9rªs ÿzS3RegionRedirector.registercKs¨|dur dS| | di¡¡r,t d¡dS| di¡ d¡rLt d¡dS|d di¡}| d¡}|d d i¡}|d vo†|jd k}|d vo¨|jd ko¨d | di¡v} |dko¸d|v} |dduoÒ|djdv} |dk} t|| | | | gƒsòdS|ddd} |d d¡}| | |¡}|duraccesspoint|outpost)[/:](?P.+)$zc^(?P[a-zA-Z0-9\-]{1,63})[/:]accesspoint[/:](?P[a-zA-Z0-9\-]{1,63}$)rNcCs||_|durtƒ|_dSr…©Ú _arn_parserrér‰Z arn_parserr5r5r9rŠÄszS3ArnParamHandler.__init__cCs| d|j¡dS)Nr¨©rªÚ handle_arn©r‰r®r5r5r9rªÉszS3ArnParamHandler.registercKs`|j|jvrdS| |¡}|dur&dS|ddkrB| |||¡n|ddkr\| |||¡dS)NÚ resource_typeÚ accesspointÚoutpost)rYÚ_BLACKLISTED_OPERATIONSÚ"_get_arn_details_from_bucket_paramÚ_store_accesspointÚ_store_outpost)r‰rÀÚmodelr|r¾Ú arn_detailsr5r5r9rÓÌs    zS3ArnParamHandler.handle_arncCsFd|vrBz&|d}|j |¡}| ||¡|WSty@Yn0dS)Nr¾)rÐrÍÚ_add_resource_type_and_namerÂ)r‰rÀrÌrÝr5r5r9rÙ×s   z4S3ArnParamHandler._get_arn_details_from_bucket_paramcCs@|j |d¡}|r2| d¡|d<| d¡|d<n t|d‚dS)NrËrÕÚ resource_name)rÌ)Ú_RESOURCE_REGEXr_Úgroupr)r‰rÌrÝr_r5r5r9rÞâs z-S3ArnParamHandler._add_resource_type_and_namecCs8|d|d<|d|d|d|d|ddœ|d<dS) Nrßr¾rÊrÈrzrÉ)rYrÊrÈrzrÉryr5)r‰rÀr|rÝr5r5r9rÚês ûz$S3ArnParamHandler._store_accesspointcCsd|d}|j |¡}|s"t|d‚| d¡}||d<| d¡||d|d|d|d d œ|d <dS) Nrß)rßÚaccesspoint_namer¾Ú outpost_namerÊrÈrzrÉ)rãrYrÊrÈrzrÉry)Ú_OUTPOST_RESOURCE_REGEXr_r rá)r‰rÀr|rÝrßr_râr5r5r9rÛûs   úz S3ArnParamHandler._store_outpost)N)r€rr‚rWrdràrärØrŠrªrÓrÙrÞrÚrÛr5r5r5r9rθsÿÿÿ   rÎc@sêeZdZdZdZd6dd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zed0d1„ƒZed2d3„ƒZed4d5„ƒZdS)7ÚS3EndpointSetterÚawsrŽNcCs@||_||_||_|dur i|_||_||_|dur<|j|_dSr…©r¡Ú_regionÚ _s3_configÚ _endpoint_urlÚ _partitionÚ_DEFAULT_PARTITION©r‰Zendpoint_resolverrzZ s3_configr`rÈr5r5r9rŠszS3EndpointSetter.__init__cCs.| d|j¡| d|j¡| d|j¡dS)Nzbefore-sign.s3zchoose-signer.s3z%before-call.s3.WriteGetObjectResponse)rªÚ set_endpointÚ set_signerÚ#update_endpoint_to_s3_object_lambdarÔr5r5r9rªs þzS3EndpointSetter.registercKsh|jrtdd‚| |d¡|jr&dS|j}| d|j¡}dj|d|dd}t|d|d ƒ|d<dS) NzOS3 client does not support accelerate endpoints for S3 Object Lambda operations©Úmsgús3-object-lambdazhttps://{host_prefix}{hostname}Ú host_prefixrc)rôrcrgF) Ú_use_accelerate_endpointr%Ú_override_signing_namerêr¡Úconstruct_endpointrèÚformatr—)r‰rÀr|r¾ÚresolverÚresolvedr•r5r5r9rð'sÿ þz4S3EndpointSetter.update_endpoint_to_s3_object_lambdacKs‚| |¡rL| |¡| |¡| |¡| |¡}| |¡| ||¡dS|jrdtfd|i|¤Ž|j r~|j fd|i|¤ŽdS)Nr‡) Ú_use_accesspoint_endpointÚ_validate_accesspoint_supportedÚ_validate_fips_supportedÚ_validate_global_regionsÚ(_resolve_region_for_accesspoint_endpointÚ._resolve_signing_name_for_accesspoint_endpointÚ_switch_to_accesspoint_endpointrõr’Ú_s3_addressing_handler)r‰r‡r¾rir5r5r9rî>s     ÿÿ zS3EndpointSetter.set_endpointcCs d|jvSrÁ©r|rˆr5r5r9rûNsz*S3EndpointSetter._use_accesspoint_endpointcCs”d|jvrdSd|jdvr,td|jd‚|j dd¡ dd¡}|jdd }||kr|j d d ¡r|td |j|fd‚ntd |j|fd‚dS)NÚfipsrãryzhClient is configured to use the FIPS psuedo-region "%s", but outpost ARNs do not support FIPS endpoints.rñzfips-rTz-fipsrzÚuse_arn_regionTzâClient is configured to use the FIPS psuedo-region "%s", but the access-point ARN provided is for the "%s" region. The use_arn_region configuration does not allow for cross-region calls when a FIPS pseudo-region is configured.z×Client is configured to use the FIPS psuedo-region "%s", but the access-point ARN provided is for the "%s" region. For clients using a FIPS psuedo-region calls to access-point ARNs in another region are not allowed.)rèr|rrVrérP)r‰r‡r¶Úaccesspoint_regionr5r5r9rýQs. þþÿüþ üþz)S3EndpointSetter._validate_fips_supportedcCs0|j dd¡rdS|jdvr,td|jd‚dS)NrT)z aws-globalz s3-external-1z‚Client is configured to use the global psuedo-region "%s". When providing access-point ARNs a regional endpoint must be specified.rñ)rérPrèrrˆr5r5r9rþus þþz)S3EndpointSetter._validate_global_regionscCs¢|jrtdd‚|jdd}||jkrmr;z.) rérPrêrr]r}rcrrÚsetÚall)r‰r]rfZ feature_partsr5r5r9rõLs       z)S3EndpointSetter._use_accelerate_endpointcCs"|jr dS|j d¡}|r|SdS)NÚvirtualZaddressing_style)rõrérP)r‰Zconfigured_addressing_styler5r5r9Ú_addressing_styleos  z"S3EndpointSetter._addressing_stylecCsH|jdkrt d¡tS|jdks,|jdur:t d¡dSt d¡tS)Nr&z'Using S3 virtual host style addressing.r^zUsing S3 path style addressing.zSDefaulting to S3 virtual host style addressing with path style addressing fallback.)r'r£r§rrrêrur r5r5r9r{s    z'S3EndpointSetter._s3_addressing_handler)NNNN)r€rr‚rìrrŠrªrðrîrûrýrþrürrÿrïrrr rrrr rrr rör>rõr'rr5r5r5r9rås@ÿ $ $  !    " råc@sØeZdZdZdZe d¡Zd3dd„Zdd„Z d d „Z d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„ZdS)4ÚS3ControlEndpointSetterrærŽz^[a-zA-Z0-9\-]{1,63}$NcCs@||_||_||_|dur i|_||_||_|dur<|j|_dSr…rçrír5r5r9rŠ˜sz S3ControlEndpointSetter.__init__cCs| d|j¡dS)Nzbefore-sign.s3-control)rªrîrÔr5r5r9rª¤sz S3ControlEndpointSetter.registercKs†| |¡r@| |¡| |¡}| |¡| ||¡| |¡nB| |¡r‚| |¡|jd}|  |d¡|  |j ¡}|  ||¡dS)NÚ outpost_idr) Ú_use_endpoint_from_arn_detailsÚ-_validate_endpoint_from_arn_details_supportedÚ _resolve_region_from_arn_detailsÚ&_resolve_signing_name_from_arn_detailsÚ"_resolve_endpoint_from_arn_detailsÚ_add_headers_from_arn_detailsÚ_use_endpoint_from_outpost_idÚ#_validate_outpost_redirection_validr|röÚ_construct_outpost_endpointrèÚ_update_request_netloc)r‰r‡r¾rir)Ú new_netlocr5r5r9rî§s           z$S3ControlEndpointSetter.set_endpointcCs d|jvS)NrÝrrˆr5r5r9r*µsz6S3ControlEndpointSetter._use_endpoint_from_arn_detailscCs d|jvS)Nr)rrˆr5r5r9r0¸sz5S3ControlEndpointSetter._use_endpoint_from_outpost_idcCsœ|j dd¡s>|jdd}||jkr>d||jf}t|d‚|jdd}||jkrjtd|j|fd‚|j d ¡r€td d‚d |jdvr˜| |¡dS) NrFrÝrzzpThe use_arn_region configuration is disabled but received arn for "%s" when the client is configured to use "%s"rñrÈzClient is configured for "%s" partition, but arn provided is for "%s" partition. The client and arn partition must be the same.r!z7S3 control client does not support accelerate endpointsrã)rérPr|rèr!rër1)r‰r‡Ú arn_regionÚ error_msgZrequest_partionr5r5r9r+»s* ü  ÿþþ ÿzES3ControlEndpointSetter._validate_endpoint_from_arn_details_supportedcCs|j d¡rtdd‚dS)NrzPClient does not support s3 dualstack configuration when an outpost is specified.rñ)rérPr!rˆr5r5r9r1Ös þz;S3ControlEndpointSetter._validate_outpost_redirection_validcCs2|j dd¡r,|jdd}| ||¡|S|jS)NrFrÝrz)rérPr|r rè)r‰r‡r5r5r5r9r,ßs  z8S3ControlEndpointSetter._resolve_region_from_arn_detailscCs|jdd}| ||¡|S)NrÝrÉr )r‰r‡Z arn_servicer5r5r9r-ès z>S3ControlEndpointSetter._resolve_signing_name_from_arn_detailscCs| ||¡}| ||¡dSr…)Ú _resolve_netloc_from_arn_detailsr3)r‰r‡rir4r5r5r9r.ís z:S3ControlEndpointSetter._resolve_endpoint_from_arn_detailscCs@t|jƒ}t|j||j|jdfƒ}t d|j|f¡||_dSr™)rrgrryr^rzr£r§)r‰r‡r4r Zarn_details_endpointr5r5r9r3ñs û ÿz.S3ControlEndpointSetter._update_request_netloccCs0|jd}d|vr| |¡S|d}| ||¡S)NrÝrãrÊ)r|r2Ú_construct_s3_control_endpoint)r‰r‡rirÝrÊr5r5r9r7ÿs   z8S3ControlEndpointSetter._resolve_netloc_from_arn_detailscCs |j |¡Sr…)Ú_HOST_LABEL_REGEXr_)r‰Úlabelr5r5r9Ú_is_valid_host_labelsz,S3ControlEndpointSetter._is_valid_host_labelcGs"|D]}| |¡st|d‚qdS)N)r:)r;r#)r‰Úlabelsr:r5r5r9Ú_validate_host_labels s z-S3ControlEndpointSetter._validate_host_labelscCs\| ||¡|jr(t|jƒj}||g}n*|dg}| |¡| |¡}| ||g¡| |¡S)Nz s3-control)r=rêrr]Ú_add_dualstackrríÚ_construct_netloc)r‰rirÊrr]rr5r5r9r8s   þ  z6S3ControlEndpointSetter._construct_s3_control_endpointcCs6| |¡|jrt|jƒjSd|| |¡g}| |¡S)Nr)r=rêrr]rr?)r‰rir]r5r5r9r2s  ýz3S3ControlEndpointSetter._construct_outpost_endpointcCs d |¡S)Nra)rf©r‰r]r5r5r9r?)sz)S3ControlEndpointSetter._construct_netloccCs|j d¡r| d¡dS)Nrr+)rérPrer@r5r5r9r>,s z&S3ControlEndpointSetter._add_dualstackcCs,|j d|¡}|j}|r(d|vr(|d}|Srrrr5r5r9r0sÿ z'S3ControlEndpointSetter._get_dns_suffixcCs$|j di¡}||d<||jd<dSrrrr5r5r9r 8sz0S3ControlEndpointSetter._override_signing_regioncCs$|j di¡}||d<||jd<dSrr)r‰r‡r r½r5r5r9röAsz.S3ControlEndpointSetter._override_signing_namecCs(|jd}| d¡}|r$| ||¡dS)NrÝrã)r|rPÚ_add_outpost_id_header)r‰r‡rÝrãr5r5r9r/Js  z5S3ControlEndpointSetter._add_headers_from_arn_detailscCs||jd<dS)Nzx-amz-outpost-id)r¬)r‰r‡rãr5r5r9rAPsz.S3ControlEndpointSetter._add_outpost_id_header)NNNN)r€rr‚rìrrWrdr9rŠrªrîr*r0r+r1r,r-r.r3r7r;r=r8r2r?r>rr rör/rAr5r5r5r9r(“s8 ÿ      r(c@s€eZdZe d¡Zddd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZdS)ÚS3ControlArnParamHandlerz[/:]NcCs||_|durtƒ|_dSr…rÏrÑr5r5r9rŠWsz!S3ControlArnParamHandler.__init__cCs| d|j¡dS)Nz!before-parameter-build.s3-controlrÒrÔr5r5r9rª\sþz!S3ControlArnParamHandler.registercKs:|jdvr| |||¡n| |||¡| |||¡dS)N)rZListRegionalBuckets)rYÚ_handle_outpost_id_paramÚ_handle_name_paramÚ_handle_bucket_param)r‰rÀrÜr|r¾r5r5r9rÓbs z#S3ControlArnParamHandler.handle_arncCsV||vr dSz0||}|j |¡}||d<| |¡|d<|WStyPYdS0dS)NrïÚ resources)rÐrÍÚ_split_resourcerÂ)r‰rÀr”rÌrÝr5r5r9Ú_get_arn_details_from_paramls  z4S3ControlArnParamHandler._get_arn_details_from_paramcCs|j |d¡S)NrË)Ú_RESOURCE_SPLIT_REGEXrc)r‰rÝr5r5r9rGxsz(S3ControlArnParamHandler._split_resourcecCsD|d}d|vr8|d|kr8d|d}t|d|d‚||d<dS)NrÊZ AccountIdzGAccount ID in arn does not match the AccountId parameter provided: "%s"rï©rÌrò)r")r‰rÀrÝZ account_idr6r5r5r9Ú_override_account_id_param{sýþz3S3ControlArnParamHandler._override_account_id_paramcCsd|vr dS|d|d<dS)NZ OutpostIdr)r5)r‰rÀrÜr|r5r5r9rCˆsz1S3ControlArnParamHandler._handle_outpost_id_paramcCsX|jdkrdS| |d¡}|dur&dS| |¡r@| |||¡nd}t|d|d‚dS)NZCreateAccessPointÚNamez4The Name parameter does not support the provided ARNrïrJ)rYrHÚ_is_outpost_accesspointÚ_store_outpost_accesspointr"©r‰rÀrÜr|rÝr6r5r5r9rDs   þz+S3ControlArnParamHandler._handle_name_paramcCs@|ddkrdS|d}t|ƒdkr(dS|ddko>|dd kS) NrÉrFrFrÇrr×rvrÖ©rr©r‰rÝrFr5r5r9rMs   z0S3ControlArnParamHandler._is_outpost_accesspointcCsD| ||¡|dd}||d<||d<|dd|d<||d<dS)NrFrkrLrâr(rãrÝ©rK)r‰rÀr|rÝrâr5r5r9rN¦s   z3S3ControlArnParamHandler._store_outpost_accesspointcCsJ| |d¡}|durdS| |¡r2| |||¡nd}t|d|d‚dS)Nr¾z6The Bucket parameter does not support the provided ARNrïrJ)rHÚ_is_outpost_bucketÚ_store_outpost_bucketr"rOr5r5r9rE®s  ÿþz-S3ControlArnParamHandler._handle_bucket_paramcCs@|ddkrdS|d}t|ƒdkr(dS|ddko>|dd kS) NrÉrFrFrÇrr×rvrµrPrQr5r5r9rS½s   z+S3ControlArnParamHandler._is_outpost_bucketcCsD| ||¡|dd}||d<||d<|dd|d<||d<dS)NrFrkr¾ror(rãrÝrR)r‰rÀr|rÝror5r5r9rTÆs   z.S3ControlArnParamHandler._store_outpost_bucket)N)r€rr‚rWrdrIrŠrªrÓrHrGrKrCrDrMrNrErSrTr5r5r5r9rBTs       rBc@sreZdZdZdZdZdZeddgZdej fdd „Z dd d „Z d d „Z dd„Z dd„Zddd„Zdd„Zdd„ZdS)ÚContainerMetadataFetcherrvrkr(z 169.254.170.2Ú localhostz 127.0.0.1NcCs(|durtjj|jd}||_||_dS)N)r)r˜r™ršÚTIMEOUT_SECONDSrœÚ_sleep)r‰rIÚsleepr5r5r9rŠ×s ÿz!ContainerMetadataFetcher.__init__cCs| |¡| ||¡S)zôRetrieve JSON metadata from container metadata. :type full_url: str :param full_url: The full URL of the metadata service. This should include the scheme as well, e.g "http://localhost:123/foo" )Ú_validate_allowed_urlÚ_retrieve_credentials)r‰Úfull_urlr¬r5r5r9Úretrieve_full_urißs z*ContainerMetadataFetcher.retrieve_full_uricCs:tj |¡}| |j¡}|s6td|jd |j¡fƒ‚dS)NzGUnsupported host '%s'. Can only retrieve metadata from these hosts: %sz, )r˜Úcompatr Ú_check_if_whitelisted_hostrcrærfÚ_ALLOWED_HOSTS)r‰r\ÚparsedZis_whitelisted_hostr5r5r9rZës ÿþÿz.ContainerMetadataFetcher._validate_allowed_urlcCs||jvrdSdS)NTF)r`)r‰r|r5r5r9r_õs z3ContainerMetadataFetcher._check_if_whitelisted_hostcCs| |¡}| |¡S)zÃRetrieve JSON metadata from ECS metadata. :type relative_uri: str :param relative_uri: A relative URI, e.g "/foo/bar?id=123" :return: The parsed JSON response. )r\r[)r‰Ú relative_urir\r5r5r9Ú retrieve_uriús z%ContainerMetadataFetcher.retrieve_uric CsŒddi}|dur| |¡d}z| |||j¡WSty„}z.r;)Útellr r.r/Úseekr1)rZstart_positionrr2r5r€r9r{q s   r{cKsD|d}|d}tr@|dur@d|vr@t|fi|¤Ž}||dd<dS)z1Only add a Content-MD5 if the system supports it.r¬r*Nz Content-MD5)r r~)rÀr¾r¬r*Z md5_digestr5r5r9Úconditionally_calculate_md5z s r„c@s eZdZefdd„Zdd„ZdS)ÚFileWebIdentityTokenLoadercCs||_||_dSr…)Ú_web_identity_token_pathrõ)r‰Zweb_identity_token_pathrõr5r5r9rŠ„ sz#FileWebIdentityTokenLoader.__init__cCs8| |j¡}| ¡WdƒS1s*0YdSr…)rõr†rñ)r‰Z token_filer5r5r9Ú__call__ˆ sz#FileWebIdentityTokenLoader.__call__N)r€rr‚ÚopenrŠr‡r5r5r5r9r…ƒ s r…c@s&eZdZddd„Zdd„Zdd„ZdS) ÚSSOTokenLoaderNcCs|dur i}||_dSr…)r¢)r‰r§r5r5r9rŠŽ szSSOTokenLoader.__init__cCst | d¡¡ ¡S)Nr)r,Úsha1r r0)r‰Ú start_urlr5r5r9Ú_generate_cache_key“ sz"SSOTokenLoader._generate_cache_keycCsR| |¡}z|j|}|dWStyLtjdddd}t|d‚Yn0dS)NZ accessTokenzFailed to load SSO token:Tr¯z@The SSO access token has either expired or is otherwise invalid.rj)rŒr¢ÚKeyErrorr£r§r)r‰r‹rrÈr6r5r5r9r‡– s    ÿzSSOTokenLoader.__call__)N)r€rr‚rŠrŒr‡r5r5r5r9r‰ s r‰)T)F)N)F)N)N)T)T)rq)šr|rWrlÚloggingr r,r7r‡r£rTr“rorsÚwarningsZdateutil.parserrZ dateutil.tzrr˜Zbotocore.awsrequestZbotocore.httpsessionZbotocore.compatrrrrrrr r r r r rZ*botocore.vendored.six.moves.urllib.requestrrZbotocore.exceptionsrrrrrrrrrrrrrrrr r!r"r#r$r%r&Zurllib3.exceptionsr'Ú getLoggerr€r£rÒr¥r¦rHZ SAFE_CHARSrdrmr½r‹Z EVENT_ALIASESÚIPV4_PATÚHEX_PATrøÚLS32_PATr6Ú _variationsÚUNRESERVED_PATrfÚIPV6_PATÚ ZONE_ID_PATÚIPV6_ADDRZ_PATr^Ú frozensetr[rErJrSrZr_r`r\rprsr~Ú Exceptionrr„Úobjectr‹rÓrërðrˆrøròrrrrrr%r3r<r6r>rErarhr¨rjrqrurrrwr‰r’r–r‘r—ršrŸr rærÂrÃrÎrår(rBrUr›rmrwr~rzr{r„r…r‰r5r5r5r9Ú sv 8`   þ·N     !$V   $ -  !` ÿ ÿ ?   !WB{d