diff options
author | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:56 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:56 -0800 |
commit | b3b0b5f1da5b9da9bf44eac33856ed6eadf37dd6 (patch) | |
tree | 51d07a20421b89642f263c08f5cea61ca4924e61 | |
parent | 6b8067e668b6a37a19e07d84e9a0d2d2a99b4d31 (diff) | |
download | gitlab-jlvillal/const_explicit.tar.gz |
docs: update docs to use gitlab.const for constantsjlvillal/const_explicit
Update the docs to use gitlab.const to access constants.
-rw-r--r-- | docs/gl_objects/access_requests.rst | 12 | ||||
-rw-r--r-- | docs/gl_objects/groups.rst | 18 | ||||
-rw-r--r-- | docs/gl_objects/notifications.rst | 16 | ||||
-rw-r--r-- | docs/gl_objects/projects.rst | 14 | ||||
-rw-r--r-- | docs/gl_objects/protected_branches.rst | 6 | ||||
-rw-r--r-- | docs/gl_objects/search.rst | 32 | ||||
-rw-r--r-- | docs/gl_objects/snippets.rst | 2 |
7 files changed, 50 insertions, 50 deletions
diff --git a/docs/gl_objects/access_requests.rst b/docs/gl_objects/access_requests.rst index 467c3e5..e384534 100644 --- a/docs/gl_objects/access_requests.rst +++ b/docs/gl_objects/access_requests.rst @@ -7,11 +7,11 @@ Users can request access to groups and projects. When access is granted the user should be given a numerical access level. The following constants are provided to represent the access levels: -* ``gitlab.GUEST_ACCESS``: ``10`` -* ``gitlab.REPORTER_ACCESS``: ``20`` -* ``gitlab.DEVELOPER_ACCESS``: ``30`` -* ``gitlab.MAINTAINER_ACCESS``: ``40`` -* ``gitlab.OWNER_ACCESS``: ``50`` +* ``gitlab.const.GUEST_ACCESS``: ``10`` +* ``gitlab.const.REPORTER_ACCESS``: ``20`` +* ``gitlab.const.DEVELOPER_ACCESS``: ``30`` +* ``gitlab.const.MAINTAINER_ACCESS``: ``40`` +* ``gitlab.const.OWNER_ACCESS``: ``50`` References ---------- @@ -43,7 +43,7 @@ Create an access request:: Approve an access request:: ar.approve() # defaults to DEVELOPER level - ar.approve(access_level=gitlab.MAINTAINER_ACCESS) # explicitly set access level + ar.approve(access_level=gitlab.const.MAINTAINER_ACCESS) # explicitly set access level Deny (delete) an access request:: diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst index 549fe53..435835f 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.DEVELOPER_ACCESS) + group.share(group2.id, gitlab.const.DEVELOPER_ACCESS) group.unshare(group2.id) Import / Export @@ -237,11 +237,11 @@ Group members The following constants define the supported access levels: -* ``gitlab.GUEST_ACCESS = 10`` -* ``gitlab.REPORTER_ACCESS = 20`` -* ``gitlab.DEVELOPER_ACCESS = 30`` -* ``gitlab.MAINTAINER_ACCESS = 40`` -* ``gitlab.OWNER_ACCESS = 50`` +* ``gitlab.const.GUEST_ACCESS = 10`` +* ``gitlab.const.REPORTER_ACCESS = 20`` +* ``gitlab.const.DEVELOPER_ACCESS = 30`` +* ``gitlab.const.MAINTAINER_ACCESS = 40`` +* ``gitlab.const.OWNER_ACCESS = 50`` Reference --------- @@ -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.GUEST_ACCESS}) + 'access_level': gitlab.const.GUEST_ACCESS}) Update a member (change the access level):: - member.access_level = gitlab.DEVELOPER_ACCESS + member.access_level = gitlab.const.DEVELOPER_ACCESS 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.DEVELOPER_ACCESS, 'ldapmain') + group.add_ldap_group_link(ldap_group_cn, gitlab.const.DEVELOPER_ACCESS, 'ldapmain') Remove a link:: diff --git a/docs/gl_objects/notifications.rst b/docs/gl_objects/notifications.rst index ab0287f..8d8d9c0 100644 --- a/docs/gl_objects/notifications.rst +++ b/docs/gl_objects/notifications.rst @@ -5,12 +5,12 @@ Notification settings You can define notification settings globally, for groups and for projects. Valid levels are defined as constants: -* ``gitlab.NOTIFICATION_LEVEL_DISABLED`` -* ``gitlab.NOTIFICATION_LEVEL_PARTICIPATING`` -* ``gitlab.NOTIFICATION_LEVEL_WATCH`` -* ``gitlab.NOTIFICATION_LEVEL_GLOBAL`` -* ``gitlab.NOTIFICATION_LEVEL_MENTION`` -* ``gitlab.NOTIFICATION_LEVEL_CUSTOM`` +* ``gitlab.const.NOTIFICATION_LEVEL_DISABLED`` +* ``gitlab.const.NOTIFICATION_LEVEL_PARTICIPATING`` +* ``gitlab.const.NOTIFICATION_LEVEL_WATCH`` +* ``gitlab.const.NOTIFICATION_LEVEL_GLOBAL`` +* ``gitlab.const.NOTIFICATION_LEVEL_MENTION`` +* ``gitlab.const.NOTIFICATION_LEVEL_CUSTOM`` You get access to fine-grained settings if you use the ``NOTIFICATION_LEVEL_CUSTOM`` level. @@ -47,10 +47,10 @@ Get the notifications settings:: Update the notifications settings:: # use a predefined level - settings.level = gitlab.NOTIFICATION_LEVEL_WATCH + settings.level = gitlab.const.NOTIFICATION_LEVEL_WATCH # create a custom setup - settings.level = gitlab.NOTIFICATION_LEVEL_CUSTOM + settings.level = gitlab.const.NOTIFICATION_LEVEL_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 30d8515..10f5aaf 100644 --- a/docs/gl_objects/projects.rst +++ b/docs/gl_objects/projects.rst @@ -439,9 +439,9 @@ Project snippets The snippet visibility can be defined using the following constants: -* ``gitlab.VISIBILITY_PRIVATE`` -* ``gitlab.VISIBILITY_INTERNAL`` -* ``gitlab.VISIBILITY_PUBLIC`` +* ``gitlab.const.VISIBILITY_PRIVATE`` +* ``gitlab.const.VISIBILITY_INTERNAL`` +* ``gitlab.const.VISIBILITY_PUBLIC`` Reference --------- @@ -480,7 +480,7 @@ Create a snippet:: 'file_name': 'foo.py', 'code': 'import gitlab', 'visibility_level': - gitlab.VISIBILITY_PRIVATE}) + gitlab.const.VISIBILITY_PRIVATE}) Update a snippet:: @@ -546,11 +546,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.DEVELOPER_ACCESS}) + gitlab.const.DEVELOPER_ACCESS}) Modify a project member (change the access level):: - member.access_level = gitlab.MAINTAINER_ACCESS + member.access_level = gitlab.const.MAINTAINER_ACCESS member.save() Remove a member from the project team:: @@ -561,7 +561,7 @@ Remove a member from the project team:: Share/unshare the project with a group:: - project.share(group.id, gitlab.DEVELOPER_ACCESS) + project.share(group.id, gitlab.const.DEVELOPER_ACCESS) project.unshare(group.id) Project hooks diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst index 88e046c..74cc3f6 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.DEVELOPER_ACCESS, - 'push_access_level': gitlab.MAINTAINER_ACCESS + 'merge_access_level': gitlab.const.DEVELOPER_ACCESS, + 'push_access_level': gitlab.const.MAINTAINER_ACCESS }) 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.MAINTAINER_ACCESS}] + 'allowed_to_unprotect': [{"access_level": gitlab.const.MAINTAINER_ACCESS}] }) Delete a protected branch:: diff --git a/docs/gl_objects/search.rst b/docs/gl_objects/search.rst index eb8ba80..4030a53 100644 --- a/docs/gl_objects/search.rst +++ b/docs/gl_objects/search.rst @@ -9,24 +9,24 @@ string. The following constants are provided to represent the possible scopes: * Shared scopes (global, group and project): - + ``gitlab.SEARCH_SCOPE_PROJECTS``: ``projects`` - + ``gitlab.SEARCH_SCOPE_ISSUES``: ``issues`` - + ``gitlab.SEARCH_SCOPE_MERGE_REQUESTS``: ``merge_requests`` - + ``gitlab.SEARCH_SCOPE_MILESTONES``: ``milestones`` - + ``gitlab.SEARCH_SCOPE_WIKI_BLOBS``: ``wiki_blobs`` - + ``gitlab.SEARCH_SCOPE_COMMITS``: ``commits`` - + ``gitlab.SEARCH_SCOPE_BLOBS``: ``blobs`` - + ``gitlab.SEARCH_SCOPE_USERS``: ``users`` + + ``gitlab.const.SEARCH_SCOPE_PROJECTS``: ``projects`` + + ``gitlab.const.SEARCH_SCOPE_ISSUES``: ``issues`` + + ``gitlab.const.SEARCH_SCOPE_MERGE_REQUESTS``: ``merge_requests`` + + ``gitlab.const.SEARCH_SCOPE_MILESTONES``: ``milestones`` + + ``gitlab.const.SEARCH_SCOPE_WIKI_BLOBS``: ``wiki_blobs`` + + ``gitlab.const.SEARCH_SCOPE_COMMITS``: ``commits`` + + ``gitlab.const.SEARCH_SCOPE_BLOBS``: ``blobs`` + + ``gitlab.const.SEARCH_SCOPE_USERS``: ``users`` * specific global scope: - + ``gitlab.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES``: ``snippet_titles`` + + ``gitlab.const.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES``: ``snippet_titles`` * specific project scope: - + ``gitlab.SEARCH_SCOPE_PROJECT_NOTES``: ``notes`` + + ``gitlab.const.SEARCH_SCOPE_PROJECT_NOTES``: ``notes`` Reference @@ -46,30 +46,30 @@ Examples Search for issues matching a specific string:: # global search - gl.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') + gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') # group search group = gl.groups.get('mygroup') - group.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') + group.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') # project search project = gl.projects.get('myproject') - project.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') + project.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') The ``search()`` methods implement the pagination support:: # get lists of 10 items, and start at page 2 - gl.search(gitlab.SEARCH_SCOPE_ISSUES, search_str, page=2, per_page=10) + gl.search(gitlab.const.SEARCH_SCOPE_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.SEARCH_SCOPE_ISSUES, search_str, as_list=False): + for item in gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, search_str, as_list=False): 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.SEARCH_SCOPE_ISSUES, search_str, as_list=False): + for item in gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, search_str, as_list=False): 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 1bedb07..47166b9 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.VISIBILITY_PUBLIC + snippet.visibility_level = gitlab.const.VISIBILITY_PUBLIC snippet.save() To update a snippet code you need to create a ``ProjectSnippet`` object:: |