Sitelet https://github.com/python-gitlab/python-gitlab/pull/3440/files
Skip to content
Open
Changes from all 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
21 changes: 21 additions & 0 deletions gitlab/v4/objects/bulk_imports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from __future__ import annotations

from typing import Any

import requests

from gitlab import cli
from gitlab import exceptions as exc
from gitlab.base import RESTObject
from gitlab.mixins import CreateMixin, ListMixin, RefreshMixin, RetrieveMixin
from gitlab.types import RequiredOptional
Expand All @@ -17,6 +23,21 @@
class BulkImport(RefreshMixin, RESTObject):
entities: BulkImportEntityManager

@cli.register_custom_action(cls_names="BulkImport")
@exc.on_http_error(exc.GitlabCancelError)
def cancel(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
"""Cancel a bulk import.

Args:
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCancelError: If the request failed
"""
path = f"{self.manager.path}/{self.encoded_id}/cancel"
return self.manager.gitlab.http_post(path, **kwargs)

Check warning on line 39 in gitlab/v4/objects/bulk_imports.py

View check run for this annotation

Codecov / codecov/patch

gitlab/v4/objects/bulk_imports.py#L38-L39

Added lines #L38 - L39 were not covered by tests


class BulkImportManager(CreateMixin[BulkImport], RetrieveMixin[BulkImport]):
_path = "/bulk_imports"
Expand Down