123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- --- contrib/python/botocore/py2/botocore/data/endpoints.json (index)
- +++ contrib/python/botocore/py2/botocore/data/endpoints.json (working tree)
- @@ -10656,6 +10656,46 @@
- }
- }
- }
- + }, {
- + "defaults" : {
- + "hostname" : "{service}.{region}.{dnsSuffix}",
- + "protocols" : [ "https" ],
- + "signatureVersions" : [ "v4" ]
- + },
- + "dnsSuffix" : "yandex.net",
- + "partition" : "yandex",
- + "partitionName" : "Yandex",
- + "regions" : {
- + "yandex" : {
- + "description" : "Yandex"
- + }
- + },
- + "services" : {
- + "s3" : {
- + "defaults" : {
- + "protocols" : [ "http", "https" ],
- + "signatureVersions" : [ "s3", "s3v4" ]
- + },
- + "endpoints" : {
- + "yandex" : {
- + "hostname" : "s3.mds.yandex.net"
- + },
- + "yandex-test" : {
- + "hostname" : "s3.mdst.yandex.net"
- + }
- + }
- + },
- + "sqs" : {
- + "defaults" : {
- + "protocols" : [ "http" ]
- + },
- + "endpoints" : {
- + "yandex" : {
- + "hostname": "sqs.yandex.net:8771"
- + }
- + }
- + }
- + }
- } ],
- "version" : 3
- }
- \ No newline at end of file
- --- contrib/python/botocore/py2/botocore/__init__.py (index)
- +++ contrib/python/botocore/py2/botocore/__init__.py (working tree)
- @@ -59,7 +59,7 @@ _xform_cache = {
- # individual case.
- ScalarTypes = ('string', 'integer', 'boolean', 'timestamp', 'float', 'double')
-
- -BOTOCORE_ROOT = os.path.dirname(os.path.abspath(__file__))
- +BOTOCORE_ROOT = os.path.dirname(__file__)
-
-
- # Used to specify anonymous (unsigned) request signature
- --- contrib/python/botocore/py2/botocore/configprovider.py (index)
- +++ contrib/python/botocore/py2/botocore/configprovider.py (working tree)
- @@ -49,7 +49,7 @@ logger = logging.getLogger(__name__)
- BOTOCORE_DEFAUT_SESSION_VARIABLES = {
- # logical: config_file, env_var, default_value, conversion_func
- 'profile': (None, ['AWS_DEFAULT_PROFILE', 'AWS_PROFILE'], None, None),
- - 'region': ('region', 'AWS_DEFAULT_REGION', None, None),
- + 'region': ('region', 'AWS_DEFAULT_REGION', 'yandex', None),
- 'data_path': ('data_path', 'AWS_DATA_PATH', None, None),
- 'config_file': (None, 'AWS_CONFIG_FILE', '~/.aws/config', None),
- 'ca_bundle': ('ca_bundle', 'AWS_CA_BUNDLE', None, None),
- --- contrib/python/botocore/py2/botocore/loaders.py (index)
- +++ contrib/python/botocore/py2/botocore/loaders.py (working tree)
- @@ -101,15 +101,19 @@ information that doesn't quite fit in the original models, but is still needed
- for the sdk. For instance, additional operation parameters might be added here
- which don't represent the actual service api.
- """
- +import collections
- import os
- import logging
-
- from botocore import BOTOCORE_ROOT
- from botocore.compat import json
- +from botocore.compat import six
- from botocore.compat import OrderedDict
- from botocore.exceptions import DataNotFoundError, UnknownServiceError
- from botocore.utils import deep_merge
-
- +from library.python import resource
- +
-
- logger = logging.getLogger(__name__)
-
- @@ -175,6 +179,51 @@ class JSONFileLoader(object):
- return json.loads(payload, object_pairs_hook=OrderedDict)
-
-
- +# SQS-119
- +class HybridJsonLoader(JSONFileLoader):
- +
- + type_data_cache = collections.defaultdict(lambda: collections.defaultdict(set))
- +
- + arcadia_resources_path = (
- + 'contrib/python/awscli/awscli/data/',
- + 'contrib/python/boto3/py2/boto3/data/',
- + 'contrib/python/botocore/py2/botocore/data/',
- + )
- +
- + @classmethod
- + def collect_service_data(cls):
- + if cls.type_data_cache:
- + return
- +
- + for res in resource.resfs_files():
- + res = six.ensure_str(res)
- + if res.startswith(cls.arcadia_resources_path):
- + splitted_path = res.split('/data/')[1].split('/')
- + if len(splitted_path) >= 3:
- + service_name, version, type_name = splitted_path[:3]
- + type_name = type_name.replace('.json', '')
- + cls.type_data_cache[type_name][service_name].add(version)
- +
- + @classmethod
- + def path_in_arcadia_resources(cls, file_path):
- + for prefix in cls.arcadia_resources_path:
- + path = '{}{}.json'.format(prefix, file_path)
- + if path in resource.resfs_files():
- + return path
- + return
- +
- + def exists(self, file_path):
- + if self.path_in_arcadia_resources(file_path):
- + return True
- + return super(HybridJsonLoader, self).exists(file_path)
- +
- + def load_file(self, file_path):
- + path = self.path_in_arcadia_resources(file_path)
- + if path:
- + return json.loads(resource.resfs_read(path).decode(encoding='utf-8'))
- + return super(HybridJsonLoader, self).load_file(file_path)
- +
- +
- def create_loader(search_path_string=None):
- """Create a Loader class.
-
- @@ -208,7 +257,7 @@ class Loader(object):
- convenience method over ``load_data`` and ``determine_latest_version``.
-
- """
- - FILE_LOADER_CLASS = JSONFileLoader
- + FILE_LOADER_CLASS = HybridJsonLoader
- # The included models in botocore/data/ that we ship with botocore.
- BUILTIN_DATA_PATH = os.path.join(BOTOCORE_ROOT, 'data')
- # For convenience we automatically add ~/.aws/models to the data path.
- @@ -284,6 +333,11 @@ class Loader(object):
- if self.file_loader.exists(full_load_path):
- services.add(service_name)
- break
- +
- + # SQS-119
- + HybridJsonLoader.collect_service_data()
- + services = services.union(HybridJsonLoader.type_data_cache[type_name].keys())
- +
- return sorted(services)
-
- @instance_cache
- @@ -335,6 +389,11 @@ class Loader(object):
- # to the type_name passed in.
- if self.file_loader.exists(full_path):
- known_api_versions.add(dirname)
- +
- + # SQS-119
- + HybridJsonLoader.collect_service_data()
- + known_api_versions = known_api_versions.union(HybridJsonLoader.type_data_cache[type_name][service_name])
- +
- if not known_api_versions:
- raise DataNotFoundError(data_path=service_name)
- return sorted(known_api_versions)
- @@ -420,6 +479,12 @@ class Loader(object):
- found = self.file_loader.load_file(possible_path)
- if found is not None:
- return found
- +
- + # SQS-119
- + found_by_arcadia_loader = self.file_loader.load_file(name)
- + if found_by_arcadia_loader is not None:
- + return found_by_arcadia_loader
- +
- # We didn't find anything that matched on any path.
- raise DataNotFoundError(data_path=name)
-
|