HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/botocore/__pycache__/regions.cpython-310.pyc
o

*we�~�@sdZddlZddlZddlZddlmZddlmZmZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZdd	lm Z m!Z!e�"e#�Z$d
Z%diiZ&Gdd
�d
�Z'Gdd�de'�Z(Gdd�de)e�Z*Gdd�d�Z+dS)z�Resolves regions and endpoints.

This module implements endpoint resolution, including resolving endpoints for a
given service and region and resolving the available endpoints for a service
in a specific AWS partition.
�N)�Enum)�UNSIGNED�
xform_name)�AUTH_TYPE_MAPS�HAS_CRT��CRT_SUPPORTED_AUTH_TYPES)�EndpointProvider)�EndpointProviderError�EndpointVariantError�!InvalidEndpointConfigurationError�InvalidHostLabelError�MissingDependencyException�
NoRegionError�ParamValidationError�$UnknownEndpointResolutionBuiltInName�UnknownRegionError�UnknownSignatureVersionError�*UnsupportedS3AccesspointConfigurationError�UnsupportedS3ConfigurationError�UnsupportedS3ControlArnError�&UnsupportedS3ControlConfigurationError)�ensure_boolean�instance_cachez{service}.{region}.{dnsSuffix}�	endpointsc@s.eZdZdZddd�Zdd�Z	dd	d
�ZdS)
�BaseEndpointResolverz3Resolves regions and endpoints. Must be subclassed.NcC�t�)a7Resolves an endpoint for a service and region combination.

        :type service_name: string
        :param service_name: Name of the service to resolve an endpoint for
            (e.g., s3)

        :type region_name: string
        :param region_name: Region/endpoint name to resolve (e.g., us-east-1)
            if no region is provided, the first found partition-wide endpoint
            will be used if available.

        :rtype: dict
        :return: Returns a dict containing the following keys:
            - partition: (string, required) Resolved partition name
            - endpointName: (string, required) Resolved endpoint name
            - hostname: (string, required) Hostname to use for this endpoint
            - sslCommonName: (string) sslCommonName to use for this endpoint.
            - credentialScope: (dict) Signature version 4 credential scope
              - region: (string) region name override when signing.
              - service: (string) service name override when signing.
            - signatureVersions: (list<string>) A list of possible signature
              versions, including s3, v4, v2, and s3v4
            - protocols: (list<string>) A list of supported protocols
              (e.g., http, https)
            - ...: Other keys may be included as well based on the metadata
        ��NotImplementedError)�self�service_name�region_name�r"�I/home/arjun/projects/env/lib/python3.10/site-packages/botocore/regions.py�construct_endpoint6sz'BaseEndpointResolver.construct_endpointcCr)z�Lists the partitions available to the endpoint resolver.

        :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]).
        r�rr"r"r#�get_available_partitionsSsz-BaseEndpointResolver.get_available_partitions�awsFcCr)a�Lists the endpoint names of a particular partition.

        :type service_name: string
        :param service_name: Name of a service to list endpoint for (e.g., s3)

        :type partition_name: string
        :param partition_name: Name of the partition to limit endpoints to.
            (e.g., aws for the public AWS endpoints, aws-cn for AWS China
            endpoints, aws-us-gov for AWS GovCloud (US) Endpoints, etc.

        :type allow_non_regional: bool
        :param allow_non_regional: Set to True to include endpoints that are
             not regional endpoints (e.g., s3-external-1,
             fips-us-gov-west-1, etc).
        :return: Returns a list of endpoint names (e.g., ["us-east-1"]).
        r)rr �partition_name�allow_non_regionalr"r"r#�get_available_endpointsZsz,BaseEndpointResolver.get_available_endpoints�N)r'F)�__name__�
__module__�__qualname__�__doc__r$r&r*r"r"r"r#r3s
�rc@s�eZdZdZddgZd%dd�Zd&dd	�Zd
d�Z			d'd
d�Z	d(dd�Z					d)dd�Z
dd�Z	d%dd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)*�EndpointResolverz7Resolves endpoints based on partition endpoint metadatazaws-isoz	aws-iso-bFcCs d|vrtd��||_||_dS)a
        :type endpoint_data: dict
        :param endpoint_data: A dict of partition data.

        :type uses_builtin_data: boolean
        :param uses_builtin_data: Whether the endpoint data originates in the
            package's data directory.
        �
