def update_host_tag_group(params): """Update a host tag group""" # TODO: ident verification mechanism with ParamDict replacement body = params['body'] ident = params['name'] if is_builtin(ident): return problem( status=405, title="Built-in cannot be modified", detail=f"The built-in host tag group {ident} cannot be modified", ) updated_details = {x: body[x] for x in body if x != "repair"} tag_group = _retrieve_group(ident) group_details = tag_group.get_dict_format() group_details.update(updated_details) try: edit_tag_group(ident, TagGroup(group_details), allow_repair=body['repair']) except RepairError: return problem( 401, f'Updating this host tag group "{ident}" requires additional authorization', 'The host tag group you intend to edit is used by other instances. You must authorize Checkmk ' 'to update the relevant instances using the repair parameter') updated_tag_group = _retrieve_group(ident) return _serve_host_tag_group(updated_tag_group.get_dict_format())
def update_host_tag_group(params): """Update a host tag group""" # TODO: ident verification mechanism with ParamDict replacement body = params["body"] ident = params["name"] if is_builtin(ident): return problem( status=405, title="Built-in cannot be modified", detail=f"The built-in host tag group {ident} cannot be modified", ) updated_details = {x: body[x] for x in body if x != "repair"} tag_group = _retrieve_group(ident) group_details = tag_group.get_dict_format() # This is an incremental update of the TaggroupSpec group_details.update(updated_details) # type: ignore[typeddict-item] try: edit_tag_group(ident, TagGroup.from_config(group_details), allow_repair=body["repair"]) except RepairError: return problem( 401, f'Updating this host tag group "{ident}" requires additional authorization', "The host tag group you intend to edit is used by other instances. You must authorize Checkmk " "to update the relevant instances using the repair parameter", ) updated_tag_group = _retrieve_group(ident) return _serve_host_tag_group(updated_tag_group.get_dict_format())
def create_host_tag_group(params): """Create a host tag group""" user.need_permission("wato.edit") host_tag_group_details = params["body"] save_tag_group(TagGroup.from_config(host_tag_group_details)) return _serve_host_tag_group( _retrieve_group(host_tag_group_details["id"]).get_dict_format())
def create_host_tag_group(params): """Create a host tag group""" host_tag_group_details = params['body'] save_tag_group(TagGroup(host_tag_group_details)) return _serve_host_tag_group( _retrieve_group(host_tag_group_details['id']).get_dict_format())
def create_host_tag_group(params): """Create a host tag group""" host_tag_group_details = params["body"] save_tag_group(TagGroup.from_config(host_tag_group_details)) return _serve_host_tag_group( _retrieve_group(host_tag_group_details["id"]).get_dict_format())