Exemple #1
0
    attributes = put_body.get("attributes", {})

    if parent_folder.has_subfolder(name):
        raise ProblemException(
            status=400,
            title="Path already exists",
            detail=f"The path '{parent_folder.name()}/{name}' already exists.",
        )

    folder = parent_folder.create_subfolder(name, title, attributes)

    return _serve_folder(folder)


@Endpoint(
    constructors.domain_object_collection_href("folder_config", "{folder}",
                                               "hosts"),
    ".../collection",
    method="get",
    path_params=[PATH_FOLDER_FIELD],
    response_schema=response_schemas.HostConfigCollection,
)
def hosts_of_folder(params):
    """Show all hosts in a folder"""
    folder: watolib.CREFolder = params["folder"]
    return host_collection(folder.hosts().values())


@Endpoint(
    constructors.object_href("folder_config", "{folder}"),
    ".../persist",
    method="put",
Exemple #2
0
            f"The service description {service_description} did not match any service",
        )
    return constructors.serve_json(
        constructors.domain_object(
            domain_type="service",
            identifier=f"{host_name}-{service_description}",
            title=f"Service {service_description}",
            extensions=service,
            links=[],
            editable=False,
            deletable=False,
        ))


@Endpoint(
    constructors.domain_object_collection_href("host", "{host_name}",
                                               "services"),
    ".../collection",
    method="get",
    path_params=[HOST_NAME],
    query_params=PARAMETERS,
    tag_group="Monitoring",
    blacklist_in=["swagger-ui"],
    response_schema=response_schemas.DomainObjectCollection,
    permissions_required=PERMISSIONS,
)
def _list_host_services(param):
    """Show the monitored services of a host

    This list is filterable by various parameters."""
    return _list_services(param)
Exemple #3
0
          request_schema=request_schemas.CreateFolder)
def create(params):
    """Create a folder"""
    put_body = params['body']
    name = put_body['name']
    title = put_body['title']
    parent_folder = put_body['parent']
    attributes = put_body.get('attributes', {})

    folder = parent_folder.create_subfolder(name, title, attributes)

    return _serve_folder(folder)


@Endpoint(
    constructors.domain_object_collection_href('folder_config', '{folder}',
                                               'hosts'),
    '.../collection',
    method='get',
    path_params=[FOLDER_FIELD],
    response_schema=response_schemas.DomainObjectCollection,
)
def hosts_of_folder(params):
    """Show all hosts in a folder
    """
    folder = params['folder']
    return host_collection(folder.hosts())


@Endpoint(constructors.object_href('folder_config', '{folder}'),
          '.../persist',
          method='put',
Exemple #4
0
            title="The requested service was not found",
            detail=
            f"The service description {service_description} did not match any service",
        )
    return constructors.serve_json(
        constructors.domain_object(
            domain_type='service',
            identifier=f"{host_name}-{service_description}",
            title=f"Service {service_description}",
            extensions=service,
            links=[],
            editable=False,
            deletable=False))


@Endpoint(constructors.domain_object_collection_href('host', '{host_name}',
                                                     'services'),
          '.../collection',
          method='get',
          path_params=[HOST_NAME],
          query_params=PARAMETERS,
          tag_group='Monitoring',
          blacklist_in=['swagger-ui'],
          response_schema=response_schemas.DomainObjectCollection)
def _list_host_services(param):
    """Show the monitored services of a host

    This list is filterable by various parameters."""
    return _list_services(param)


@Endpoint(