b3q module

Boto3 utility library that supports parameter-driven and predicate-driven retrieval of collections of AWS resources.

b3q.b3q.get(method, arguments=None, constraints=None, attribute=None)[source]

Assemble all items in a paged response pattern from the supplied AWS API retrieval method.

Parameters
  • method (Callable) – AWS API retrieval method (such as Lambda.Client.get_function).

  • arguments (Optional[dict]) – Named arguments to be supplied to the method.

  • constraints (Optional[dict]) – Attribute-value pairs that must appear in an item (or it is excluded).

  • attribute (Optional[str]) – Attribute (of a response object) under which retrieved items are found.

>>> import itertools
>>> def method(identifier, position=None):
...     if position is None:
...         position = 0
...     return dict({
...         'items': [{'value': position, 'parity': position % 2}],
...     }, **({'position': position + 1} if position <= 4 else {}))
>>> [item['value'] for item in itertools.islice(get(
...     method,
...     arguments={'identifier': 0},
...     constraints={'parity': 0}
... ), 0, 4)]
[0, 2, 4]
Return type

Iterable