Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde8c6e8

Browse files
docs: useas_list=False orall=True in Getting started
In the "Getting started with the API" section of the documentation,use either `as_list=False` or `all=True` in the example usages of the`list()` method.Also add a warning about the fact that `list()` by default does notreturn all items.
1 parent09b3b22 commitde8c6e8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎docs/api-usage.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,26 @@ Examples:
9393
..code-block::python
9494
9595
# list all the projects
96-
projects= gl.projects.list()
96+
projects= gl.projects.list(as_list=False)
9797
for projectin projects:
9898
print(project)
9999
100100
# get the group with id == 2
101101
group= gl.groups.get(2)
102-
for projectin group.projects.list():
102+
for projectin group.projects.list(as_list=False):
103103
print(project)
104104
105105
# create a new user
106106
user_data= {'email':'jen@foo.com','username':'jen','name':'Jen'}
107107
user= gl.users.create(user_data)
108108
print(user)
109109
110+
..warning::
111+
Calling ``list()`` without any arguments will by default not return the complete list
112+
of items. Use either the ``all=True`` or ``as_list=False`` parameters to get all the
113+
items when using listing methods. See the:ref:`pagination` section for more
114+
information.
115+
110116
You can list the mandatory and optional attributes for object creation and
111117
update with the manager's ``get_create_attrs()`` and ``get_update_attrs()``
112118
methods. They return 2 tuples, the first one is the list of mandatory
@@ -133,7 +139,7 @@ Some objects also provide managers to access related GitLab resources:
133139
134140
# list the issues for a project
135141
project= gl.projects.get(1)
136-
issues= project.issues.list()
142+
issues= project.issues.list(all=True)
137143
138144
python-gitlab allows to send any data to the GitLab server when making queries.
139145
In case of invalid or missing arguments python-gitlab will raise an exception
@@ -150,9 +156,9 @@ conflict with python or python-gitlab when using them as kwargs:
150156

151157
..code-block::python
152158
153-
gl.user_activities.list(from='2019-01-01')## invalid
159+
gl.user_activities.list(from='2019-01-01',as_list=False)## invalid
154160
155-
gl.user_activities.list(query_parameters={'from':'2019-01-01'})# OK
161+
gl.user_activities.list(query_parameters={'from':'2019-01-01'},as_list=False)# OK
156162
157163
Gitlab Objects
158164
==============
@@ -233,6 +239,8 @@ a project (the previous example used 2 API calls):
233239
project= gl.projects.get(1,lazy=True)# no API call
234240
project.star()# API call
235241
242+
.. _pagination:
243+
236244
Pagination
237245
==========
238246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp