Skip to content

Commit 27e839a

Browse files
committed
feat(api): convert gitlab.const to Enums
This allows accessing the elements by value, i.e.: import gitlab.const gitlab.const.AccessLevel(20)
1 parent 57283fc commit 27e839a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

gitlab/const.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
from enum import Enum
19+
1820
from gitlab.__version__ import __title__, __version__
1921

2022
DEFAULT_URL: str = "https://gitlab.com"
2123

24+
# TODO: deprecate these in favor of AccessLevel
2225
NO_ACCESS: int = 0
2326
MINIMAL_ACCESS: int = 5
2427
GUEST_ACCESS: int = 10
@@ -27,17 +30,48 @@
2730
MAINTAINER_ACCESS: int = 40
2831
OWNER_ACCESS: int = 50
2932

33+
34+
class AccessLevel(Enum):
35+
NO_ACCESS: int = 0
36+
MINIMAL_ACCESS: int = 5
37+
GUEST_ACCESS: int = 10
38+
REPORTER_ACCESS: int = 20
39+
DEVELOPER_ACCESS: int = 30
40+
MAINTAINER_ACCESS: int = 40
41+
OWNER_ACCESS: int = 50
42+
43+
44+
# TODO: deprecate these in favor of Visibility
3045
VISIBILITY_PRIVATE: str = "private"
3146
VISIBILITY_INTERNAL: str = "internal"
3247
VISIBILITY_PUBLIC: str = "public"
3348

49+
50+
class Visibility(Enum):
51+
VISIBILITY_PRIVATE: str = "private"
52+
VISIBILITY_INTERNAL: str = "internal"
53+
VISIBILITY_PUBLIC: str = "public"
54+
55+
56+
# TODO: deprecate these in favor of NotificationLevel
3457
NOTIFICATION_LEVEL_DISABLED: str = "disabled"
3558
NOTIFICATION_LEVEL_PARTICIPATING: str = "participating"
3659
NOTIFICATION_LEVEL_WATCH: str = "watch"
3760
NOTIFICATION_LEVEL_GLOBAL: str = "global"
3861
NOTIFICATION_LEVEL_MENTION: str = "mention"
3962
NOTIFICATION_LEVEL_CUSTOM: str = "custom"
4063

64+
65+
class NotificationLevel(Enum):
66+
NOTIFICATION_LEVEL_DISABLED: str = "disabled"
67+
NOTIFICATION_LEVEL_PARTICIPATING: str = "participating"
68+
NOTIFICATION_LEVEL_WATCH: str = "watch"
69+
NOTIFICATION_LEVEL_GLOBAL: str = "global"
70+
NOTIFICATION_LEVEL_MENTION: str = "mention"
71+
NOTIFICATION_LEVEL_CUSTOM: str = "custom"
72+
73+
74+
# TODO: deprecate these in favor of SearchScope
4175
# Search scopes
4276
# all scopes (global, group and project)
4377
SEARCH_SCOPE_PROJECTS: str = "projects"
@@ -49,6 +83,20 @@
4983
SEARCH_SCOPE_BLOBS: str = "blobs"
5084
SEARCH_SCOPE_USERS: str = "users"
5185

86+
87+
# Search scopes
88+
# all scopes (global, group and project)
89+
class SearchScope(Enum):
90+
SEARCH_SCOPE_PROJECTS: str = "projects"
91+
SEARCH_SCOPE_ISSUES: str = "issues"
92+
SEARCH_SCOPE_MERGE_REQUESTS: str = "merge_requests"
93+
SEARCH_SCOPE_MILESTONES: str = "milestones"
94+
SEARCH_SCOPE_WIKI_BLOBS: str = "wiki_blobs"
95+
SEARCH_SCOPE_COMMITS: str = "commits"
96+
SEARCH_SCOPE_BLOBS: str = "blobs"
97+
SEARCH_SCOPE_USERS: str = "users"
98+
99+
52100
# specific global scope
53101
SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES: str = "snippet_titles"
54102

0 commit comments

Comments
 (0)