Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions gvm/protocols/gmp/_gmpnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,9 +2012,33 @@ def download_report_export(

Returns:
A request for the download_report_export GMP command.

Raises:
RequiredArgument: If report_export_id is not provided.
"""
return self._send_request_and_transform_response(
ReportExports.download_report_export(
report_export_id=report_export_id,
)
)

def cancel_report_export(
self,
report_export_id: EntityID,
) -> T:
"""Request cancellation of a report export.

Args:
report_export_id: UUID of the report export to cancel.

Returns:
A request for the cancel_report_export GMP command.

Raises:
RequiredArgument: If report_export_id is not provided.
"""
return self._send_request_and_transform_response(
ReportExports.cancel_report_export(
report_export_id=report_export_id,
)
)
4 changes: 4 additions & 0 deletions gvm/protocols/gmp/requests/next/_audit_report.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gvm.errors import RequiredArgument
from gvm.protocols.core import Request
from gvm.protocols.gmp.requests import EntityID
Expand Down
30 changes: 30 additions & 0 deletions gvm/protocols/gmp/requests/next/_report_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,33 @@ def download_report_export(
)

return cmd

@classmethod
def cancel_report_export(
cls,
report_export_id: EntityID,
) -> Request:
"""Request cancellation of a report export.

Args:
report_export_id: UUID of the report export to cancel.

Returns:
A request for the cancel_report_export GMP command.

Raises:
RequiredArgument: If report_export_id is not provided.
"""
if not report_export_id:
raise RequiredArgument(
function=cls.cancel_report_export.__name__,
argument="report_export_id",
)

cmd = XmlCommand("cancel_report_export")
cmd.set_attribute(
"report_export_id",
str(report_export_id),
)

return cmd
2 changes: 2 additions & 0 deletions tests/protocols/gmpnext/entities/report_exports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from .test_cancel_report_export import GmpCancelReportExportTestMixin
from .test_download_report_export import GmpDownloadReportExportTestMixin
from .test_get_report_export import GmpGetReportExportTestMixin
from .test_get_report_exports import GmpGetReportExportsTestMixin

__all__ = [
"GmpCancelReportExportTestMixin",
"GmpDownloadReportExportTestMixin",
"GmpGetReportExportTestMixin",
"GmpGetReportExportsTestMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
from gvm.errors import RequiredArgument


class GmpCancelReportExportTestMixin:
def test_cancel_report_export_without_id(self):
with self.assertRaises(RequiredArgument):
self.gmp.cancel_report_export(None)

with self.assertRaises(RequiredArgument):
self.gmp.cancel_report_export("")

def test_cancel_report_export_with_id(self):
self.gmp.cancel_report_export(report_export_id="e1")

self.connection.send.has_been_called_with(
b'<cancel_report_export report_export_id="e1"/>'
)
7 changes: 7 additions & 0 deletions tests/protocols/gmpnext/entities/test_report_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ...gmpnext import GMPTestCase
from .report_exports import (
GmpCancelReportExportTestMixin,
GmpDownloadReportExportTestMixin,
GmpGetReportExportsTestMixin,
GmpGetReportExportTestMixin,
Expand All @@ -23,3 +24,9 @@ class GmpGmpDownloadReportExportTestCase(
GmpDownloadReportExportTestMixin, GMPTestCase
):
pass


class GmpCancelReportExportTestCase(
GmpCancelReportExportTestMixin, GMPTestCase
):
pass
Loading