Fix/ngalert generation (#33172)

* fixes pkg names & alerting openapi generation

* cleans up api generation, uses docker & removes python
This commit is contained in:
Owen Diehl
2021-04-20 13:12:32 -04:00
committed by GitHub
parent 8db3eb90ae
commit e065e19583
20 changed files with 157 additions and 123 deletions

View File

@@ -1,25 +1,27 @@
.DEFAULT_GOAL := all
GENERATED_GO_MATCHERS = ./go/*.go
swagger-codegen-api:
swagger-codegen generate -v \
-i https://grafana.github.io/alerting-api/post.json \
docker run --rm -v $$(pwd):/local --user $$(id -u):$$(id -g) swaggerapi/swagger-codegen-cli generate \
-i /local/tooling/post.json \
-l go-server \
-Dapis \
-o ../ \
-o /local \
--additional-properties packageName=api \
-t ./templates \
-t /local/tooling/swagger-codegen/templates \
# --import-mappings eval.RelativeTimeRange="github.com/grafana/grafana/pkg/services/ngalert/eval" \
# --type-mappings RelativeTimeRange=eval.RelativeTimeRange
copy-files:
python move-and-rename.py
ls -1 go | xargs -n 1 -I {} mv go/{} generated_base_{}
fix:
sed -i -e 's/apimodels\.\[\]PostableAlert/apimodels.PostableAlerts/' ../go/*.go
sed -i -e 's/apimodels\.\[\]UpdateDashboardAclCommand/apimodels.Permissions/' ../go/*.go
goimports -w -v ../go/*.go
sed -i -e 's/apimodels\.\[\]PostableAlert/apimodels.PostableAlerts/' $(GENERATED_GO_MATCHERS)
sed -i -e 's/apimodels\.\[\]UpdateDashboardAclCommand/apimodels.Permissions/' $(GENERATED_GO_MATCHERS)
goimports -w -v $(GENERATED_GO_MATCHERS)
clean:
rm -rf ../go
rm -rf ./go
all: swagger-codegen-api fix copy-files clean

View File

@@ -4,6 +4,7 @@
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
*/
package api
import (

View File

@@ -4,6 +4,7 @@
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
*/
package api
import (

View File

@@ -4,6 +4,7 @@
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
*/
package api
import (

View File

@@ -4,6 +4,7 @@
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
*/
package api
import (

View File

@@ -1,7 +0,0 @@
import os
path = '../go'
files = os.listdir(path)
dest_dir = "../"
for index, file in enumerate(files):
os.rename(os.path.join(path, file), os.path.join(dest_dir, ''.join(['generated_base_',file.split('.')[0], '.go'])))

View File

@@ -1,6 +1,6 @@
.DEFAULT_GOAL := openapi
API_DIR = pkg/api
API_DIR = definitions
GO_PKG_FILES = $(shell find $(API_DIR) -name *.go -print)
spec.json: $(GO_PKG_FILES)

View File

@@ -32,6 +32,18 @@ func main() {
log.Fatal(err)
}
info, ok := data["info"].(map[string]interface{})
if info == nil {
log.Fatal("expecting 'info' field")
}
if !ok {
log.Fatal("unable to turn info field into map[string]interface{}")
}
if info["title"] == nil {
info["title"] = "Unified Alerting API"
}
definitions, ok := data["definitions"]
if !ok {
log.Fatal("no definitions")

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -1,8 +1,10 @@
// Package definitions includes the types required for generating or consuming an OpenAPI
// spec for the Unified Alerting API.
// Documentation of the API.
//
// Schemes: http, https
// BasePath: /api/v1
// Version: 1.0.0
// Version: 1.1.0
//
// Consumes:
// - application/json
@@ -18,8 +20,7 @@
// type: basic
//
// swagger:meta
package api
package definitions
// swagger:model
type ValidationError struct {

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"time"

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package api
package definitions
import (
"encoding/json"

View File

@@ -6,7 +6,7 @@
"definitions": {
"Ack": {
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Alert": {
"properties": {
@@ -38,7 +38,7 @@
],
"title": "Alert has info for an alert.",
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertDiscovery": {
"properties": {
@@ -55,14 +55,12 @@
],
"title": "AlertDiscovery has info for all active alerts.",
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertGroup": {
"$ref": "#/definitions/alertGroup"
},
"AlertGroups": {
"$ref": "#/definitions/alertGroups"
},
"AlertGroups": {},
"AlertInstancesResponse": {
"properties": {
"instances": {
@@ -79,7 +77,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertNotification": {
"properties": {
@@ -186,7 +184,7 @@
"status"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertingRule": {
"description": "adapted from cortex",
@@ -254,7 +252,7 @@
"alerts"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"ApiRuleNode": {
"properties": {
@@ -289,7 +287,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Authorization": {
"properties": {
@@ -355,7 +353,7 @@
},
"title": "Config is the top-level configuration for Alertmanager's config files.",
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"CreateAlertNotificationCommand": {
"properties": {
@@ -428,7 +426,7 @@
"status"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Duration": {
"format": "int64",
@@ -557,15 +555,13 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Failure": {
"$ref": "#/definitions/ResponseDetails"
},
"GettableAlert": {},
"GettableAlerts": {
"$ref": "#/definitions/gettableAlerts"
},
"GettableAlerts": {},
"GettableApiAlertingConfig": {
"properties": {
"global": {
@@ -598,7 +594,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableApiReceiver": {
"properties": {
@@ -672,7 +668,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableExtendedRuleNode": {
"properties": {
@@ -710,7 +706,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableGrafanaReceiver": {
"$ref": "#/definitions/AlertNotification"
@@ -726,7 +722,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableGrafanaRule": {
"properties": {
@@ -807,7 +803,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableRuleGroupConfig": {
"properties": {
@@ -827,7 +823,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableSilence": {
"$ref": "#/definitions/gettableSilence"
@@ -847,7 +843,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GlobalConfig": {
"description": "GlobalConfig defines configuration parameters that are valid globally\nunless overwritten.",
@@ -1081,7 +1077,7 @@
"type": "array"
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"NotifierConfig": {
"properties": {
@@ -1329,7 +1325,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableApiReceiver": {
"properties": {
@@ -1403,7 +1399,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableExtendedRuleNode": {
"properties": {
@@ -1441,7 +1437,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableGrafanaReceiver": {
"$ref": "#/definitions/CreateAlertNotificationCommand"
@@ -1457,7 +1453,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableGrafanaRule": {
"properties": {
@@ -1500,7 +1496,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableRuleGroupConfig": {
"properties": {
@@ -1520,7 +1516,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableSilence": {},
"PostableUserConfig": {
@@ -1537,7 +1533,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PushoverConfig": {
"properties": {
@@ -1593,6 +1589,7 @@
"x-go-package": "github.com/prometheus/alertmanager/config"
},
"Receiver": {
"$ref": "#/definitions/receiver",
"properties": {
"email_configs": {
"items": {
@@ -1686,7 +1683,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Route": {
"properties": {
@@ -1721,6 +1718,13 @@
"matchers": {
"$ref": "#/definitions/Matchers"
},
"mute_time_intervals": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "MuteTimeIntervals"
},
"receiver": {
"type": "string",
"x-go-name": "Receiver"
@@ -1783,7 +1787,7 @@
"type"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleDiscovery": {
"properties": {
@@ -1799,7 +1803,7 @@
"groups"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleGroup": {
"properties": {
@@ -1842,7 +1846,7 @@
"interval"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleGroupConfigResponse": {
"properties": {
@@ -1862,7 +1866,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleResponse": {
"properties": {
@@ -1885,7 +1889,7 @@
"status"
],
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleType": {
"title": "RuleType models the type of a rule.",
@@ -2157,7 +2161,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"TestRuleResponse": {
"properties": {
@@ -2169,9 +2173,10 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -2204,9 +2209,9 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"type": "object",
"x-go-package": "github.com/prometheus/common/config"
"x-go-package": "net/url"
},
"Userinfo": {
"description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",
@@ -2221,7 +2226,7 @@
}
},
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Vector": {
"description": "Vector is basically only an alias for model.Samples, but the\ncontract is that in a Vector, all Samples have the same timestamp.",
@@ -2551,7 +2556,7 @@
"receivers": {
"description": "receivers",
"items": {
"$ref": "#/definitions/receiver"
"$ref": "#/definitions/Receiver"
},
"type": "array",
"x-go-name": "Receivers"
@@ -2589,7 +2594,7 @@
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
"$ref": "#/definitions/GettableAlert"
},
"type": "array",
"x-go-name": "GettableAlerts",
@@ -2655,7 +2660,7 @@
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/GettableSilence"
"$ref": "#/definitions/gettableSilence"
},
"type": "array",
"x-go-name": "GettableSilences",
@@ -2677,11 +2682,16 @@
"description": "The custom marshaling for labels.Labels ends up doing this anyways.",
"title": "override the labels type with a map for generation.",
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"matcher": {
"description": "Matcher matcher",
"properties": {
"isEqual": {
"description": "is equal",
"type": "boolean",
"x-go-name": "IsEqual"
},
"isRegex": {
"description": "is regex",
"type": "boolean",
@@ -2950,8 +2960,9 @@
}
},
"info": {
"title": "Documentation of the API.",
"version": "1.0.0"
"description": "Package definitions includes the types required for generating or consuming an OpenAPI\nspec for the Unified Alerting API.\nDocumentation of the API.",
"title": "Unified Alerting API",
"version": "1.1.0"
},
"paths": {
"/api/alertmanager/{Recipient}/api/v2/alerts": {

View File

@@ -11,8 +11,8 @@
],
"swagger": "2.0",
"info": {
"title": "Documentation of the API.",
"version": "1.0.0"
"description": "Package definitions includes the types required for generating or consuming an OpenAPI\nspec for the Unified Alerting API.\nDocumentation of the API.",
"version": "1.1.0"
},
"basePath": "/api/v1",
"paths": {
@@ -811,7 +811,7 @@
"definitions": {
"Ack": {
"type": "object",
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Alert": {
"type": "object",
@@ -843,7 +843,7 @@
"x-go-name": "Value"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertDiscovery": {
"type": "object",
@@ -860,13 +860,13 @@
"x-go-name": "Alerts"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertGroup": {
"$ref": "#/definitions/alertGroup"
},
"AlertGroups": {
"$ref": "#/definitions/alertGroups"
"$ref": "#/definitions/AlertGroups"
},
"AlertInstancesResponse": {
"type": "object",
@@ -884,7 +884,7 @@
"x-go-name": "Instances"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertNotification": {
"type": "object",
@@ -991,7 +991,7 @@
"x-go-name": "Status"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertingRule": {
"description": "adapted from cortex",
@@ -1059,7 +1059,7 @@
"$ref": "#/definitions/RuleType"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"ApiRuleNode": {
"type": "object",
@@ -1094,7 +1094,7 @@
"x-go-name": "Record"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Authorization": {
"type": "object",
@@ -1160,7 +1160,7 @@
"x-go-name": "Templates"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"CreateAlertNotificationCommand": {
"type": "object",
@@ -1233,7 +1233,7 @@
"x-go-name": "Status"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Duration": {
"type": "integer",
@@ -1363,7 +1363,7 @@
"$ref": "#/definitions/WechatConfig"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Failure": {
"$ref": "#/definitions/ResponseDetails"
@@ -1372,7 +1372,7 @@
"$ref": "#/definitions/GettableAlert"
},
"GettableAlerts": {
"$ref": "#/definitions/gettableAlerts"
"$ref": "#/definitions/GettableAlerts"
},
"GettableApiAlertingConfig": {
"type": "object",
@@ -1406,7 +1406,7 @@
"x-go-name": "Templates"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableApiReceiver": {
"type": "object",
@@ -1480,7 +1480,7 @@
"x-go-name": "WechatConfigs"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableExtendedRuleNode": {
"type": "object",
@@ -1518,7 +1518,7 @@
"x-go-name": "Record"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableGrafanaReceiver": {
"$ref": "#/definitions/AlertNotification"
@@ -1534,7 +1534,7 @@
"x-go-name": "GrafanaManagedReceivers"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableGrafanaRule": {
"type": "object",
@@ -1615,7 +1615,7 @@
"x-go-name": "Version"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableRuleGroupConfig": {
"type": "object",
@@ -1635,7 +1635,7 @@
"x-go-name": "Rules"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableSilence": {
"$ref": "#/definitions/gettableSilence"
@@ -1657,7 +1657,7 @@
"x-go-name": "TemplateFiles"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GlobalConfig": {
"description": "GlobalConfig defines configuration parameters that are valid globally\nunless overwritten.",
@@ -1892,7 +1892,7 @@
"$ref": "#/definitions/GettableRuleGroupConfig"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"NotifierConfig": {
"type": "object",
@@ -2140,7 +2140,7 @@
"x-go-name": "Templates"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableApiReceiver": {
"type": "object",
@@ -2214,7 +2214,7 @@
"x-go-name": "WechatConfigs"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableExtendedRuleNode": {
"type": "object",
@@ -2252,7 +2252,7 @@
"x-go-name": "Record"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableGrafanaReceiver": {
"$ref": "#/definitions/CreateAlertNotificationCommand"
@@ -2268,7 +2268,7 @@
"x-go-name": "GrafanaManagedReceivers"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableGrafanaRule": {
"type": "object",
@@ -2311,7 +2311,7 @@
"x-go-name": "UID"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableRuleGroupConfig": {
"type": "object",
@@ -2331,7 +2331,7 @@
"x-go-name": "Rules"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PostableSilence": {
"$ref": "#/definitions/PostableSilence"
@@ -2350,7 +2350,7 @@
"x-go-name": "TemplateFiles"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"PushoverConfig": {
"type": "object",
@@ -2471,7 +2471,7 @@
"x-go-name": "WechatConfigs"
}
},
"$ref": "#/definitions/Receiver"
"$ref": "#/definitions/receiver"
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
@@ -2500,7 +2500,7 @@
"x-go-name": "Msg"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Route": {
"type": "object",
@@ -2537,6 +2537,13 @@
"matchers": {
"$ref": "#/definitions/Matchers"
},
"mute_time_intervals": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "MuteTimeIntervals"
},
"receiver": {
"type": "string",
"x-go-name": "Receiver"
@@ -2597,7 +2604,7 @@
"$ref": "#/definitions/RuleType"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleDiscovery": {
"type": "object",
@@ -2613,7 +2620,7 @@
"x-go-name": "RuleGroups"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleGroup": {
"type": "object",
@@ -2656,7 +2663,7 @@
"x-go-name": "Rules"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleGroupConfigResponse": {
"type": "object",
@@ -2676,7 +2683,7 @@
"x-go-name": "Rules"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleResponse": {
"type": "object",
@@ -2699,7 +2706,7 @@
"x-go-name": "Status"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"RuleType": {
"type": "string",
@@ -2971,7 +2978,7 @@
"$ref": "#/definitions/EvalAlertConditionCommand"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"TestRuleResponse": {
"type": "object",
@@ -2983,11 +2990,12 @@
"$ref": "#/definitions/AlertInstancesResponse"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
"type": "object",
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -3020,7 +3028,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"x-go-package": "github.com/prometheus/common/config"
"x-go-package": "net/url"
},
"Userinfo": {
"description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",
@@ -3035,7 +3043,7 @@
"x-go-name": "Msg"
}
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Vector": {
"description": "Vector is basically only an alias for model.Samples, but the\ncontract is that in a Vector, all Samples have the same timestamp.",
@@ -3377,7 +3385,7 @@
"description": "receivers",
"type": "array",
"items": {
"$ref": "#/definitions/receiver"
"$ref": "#/definitions/Receiver"
},
"x-go-name": "Receivers"
},
@@ -3404,7 +3412,7 @@
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/gettableAlert"
"$ref": "#/definitions/GettableAlert"
},
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
@@ -3470,7 +3478,7 @@
"description": "GettableSilences gettable silences",
"type": "array",
"items": {
"$ref": "#/definitions/GettableSilence"
"$ref": "#/definitions/gettableSilence"
},
"x-go-name": "GettableSilences",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
@@ -3491,7 +3499,7 @@
"additionalProperties": {
"type": "string"
},
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"matcher": {
"description": "Matcher matcher",
@@ -3502,6 +3510,11 @@
"value"
],
"properties": {
"isEqual": {
"description": "is equal",
"type": "boolean",
"x-go-name": "IsEqual"
},
"isRegex": {
"description": "is regex",
"type": "boolean",

View File

@@ -8,7 +8,7 @@ import (
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/models"
apimodels "github.com/grafana/alerting-api/pkg/api"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/middleware"
)
@@ -22,5 +22,3 @@ func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service) {
}, middleware.ReqSignedIn)
}{{#operation}}
{{/operation}}{{/operations}}