summaryrefslogtreecommitdiff
path: root/docs/gl_objects
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-06-22 23:46:54 +0200
committerJohn Villalovos <john@sodarock.com>2022-06-27 16:36:23 -0700
commit323ab3c5489b0d35f268bc6c22ade782cade6ba4 (patch)
treee59ac0a69456efaf9f113e307062505a51dd0853 /docs/gl_objects
parentd65213385a6f497c2595d3af3a41756919b9c9a1 (diff)
downloadgitlab-323ab3c5489b0d35f268bc6c22ade782cade6ba4.tar.gz
test: add tests and clean up usage for new enums
Diffstat (limited to 'docs/gl_objects')
-rw-r--r--docs/gl_objects/access_requests.rst2
-rw-r--r--docs/gl_objects/groups.rst8
-rw-r--r--docs/gl_objects/notifications.rst4
-rw-r--r--docs/gl_objects/projects.rst8
-rw-r--r--docs/gl_objects/protected_branches.rst6
-rw-r--r--docs/gl_objects/search.rst12
-rw-r--r--docs/gl_objects/snippets.rst2
7 files changed, 21 insertions, 21 deletions
diff --git a/docs/gl_objects/access_requests.rst b/docs/gl_objects/access_requests.rst
index f68b70b..3e4110b 100644
--- a/docs/gl_objects/access_requests.rst
+++ b/docs/gl_objects/access_requests.rst
@@ -43,7 +43,7 @@ Create an access request::
Approve an access request::
ar.approve() # defaults to DEVELOPER level
- ar.approve(access_level=gitlab.const.AccessLevel.MAINTAINER.value) # explicitly set access level
+ ar.approve(access_level=gitlab.const.AccessLevel.MAINTAINER) # explicitly set access level
Deny (delete) an access request::
diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst
index 807769d..c4d9fdc 100644
--- a/docs/gl_objects/groups.rst
+++ b/docs/gl_objects/groups.rst
@@ -80,7 +80,7 @@ Remove a group::
Share/unshare the group with a group::
- group.share(group2.id, gitlab.const.AccessLevel.DEVELOPER.value)
+ group.share(group2.id, gitlab.const.AccessLevel.DEVELOPER)
group.unshare(group2.id)
Import / Export
@@ -284,11 +284,11 @@ Get a member of a group, including members inherited through ancestor groups::
Add a member to the group::
member = group.members.create({'user_id': user_id,
- 'access_level': gitlab.const.AccessLevel.GUEST.value})
+ 'access_level': gitlab.const.AccessLevel.GUEST})
Update a member (change the access level)::
- member.access_level = gitlab.const.AccessLevel.DEVELOPER.value
+ member.access_level = gitlab.const.AccessLevel.DEVELOPER
member.save()
Remove a member from the group::
@@ -316,7 +316,7 @@ LDAP group links
Add an LDAP group link to an existing GitLab group::
- group.add_ldap_group_link(ldap_group_cn, gitlab.const.AccessLevel.DEVELOPER.value, 'ldapmain')
+ group.add_ldap_group_link(ldap_group_cn, gitlab.const.AccessLevel.DEVELOPER, 'ldapmain')
Remove a link::
diff --git a/docs/gl_objects/notifications.rst b/docs/gl_objects/notifications.rst
index 8d1667f..bc97b1a 100644
--- a/docs/gl_objects/notifications.rst
+++ b/docs/gl_objects/notifications.rst
@@ -47,10 +47,10 @@ Get the notifications settings::
Update the notifications settings::
# use a predefined level
- settings.level = gitlab.const.NotificationLevel.WATCH.value
+ settings.level = gitlab.const.NotificationLevel.WATCH
# create a custom setup
- settings.level = gitlab.const.NotificationLevel.CUSTOM.value
+ settings.level = gitlab.const.NotificationLevel.CUSTOM
settings.save() # will create additional attributes, but not mandatory
settings.new_merge_request = True
diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst
index 5b0e208..b5a5d66 100644
--- a/docs/gl_objects/projects.rst
+++ b/docs/gl_objects/projects.rst
@@ -511,7 +511,7 @@ Create a snippet::
'file_name': 'foo.py',
'code': 'import gitlab',
'visibility_level':
- gitlab.const.Visibility.PRIVATE.value})
+ gitlab.const.Visibility.PRIVATE})
Update a snippet::
@@ -577,11 +577,11 @@ Get a member of a project, including members inherited through ancestor groups::
Add a project member::
member = project.members.create({'user_id': user.id, 'access_level':
- gitlab.const.AccessLevel.DEVELOPER.value})
+ gitlab.const.AccessLevel.DEVELOPER})
Modify a project member (change the access level)::
- member.access_level = gitlab.const.AccessLevel.MAINTAINER.value
+ member.access_level = gitlab.const.AccessLevel.MAINTAINER
member.save()
Remove a member from the project team::
@@ -592,7 +592,7 @@ Remove a member from the project team::
Share/unshare the project with a group::
- project.share(group.id, gitlab.const.AccessLevel.DEVELOPER.value)
+ project.share(group.id, gitlab.const.AccessLevel.DEVELOPER)
project.unshare(group.id)
Project hooks
diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst
index fd20347..15e8948 100644
--- a/docs/gl_objects/protected_branches.rst
+++ b/docs/gl_objects/protected_branches.rst
@@ -31,8 +31,8 @@ Create a protected branch::
p_branch = project.protectedbranches.create({
'name': '*-stable',
- 'merge_access_level': gitlab.const.AccessLevel.DEVELOPER.value,
- 'push_access_level': gitlab.const.AccessLevel.MAINTAINER.value
+ 'merge_access_level': gitlab.const.AccessLevel.DEVELOPER,
+ 'push_access_level': gitlab.const.AccessLevel.MAINTAINER
})
Create a protected branch with more granular access control::
@@ -41,7 +41,7 @@ Create a protected branch with more granular access control::
'name': '*-stable',
'allowed_to_push': [{"user_id": 99}, {"user_id": 98}],
'allowed_to_merge': [{"group_id": 653}],
- 'allowed_to_unprotect': [{"access_level": gitlab.const.AccessLevel.MAINTAINER.value}]
+ 'allowed_to_unprotect': [{"access_level": gitlab.const.AccessLevel.MAINTAINER}]
})
Delete a protected branch::
diff --git a/docs/gl_objects/search.rst b/docs/gl_objects/search.rst
index f443d89..2720dc4 100644
--- a/docs/gl_objects/search.rst
+++ b/docs/gl_objects/search.rst
@@ -46,30 +46,30 @@ Examples
Search for issues matching a specific string::
# global search
- gl.search(gitlab.const.SearchScope.ISSUES.value, 'regression')
+ gl.search(gitlab.const.SearchScope.ISSUES, 'regression')
# group search
group = gl.groups.get('mygroup')
- group.search(gitlab.const.SearchScope.ISSUES.value, 'regression')
+ group.search(gitlab.const.SearchScope.ISSUES, 'regression')
# project search
project = gl.projects.get('myproject')
- project.search(gitlab.const.SearchScope.ISSUES.value, 'regression')
+ project.search(gitlab.const.SearchScope.ISSUES, 'regression')
The ``search()`` methods implement the pagination support::
# get lists of 10 items, and start at page 2
- gl.search(gitlab.const.SearchScope.ISSUES.value, search_str, page=2, per_page=10)
+ gl.search(gitlab.const.SearchScope.ISSUES, search_str, page=2, per_page=10)
# get a generator that will automatically make required API calls for
# pagination
- for item in gl.search(gitlab.const.SearchScope.ISSUES.value, search_str, iterator=True):
+ for item in gl.search(gitlab.const.SearchScope.ISSUES, search_str, iterator=True):
do_something(item)
The search API doesn't return objects, but dicts. If you need to act on
objects, you need to create them explicitly::
- for item in gl.search(gitlab.const.SearchScope.ISSUES.value, search_str, iterator=True):
+ for item in gl.search(gitlab.const.SearchScope.ISSUES, search_str, iterator=True):
issue_project = gl.projects.get(item['project_id'], lazy=True)
issue = issue_project.issues.get(item['iid'])
issue.state = 'closed'
diff --git a/docs/gl_objects/snippets.rst b/docs/gl_objects/snippets.rst
index b5ad3d0..1ca89fa 100644
--- a/docs/gl_objects/snippets.rst
+++ b/docs/gl_objects/snippets.rst
@@ -44,7 +44,7 @@ Create a snippet::
Update the snippet attributes::
- snippet.visibility_level = gitlab.const.Visibility.PUBLIC.value
+ snippet.visibility_level = gitlab.const.Visibility.PUBLIC
snippet.save()
To update a snippet code you need to create a ``ProjectSnippet`` object::