boto3.resources.response

Module Contents

all_not_none(iterable)

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.

build_identifiers(identifiers, parent, params=None, raw_response=None)

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.

Parameters:
  • 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.
Return type:

list

Returns:

An ordered list of (name, value) identifier tuples.

build_empty_response(search_path, operation_name, service_model)

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.

Parameters:
  • search_path (string) – JMESPath expression to search in the response
  • operation_name (string) – Name of the underlying service operation.
  • service_model (botocore.model.ServiceModel) – The Botocore service model
Return type:

dict, list, or None

Returns:

An appropriate empty value

class RawHandler(search_path)

Bases:object

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.

Parameters:search_path (string) – JMESPath expression to search in the response
Return type:dict
Returns:Service response
__call__(self, parent, params, response)
Parameters:
  • parent (ServiceResource) – The resource instance to which this action is attached.
  • params (dict) – Request parameters sent to the service.
  • response (dict) – Low-level operation response.
class ResourceHandler(search_path, factory, resource_model, service_context, operation_name=None)

Bases:object

Creates a new resource or list of new resources from the low-level response based on the given response resource definition.

Parameters:
  • 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.
Return type:

ServiceResource or list

Returns:

New resource instance(s).

__call__(self, parent, params, response)
Parameters:
  • parent (ServiceResource) – The resource instance to which this action is attached.
  • params (dict) – Request parameters sent to the service.
  • response (dict) – Low-level operation response.
handle_response_item(self, resource_cls, parent, identifiers, resource_data)

Handles the creation of a single response item by setting parameters and creating the appropriate resource instance.

Parameters:
  • 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.
Return type:

ServiceResource

Returns:

New resource instance.