Example #1
0
class AcknowledgeHostProblem(BaseSchema):
    sticky = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=param_description(acknowledge_host_problem.__doc__,
                                      'sticky'),
    )

    persistent = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=param_description(acknowledge_host_problem.__doc__,
                                      'persistent'),
    )

    notify = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=param_description(acknowledge_host_problem.__doc__,
                                      'notify'),
    )

    comment = fields.String(
        required=False,
        missing="Acknowledged",
        example='This was expected.',
        description=param_description(acknowledge_host_problem.__doc__,
                                      'comment'),
    )
Example #2
0
class UpdateHostTagGroup(BaseSchema):
    title = fields.String(
        required=False,
        example="Kubernetes",
        description="A title for the host tag",
    )
    topic = fields.String(
        required=False,
        example="Data Sources",
        description="Different tags can be grouped in a topic",
    )

    help = fields.String(
        required=False,
        example="Kubernetes Pods",
        description="A help description for the tag group",
    )
    tags = Tags(
        fields.Nested(HostTag),
        required=False,
        example=[{
            "ident": "pod",
            "title": "Pod"
        }],
        description="A list of host tags belonging to the host tag group",
    )
    repair = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=
        "The host tag group can be in use by other hosts. Setting repair to True gives permission to automatically update the tag from the affected hosts."
    )
Example #3
0
class DeleteHostTagGroup(BaseSchema):
    repair = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=
        "The host tag group can still be in use. Setting repair to True gives permission to automatically remove the tag from the affected hosts."
    )
Example #4
0
class CreateHostDowntime(CreateDowntimeBase):
    host_name = MONITORED_HOST
    duration = HOST_DURATION
    include_all_services = fields.Boolean(
        required=False,
        description=param_description(schedule_host_downtime.__doc__, 'include_all_services'),
        example=False,
        missing=False,
    )
Example #5
0
class CreateServiceGroupDowntime(CreateDowntimeBase):
    servicegroup_name = SERVICEGROUP_NAME
    include_hosts = fields.Boolean(
        required=False,
        description=param_description(schedule_servicegroup_service_downtime.__doc__,
                                      'include_hosts'),
        example=False,
        missing=False,
    )
    duration = HOST_DURATION
Example #6
0
class AcknowledgeServiceProblemBase(BaseSchema):
    acknowledge_type = fields.String(
        required=True,
        description="The acknowledge service selection type.",
        enum=['service', 'servicegroup', 'service_by_query'],
        example="service",
    )

    sticky = fields.Boolean(
        required=False,
        missing=True,
        example=False,
        description=param_description(acknowledge_service_problem.__doc__,
                                      'sticky'),
    )

    persistent = fields.Boolean(
        required=False,
        missing=False,
        example=False,
        description=param_description(acknowledge_service_problem.__doc__,
                                      'persistent'),
    )

    notify = fields.Boolean(
        required=False,
        missing=True,
        example=False,
        description=param_description(acknowledge_service_problem.__doc__,
                                      'notify'),
    )

    comment = fields.String(
        required=True,
        example='This was expected.',
        description=param_description(acknowledge_service_problem.__doc__,
                                      'comment'),
    )
Example #7
0
class CreateHostGroupDowntime(CreateDowntimeBase):
    hostgroup_name = fields.String(
        required=True,
        description=param_description(schedule_hostgroup_host_downtime.__doc__, 'hostgroup_name'),
        example='Servers',
    )
    include_all_services = fields.Boolean(
        required=False,
        description=param_description(schedule_hostgroup_host_downtime.__doc__,
                                      'include_all_services'),
        example=False,
        missing=False,
    )
    duration = HOST_DURATION
Example #8
0
class ActivateChanges(BaseSchema):
    redirect = fields.Boolean(
        description=
        "Redirect immediately to the 'Wait for completion' endpoint.",
        required=False,
        missing=False,
        example=False,
    )
    sites = fields.List(
        fields.String(),
        description=
        ("On which sites the configuration shall be activated. An empty list "
         "means all sites which have pending changes."),
        required=False,
        missing=[],
        example=['production'],
    )
Example #9
0

class AcknowledgeServiceRelatedProblem(OneOfSchema):
    type_field = 'acknowledge_type'
    type_field_remove = False
    type_schemas = {
        'service': AcknowledgeSpecificServiceProblem,
        'servicegroup': AcknowledgeServiceGroupProblem,
        'service_by_query': AcknowledgeServiceQueryProblem,
    }


SERVICE_STICKY_FIELD = fields.Boolean(
    required=False,
    missing=False,
    example=False,
    description=param_description(acknowledge_service_problem.__doc__,
                                  'sticky'),
)

SERVICE_PERSISTENT_FIELD = fields.Boolean(
    required=False,
    missing=False,
    example=False,
    description=param_description(acknowledge_service_problem.__doc__,
                                  'persistent'),
)

SERVICE_NOTIFY_FIELD = fields.Boolean(
    required=False,
    missing=False,
Example #10
0
        host.folder().delete_hosts([host.name()])
    return Response(status=204)


@Endpoint(
    constructors.object_href('host_config', '{host_name}'),
    'cmk/show',
    method='get',
    path_params=[HOST_NAME],
    query_params=[{
        'effective_attributes':
        fields.Boolean(
            missing=False,
            required=False,
            example=False,
            description=
            ("Show all effective attributes, which affect this host, not just the "
             "attributes which were set on this host specifically. This includes "
             "all attributes of all of this host's parent folders."),
        )
    }],
    etag='output',
    response_schema=response_schemas.DomainObject)
def show_host(params):
    """Show a host"""
    host_name = params['host_name']
    host: watolib.CREHost = watolib.Host.host(host_name)
    if host is None:
        return problem(
            404, f'Host "{host_name}" is not known.',
            'The host you asked for is not known. Please check for eventual misspellings.'
Example #11
0
    '.../collection',
    method='get',
    query_params=[{
        'parent':
        fields.FolderField(
            description=
            "Show all sub-folders of this folder. The default is the root-folder.",
            example='/servers',
            missing=watolib.Folder.
            root_folder,  # because we can't load it too early.
        ),
        'show_hosts':
        fields.Boolean(
            description=
            ("When set, all hosts that are stored in each folder will also be shown. "
             "On large setups this may come at a performance cost, so by default this "
             "is switched off."),
            example=False,
            missing=False,
        )
    }],
    response_schema=response_schemas.FolderCollection)
def list_folders(params):
    """Show all folders"""
    folders = params['parent'].subfolders()
    return constructors.serve_json(
        _folders_collection(folders, params['show_hosts']))


def _folders_collection(
    folders: List[CREFolder],
    show_hosts: bool,