partitionsz%Missing "partitions" in endpoint dataN)�
ValueError�_endpoint_data�uses_builtin_data)r�
endpoint_datar4r"r"r#�__init__us	
zEndpointResolver.__init__r'cCsB|jdD]}|d|krq|d}||vrq||dSdS)Nr1�	partition�servicesr)r3)rr r(r7r8r"r"r#�get_service_endpoints_data�s�z+EndpointResolver.get_service_endpoints_datacCs&g}|jdD]	}|�|d�q|S)Nr1r7)r3�append)r�resultr7r"r"r#r&�sz)EndpointResolver.get_available_partitionsNcCs�g}|jdD]@}|d|krq|d}||vrq||d}|D]%}	|	|dv}
|r=|
r=|�||	|�}|r<|�|	�q!|sA|
rF|�|	�q!q|S)Nr1r7r8r�regions)r3�_retrieve_variant_datar:)rr r(r)�endpoint_variant_tagsr;r7r8�service_endpoints�
endpoint_name�is_regional_endpoint�variant_datar"r"r#r*�s,�
�
��z(EndpointResolver.get_available_endpointscCs\|jdD]&}|d|kr+|r%|�|�d�|�}|r$d|vr$|dSq|dSqdS)Nr1r7�defaults�	dnsSuffix)r3r=�get)rr(r>r7�variantr"r"r#�get_partition_dns_suffix�s
���	z)EndpointResolver.get_partition_dns_suffixc	Cs�|dkr|r|durd}|dur4d}|jdD]
}|d|kr!|}q|dur2|�|||||d�}|SdS|jdD]}|rE|d|jvrEq9|�|||||�}|rT|Sq9dS)N�s3z	us-east-1r1r7T)r3�_endpoint_for_partition�!_UNSUPPORTED_DUALSTACK_PARTITIONS)	rr r!r(�use_dualstack_endpoint�use_fips_endpoint�valid_partitionr7r;r"r"r#r$�sN	�������z#EndpointResolver.construct_endpointcCs4|jdD]}|�||�r|dSqt|dd��)Nr1r7z,No partition found for provided region_name.)r!�	error_msg)r3�
_region_matchr)rr!r7r"r"r#�get_partition_for_region�s��z)EndpointResolver.get_partition_for_regionc
Cs|d}|r||jvrd|}tdg|d��|d�|t�}	|dur.d|	vr+|	d}nt��|||	|||d�}
||	dvrE|jdi|
��S|�||�sM|r|	�d�}|	�d	d
�}|rp|spt�d|||�||
d<|jdi|
��St�d
||�|jdi|
��SdS)Nr7z@Dualstack endpoints are currently not supported for %s partition�	dualstack��tagsrNr8�partitionEndpoint)r7r �service_datar@rKrLr�isRegionalizedTz'Using partition endpoint for %s, %s: %sr@z*Creating a regex based endpoint for %s, %sr")	rJrrE�DEFAULT_SERVICE_DATAr�_resolverO�LOG�debug)
rr7r r!rKrL�force_partitionr(rNrU�resolve_kwargs�partition_endpoint�is_regionalizedr"r"r#rI�sX	�
���
�

���z(EndpointResolver._endpoint_for_partitioncCs0||dvrdSd|vrt�|d��|�SdS)Nr<T�regionRegexF)�re�compile�match)rr7r!r"r"r#rO9s
zEndpointResolver._region_matchcCs>|�dg�}|D]}t|d�t|�kr|��}|SqdS)N�variantsrS)rE�set�copy)rr5rSrcrFr;r"r"r#r=@s��z'EndpointResolver._retrieve_variant_datacCs$g}|r	|�d�|r|�d�|S)NrQ�fips)r:)rrKrLrSr"r"r#�_create_tag_listGs

