示例#1
0
class HostParameters(BaseSchema):
    """All the parameters for the hosts list.

    Examples:

        >>> p = HostParameters()
        >>> p.load({})['columns']
        [Column(hosts.name: string)]

        >>> p.load({})['sites']
        []

    """

    sites = fields.List(
        gui_fields.SiteField(),
        description="Restrict the query to this particular site.",
        load_default=[],
    )
    query = gui_fields.query_field(Hosts, required=False)
    columns = gui_fields.column_field(Hosts, mandatory=[Hosts.name], example=["name"])
示例#2
0
definition on GitHub.
"""
from cmk.utils.livestatus_helpers.expressions import And
from cmk.utils.livestatus_helpers.queries import Query
from cmk.utils.livestatus_helpers.tables import Services

from cmk.gui import fields, sites
from cmk.gui.plugins.openapi.restful_objects import constructors, Endpoint, response_schemas
from cmk.gui.plugins.openapi.restful_objects.constructors import object_action_href
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME, OPTIONAL_HOST_NAME
from cmk.gui.plugins.openapi.utils import problem

PARAMETERS = [{
    'sites':
    fields.List(
        fields.SiteField(),
        description="Restrict the query to this particular site.",
        missing=list,
    ),
    'query':
    fields.query_field(
        Services,
        required=False,
        example='{"op": "=", "left": "host_name", "right": "example.com"}',
    ),
    'columns':
    fields.column_field(
        Services,
        mandatory=[
            Services.host_name,
            Services.description,
示例#3
0
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME, OPTIONAL_HOST_NAME
from cmk.gui.plugins.openapi.utils import problem

from cmk import fields

PERMISSIONS = permissions.Ignore(
    permissions.AnyPerm([
        permissions.Perm("general.see_all"),
        permissions.Perm("bi.see_all"),
        permissions.Perm("mkeventd.seeall"),
    ]))

PARAMETERS = [{
    "sites":
    fields.List(
        gui_fields.SiteField(),
        description="Restrict the query to this particular site.",
        load_default=list,
    ),
    "query":
    gui_fields.query_field(
        Services,
        required=False,
        example='{"op": "=", "left": "host_name", "right": "example.com"}',
    ),
    "columns":
    gui_fields.column_field(
        Services,
        mandatory=[
            Services.host_name,
            Services.description,
示例#4
0
 def openapi_field(self) -> fields.Field:
     return fields.SiteField(
         description="The site that should monitor this host.")