- Notifications
You must be signed in to change notification settings - Fork674
docs: useas_list=False orall=True in Getting started#1884
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
18 changes: 13 additions & 5 deletionsdocs/api-usage.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -93,20 +93,26 @@ Examples: | ||
| .. code-block:: python | ||
| # list all the projects | ||
| projects = gl.projects.list(as_list=False) | ||
| for project in projects: | ||
| print(project) | ||
| # get the group with id == 2 | ||
| group = gl.groups.get(2) | ||
| for project in group.projects.list(as_list=False): | ||
nejch marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| print(project) | ||
| # create a new user | ||
| user_data = {'email': 'jen@foo.com', 'username': 'jen', 'name': 'Jen'} | ||
| user = gl.users.create(user_data) | ||
| print(user) | ||
| .. warning:: | ||
| Calling ``list()`` without any arguments will by default not return the complete list | ||
| of items. Use either the ``all=True`` or ``as_list=False`` parameters to get all the | ||
| items when using listing methods. See the :ref:`pagination` section for more | ||
| information. | ||
| You can list the mandatory and optional attributes for object creation and | ||
| update with the manager's ``get_create_attrs()`` and ``get_update_attrs()`` | ||
| 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: | ||
| # list the issues for a project | ||
| project = gl.projects.get(1) | ||
| issues = project.issues.list(all=True) | ||
| python-gitlab allows to send any data to the GitLab server when making queries. | ||
| 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: | ||
| .. code-block:: python | ||
| gl.user_activities.list(from='2019-01-01', as_list=False) ## invalid | ||
| gl.user_activities.list(query_parameters={'from': '2019-01-01'}, as_list=False) # OK | ||
| Gitlab Objects | ||
| ============== | ||
| @@ -233,6 +239,8 @@ a project (the previous example used 2 API calls): | ||
| project = gl.projects.get(1, lazy=True) # no API call | ||
| project.star() # API call | ||
| .. _pagination: | ||
| Pagination | ||
| ========== | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.