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

Commit4794ecc

Browse files
nejchJohnVillalovos
authored andcommitted
feat(projects): add support for project restore API
1 parent9833632 commit4794ecc

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

‎docs/gl_objects/projects.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Delete a project::
115115
# or
116116
project.delete()
117117

118+
Restore a project marked for deletion (Premium only)::
119+
120+
project.restore()
121+
118122
Fork a project::
119123

120124
fork = project.forks.create({})

‎gitlab/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ class GitlabRepairError(GitlabOperationError):
286286
pass
287287

288288

289+
classGitlabRestoreError(GitlabOperationError):
290+
pass
291+
292+
289293
classGitlabRevertError(GitlabOperationError):
290294
pass
291295

‎gitlab/v4/objects/projects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,21 @@ def upload(
477477
assertisinstance(data,dict)
478478
return {"alt":data["alt"],"url":data["url"],"markdown":data["markdown"]}
479479

480+
@cli.register_custom_action("Project")
481+
@exc.on_http_error(exc.GitlabRestoreError)
482+
defrestore(self,**kwargs:Any)->None:
483+
"""Restore a project marked for deletion.
484+
485+
Args:
486+
**kwargs: Extra options to send to the server (e.g. sudo)
487+
488+
Raises:
489+
GitlabAuthenticationError: If authentication is not correct
490+
GitlabRestoreError: If the server failed to perform the request
491+
"""
492+
path=f"/projects/{self.encoded_id}/restore"
493+
self.manager.gitlab.http_post(path,**kwargs)
494+
480495
@cli.register_custom_action("Project",optional=("wiki",))
481496
@exc.on_http_error(exc.GitlabGetError)
482497
defsnapshot(

‎tests/unit/objects/test_projects.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,19 @@ def resp_delete_push_rules_project(no_content):
504504
yieldrsps
505505

506506

507+
@pytest.fixture
508+
defresp_restore_project(created_content):
509+
withresponses.RequestsMock()asrsps:
510+
rsps.add(
511+
method=responses.POST,
512+
url="http://localhost/api/v4/projects/1/restore",
513+
json=created_content,
514+
content_type="application/json",
515+
status=201,
516+
)
517+
yieldrsps
518+
519+
507520
@pytest.fixture
508521
defresp_start_pull_mirroring_project():
509522
withresponses.RequestsMock()asrsps:
@@ -753,6 +766,10 @@ def test_project_pull_mirror(project, resp_start_pull_mirroring_project):
753766
project.mirror_pull()
754767

755768

769+
deftest_project_restore(project,resp_restore_project):
770+
project.restore()
771+
772+
756773
deftest_project_snapshot(project,resp_snapshot_project):
757774
tar_file=project.snapshot()
758775
assertisinstance(tar_file,bytes)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp