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
|
# SPDX-FileCopyrightText: 2024 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""
Greenbone Management Protocol (GMP) version 22.5
"""
from typing import Optional
from .._protocol import T
from ._gmp224 import GMPv224
from .requests.v225 import (
ResourceNames,
ResourceType,
)
class GMPv225(GMPv224[T]):
"""
A class implementing the Greenbone Management Protocol (GMP) version 22.5
Example:
.. code-block:: python
from gvm.protocols.gmp import GMPv225 as GMP
with GMP(connection) as gmp:
resp = gmp.get_tasks()
"""
@staticmethod
def get_protocol_version() -> tuple[int, int]:
return (22, 5)
def get_resource_names(
self,
resource_type: ResourceType,
*,
filter_string: Optional[str] = None,
) -> T:
"""Request a list of resource names and IDs
Arguments:
resource_type: Type must be either ALERT, CERT_BUND_ADV,
CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER,
GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION,
PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE,
SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE
or USER
filter_string: Filter term to use for the query
"""
return self._send_request_and_transform_response(
ResourceNames.get_resource_names(
resource_type, filter_string=filter_string
)
)
def get_resource_name(
self, resource_id: str, resource_type: ResourceType
) -> T:
"""Request a single resource name
Arguments:
resource_id: ID of an existing resource
resource_type: Type must be either ALERT, CERT_BUND_ADV,
CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER,
GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION,
PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE,
SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE
or USER
"""
return self._send_request_and_transform_response(
ResourceNames.get_resource_name(resource_id, resource_type)
)
|