HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3.6/site-packages/botocore/__pycache__/regions.cpython-36.pyc
3

�T_#�@sZdZddlZddlZddlmZeje�ZdZdiiZ	Gdd�de
�ZGdd	�d	e�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)�
NoRegionErrorz{service}.{region}.{dnsSuffix}�	endpointsc@s,eZdZdZddd�Zdd�Zdd	d
�ZdS)
�BaseEndpointResolverz3Resolves regions and endpoints. Must be subclassed.NcCst�dS)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
        N)�NotImplementedError)�self�service_name�region_name�r	�/usr/lib/python3.6/regions.py�construct_endpointsz'BaseEndpointResolver.construct_endpointcCst�dS)z�Lists the partitions available to the endpoint resolver.

        :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]).
        N)r)rr	r	r
�get_available_partitions<sz-BaseEndpointResolver.get_available_partitions�awsFcCst�dS)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"]).
        N)r)rr�partition_name�allow_non_regionalr	r	r
�get_available_endpointsCsz,BaseEndpointResolver.get_available_endpoints)N)r
F)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
rs

rc@s^eZdZdZdd�Zdd�Zddd	�Zddd�Zdd
d�Zdd�Z	dd�Z
dd�Zdd�Zd
S)�EndpointResolverz7Resolves endpoints based on partition endpoint metadatacCsd|krtd��||_dS)zA
        :param endpoint_data: A dict of partition data.
        �
partitionsz%Missing "partitions" in endpoint dataN)�
ValueError�_endpoint_data)rZ
endpoint_datar	r	r
�__init__ZszEndpointResolver.__init__cCs*g}x |jdD]}|j|d�qW|S)Nr�	partition)r�append)r�resultrr	r	r
rbsz)EndpointResolver.get_available_partitionsr
FcCslg}xb|jdD]T}|d|kr"q|d}||kr4qx.||dD]}|sV||dkrB|j|�qBWqW|S)Nrr�servicesr�regions)rr)rrrrrrr�
endpoint_namer	r	r
rhsz(EndpointResolver.get_available_endpointsNcCs~|dk	rPd}x"|jdD]}|d|kr|}qW|dk	rL|j|||d�}|SdSx(|jdD]}|j|||�}|r\|Sq\WdS)NrrT)r�_endpoint_for_partition)rrrrZvalid_partitionrrr	r	r
rvs
z#EndpointResolver.construct_endpointcCs�|dj|t�}|dkr0d|kr*|d}nt��||dkrL|j||||�S|j||�s\|r�|jd�}|jdd�}|r�|r�tjd|||�|j||||�Stjd||�|j||||�SdS)NrZpartitionEndpointrZisRegionalizedTz'Using partition endpoint for %s, %s: %sz*Creating a regex based endpoint for %s, %s)�get�DEFAULT_SERVICE_DATAr�_resolve�
_region_match�LOG�debug)rrrrZforce_partition�service_dataZpartition_endpointZis_regionalizedr	r	r
r �s*



z(EndpointResolver._endpoint_for_partitioncCs0||dkrdSd|kr,tj|d�j|�SdS)NrTZregionRegexF)�re�compile�match)rrrr	r	r
r$�s
zEndpointResolver._region_matchcCs�|dj|i�}|d|d<||d<|j|jdi�|�|j|jdi�|�|jdt�}|j||d||�|d<d|kr�|j||d||�|d<|d|d<|S)NrrZendpointNameZdefaults�hostnameZ
sslCommonName�	dnsSuffix)r!�_merge_keys�DEFAULT_URI_TEMPLATE�_expand_template)rrrr'rrr+r	r	r
r#�s

zEndpointResolver._resolvecCs&x |D]}||kr||||<qWdS)Nr	)rZ	from_datar�keyr	r	r
r-�s
zEndpointResolver._merge_keyscCs|j|||dd�S)Nr,)ZserviceZregionr,)�format)rr�templaterrr	r	r
r/�sz!EndpointResolver._expand_template)r
F)NN)F)
rrrrrrrrr r$r#r-r/r	r	r	r
rXs


r)
rZloggingr(Zbotocore.exceptionsrZ	getLoggerrr%r.r"�objectrrr	r	r	r
�<module>s
;