Skip to content

Commit b23e344

Browse files
author
Gauvain Pocentek
committed
[docs] document get_create_attrs in the API tutorial
1 parent 8c9ad29 commit b23e344

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

docs/api-usage.rst

+36-27
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,7 @@ python-gitlab supports both GitLab v3 and v4 APIs.
77
v3 being deprecated by GitLab, its support in python-gitlab will be minimal.
88
The development team will focus on v4.
99

10-
v3 is still the default API used by python-gitlab, for compatibility reasons..
11-
12-
13-
Base types
14-
==========
15-
16-
The ``gitlab`` package provides some base types.
17-
18-
* ``gitlab.Gitlab`` is the primary class, handling the HTTP requests. It holds
19-
the GitLab URL and authentication information.
20-
21-
For v4 the following types are defined:
22-
23-
* ``gitlab.base.RESTObject`` is the base class for all the GitLab v4 objects.
24-
These objects provide an abstraction for GitLab resources (projects, groups,
25-
and so on).
26-
* ``gitlab.base.RESTManager`` is the base class for v4 objects managers,
27-
providing the API to manipulate the resources and their attributes.
28-
29-
For v3 the following types are defined:
30-
31-
* ``gitlab.base.GitlabObject`` is the base class for all the GitLab v3 objects.
32-
These objects provide an abstraction for GitLab resources (projects, groups,
33-
and so on).
34-
* ``gitlab.base.BaseManager`` is the base class for v3 objects managers,
35-
providing the API to manipulate the resources and their attributes.
10+
v3 is still the default API used by python-gitlab, for compatibility reasons.
3611

3712

3813
``gitlab.Gitlab`` class
@@ -109,6 +84,17 @@ Examples:
10984
user = gl.users.create(user_data)
11085
print(user)
11186
87+
You can list the mandatory and optional attributes for object creation
88+
with the manager's ``get_create_attrs()`` method. It returns 2 tuples, the
89+
first one is the list of mandatory attributes, the second one the list of
90+
optional attribute:
91+
92+
.. code-block:: python
93+
94+
# v4 only
95+
print(gl.projects.get_create_attrs())
96+
(('name',), ('path', 'namespace_id', ...))
97+
11298
The attributes of objects are defined upon object creation, and depend on the
11399
GitLab API itself. To list the available information associated with an object
114100
use the python introspection tools for v3, or the ``attributes`` attribute for
@@ -150,7 +136,6 @@ You can update or delete a remote object when it exists locally:
150136
# delete the resource
151137
project.delete()
152138
153-
154139
Some classes provide additional methods, allowing more actions on the GitLab
155140
resources. For example:
156141

@@ -160,6 +145,30 @@ resources. For example:
160145
project = gl.projects.get(1)
161146
project.star()
162147
148+
Base types
149+
==========
150+
151+
The ``gitlab`` package provides some base types.
152+
153+
* ``gitlab.Gitlab`` is the primary class, handling the HTTP requests. It holds
154+
the GitLab URL and authentication information.
155+
156+
For v4 the following types are defined:
157+
158+
* ``gitlab.base.RESTObject`` is the base class for all the GitLab v4 objects.
159+
These objects provide an abstraction for GitLab resources (projects, groups,
160+
and so on).
161+
* ``gitlab.base.RESTManager`` is the base class for v4 objects managers,
162+
providing the API to manipulate the resources and their attributes.
163+
164+
For v3 the following types are defined:
165+
166+
* ``gitlab.base.GitlabObject`` is the base class for all the GitLab v3 objects.
167+
These objects provide an abstraction for GitLab resources (projects, groups,
168+
and so on).
169+
* ``gitlab.base.BaseManager`` is the base class for v3 objects managers,
170+
providing the API to manipulate the resources and their attributes.
171+
163172
Lazy objects (v4 only)
164173
======================
165174

0 commit comments

Comments
 (0)