Example #1
0
def update(params):
    """Update a contact group"""
    name = params['name']
    group = fetch_group(name, "contact")
    constructors.require_etag(constructors.etag_of_dict(group))
    edit_group(name, 'contact', params['body'])
    group = fetch_group(name, "contact")
    return serve_group(group, serialize_group('contact_group_config'))
Example #2
0
def update(params):
    """Update a host group"""
    name = params["name"]
    group = fetch_group(name, "host")
    constructors.require_etag(constructors.etag_of_dict(group))
    edit_group(name, "host", updated_group_details(name, "host", params["body"]))
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group("host_group_config"))
Example #3
0
def update(params):
    """Update a service-group"""
    name = params['name']
    group = fetch_group(name, "service")
    constructors.require_etag(constructors.etag_of_dict(group))
    edit_group(name, group_type='service', extra_info=params['body'])
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group('service_group_config'))
Example #4
0
def update(params):
    """Update a host group"""
    name = params['name']
    group = fetch_group(name, "host")
    constructors.require_etag(constructors.etag_of_dict(group))
    edit_group(name, 'host', updated_group_details(name, 'host',
                                                   params['body']))
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group('host_group_config'))
def update(params):
    """Update a contact group"""
    user.need_permission("wato.edit")
    name = params["name"]
    group = fetch_group(name, "contact")
    constructors.require_etag(constructors.etag_of_dict(group))
    edit_group(name, "contact",
               updated_group_details(name, "contact", params["body"]))
    group = fetch_group(name, "contact")
    return serve_group(group, serialize_group("contact_group_config"))
Example #6
0
def delete(params):
    """Delete a contact group"""
    name = params['name']
    group = fetch_group(name, "contact")
    constructors.require_etag(constructors.etag_of_dict(group))
    watolib.delete_group(name, 'contact')
    return Response(status=204)
Example #7
0
def delete(params):
    """Delete a service-group"""
    name = params['name']
    group = fetch_group(name, "service")
    constructors.require_etag(constructors.etag_of_dict(group))
    watolib.delete_group(name, group_type='service')
    return Response(status=204)
Example #8
0
def create(params):
    """Create a contact group"""
    body = params['body']
    name = body['name']
    alias = body.get('alias')
    add_group(name, 'contact', {'alias': alias})
    group = fetch_group(name, "contact")
    return serve_group(group, serialize_group('contact_group_config'))
Example #9
0
def create(params):
    """Create a service-group"""
    body = params['body']
    name = body['name']
    alias = body.get('alias')
    add_group(name, 'service', {'alias': alias})
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group('service_group_config'))
Example #10
0
def create(params):
    """Create a contact group"""
    body = params['body']
    name = body['name']
    group_details = {"alias": body.get("alias")}
    if version.is_managed_edition():
        group_details = update_customer_info(group_details, body["customer"])
    add_group(name, 'contact', group_details)
    group = fetch_group(name, "contact")
    return serve_group(group, serialize_group('contact_group_config'))
Example #11
0
def create(params):
    """Create a host group"""
    body = params["body"]
    name = body["name"]
    group_details = {"alias": body.get("alias")}
    if version.is_managed_edition():
        group_details = update_customer_info(group_details, body["customer"])
    add_group(name, "host", group_details)
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group("host_group_config"))
Example #12
0
def create(params):
    """Create a service group"""
    user.need_permission("wato.edit")
    body = params["body"]
    name = body["name"]
    group_details = {"alias": body.get("alias")}
    if version.is_managed_edition():
        group_details = update_customer_info(group_details, body["customer"])
    groups.add_group(name, "service", group_details)
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group("service_group_config"))
Example #13
0
def bulk_delete(params):
    """Bulk delete service groups"""
    entries = params['entries']
    for group_name in entries:
        _group = fetch_group(group_name,
                             "service",
                             status=400,
                             message="service group %s was not found" %
                             group_name)
    for group_name in entries:
        watolib.delete_group(group_name, group_type='service')
    return Response(status=204)
Example #14
0
def bulk_delete(params):
    """Bulk delete contact groups"""
    entries = params['entries']
    for group_name in entries:
        _group = fetch_group(
            group_name,
            "contact",
            status=400,
            message=f"contact group {group_name} was not found",
        )
    for group_name in entries:
        watolib.delete_group(group_name, 'contact')
    return Response(status=204)
Example #15
0
def bulk_delete(params):
    """Bulk delete service groups"""
    user.need_permission("wato.edit")
    body = params["body"]
    entries = body["entries"]
    for group_name in entries:
        _group = fetch_group(group_name,
                             "service",
                             status=400,
                             message="service group %s was not found" %
                             group_name)
    for group_name in entries:
        groups.delete_group(group_name, group_type="service")
    return Response(status=204)
Example #16
0
def bulk_delete(params):
    """Bulk delete host groups"""
    body = params["body"]
    entries = body["entries"]
    for group_name in entries:
        message = "host group %s was not found" % group_name
        _group = fetch_group(
            group_name,
            "host",
            status=400,
            message=message,
        )

    for group_name in entries:
        watolib.delete_group(group_name, "host")
    return Response(status=204)
Example #17
0
def bulk_delete(params):
    """Bulk delete host groups"""
    # TODO: etag implementation
    entries = params['entries']
    for group_name in entries:
        message = "host group %s was not found" % group_name
        _group = fetch_group(
            group_name,
            "host",
            status=400,
            message=message,
        )  # TODO: etag check should be done here

    for group_name in entries:
        watolib.delete_group(group_name, 'host')
    return Response(status=204)
Example #18
0
def bulk_delete(params):
    """Bulk delete contact groups"""
    body = params["body"]
    entries = body["entries"]
    for group_name in entries:
        _group = fetch_group(
            group_name,
            "contact",
            status=400,
            message=f"contact group {group_name} was not found",
        )
    with endpoint.do_not_track_permissions(), SuperUserContext():
        for group_name in entries:
            # We need to supress this, because a lot of dashboard permissions are checked for
            # various reasons.
            delete_group(group_name, "contact")
    return Response(status=204)
Example #19
0
def get(params):
    """Show a host group"""
    user.need_permission("wato.groups")
    name = params["name"]
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group("host_group_config"))
Example #20
0
def get(params):
    """Show a host group"""
    name = params["name"]
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group("host_group_config"))
Example #21
0
def get(params):
    """Show a host-group"""
    name = params['name']
    group = fetch_group(name, "host")
    return serve_group(group, serialize_group('host_group_config'))
Example #22
0
def show_group(params):
    """Show a service-group"""
    name = params['name']
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group('service_group_config'))
Example #23
0
def show_group(params):
    """Show a service group"""
    user.need_permission("wato.groups")
    name = params["name"]
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group("service_group_config"))
def show_group(params):
    """Show a service group"""
    name = params["name"]
    group = fetch_group(name, "service")
    return serve_group(group, serialize_group("service_group_config"))
Example #25
0
def show(params):
    """Show a contact group"""
    name = params['name']
    group = fetch_group(name, "contact")
    return serve_group(group, serialize_group('contact_group_config'))