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
48 changes: 11 additions & 37 deletions gvm/protocols/gmp/_gmpnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from ._gmp227 import GMPv227
from .requests.next import (
AgentGroups,
AgentInstallers,
AgentInstallerInstructionLanguageType,
AgentInstallerInstructions,
Agents,
Credentials,
CredentialStoreCredentialType,
Expand Down Expand Up @@ -55,52 +56,25 @@ class GMPNext(GMPv227[T]):
def get_protocol_version() -> tuple[int, int]:
return (22, 8)

def get_agent_installers(
def get_agent_installer_instruction(
self,
*,
filter_string: str | None = None,
filter_id: EntityID | None = None,
trash: bool | None = None,
details: bool | None = None,
scanner_id: EntityID,
language_type: AgentInstallerInstructionLanguageType,
) -> T:
"""Request a list of agent installers
"""Request an agent installer instruction.

Args:
filter_string: Filter term to use for the query
filter_id: UUID of an existing filter to use for the query
trash: Whether to get the trashcan agent installers instead
details: Whether to include extra details like tasks using this
scanner
scanner_id: UUID of the Agent controller to get the installer instruction for.
language_type: Language of the installer instruction.
"""
return self._send_request_and_transform_response(
AgentInstallers.get_agent_installers(
filter_string=filter_string,
filter_id=filter_id,
trash=trash,
details=details,
AgentInstallerInstructions.get_agent_installer_instruction(
scanner_id=scanner_id,
language_type=language_type,
)
)

def get_agent_installer(self, agent_installer_id: EntityID) -> T:
"""Request a single agent installer

Args:
agent_installer_id: UUID of an existing agent installer
"""
return self._send_request_and_transform_response(
AgentInstallers.get_agent_installer(agent_installer_id)
)

def get_agent_installer_file(self, agent_installer_id: EntityID) -> T:
"""Request a single agent installer file

Args:
agent_installer_id: UUID of an existing agent installer
"""
return self._send_request_and_transform_response(
AgentInstallers.get_agent_installer_file(agent_installer_id)
)

def get_agents(
self,
*,
Expand Down
8 changes: 6 additions & 2 deletions gvm/protocols/gmp/requests/next/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later

from gvm.protocols.gmp.requests.next._agent_groups import AgentGroups
from gvm.protocols.gmp.requests.next._agent_installers import AgentInstallers
from gvm.protocols.gmp.requests.next._agent_installer_instructions import (
AgentInstallerInstructionLanguageType,
AgentInstallerInstructions,
)
from gvm.protocols.gmp.requests.next._agents import Agents
from gvm.protocols.gmp.requests.next._credential_stores import CredentialStores
from gvm.protocols.gmp.requests.next._credentials import (
Expand Down Expand Up @@ -115,7 +118,8 @@

__all__ = (
"AgentGroups",
"AgentInstallers",
"AgentInstallerInstructionLanguageType",
"AgentInstallerInstructions",
"Agents",
"AggregateStatistic",
"Aggregates",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from enum import Enum

from gvm.errors import RequiredArgument
from gvm.protocols.core import Request
from gvm.protocols.gmp.requests._entity_id import EntityID
from gvm.xml import XmlCommand


class AgentInstallerInstructionLanguageType(Enum):
EN = "en"
DE = "de"


class AgentInstallerInstructions:
@classmethod
def get_agent_installer_instruction(
cls,
scanner_id: EntityID,
language_type: AgentInstallerInstructionLanguageType,
) -> Request:
"""Request an agent installer instruction.

Args:
scanner_id: UUID of the Agent controller to get the installer instruction for.
language_type: Language of the installer instruction.
"""
if not scanner_id:
raise RequiredArgument(
function=cls.get_agent_installer_instruction.__name__,
argument="scanner_id",
)

if not language_type:
raise RequiredArgument(
function=cls.get_agent_installer_instruction.__name__,
argument="language_type",
)

cmd = XmlCommand("get_agent_installer_instruction")
cmd.set_attribute("scanner_id", str(scanner_id))
cmd.set_attribute("language", language_type.value)

return cmd
81 changes: 0 additions & 81 deletions gvm/protocols/gmp/requests/next/_agent_installers.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SPDX-FileCopyrightText: 2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

from gvm.errors import RequiredArgument
from gvm.protocols.gmp.requests.next import (
AgentInstallerInstructionLanguageType,
)


class GmpGetAgentInstallerInstructionTestMixin:
def test_get_agent_installer_instruction(self):
self.gmp.get_agent_installer_instruction(
scanner_id="scanner1",
language_type=AgentInstallerInstructionLanguageType.EN,
)

self.connection.send.has_been_called_with(
b'<get_agent_installer_instruction scanner_id="scanner1" language="en"/>'
)

def test_get_agent_installer_instruction_de(self):
self.gmp.get_agent_installer_instruction(
scanner_id="scanner1",
language_type=AgentInstallerInstructionLanguageType.DE,
)

self.connection.send.has_been_called_with(
b'<get_agent_installer_instruction scanner_id="scanner1" language="de"/>'
)

def test_get_agent_installer_instruction_without_scanner_id(self):
with self.assertRaises(RequiredArgument):
self.gmp.get_agent_installer_instruction(
scanner_id=None,
language_type=AgentInstallerInstructionLanguageType.EN,
)

with self.assertRaises(RequiredArgument):
self.gmp.get_agent_installer_instruction(
scanner_id="",
language_type=AgentInstallerInstructionLanguageType.EN,
)

def test_get_agent_installer_instruction_without_language_type(self):
with self.assertRaises(RequiredArgument):
self.gmp.get_agent_installer_instruction(
scanner_id="scanner1",
language_type=None,
)

with self.assertRaises(RequiredArgument):
self.gmp.get_agent_installer_instruction(
scanner_id="scanner1",
language_type="",
)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2023-2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

from ...gmpnext import GMPTestCase
from .agent_installer_instructions.test_get_aget_installer_instruction import (
GmpGetAgentInstallerInstructionTestMixin,
)


class GMPGetAgentInstallerInstructionTestCase(
GmpGetAgentInstallerInstructionTestMixin, GMPTestCase
):
pass
Loading
Loading