z!EndpointResolver._create_tag_listcCs4i}|||fD]}|�||�}|r|�||�q|Sr+)r=�_merge_keys)rrSr5�service_defaults�partition_defaultsr;rcrFr"r"r#�_resolve_variantOs�z!EndpointResolver._resolve_variantc
Cs"|�di��|i�}|�d�rt�d|�|�di�}|�di�}	|�||�}
|
rK|�|
|||	�}|ikrDd|�d|��}t|
|d��|�||�n|}d|vrW|d|d<|d	|d	<||d
<|�||�|�|	|�|�||d|||d�|d<d|vr�|�||d|||d�|d<|S)
Nr�
deprecatedz5Client is configured with the deprecated endpoint: %srCzEndpoint does not exist for z in region rRrDr7�endpointName�hostname�
sslCommonName)rErY�warningrgrkrrh�_expand_template)
rr7r rUr@rKrLr5rirjrSr;rNr"r"r#rXYs\	�
�������zEndpointResolver._resolvecCs"|D]}||vr||||<qdSr+r")r�	from_datar;�keyr"r"r#rh�s
��zEndpointResolver._merge_keyscCs|j|||d�S)N)�service�regionrD)�format)rr7�templater r@rDr"r"r#rq�s�z!EndpointResolver._expand_template)F)r')r'FNr+)NNFF)r,r-r.r/rJr6r9r&r*rGr$rPrIrOr=rgrkrXrhrqr"r"r"r#r0ps6

		
�
�
�2
�A
Br0c@s8eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dS)
�EndpointResolverBuiltinszAWS::RegionzAWS::UseFIPSzAWS::UseDualStackzAWS::STS::UseGlobalEndpointzAWS::S3::UseGlobalEndpointzAWS::S3::AcceleratezAWS::S3::ForcePathStylezAWS::S3::UseArnRegionzAWS::S3Control::UseArnRegionz'AWS::S3::DisableMultiRegionAccessPointsz
SDK::EndpointN)r,r-r.�
AWS_REGION�AWS_USE_FIPS�AWS_USE_DUALSTACK�AWS_STS_USE_GLOBAL_ENDPOINT�AWS_S3_USE_GLOBAL_ENDPOINT�AWS_S3_ACCELERATE�AWS_S3_FORCE_PATH_STYLE�AWS_S3_USE_ARN_REGION�AWS_S3CONTROL_USE_ARN_REGION�AWS_S3_DISABLE_MRAP�SDK_ENDPOINTr"r"r"r#rx�srxc@s�eZdZdZ		d$dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zedd��Z
edd��Zedd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)%�EndpointRulesetResolverz5Resolves endpoints using a service's endpoint rulesetTNc		CsHt||d�|_|jjj|_||_||_||_||_||_	||_
i|_dS)N)�ruleset_data�partition_data)r	�	_provider�ruleset�
parameters�_param_definitions�_service_model�	_builtins�_client_context�_event_emitter�_use_ssl�_requested_auth_scheme�_instance_cache)	r�endpoint_ruleset_datar��
service_model�builtins�client_context�
event_emitter�use_ssl�requested_auth_schemer"r"r#r6�s�
z EndpointRulesetResolver.__init__c
Cs�|duri}|duri}|�|||�}t�d|�z|jjdi|��}Wnty?}z|�||�}|dur8�||�d}~wwt�d|j�|js_|j�	d�r_|j
d|jdd���d�}|j
dd	�|j��D�d
�}|S)zAInvokes the provider with params defined in the service's rulesetNz-Calling endpoint provider with parameters: %szEndpoint provider result: %szhttps://zhttp://�)�urlcSsi|]	\}}||d�qS)rr")�.0rs�valr"r"r#�
<dictcomp>
s�z>EndpointRulesetResolver.construct_endpoint.<locals>.<dictcomp>)�headersr")
�_get_provider_paramsrYrZr��resolve_endpointr
�#ruleset_error_to_botocore_exceptionr�r��
startswith�_replacer��items)r�operation_model�	call_args�request_context�provider_params�provider_result�ex�botocore_exceptionr"r"r#r$�sD��

�������z*EndpointRulesetResolver.construct_endpointc	Csli}|�|||�}|j��D]%\}}|j|||d�}|dur+|jdur+|j|j|d�}|dur3|||<q|S)a�Resolve a value for each parameter defined in the service's ruleset

        The resolution order for parameter values is:
        1. Operation-specific static context values from the service definition
        2. Operation-specific dynamic context values from API parameters
        3. Client-specific context parameters
        4. Built-in values such as region, FIPS usage, ...
        )�
