Find and load data models. This class will handle searching for and loading data models. The main method used here is ``load_service_model``, which is a convenience method over ``load_data`` and ``determine_latest_version``.
| 203 | |
| 204 | |
| 205 | class Loader: |
| 206 | """Find and load data models. |
| 207 | |
| 208 | This class will handle searching for and loading data models. |
| 209 | |
| 210 | The main method used here is ``load_service_model``, which is a |
| 211 | convenience method over ``load_data`` and ``determine_latest_version``. |
| 212 | |
| 213 | """ |
| 214 | |
| 215 | FILE_LOADER_CLASS = JSONFileLoader |
| 216 | # The included models in botocore/data/ that we ship with botocore. |
| 217 | BUILTIN_DATA_PATH = os.path.join(BOTOCORE_ROOT, 'data') |
| 218 | # For convenience we automatically add ~/.aws/models to the data path. |
| 219 | CUSTOMER_DATA_PATH = os.path.join( |
| 220 | os.path.expanduser('~'), '.aws', 'models' |
| 221 | ) |
| 222 | BUILTIN_EXTRAS_TYPES = ['sdk'] |
| 223 | |
| 224 | def __init__( |
| 225 | self, |
| 226 | extra_search_paths=None, |
| 227 | file_loader=None, |
| 228 | cache=None, |
| 229 | include_default_search_paths=True, |
| 230 | include_default_extras=True, |
| 231 | ): |
| 232 | self._cache = {} |
| 233 | if file_loader is None: |
| 234 | file_loader = self.FILE_LOADER_CLASS() |
| 235 | self.file_loader = file_loader |
| 236 | if extra_search_paths is not None: |
| 237 | self._search_paths = extra_search_paths |
| 238 | else: |
| 239 | self._search_paths = [] |
| 240 | if include_default_search_paths: |
| 241 | self._search_paths.extend( |
| 242 | [self.CUSTOMER_DATA_PATH, self.BUILTIN_DATA_PATH] |
| 243 | ) |
| 244 | |
| 245 | self._extras_types = [] |
| 246 | if include_default_extras: |
| 247 | self._extras_types.extend(self.BUILTIN_EXTRAS_TYPES) |
| 248 | |
| 249 | self._extras_processor = ExtrasProcessor() |
| 250 | |
| 251 | @property |
| 252 | def search_paths(self): |
| 253 | return self._search_paths |
| 254 | |
| 255 | @property |
| 256 | def extras_types(self): |
| 257 | return self._extras_types |
| 258 | |
| 259 | @instance_cache |
| 260 | def list_available_services(self, type_name): |
| 261 | """List all known services. |
| 262 |
no outgoing calls