The models defined in this file represent the resource JSON description format and provide a layer of abstraction from the raw JSON. The advantages of this are:
These models are used both by the resource factory to generate resource classes as well as by the documentation generator.
A service operation action.
(string) The name of the action
(string) The JMESPath search path or None
(ResponseResource) This action's resource or None
A group of resources. See Action.
An item which has parameters exposed via the params property. A request has an operation and parameters, while a waiter has a name, a low-level waiter name and parameters.
A resource identifier, given by its name.
(string) The name of the identifier
An auto-filled parameter which has a source and target. For example, the QueueUrl may be auto-filled from a resource's url identifier when making calls to queue.receive_messages.
(string) The name of the source, if given
(string) The JMESPath query of the source
(string) Where the source is defined
(string) The destination parameter name
(string|int|float|bool) The source constant value
A service operation action request.
(string) The name of the low-level service operation
A model representing a resource, defined via a JSON description format. A resource has identifiers, attributes, actions, sub-resources, references and collections. For more information on resources, see Resources.
Get a list of collections for this resource.
Get a dictionary of attribute names to original name and shape models that represent the attributes of this resource. Looks like the following:
- {
- 'some_name': ('SomeName', <Shape...>)
}
Get a list of resource identifiers.
Load a name translation map given a shape. This will set up renamed values for any collisions, e.g. if the shape, an action, and a subresource all are all named foo then the resource will have an action foo, a subresource named Foo and a property named foo_attribute. This is the order of precedence, from most important to least important:
Batch actions are only exposed on collections, so do not get modified here. Subresources use upper camel casing, so are unlikely to collide with anything but other subresources.
Creates a structure like this:
renames = {
('action', 'id'): 'id_action',
('collection', 'id'): 'id_collection',
('attribute', 'id'): 'id_attribute'
}
# Get the final name for an action named 'id'
name = renames.get(('action', 'id'), 'id')
(string) The name of this resource
Get a list of reference resources.
(string) The service shape name for this resource or None
Get a list of sub-resources.
A resource response to create after performing an action.
A list of resource identifiers.
Get the resource model for the response resource.
(string) The JMESPath search query or None
(string) The name of the response resource type
An event waiter specification.
(string) The name of this waiter
(string) The name of the underlying event waiter
This method provides a basic reverse JMESPath implementation that lets you go from a JMESPath-like string to a possibly deeply nested object. The params are mutated in-place, so subsequent calls can modify the same element by its index.
>>> build_param_structure(params, 'test[0]', 1)
>>> print(params)
{'test': [1]}
>>> build_param_structure(params, 'foo.bar[0].baz', 'hello world')
>>> print(params)
{'test': [1], 'foo': {'bar': [{'baz': 'hello, world'}]}}
Handle request parameters that can be filled in from identifiers, resource data members or constants.
By passing params, you can invoke this method multiple times and build up a parameter dict over time, which is particularly useful for reverse JMESPath expressions that append to lists.
dict
Pre-filled parameters to be sent to the request operation.
Get a data member from a parent using a JMESPath search query, loading the parent if required. If the parent cannot be loaded and no data is present then an exception is raised.
When no data is present and the resource cannot be loaded.
The queried data or None.
A raw action response handler. This passed through the response dictionary, optionally after performing a JMESPath search if one has been defined for the action.
Creates a new resource or list of new resources from the low-level response based on the given response resource definition.
ServiceResource or list
New resource instance(s).
Handles the creation of a single response item by setting parameters and creating the appropriate resource instance.
ServiceResource
New resource instance.
Return True if all elements of the iterable are not None (or if the iterable is empty). This is like the built-in all, except checks against None, so 0 and False are allowable values.
Creates an appropriate empty response for the type that is expected, based on the service model's shape type. For example, a value that is normally a list would then return an empty list. A structure would return an empty dict, and a number would return None.
dict, list, or None
An appropriate empty value
Builds a mapping of identifier names to values based on the identifier source location, type, and target. Identifier values may be scalars or lists depending on the source type and location.
list
An ordered list of (name, value) identifier tuples.
An action which operates on a batch of items in a collection, typically a single page of results from the collection's underlying service operation call. For example, this allows you to delete up to 999 S3 objects in a single operation rather than calling .delete() on each one individually.
A custom, modeled action to inject into a resource.
A class representing a callable action on a resource, for example sqs.get_queue_by_name(...) or s3.Bucket('foo').delete(). The action may construct parameters from existing resource identifiers and may return either a raw response or a new resource instance.
A class representing a callable waiter action on a resource, for example s3.Bucket('foo').wait_until_bucket_exists(). The waiter action may construct parameters from existing resource identifiers.
An object containing metadata about a resource.
(BaseClient) Low-level Botocore client
(dict) Loaded resource data attributes
(list) List of identifier names
(string) The service name, e.g. 's3'
A base class for resources.
Stores metadata about this resource instance, such as the service_name, the low-level client and any cached data from when the instance was hydrated. For example:
# Get a low-level client from a resource instance
client = resource.meta.client
response = client.operation(Param='foo')
# Print the resource instance's service short name
print(resource.meta.service_name)
See ResourceMeta for more information.
A factory to create new ServiceResource classes from a ResourceModel. There are two types of lookups that can be done: one on the service itself (e.g. an SQS resource) and another on models contained within the service (e.g. an SQS Queue resource).
Loads a resource from a model, creating a new ServiceResource subclass with the correct properties and methods, named based on the service and resource name, e.g. EC2.Instance.
Subclass of ServiceResource
The service or resource class.