Skip to content

Commit 979053c

Browse files
fix: add support for projects.groups.*
Add support for `projects.groups.*` endpoints. Required re-arranging the code to prevent circular imports.
1 parent 8d4c953 commit 979053c

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

gitlab/v4/objects/groups.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,50 @@
3030
from .milestones import GroupMilestoneManager # noqa: F401
3131
from .notification_settings import GroupNotificationSettingsManager # noqa: F401
3232
from .packages import GroupPackageManager # noqa: F401
33-
from .projects import GroupProjectManager # noqa: F401
3433
from .runners import GroupRunnerManager # noqa: F401
3534
from .statistics import GroupIssuesStatisticsManager # noqa: F401
3635
from .variables import GroupVariableManager # noqa: F401
3736
from .wikis import GroupWikiManager # noqa: F401
3837

3938
__all__ = [
4039
"Group",
41-
"GroupManager",
4240
"GroupDescendantGroup",
4341
"GroupDescendantGroupManager",
42+
"GroupManager",
43+
"GroupProject",
44+
"GroupProjectManager",
4445
"GroupSubgroup",
4546
"GroupSubgroupManager",
4647
]
4748

4849

50+
class GroupProject(RESTObject):
51+
pass
52+
53+
54+
class GroupProjectManager(ListMixin, RESTManager):
55+
_path = "/groups/{group_id}/projects"
56+
_obj_cls = GroupProject
57+
_from_parent_attrs = {"group_id": "id"}
58+
_list_filters = (
59+
"archived",
60+
"visibility",
61+
"order_by",
62+
"sort",
63+
"search",
64+
"simple",
65+
"owned",
66+
"starred",
67+
"with_custom_attributes",
68+
"include_subgroups",
69+
"with_issues_enabled",
70+
"with_merge_requests_enabled",
71+
"with_shared",
72+
"min_access_level",
73+
"with_security_reports",
74+
)
75+
76+
4977
class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
5078
_short_print_attr = "name"
5179

gitlab/v4/objects/projects.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from .events import ProjectEventManager # noqa: F401
3333
from .export_import import ProjectExportManager, ProjectImportManager # noqa: F401
3434
from .files import ProjectFileManager # noqa: F401
35+
from .groups import GroupManager # noqa: F401
3536
from .hooks import ProjectHookManager # noqa: F401
3637
from .issues import ProjectIssueManager # noqa: F401
3738
from .jobs import ProjectJobManager # noqa: F401
@@ -71,8 +72,6 @@
7172
from .wikis import ProjectWikiManager # noqa: F401
7273

7374
__all__ = [
74-
"GroupProject",
75-
"GroupProjectManager",
7675
"Project",
7776
"ProjectManager",
7877
"ProjectFork",
@@ -82,33 +81,6 @@
8281
]
8382

8483

85-
class GroupProject(RESTObject):
86-
pass
87-
88-
89-
class GroupProjectManager(ListMixin, RESTManager):
90-
_path = "/groups/{group_id}/projects"
91-
_obj_cls = GroupProject
92-
_from_parent_attrs = {"group_id": "id"}
93-
_list_filters = (
94-
"archived",
95-
"visibility",
96-
"order_by",
97-
"sort",
98-
"search",
99-
"simple",
100-
"owned",
101-
"starred",
102-
"with_custom_attributes",
103-
"include_subgroups",
104-
"with_issues_enabled",
105-
"with_merge_requests_enabled",
106-
"with_shared",
107-
"min_access_level",
108-
"with_security_reports",
109-
)
110-
111-
11284
class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTObject):
11385
_short_print_attr = "path"
11486

@@ -132,6 +104,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
132104
files: ProjectFileManager
133105
forks: "ProjectForkManager"
134106
generic_packages: GenericPackageManager
107+
groups: GroupManager
135108
hooks: ProjectHookManager
136109
imports: ProjectImportManager
137110
issues: ProjectIssueManager

0 commit comments

Comments
 (0)