Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support forprojects.groups.list()#1718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/project_groups
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletionsdocs/gl_objects/projects.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,6 +92,11 @@ Create a project in a group::
group_id = gl.groups.list(search='my-group')[0].id
project = gl.projects.create({'name': 'myrepo', 'namespace_id': group_id})

List a project's groups::

# Get a list of ancestor/parent groups for a project.
groups = project.groups.list()

Update a project::

project.snippets_enabled = 1
Expand Down
19 changes: 19 additions & 0 deletionsgitlab/v4/objects/projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -109,6 +109,24 @@ class GroupProjectManager(ListMixin, RESTManager):
)


class ProjectGroup(RESTObject):
pass


class ProjectGroupManager(ListMixin, RESTManager):
_path = "/projects/{project_id}/groups"
_obj_cls = ProjectGroup
_from_parent_attrs = {"project_id": "id"}
_list_filters = (
"search",
"skip_groups",
"with_shared",
"shared_min_access_level",
"shared_visible_only",
)
_types = {"skip_groups": types.ListAttribute}


class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTObject):
_short_print_attr = "path"

Expand All@@ -132,6 +150,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
files: ProjectFileManager
forks: "ProjectForkManager"
generic_packages: GenericPackageManager
groups: ProjectGroupManager
hooks: ProjectHookManager
imports: ProjectImportManager
issues: ProjectIssueManager
Expand Down
18 changes: 18 additions & 0 deletionstests/functional/api/test_projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -311,3 +311,21 @@ def test_project_wiki(project):
wiki.save()
wiki.delete()
assert len(project.wikis.list()) == 0


def test_project_groups_list(gl, group):
"""Test listing groups of a project"""
# Create a subgroup of our top-group, we will place our new project inside
# this group.
group2 = gl.groups.create(
{"name": "group2_proj", "path": "group2_proj", "parent_id": group.id}
)
data = {
"name": "test-project-tpsg",
"namespace_id": group2.id,
}
project = gl.projects.create(data)

groups = project.groups.list()
group_ids = set([x.id for x in groups])
assert set((group.id, group2.id)) == group_ids

[8]ページ先頭

©2009-2025 Movatter.jp