:ivar service_description: The parsed service description dictionary.
| 298 | |
| 299 | |
| 300 | class ServiceModel: |
| 301 | """ |
| 302 | |
| 303 | :ivar service_description: The parsed service description dictionary. |
| 304 | |
| 305 | """ |
| 306 | |
| 307 | def __init__(self, service_description, service_name=None): |
| 308 | """ |
| 309 | |
| 310 | :type service_description: dict |
| 311 | :param service_description: The service description model. This value |
| 312 | is obtained from a botocore.loader.Loader, or from directly loading |
| 313 | the file yourself:: |
| 314 | |
| 315 | service_description = json.load( |
| 316 | open('/path/to/service-description-model.json')) |
| 317 | model = ServiceModel(service_description) |
| 318 | |
| 319 | :type service_name: str |
| 320 | :param service_name: The name of the service. Normally this is |
| 321 | the endpoint prefix defined in the service_description. However, |
| 322 | you can override this value to provide a more convenient name. |
| 323 | This is done in a few places in botocore (ses instead of email, |
| 324 | emr instead of elasticmapreduce). If this value is not provided, |
| 325 | it will default to the endpointPrefix defined in the model. |
| 326 | |
| 327 | """ |
| 328 | self._service_description = service_description |
| 329 | # We want clients to be able to access metadata directly. |
| 330 | self.metadata = service_description.get('metadata', {}) |
| 331 | self._shape_resolver = ShapeResolver( |
| 332 | service_description.get('shapes', {}) |
| 333 | ) |
| 334 | self._signature_version = NOT_SET |
| 335 | self._service_name = service_name |
| 336 | self._instance_cache = {} |
| 337 | |
| 338 | def shape_for(self, shape_name, member_traits=None): |
| 339 | return self._shape_resolver.get_shape_by_name( |
| 340 | shape_name, member_traits |
| 341 | ) |
| 342 | |
| 343 | def shape_for_error_code(self, error_code): |
| 344 | return self._error_code_cache.get(error_code, None) |
| 345 | |
| 346 | @CachedProperty |
| 347 | def _error_code_cache(self): |
| 348 | error_code_cache = {} |
| 349 | for error_shape in self.error_shapes: |
| 350 | code = error_shape.error_code |
| 351 | error_code_cache[code] = error_shape |
| 352 | return error_code_cache |
| 353 | |
| 354 | def resolve_shape_ref(self, shape_ref): |
| 355 | return self._shape_resolver.resolve_shape_ref(shape_ref) |
| 356 | |
| 357 | @CachedProperty |
no outgoing calls