FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: add cancel API for BulkImport (#3292) by AquaticAzelf · Pull Request #3440 · python-gitlab/python-gitlab · GitHub

Repository navigation

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 21 additions & 0 deletions gitlab/v4/objects/bulk_imports.py
Show comments Show annotations View file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL