#2045 Merge from develop and bump version to 2.0.0dev17

Open

@@ -16,7 +16,7 @@
Loading
16 16
import re
17 17
import logging
18 18
19 -
__version__ = '2.0.0dev16'
19 +
__version__ = '2.0.0dev17'
20 20
21 21
22 22
class NullHandler(logging.Handler):

@@ -115,15 +115,28 @@
Loading
115 115
                    result.append(endpoint_name)
116 116
        return result
117 117
118 -
    def construct_endpoint(self, service_name, region_name=None):
118 +
    def construct_endpoint(self, service_name, region_name=None, partition_name=None):
119 +
        if partition_name is not None:
120 +
            valid_partition = None
121 +
            for partition in self._endpoint_data['partitions']:
122 +
                if partition['partition'] == partition_name:
123 +
                    valid_partition = partition
124 +
125 +
            if valid_partition is not None:
126 +
                result = self._endpoint_for_partition(valid_partition, service_name,
127 +
                             region_name, True)
128 +
                return result
129 +
            return None
130 +
119 131
        # Iterate over each partition until a match is found.
120 132
        for partition in self._endpoint_data['partitions']:
121 133
            result = self._endpoint_for_partition(
122 134
                partition, service_name, region_name)
123 135
            if result:
124 136
                return result
125 137
126 -
    def _endpoint_for_partition(self, partition, service_name, region_name):
138 +
    def _endpoint_for_partition(self, partition, service_name, region_name,
139 +
            force_partition=False):
127 140
        # Get the service from the partition, or an empty template.
128 141
        service_data = partition['services'].get(
129 142
            service_name, DEFAULT_SERVICE_DATA)
@@ -138,7 +151,7 @@
Loading
138 151
            return self._resolve(
139 152
                partition, service_name, service_data, region_name)
140 153
        # Check to see if the endpoint provided is valid for the partition.
141 -
        if self._region_match(partition, region_name):
154 +
        if self._region_match(partition, region_name) or force_partition:
142 155
            # Use the partition endpoint if set and not regionalized.
143 156
            partition_endpoint = service_data.get('partitionEndpoint')
144 157
            is_regionalized = service_data.get('isRegionalized', True)

@@ -251,6 +251,15 @@
Loading
251 251
        region_name = self._check_default_region(service_name, region_name)
252 252
        resolved = self.endpoint_resolver.construct_endpoint(
253 253
            service_name, region_name)
254 +
255 +
        # If we can't resolve the region, we'll attempt to get a global
256 +
        # endpoint for non-regionalized services (iam, route53, etc)
257 +
        if not resolved:
258 +
            # TODO: fallback partition_name should be configurable in the
259 +
            # future for users to define as needed.
260 +
            resolved = self.endpoint_resolver.construct_endpoint(
261 +
                service_name, region_name, partition_name='aws')
262 +
254 263
        if resolved:
255 264
            return self._create_endpoint(
256 265
                resolved, service_name, region_name, endpoint_url, is_secure)

Learn more Showing 1 files with coverage changes found.

Changes in botocore/credentials.py
-1
+1
Loading file...
Files Coverage
botocore 0.01% 92.71%
Project Totals (58 files) 92.71%
Loading