Skip to content

Commit 27c1e95

Browse files
author
Gauvain Pocentek
committed
[v4] Rename the visibility attribute
Also change the value of the VISIBILITY_* consts, and move them to the `objects` module root. TODO: deal the numerical value used by v3.
1 parent 9b625f0 commit 27c1e95

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

gitlab/v4/objects.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
from gitlab.exceptions import * # noqa
3131
from gitlab import utils
3232

33+
VISIBILITY_PRIVATE = 'private'
34+
VISIBILITY_INTERNAL = 'internal'
35+
VISIBILITY_PUBLIC = 'public'
36+
3337

3438
class SidekiqManager(object):
3539
"""Manager for the Sidekiq methods.
@@ -102,7 +106,7 @@ class UserProject(GitlabObject):
102106
requiredCreateAttrs = ['name']
103107
optionalCreateAttrs = ['default_branch', 'issues_enabled', 'wall_enabled',
104108
'merge_requests_enabled', 'wiki_enabled',
105-
'snippets_enabled', 'public', 'visibility_level',
109+
'snippets_enabled', 'public', 'visibility',
106110
'description', 'builds_enabled', 'public_builds',
107111
'import_url', 'only_allow_merge_if_build_succeeds']
108112

@@ -490,8 +494,8 @@ class Snippet(GitlabObject):
490494
_url = '/snippets'
491495
_constructorTypes = {'author': 'User'}
492496
requiredCreateAttrs = ['title', 'file_name', 'content']
493-
optionalCreateAttrs = ['lifetime', 'visibility_level']
494-
optionalUpdateAttrs = ['title', 'file_name', 'content', 'visibility_level']
497+
optionalCreateAttrs = ['lifetime', 'visibility']
498+
optionalUpdateAttrs = ['title', 'file_name', 'content', 'visibility']
495499
shortPrintAttr = 'title'
496500

497501
def raw(self, streamed=False, action=None, chunk_size=1024, **kwargs):
@@ -1568,8 +1572,8 @@ class ProjectSnippet(GitlabObject):
15681572
_constructorTypes = {'author': 'User'}
15691573
requiredUrlAttrs = ['project_id']
15701574
requiredCreateAttrs = ['title', 'file_name', 'code']
1571-
optionalCreateAttrs = ['lifetime', 'visibility_level']
1572-
optionalUpdateAttrs = ['title', 'file_name', 'code', 'visibility_level']
1575+
optionalCreateAttrs = ['lifetime', 'visibility']
1576+
optionalUpdateAttrs = ['title', 'file_name', 'code', 'visibility']
15731577
shortPrintAttr = 'title'
15741578
managers = (
15751579
('notes', 'ProjectSnippetNoteManager',
@@ -1777,7 +1781,7 @@ class Project(GitlabObject):
17771781
'issues_enabled', 'merge_requests_enabled',
17781782
'builds_enabled', 'wiki_enabled',
17791783
'snippets_enabled', 'container_registry_enabled',
1780-
'shared_runners_enabled', 'visibility_level',
1784+
'shared_runners_enabled', 'visibility',
17811785
'import_url', 'public_builds',
17821786
'only_allow_merge_if_build_succeeds',
17831787
'only_allow_merge_if_all_discussions_are_resolved',
@@ -1786,7 +1790,7 @@ class Project(GitlabObject):
17861790
'issues_enabled', 'merge_requests_enabled',
17871791
'builds_enabled', 'wiki_enabled',
17881792
'snippets_enabled', 'container_registry_enabled',
1789-
'shared_runners_enabled', 'visibility_level',
1793+
'shared_runners_enabled', 'visibility',
17901794
'import_url', 'public_builds',
17911795
'only_allow_merge_if_build_succeeds',
17921796
'only_allow_merge_if_all_discussions_are_resolved',
@@ -1825,10 +1829,6 @@ class Project(GitlabObject):
18251829
('variables', 'ProjectVariableManager', [('project_id', 'id')]),
18261830
)
18271831

1828-
VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE
1829-
VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL
1830-
VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC
1831-
18321832
def repository_tree(self, path='', ref_name='', **kwargs):
18331833
"""Return a list of files in the repository.
18341834
@@ -2184,9 +2184,9 @@ class GroupProjectManager(ProjectManager):
21842184
class Group(GitlabObject):
21852185
_url = '/groups'
21862186
requiredCreateAttrs = ['name', 'path']
2187-
optionalCreateAttrs = ['description', 'visibility_level', 'parent_id',
2187+
optionalCreateAttrs = ['description', 'visibility', 'parent_id',
21882188
'lfs_enabled', 'request_access_enabled']
2189-
optionalUpdateAttrs = ['name', 'path', 'description', 'visibility_level',
2189+
optionalUpdateAttrs = ['name', 'path', 'description', 'visibility',
21902190
'lfs_enabled', 'request_access_enabled']
21912191
shortPrintAttr = 'name'
21922192
managers = (
@@ -2204,10 +2204,6 @@ class Group(GitlabObject):
22042204
MASTER_ACCESS = gitlab.MASTER_ACCESS
22052205
OWNER_ACCESS = gitlab.OWNER_ACCESS
22062206

2207-
VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE
2208-
VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL
2209-
VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC
2210-
22112207
def transfer_project(self, id, **kwargs):
22122208
"""Transfers a project to this new groups.
22132209

0 commit comments

Comments
 (0)