in boto3/resources/action.py [0:0]
def __call__(self, parent, *args, **kwargs):
"""
Perform the batch action's operation on every page of results
from the collection.
:type parent:
:py:class:`~boto3.resources.collection.ResourceCollection`
:param parent: The collection iterator to which this action
is attached.
:rtype: list(dict)
:return: A list of low-level response dicts from each call.
"""
service_name = None
client = None
responses = []
operation_name = xform_name(self._action_model.request.operation)
# Unlike the simple action above, a batch action must operate
# on batches (or pages) of items. So we get each page, construct
# the necessary parameters and call the batch operation.
for page in parent.pages():
params = {}
for index, resource in enumerate(page):
# There is no public interface to get a service name
# or low-level client from a collection, so we get
# these from the first resource in the collection.
if service_name is None:
service_name = resource.meta.service_name
if client is None:
client = resource.meta.client
create_request_parameters(
resource, self._action_model.request,
params=params, index=index)
if not params:
# There are no items, no need to make a call.
break
params.update(kwargs)
logger.debug('Calling %s:%s with %r',
service_name, operation_name, params)
response = getattr(client, operation_name)(*args, **params)
logger.debug('Response: %r', response)
responses.append(
self._response_handler(parent, params, response))
return responses