aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch
blob: 2b55bd6b97106de0381dadf065f35d41e15387ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
--- contrib/python/botocore/py3/botocore/data/endpoints.json	(index)
+++ contrib/python/botocore/py3/botocore/data/endpoints.json	(working tree)
@@ -18857,6 +18857,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/py3/botocore/__init__.py	(index)
+++ contrib/python/botocore/py3/botocore/__init__.py	(working tree)
@@ -60,7 +60,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/py3/botocore/configprovider.py	(index)
+++ contrib/python/botocore/py3/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/py3/botocore/loaders.py	(index)
+++ contrib/python/botocore/py3/botocore/loaders.py	(working tree)
@@ -101,14 +101,17 @@ 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 logging
 import os
 
 from botocore import BOTOCORE_ROOT
-from botocore.compat import HAS_GZIP, OrderedDict, json
+from botocore.compat import HAS_GZIP, OrderedDict, json, six
 from botocore.exceptions import DataNotFoundError, UnknownServiceError
 from botocore.utils import deep_merge
 
+from library.python import resource
+
 _JSON_OPEN_METHODS = {
     '.json': open,
 }
@@ -197,6 +200,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/py3/boto3/data/',
+        'contrib/python/botocore/py3/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.
 
@@ -231,7 +279,7 @@ class Loader(object):
 
     """

-    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.
@@ -316,6 +364,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
@@ -367,6 +420,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)
@@ -454,6 +512,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)