Skip to content

Commit d900910

Browse files
remyj38nejch
authored andcommitted
feat(api): support project remote mirror deletion
1 parent 0d49164 commit d900910

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

docs/gl_objects/remote_mirrors.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ Update an existing remote mirror's attributes::
3232
mirror.enabled = False
3333
mirror.only_protected_branches = True
3434
mirror.save()
35+
36+
Delete an existing remote mirror::
37+
38+
mirror.delete()

gitlab/v4/objects/projects.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from gitlab.mixins import (
2424
CreateMixin,
2525
CRUDMixin,
26+
DeleteMixin,
2627
GetWithoutIdMixin,
2728
ListMixin,
2829
ObjectDeleteMixin,
@@ -1199,11 +1200,13 @@ def create(
11991200
return cast(ProjectFork, CreateMixin.create(self, data, path=path, **kwargs))
12001201

12011202

1202-
class ProjectRemoteMirror(SaveMixin, RESTObject):
1203+
class ProjectRemoteMirror(ObjectDeleteMixin, SaveMixin, RESTObject):
12031204
pass
12041205

12051206

1206-
class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManager):
1207+
class ProjectRemoteMirrorManager(
1208+
ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
1209+
):
12071210
_path = "/projects/{project_id}/remote_mirrors"
12081211
_obj_cls = ProjectRemoteMirror
12091212
_from_parent_attrs = {"project_id": "id"}

tests/functional/api/test_projects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ def test_project_remote_mirrors(project):
282282
assert mirror.url == mirror_url
283283
assert mirror.enabled is True
284284

285+
mirror.delete()
286+
285287

286288
def test_project_services(project):
287289
# Use 'update' to create a service as we don't have a 'create' method and

tests/unit/objects/test_remote_mirrors.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def resp_remote_mirrors():
4848
content_type="application/json",
4949
status=200,
5050
)
51+
52+
rsps.add(
53+
method=responses.DELETE,
54+
url="http://localhost/api/v4/projects/1/remote_mirrors/1",
55+
status=204,
56+
)
5157
yield rsps
5258

5359

@@ -70,3 +76,8 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors):
7076
mirror.save()
7177
assert mirror.update_status == "finished"
7278
assert mirror.only_protected_branches
79+
80+
81+
def test_delete_project_remote_mirror(project, resp_remote_mirrors):
82+
mirror = project.remote_mirrors.create({"url": "https://example.com"})
83+
mirror.delete()

0 commit comments

Comments
 (0)