Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add build_full_result() to Paginator #4078

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions docs/source/guide/paginators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ underlying API operation. The ``paginate`` method then returns an iterable
print(page['Contents'])


Optional ``build_full_result()`` function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While ``PageIterator`` is the recommended approach for handling paginated results,
there's also a convenient function called ``build_full_result()`` that can retrieve all results at once.::

import boto3

# Create a client
client = boto3.client('s3', region_name='us-west-2')

# Create a reusable Paginator
paginator = client.get_paginator('list_objects_v2')

# Invoke build_full_result() from the Paginator
full_result = paginator.paginate(Bucket='my-bucket').build_full_result()

print(full_result)

See `source code <https://github.com/boto/botocore/blob/master/botocore/paginate.py#L477>`_.


Customizing page iterators
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -47,8 +69,10 @@ the pages of API operation results. The ``paginate`` method accepts a
pagination::

paginator = client.get_paginator('list_objects_v2')
page_iterator = paginator.paginate(Bucket='my-bucket',
PaginationConfig={'MaxItems': 10})
page_iterator = paginator.paginate(
Bucket="my-bucket",
PaginationConfig={"MaxItems": 10},
)

``MaxItems``
Limits the maximum number of total returned items returned while
Expand Down Expand Up @@ -82,8 +106,10 @@ to the client::

client = boto3.client('s3', region_name='us-west-2')
paginator = client.get_paginator('list_objects_v2')
operation_parameters = {'Bucket': 'my-bucket',
'Prefix': 'foo/baz'}
operation_parameters = {
"Bucket": "my-bucket",
"Prefix": "foo/baz",
}
page_iterator = paginator.paginate(**operation_parameters)
for page in page_iterator:
print(page['Contents'])
Expand Down