Пример #1
0
class HostParameters(BaseSchema):
    """All the parameters for the hosts list.

    Examples:

        >>> p = HostParameters()
        >>> p.load({})['columns']
        ['name']

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

    """
    sites = fields.List(
        fields.SiteField(),
        description="Restrict the query to this particular site.",
        missing=[],
    )
    query = fields.query_field(Hosts, required=False)
    columns = fields.List(
        fields.LiveStatusColumn(
            table=Hosts,
            mandatory=[Hosts.name.name],
            required=True,
        ),
        description=("The desired columns of the hosts table. "
                     "If left empty, only the name column is used."),
        missing=[Hosts.name.name],
        required=False,
    )
Пример #2
0
class HostParameters(BaseSchema):
    """All the parameters for the hosts list.

    Examples:

        >>> p = HostParameters()
        >>> p.load({})['columns']
        ['name']

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

    """
    sites = fields.List(
        fields.String(),
        description="Restrict the query to this particular site.",
        missing=[],
    )
    query = fields.Nested(
        fields.ExprSchema,
        description=(
            "An query expression in nested dictionary form. If you want to "
            "use multiple expressions, nest them with the AND/OR operators."),
        many=False,
        example=json.dumps({
            'op': 'not',
            'expr': {
                'op': '=',
                'left': 'hosts.name',
                'right': 'example.com'
            }
        }),
        required=False,
    )
    columns = fields.List(
        fields.LiveStatusColumn(
            table=Hosts,
            mandatory=[Hosts.name.name],
            required=True,
        ),
        description=
        ("The desired columns of the hosts table. If left empty, a default set of "
         "columns is used."),
        missing=[Hosts.name.name],
        required=False,
    )
Пример #3
0
from cmk.gui.plugins.openapi.endpoints.utils import verify_columns
from cmk.gui.plugins.openapi.livestatus_helpers.queries import Query
from cmk.gui.plugins.openapi.livestatus_helpers.tables import Services
from cmk.gui.plugins.openapi.restful_objects import (
    Endpoint,
    constructors,
    response_schemas,
)
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME, OPTIONAL_HOST_NAME

PARAMETERS = [{
    'site': fields.String(description="Restrict the query to this particular site."),
    'query': fields.query_field(Services, required=False),
    'columns': fields.List(
        fields.LiveStatusColumn(
            table=Services,
            mandatory=[Services.host_name.name, Services.description.name],
        ),
        required=False,
        description="The desired columns of the services table. If left empty, a default set"
        " of columns is used.",
        missing=[
            Services.host_name.name,
            Services.description.name,
        ],
    ),
}]


@Endpoint(constructors.domain_object_sub_collection_href('host', '{host_name}', 'services'),
          '.../collection',
          method='get',