Skip to content

Commit

Permalink
feat(api): support project remote mirror deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
remyj38 authored and nejch committed Oct 7, 2023
1 parent 0d49164 commit d900910
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/remote_mirrors.rst
Expand Up @@ -32,3 +32,7 @@ Update an existing remote mirror's attributes::
mirror.enabled = False
mirror.only_protected_branches = True
mirror.save()

Delete an existing remote mirror::

mirror.delete()
7 changes: 5 additions & 2 deletions gitlab/v4/objects/projects.py
Expand Up @@ -23,6 +23,7 @@
from gitlab.mixins import (
CreateMixin,
CRUDMixin,
DeleteMixin,
GetWithoutIdMixin,
ListMixin,
ObjectDeleteMixin,
Expand Down Expand Up @@ -1199,11 +1200,13 @@ def create(
return cast(ProjectFork, CreateMixin.create(self, data, path=path, **kwargs))


class ProjectRemoteMirror(SaveMixin, RESTObject):
class ProjectRemoteMirror(ObjectDeleteMixin, SaveMixin, RESTObject):
pass


class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManager):
class ProjectRemoteMirrorManager(
ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
):
_path = "/projects/{project_id}/remote_mirrors"
_obj_cls = ProjectRemoteMirror
_from_parent_attrs = {"project_id": "id"}
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/api/test_projects.py
Expand Up @@ -282,6 +282,8 @@ def test_project_remote_mirrors(project):
assert mirror.url == mirror_url
assert mirror.enabled is True

mirror.delete()


def test_project_services(project):
# Use 'update' to create a service as we don't have a 'create' method and
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/objects/test_remote_mirrors.py
Expand Up @@ -48,6 +48,12 @@ def resp_remote_mirrors():
content_type="application/json",
status=200,
)

rsps.add(
method=responses.DELETE,
url="http://localhost/api/v4/projects/1/remote_mirrors/1",
status=204,
)
yield rsps


Expand All @@ -70,3 +76,8 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors):
mirror.save()
assert mirror.update_status == "finished"
assert mirror.only_protected_branches


def test_delete_project_remote_mirror(project, resp_remote_mirrors):
mirror = project.remote_mirrors.create({"url": "https://example.com"})
mirror.delete()

0 comments on commit d900910

Please sign in to comment.