-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
331 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1 @@ | ||
# NOTE: These imports are deprecated and will be removed in 2.x | ||
import os | ||
|
||
# Enabling this will enable the old http exception behavior that exposed raw aiohttp | ||
# exceptions and old session variables available via __init__. Disabling will swap to | ||
# botocore exceptions and will not have these imports to match botocore. | ||
# NOTE: without setting this to 0, retries may not work, see #876 | ||
DEPRECATED_1_4_0_APIS = int(os.getenv('AIOBOTOCORE_DEPRECATED_1_4_0_APIS', '0')) | ||
|
||
if DEPRECATED_1_4_0_APIS: | ||
from .session import get_session, AioSession | ||
|
||
__all__ = ['get_session', 'AioSession'] | ||
|
||
__version__ = '2.1.2' | ||
__version__ = '2.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from botocore.configprovider import os, SmartDefaultsConfigStoreFactory | ||
|
||
|
||
class AioSmartDefaultsConfigStoreFactory(SmartDefaultsConfigStoreFactory): | ||
async def merge_smart_defaults(self, config_store, mode, region_name): | ||
if mode == 'auto': | ||
mode = await self.resolve_auto_mode(region_name) | ||
default_configs = self._default_config_resolver.get_default_config_values( | ||
mode) | ||
for config_var in default_configs: | ||
config_value = default_configs[config_var] | ||
method = getattr(self, f'_set_{config_var}', None) | ||
if method: | ||
method(config_store, config_value) | ||
|
||
async def resolve_auto_mode(self, region_name): | ||
current_region = None | ||
if os.environ.get('AWS_EXECUTION_ENV'): | ||
default_region = os.environ.get('AWS_DEFAULT_REGION') | ||
current_region = os.environ.get('AWS_REGION', default_region) | ||
if not current_region: | ||
if self._instance_metadata_region: | ||
current_region = self._instance_metadata_region | ||
else: | ||
try: | ||
current_region = \ | ||
await self._imds_region_provider.provide() | ||
self._instance_metadata_region = current_region | ||
except Exception: | ||
pass | ||
|
||
if current_region: | ||
if region_name == current_region: | ||
return 'in-region' | ||
else: | ||
return 'cross-region' | ||
return 'standard' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.