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

Commit9322db6

Browse files
feat(group): add support for group restore API
1 parentaa44f2a commit9322db6

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

‎docs/gl_objects/groups.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ Remove a group::
8888
# or
8989
group.delete()
9090

91+
Restore a Group marked for deletion (Premium only):::
92+
93+
group.restore()
94+
95+
9196
Share/unshare the group with a group::
9297

9398
group.share(group2.id, gitlab.const.AccessLevel.DEVELOPER)

‎gitlab/v4/objects/groups.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,21 @@ def unshare(self, group_id: int, **kwargs: Any) -> None:
287287
path=f"/groups/{self.encoded_id}/share/{group_id}"
288288
self.manager.gitlab.http_delete(path,**kwargs)
289289

290+
@cli.register_custom_action("Group")
291+
@exc.on_http_error(exc.GitlabRestoreError)
292+
defrestore(self,**kwargs:Any)->None:
293+
"""Restore a group marked for deletion..
294+
295+
Args:
296+
**kwargs: Extra options to send to the server (e.g. sudo)
297+
298+
Raises:
299+
GitlabAuthenticationError: If authentication is not correct
300+
GitlabRestoreError: If the server failed to perform the request
301+
"""
302+
path=f"/groups/{self.encoded_id}/restore"
303+
self.manager.gitlab.http_post(path,**kwargs)
304+
290305

291306
classGroupManager(CRUDMixin,RESTManager):
292307
_path="/groups"

‎tests/unit/objects/test_groups.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,19 @@ def resp_delete_saml_group_link(no_content):
316316
yieldrsps
317317

318318

319+
@pytest.fixture
320+
defresp_restore_group(created_content):
321+
withresponses.RequestsMock()asrsps:
322+
rsps.add(
323+
method=responses.POST,
324+
url="http://localhost/api/v4/groups/1/restore",
325+
json=created_content,
326+
content_type="application/json",
327+
status=201,
328+
)
329+
yieldrsps
330+
331+
319332
deftest_get_group(gl,resp_groups):
320333
data=gl.groups.get(1)
321334
assertisinstance(data,gitlab.v4.objects.Group)
@@ -453,3 +466,7 @@ def test_create_saml_group_link(group, resp_create_saml_group_link):
453466
deftest_delete_saml_group_link(group,resp_delete_saml_group_link):
454467
saml_group_link=group.saml_group_links.create(create_saml_group_link_request_body)
455468
saml_group_link.delete()
469+
470+
471+
deftest_group_restore(group,resp_restore_group):
472+
group.restore()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp