1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# SPDX-License-Identifier: GPL-3.0-or-later
from typing import Optional
from gvm.errors import RequiredArgument
from gvm.protocols.core import Request
from gvm.protocols.gmp.requests._entity_id import EntityID
from gvm.utils import to_bool
from gvm.xml import XmlCommand
class AgentInstallers:
@staticmethod
def get_agent_installers(
*,
filter_string: Optional[str] = None,
filter_id: Optional[EntityID] = None,
trash: Optional[bool] = None,
details: Optional[bool] = None,
) -> Request:
"""Request a list of agent installers
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
"""
cmd = XmlCommand("get_agent_installers")
cmd.add_filter(filter_string, filter_id)
if trash is not None:
cmd.set_attribute("trash", to_bool(trash))
if details is not None:
cmd.set_attribute("details", to_bool(details))
return cmd
@classmethod
def get_agent_installer(cls, agent_installer_id: EntityID) -> Request:
"""Request a single agent installer
Args:
agent_installer_id: UUID of an existing agent installer
"""
if not agent_installer_id:
raise RequiredArgument(
function=cls.get_agent_installer.__name__,
argument="agent_installer_id",
)
cmd = XmlCommand("get_agent_installers")
cmd.set_attribute("agent_installer_id", str(agent_installer_id))
# for single entity always request all details
cmd.set_attribute("details", "1")
return cmd
@classmethod
def get_agent_installer_file(cls, agent_installer_id: EntityID) -> Request:
"""Request a single agent installer
Args:
agent_installer_id: UUID of an existing agent installer
"""
if not agent_installer_id:
raise RequiredArgument(
function=cls.get_agent_installer.__name__,
argument="agent_installer_id",
)
cmd = XmlCommand("get_agent_installer_file")
cmd.set_attribute("agent_installer_id", str(agent_installer_id))
return cmd
|