param_namer�r�N)�builtin_namer�)�_get_customized_builtinsr�r��_resolve_param_from_context�builtin�_resolve_param_as_builtin)	rr�r�r�r��customized_builtinsr��	param_def�	param_valr"r"r#r�s&����z,EndpointRulesetResolver._get_provider_paramscCs<|�||�}|dur|S|�|||�}|dur|S|�|�Sr+)�&_resolve_param_as_static_context_param�'_resolve_param_as_dynamic_context_param�&_resolve_param_as_client_context_param)rr�r�r��static�dynamicr"r"r#r�5s��
z3EndpointRulesetResolver._resolve_param_from_contextcCs|�|�}|�|�Sr+)�_get_static_context_paramsrE)rr�r��static_ctx_paramsr"r"r#r�Ds

z>EndpointRulesetResolver._resolve_param_as_static_context_paramcCs(|�|�}||vr||}|�|�SdSr+)�_get_dynamic_context_paramsrE)rr�r�r��dynamic_ctx_params�member_namer"r"r#r�Js


�z?EndpointRulesetResolver._resolve_param_as_dynamic_context_paramcCs(|��}||vr||}|j�|�SdSr+)�_get_client_context_paramsr�rE)rr��client_ctx_params�client_ctx_varnamer"r"r#r�Rs
�z>EndpointRulesetResolver._resolve_param_as_client_context_paramcCs"|tj��vrt|d��|�|�S)N��name)rx�__members__�valuesrrE)rr�r�r"r"r#r�Xs

z1EndpointRulesetResolver._resolve_param_as_builtincC�dd�|jD�S)z=Mapping of param names to static param value for an operationcS�i|]}|j|j�qSr")r��value�r��paramr"r"r#r�`���zFEndpointRulesetResolver._get_static_context_params.<locals>.<dictcomp>)�static_context_parameters�rr�r"r"r#r�]��z2EndpointRulesetResolver._get_static_context_paramscCr�)z7Mapping of param names to member names for an operationcSr�r")r�r�r�r"r"r#r�hr�zGEndpointRulesetResolver._get_dynamic_context_params.<locals>.<dictcomp>)�context_parametersr�r"r"r#r�er�z3EndpointRulesetResolver._get_dynamic_context_paramscCsdd�|jjD�S)z7Mapping of param names to client configuration variablecSsi|]	}|jt|j��qSr")r�rr�r"r"r#r�ps��zFEndpointRulesetResolver._get_client_context_params.<locals>.<dictcomp>)r��client_context_parametersr%r"r"r#r�ms�z2EndpointRulesetResolver._get_client_context_paramscCs6|jj��}t�|j�}|jjd|||||d�|S)Nzbefore-endpoint-resolution.%s)r��model�params�context)r��
service_id�	hyphenizerer�r��emit)rr�r�r�r�r�r"r"r#r�us�z0EndpointRulesetResolver._get_customized_builtinscs�t|t�rt|�dkrtd��t�dd�dd�|D���j��jtkr(difS�fdd�|D�}�jd	urSzt	�fd
d�|D��\}}WnEt
yRd	ifYSwz
t	dd�|D��\}}Wn*t
y�d
}dd�|D�}ts{tdd�|D��}|r�t
dd��td�|�d��wi}d|vr�|d|d<nd|vr�t|d�dkr�|dd|d<d|vr�|j|dd�d|vr�t|d�|d<t�d|d||�||fS)a�Convert an Endpoint's authSchemes property to a signing_context dict

        :type auth_schemes: list
        :param auth_schemes: A list of dictionaries taken from the
            ``authSchemes`` property of an Endpoint object returned by
            ``EndpointProvider``.

        :rtype: str, dict
        :return: Tuple of auth type string (to be used in
            ``request_context['auth_type']``) and signing context dict (for use
            in ``request_context['signing']``).
        rz&auth_schemes must be a non-empty list.z_Selecting from endpoint provider's list of auth schemes: %s. User selected auth scheme is: "%s"z, cSsg|]}d|�d��d��qS)�"r�)rE�r��sr"r"r#�
