rules

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// MaxRules is the Elasticsearch default limit of rules per ruleset.
	MaxRules = 100
)

Variables

This section is empty.

Functions

func DeleteRule

func DeleteRule(c zhttp.Context)

DeleteRule deletes a rule of a query ruleset

@Id DeleteQueryRule @Summary Delete query rule for compatible ES @security BasicAuth @Tags QueryRules @Produce json @Param id path string true "Ruleset id" @Param rule_id path string true "Rule id" @Success 200 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Router /es/_query_rules/{id}/_rule/{rule_id} [delete]

func DeleteRuleset

func DeleteRuleset(c zhttp.Context)

DeleteRuleset deletes a query ruleset

@Id DeleteQueryRuleset @Summary Delete query ruleset for compatible ES @security BasicAuth @Tags QueryRules @Produce json @Param id path string true "Ruleset id" @Success 200 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Router /es/_query_rules/{id} [delete]

func GetRule

func GetRule(c zhttp.Context)

GetRule returns a rule of a query ruleset

@Id GetQueryRule @Summary Get query rule for compatible ES @security BasicAuth @Tags QueryRules @Produce json @Param id path string true "Ruleset id" @Param rule_id path string true "Rule id" @Success 200 {object} meta.QueryRule @Failure 404 {object} map[string]interface{} @Router /es/_query_rules/{id}/_rule/{rule_id} [get]

func GetRuleset

func GetRuleset(c zhttp.Context)

GetRuleset returns a query ruleset

@Id GetQueryRuleset @Summary Get query ruleset for compatible ES @security BasicAuth @Tags QueryRules @Produce json @Param id path string true "Ruleset id" @Success 200 {object} meta.QueryRuleset @Failure 404 {object} map[string]interface{} @Router /es/_query_rules/{id} [get]

func ListRulesets

func ListRulesets(c zhttp.Context)

ListRulesets lists the query rulesets sorted by id

@Id ListQueryRulesets @Summary List query rulesets for compatible ES @security BasicAuth @Tags QueryRules @Produce json @Param from query int false "Starting offset" @Param size query int false "Max results, default 100" @Success 200 {object} rules.ListResponse @Failure 400 {object} map[string]interface{} @Router /es/_query_rules [get]

func PutRule

func PutRule(c zhttp.Context)

PutRule creates or replaces a rule, creating its ruleset when missing

@Id PutQueryRule @Summary Create or update query rule for compatible ES @security BasicAuth @Tags QueryRules @Accept json @Produce json @Param id path string true "Ruleset id" @Param rule_id path string true "Rule id" @Param rule body meta.QueryRule true "Rule" @Success 200 {object} rules.ResultResponse "Updated" @Success 201 {object} rules.ResultResponse "Created" @Failure 400 {object} map[string]interface{} @Router /es/_query_rules/{id}/_rule/{rule_id} [put]

func PutRuleset

func PutRuleset(c zhttp.Context)

PutRuleset creates or replaces a query ruleset

@Id PutQueryRuleset @Summary Create or update query ruleset for compatible ES @security BasicAuth @Tags QueryRules @Accept json @Produce json @Param id path string true "Ruleset id" @Param ruleset body meta.QueryRuleset true "Rules" @Success 200 {object} rules.ResultResponse "Updated" @Success 201 {object} rules.ResultResponse "Created" @Failure 400 {object} map[string]interface{} @Router /es/_query_rules/{id} [put]

func TestRuleset

func TestRuleset(c zhttp.Context)

TestRuleset returns the rules of a ruleset matching match_criteria

@Id TestQueryRuleset @Summary Test query ruleset for compatible ES @security BasicAuth @Tags QueryRules @Accept json @Produce json @Param id path string true "Ruleset id" @Param body body rules.TestRequest true "Criteria to match, e.g. {\"match_criteria\":{\"query_string\":\"boots\"}}" @Success 200 {object} rules.TestResponse @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Router /es/_query_rules/{id}/_test [post]

Types

type ListResponse

type ListResponse struct {
	Count   int              `json:"count"`
	Results []RulesetSummary `json:"results"`
}

ListResponse is a page of the rulesets.

type MatchedRule

type MatchedRule struct {
	RulesetID string `json:"ruleset_id"`
	RuleID    string `json:"rule_id"`
}

MatchedRule is a rule matched by the test API.

type ResultResponse

type ResultResponse struct {
	Result string `json:"result"`
}

ResultResponse is the response of a ruleset or rule change.

type RulesetSummary

type RulesetSummary struct {
	RulesetID               string         `json:"ruleset_id"`
	RuleTotalCount          int            `json:"rule_total_count"`
	RuleCriteriaTypesCounts map[string]int `json:"rule_criteria_types_counts"`
	RuleTypeCounts          map[string]int `json:"rule_type_counts"`
}

RulesetSummary is a ruleset of the list response.

type TestRequest

type TestRequest struct {
	MatchCriteria map[string]interface{} `json:"match_criteria" binding:"required"`
}

TestRequest is the body of the test API; the match_criteria keys are free-form.

type TestResponse

type TestResponse struct {
	TotalMatchedRules int           `json:"total_matched_rules"`
	MatchedRules      []MatchedRule `json:"matched_rules"`
}

TestResponse is the response of the test API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL