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:
Pythonic interface (e.g. action.request.operation
)
Consumers need not change for minor JSON changes (e.g. renamed field)
These models are used both by the resource factory to generate resource classes as well as by the documentation generator.
A service operation action.
name (string) – The name of the action
definition (dict) – The JSON definition
resource_defs (dict) – All resources defined in the service
(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
.
name (string) – The name of the collection
definition (dict) – The JSON definition
resource_defs (dict) – All resources defined in the service
Get a list of batch actions supported by the resource type contained in this action. This is a shortcut for accessing the same information through the resource model.
list(Action
)
(string
) The name of the action
(string
) The JMESPath search path or None
(ResponseResource
) This action’s resource or None
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.
definition (dict) – The JSON definition
A resource identifier, given by its name.
name (string) – The name of the identifier
(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
.
target (string) – The destination parameter name, e.g. QueueUrl
source_type (string) – Where the source is defined.
source (string) – The source name, e.g. Url
(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.
definition (dict) – The JSON definition
(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 guide_resources.
name (string) – The name of this resource, e.g. sqs
or Queue
definition (dict) – The JSON definition
resource_defs (dict) – All resources defined in the service
Get a list of collections for this resource.
list(Collection
)
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…>)
}
shape (ibm_botocore.model.Shape) – The underlying shape for this resource.
dict
Mapping of resource attributes.
Get a list of resource identifiers.
list(Identifier
)
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:
Load action (resource.load)
Identifiers
Actions
Subresources
References
Collections
Waiters
Attributes (shape members)
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')
shape (ibm_botocore.model.Shape) – The underlying shape for this resource.
(string
) The name of this resource
(string
) The service shape name for this resource or None
A resource response to create after performing an action.
definition (dict) – The JSON definition
resource_defs (dict) – All resources defined in the service
A list of resource identifiers.
list(Identifier
)
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.
name (string) – Name of the waiter
definition (dict) – The JSON definition
(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.
parent (ServiceResource) – The resource instance to which this action is attached.
request_model (Request
) – The action request model.
params (dict) – If set, then add to this existing dict. It is both edited in-place and returned.
index (int) – The position of an item within a list
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.
parent (ServiceResource) – The resource instance to which contains data we are interested in.
path (string) – The JMESPath expression to query
ResourceLoadException – 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.
search_path (string) – JMESPath expression to search in the response
dict
Service response
Creates a new resource or list of new resources from the low-level response based on the given response resource definition.
search_path (string) – JMESPath expression to search in the response
factory (ResourceFactory) – The factory that created the resource class to which this action is attached.
resource_model (ResponseResource
) – Response resource model.
service_context (ServiceContext
) – Context about the AWS service
operation_name (string) – Name of the underlying service operation, if it exists.
ServiceResource or list
New resource instance(s).
Handles the creation of a single response item by setting parameters and creating the appropriate resource instance.
resource_cls (ServiceResource subclass) – The resource class to instantiate.
parent (ServiceResource) – The resource instance to which this action is attached.
identifiers (dict) – Map of identifier names to value or values.
resource_data (dict or None) – Data for resource attributes.
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.
search_path (string) – JMESPath expression to search in the response
operation_name (string) – Name of the underlying service operation.
service_model (ibm_botocore.model.ServiceModel) – The Botocore service model
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.
identifiers (list) – List of Parameter
definitions
parent (ServiceResource) – The resource instance to which this action is attached.
params (dict) – Request parameters sent to the service.
raw_response (dict) – Low-level operation response.
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.
action_model (:py:class`~ibm_boto3.resources.model.Action`) – The action model.
factory (ResourceFactory) – The factory that created the resource class to which this action is attached.
service_context (ServiceContext
) – Context about the AWS service
A custom, modeled action to inject into a resource.
action_name (str) – The name of the action to inject, e.g. ‘delete_tags’
action_model (dict) – A JSON definition of the action, as if it were part of the resource model.
function (function) – The function to perform when the action is called. The first argument should be ‘self’, which will be the resource the function is to be called on.
event_emitter (ibm_botocore.hooks.BaseEventHooks
) – The session event emitter.
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.
action_model (:py:class`~ibm_boto3.resources.model.Action`) – The action model.
factory (ResourceFactory) – The factory that created the resource class to which this action is attached.
service_context (ServiceContext
) – Context about the AWS service
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.
waiter_model (:py:class`~ibm_boto3.resources.model.Waiter`) – The action waiter.
waiter_resource_name (string) – The name of the waiter action for the
resource. It usually begins with a
wait_until_
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.
client (ibm_botocore.client) – A low-level Botocore client instance
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.
resource_name (string) – Name of the resource to look up. For services,
this should match the service_name
.
single_resource_json_definition (dict) – The loaded json of a single service resource or resource definition.
service_context (ServiceContext
) – Context about the AWS service
Subclass of ServiceResource
The service or resource class.