<listcomp>�szGEndpointRulesetResolver.auth_schemes_to_signing_ctx.<locals>.<listcomp>�nonecs&g|]}i|�d��|d�i��qSr�)�_strip_sig_prefix�r��schemer%r"r#r��s��Nc3s,�|]}���j|d�r�j|fVqdS�r�N)�._does_botocore_authname_match_ruleset_authnamer�r�r%r"r#�	<genexpr>�s�
��
�zFEndpointRulesetResolver.auth_schemes_to_signing_ctx.<locals>.<genexpr>css(�|]}|dtvr|d|fVqdSr�)rr�r"r"r#r��s�
��FcSsg|]}|d�qSr�r"r�r"r"r#r��scss�|]}|tvVqdSr+rr�r"r"r#r��s
��
�zbThis operation requires an additional dependency. Use pip install botocore[crt] before proceeding.��msg)�signature_version�
signingRegionru�signingRegionSet�signingName)�signing_name�disableDoubleEncodingz?Selected auth type "%s" as "%s" with signing context params: %sr�)�
isinstance�list�len�	TypeErrorrYrZ�joinr�r�next�
StopIterationr�anyrr�updater)r�auth_schemesr�r��fixable_with_crt�auth_type_options�signing_contextr"r%r#�auth_schemes_to_signing_ctx�st
�

�
���������z3EndpointRulesetResolver.auth_schemes_to_signing_ctxcCs|�d�r|dd�S|S)z6Normalize auth type names by removing any "sig" prefix�sig�N)r�)r�	auth_namer"r"r#r��sz)EndpointRulesetResolver._strip_sig_prefixcCs>|�|�}|�d�d}|dkr|�d�r|dd�}||kS)a\
        Whether a valid string provided as signature_version parameter for
        client construction refers to the same auth methods as a string
        returned by the endpoint ruleset provider. This accounts for:

        * The ruleset prefixes auth names with "sig"
        * The s3 and s3control rulesets don't distinguish between v4[a] and
          s3v4[a] signers
        * The v2, v3, and HMAC v1 based signers (s3, s3-*) are botocore legacy
          features and do not exist in the rulesets
        * Only characters up to the first dash are considered

        Example matches:
        * v4, sigv4
        * v4, v4
        * s3v4, sigv4
        * s3v7, sigv7 (hypothetical example)
        * s3v4a, sigv4a
        * s3v4-query, sigv4

        Example mismatches:
        * v4a, sigv4
        * s3, sigv4
        * s3-presign-post, sigv4
        �-rrH�N)r��splitr�)r�botoname�rsnamer"r"r#r��s

zFEndpointRulesetResolver._does_botocore_authname_match_ruleset_authnamecCsh|j�d�}|durdS|�d�r+z	|�d�d}Wnty%|}Ynwt|d�S|jj}|dkro|dks;|d	kr@t|d
�S|�d�s^|�d�s^|�d
�s^|�d�s^|�d�s^|�d�rct	|d
�S|�
��d�rot|d�S|dkr�|�d�r�|�d�}t||d�S|�d�s�|�d�r�t
|d
�S|dkr�t|d�S|dkr�|�d�r�t|d
�S|dkr�t|d
�SdS)z�Attempts to translate ruleset errors to pre-existing botocore
        exception types by string matching exception strings.
        r�NzInvalid region in ARN: �`�)�labelrHz/S3 Object Lambda does not support S3 Acceleratez#Accelerate cannot be used with FIPSr�zS3 Outposts does not supportzS3 MRAP does not supportz!S3 Object Lambda does not supportzAccess Points do not supportzInvalid configuration:z#Client was configured for partitionzinvalid arn:)�report�	s3controlzInvalid ARN:�Bucket)�arnr�z!AccountId is required but not set�eventszUInvalid Configuration: FIPS is not supported with EventBridge multi-region endpoints.z&EndpointId must be a valid host label.)�kwargsrEr�r��
IndexErrorr
r�r rr�lowerrrrr)r�ruleset_exceptionr�r�rr rr"r"r#r�	s`
�

������



�

�

z;EndpointRulesetResolver.ruleset_error_to_botocore_exception)TN)r,r-r.r/r6r$r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r"r"r"r#r��s.

�2!


a r�),r/re�loggingr`�enumr�botocorerr�
botocore.authrr�botocore.crtr�botocore.endpoint_providerr	�botocore.exceptionsr
rrr
rrrrrrrrrr�botocore.utilsrr�	getLoggerr,rY�DEFAULT_URI_TEMPLATErWrr0�strrxr�r"r"r"r#�<module>s(@
=: