Example #1
0
def bulk_update(params):
    """Bulk update service-groups"""
    body = params['body']
    entries = body['entries']
    updated_service_groups = update_groups("service", entries)
    return constructors.serve_json(
        serialize_group_list('service_group_config', updated_service_groups))
Example #2
0
def bulk_update(params):
    """Bulk update host-groups"""
    body = params['body']
    entries = body['entries']
    updated_contact_groups = update_groups("contact", entries)
    return constructors.serve_json(
        serialize_group_list('contact_group_config', updated_contact_groups))
def list_groups(params):
    """Show all host groups"""
    collection = [{
        "id": k,
        "alias": v["alias"]
    } for k, v in load_host_group_information().items()]
    return constructors.serve_json(
        serialize_group_list("host_group_config", collection))
def list_group(params):
    """Show all contact groups"""
    user.need_permission("wato.users")
    collection = [{
        "id": k,
        "alias": v["alias"]
    } for k, v in load_contact_group_information().items()]
    return constructors.serve_json(
        serialize_group_list("contact_group_config", collection), )
Example #5
0
def bulk_update(params):
    """Bulk update host groups

    Please be aware that when doing bulk updates, it is not possible to prevent the
    [Updating Values]("lost update problem"), which is normally prevented by the ETag locking
    mechanism. Use at your own risk
    """
    body = params["body"]
    entries = body["entries"]
    updated_host_groups = update_groups("host", entries)
    return constructors.serve_json(serialize_group_list("host_group_config", updated_host_groups))
Example #6
0
def bulk_create(params):
    """Bulk create host groups"""
    body = params['body']
    entries = body['entries']
    contact_group_details = load_groups("contact", entries)

    contact_group_names = []
    for group_name, group_alias in contact_group_details.items():
        add_group(group_name, 'contact', {'alias': group_alias})
        contact_group_names.append(group_name)

    contact_groups = fetch_specific_groups(contact_group_names, "contact")
    return constructors.serve_json(serialize_group_list('contact_group_config', contact_groups))
Example #7
0
def bulk_create(params):
    """Bulk create host groups"""
    body = params["body"]
    entries = body["entries"]
    host_group_details = prepare_groups("host", entries)

    host_group_names = []
    for group_name, group_details in host_group_details.items():
        add_group(group_name, "host", group_details)
        host_group_names.append(group_name)

    host_groups = fetch_specific_groups(host_group_names, "host")
    return constructors.serve_json(serialize_group_list("host_group_config", host_groups))
Example #8
0
def bulk_create(params):
    """Bulk create service groups"""
    body = params['body']
    entries = body['entries']
    service_group_details = load_groups("service", entries)

    service_group_names = []
    for group_name, group_alias in service_group_details.items():
        add_group(group_name, 'service', {'alias': group_alias})
        service_group_names.append(group_name)

    service_groups = fetch_specific_groups(service_group_names, "service")
    return constructors.serve_json(
        serialize_group_list('service_group_config', service_groups))
def bulk_create(params):
    """Bulk create host groups"""
    user.need_permission("wato.edit")
    body = params["body"]
    entries = body["entries"]
    contact_group_details = prepare_groups("contact", entries)

    contact_group_names = []
    for group_name, group_details in contact_group_details.items():
        add_group(group_name, "contact", group_details)
        contact_group_names.append(group_name)

    contact_groups = fetch_specific_groups(contact_group_names, "contact")
    return constructors.serve_json(
        serialize_group_list("contact_group_config", contact_groups))
Example #10
0
def list_groups(params):
    """List service-groups"""
    return constructors.serve_json(
        serialize_group_list('service_group_config',
                             list(load_service_group_information().values())))
Example #11
0
def list_group(params):
    """Show all contact groups"""
    return constructors.serve_json(
        serialize_group_list('contact_group_config',
                             list(load_contact_group_information().values())),)