mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ngalert openapi: Fix ObjectMatchers definition (#79477)
These don't get marshalled and unmarshalled in the same way as they are represented in Go This PR changes the OpenAPI spec to reflect what the API accepts and sends back
This commit is contained in:
@@ -2270,9 +2270,18 @@
|
|||||||
"title": "OAuth2 is the oauth2 client configuration.",
|
"title": "OAuth2 is the oauth2 client configuration.",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"ObjectMatcher": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
"ObjectMatchers": {
|
"ObjectMatchers": {
|
||||||
"$ref": "#/definitions/Matchers",
|
"items": {
|
||||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed."
|
"$ref": "#/definitions/ObjectMatcher"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
},
|
},
|
||||||
"OpsGenieConfig": {
|
"OpsGenieConfig": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4414,6 +4423,7 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"alertGroup": {
|
"alertGroup": {
|
||||||
|
"description": "AlertGroup alert group",
|
||||||
"properties": {
|
"properties": {
|
||||||
"alerts": {
|
"alerts": {
|
||||||
"description": "alerts",
|
"description": "alerts",
|
||||||
@@ -4542,7 +4552,6 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableAlert": {
|
"gettableAlert": {
|
||||||
"description": "GettableAlert gettable alert",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"annotations": {
|
"annotations": {
|
||||||
"$ref": "#/definitions/labelSet"
|
"$ref": "#/definitions/labelSet"
|
||||||
@@ -4652,13 +4661,13 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
},
|
},
|
||||||
"integration": {
|
"integration": {
|
||||||
"description": "Integration integration",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"lastNotifyAttempt": {
|
"lastNotifyAttempt": {
|
||||||
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
||||||
|
|||||||
@@ -1273,13 +1273,22 @@ type PostableGrafanaReceivers struct {
|
|||||||
|
|
||||||
type EncryptFn func(ctx context.Context, payload []byte) ([]byte, error)
|
type EncryptFn func(ctx context.Context, payload []byte) ([]byte, error)
|
||||||
|
|
||||||
|
// ObjectMatcher is a matcher that can be used to filter alerts.
|
||||||
|
// swagger:model ObjectMatcher
|
||||||
|
type ObjectMatcherAPIModel [3]string
|
||||||
|
|
||||||
|
// ObjectMatchers is a list of matchers that can be used to filter alerts.
|
||||||
|
// swagger:model ObjectMatchers
|
||||||
|
type ObjectMatchersAPIModel []ObjectMatcherAPIModel
|
||||||
|
|
||||||
|
// swagger:ignore
|
||||||
// ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects
|
// ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects
|
||||||
// that have already been parsed.
|
// that have already been parsed.
|
||||||
type ObjectMatchers labels.Matchers
|
type ObjectMatchers labels.Matchers
|
||||||
|
|
||||||
// UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.
|
// UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.
|
||||||
func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
var rawMatchers [][3]string
|
var rawMatchers ObjectMatchersAPIModel
|
||||||
if err := unmarshal(&rawMatchers); err != nil {
|
if err := unmarshal(&rawMatchers); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1326,7 +1335,7 @@ func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error
|
|||||||
|
|
||||||
// UnmarshalJSON implements the json.Unmarshaler interface for Matchers.
|
// UnmarshalJSON implements the json.Unmarshaler interface for Matchers.
|
||||||
func (m *ObjectMatchers) UnmarshalJSON(data []byte) error {
|
func (m *ObjectMatchers) UnmarshalJSON(data []byte) error {
|
||||||
var rawMatchers [][3]string
|
var rawMatchers ObjectMatchersAPIModel
|
||||||
if err := json.Unmarshal(data, &rawMatchers); err != nil {
|
if err := json.Unmarshal(data, &rawMatchers); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1360,9 +1369,9 @@ func (m *ObjectMatchers) UnmarshalJSON(data []byte) error {
|
|||||||
|
|
||||||
// MarshalYAML implements the yaml.Marshaler interface for Matchers.
|
// MarshalYAML implements the yaml.Marshaler interface for Matchers.
|
||||||
func (m ObjectMatchers) MarshalYAML() (interface{}, error) {
|
func (m ObjectMatchers) MarshalYAML() (interface{}, error) {
|
||||||
result := make([][3]string, len(m))
|
result := make(ObjectMatchersAPIModel, len(m))
|
||||||
for i, matcher := range m {
|
for i, matcher := range m {
|
||||||
result[i] = [3]string{matcher.Name, matcher.Type.String(), matcher.Value}
|
result[i] = ObjectMatcherAPIModel{matcher.Name, matcher.Type.String(), matcher.Value}
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -1372,9 +1381,9 @@ func (m ObjectMatchers) MarshalJSON() ([]byte, error) {
|
|||||||
if len(m) == 0 {
|
if len(m) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
result := make([][3]string, len(m))
|
result := make(ObjectMatchersAPIModel, len(m))
|
||||||
for i, matcher := range m {
|
for i, matcher := range m {
|
||||||
result[i] = [3]string{matcher.Name, matcher.Type.String(), matcher.Value}
|
result[i] = ObjectMatcherAPIModel{matcher.Name, matcher.Type.String(), matcher.Value}
|
||||||
}
|
}
|
||||||
return json.Marshal(result)
|
return json.Marshal(result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2270,9 +2270,18 @@
|
|||||||
"title": "OAuth2 is the oauth2 client configuration.",
|
"title": "OAuth2 is the oauth2 client configuration.",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"ObjectMatcher": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
"ObjectMatchers": {
|
"ObjectMatchers": {
|
||||||
"$ref": "#/definitions/Matchers",
|
"items": {
|
||||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed."
|
"$ref": "#/definitions/ObjectMatcher"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
},
|
},
|
||||||
"OpsGenieConfig": {
|
"OpsGenieConfig": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4603,7 +4612,6 @@
|
|||||||
"type": "array"
|
"type": "array"
|
||||||
},
|
},
|
||||||
"gettableSilence": {
|
"gettableSilence": {
|
||||||
"description": "GettableSilence gettable silence",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"comment": {
|
"comment": {
|
||||||
"description": "comment",
|
"description": "comment",
|
||||||
@@ -4652,6 +4660,7 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5695,9 +5695,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ObjectMatcher": {
|
||||||
|
"type": "array",
|
||||||
|
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ObjectMatchers": {
|
"ObjectMatchers": {
|
||||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed.",
|
"type": "array",
|
||||||
"$ref": "#/definitions/Matchers"
|
"items": {
|
||||||
|
"$ref": "#/definitions/ObjectMatcher"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"OpsGenieConfig": {
|
"OpsGenieConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -8032,7 +8041,6 @@
|
|||||||
"$ref": "#/definitions/gettableAlerts"
|
"$ref": "#/definitions/gettableAlerts"
|
||||||
},
|
},
|
||||||
"gettableSilence": {
|
"gettableSilence": {
|
||||||
"description": "GettableSilence gettable silence",
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"comment",
|
"comment",
|
||||||
@@ -8082,6 +8090,7 @@
|
|||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
|
|||||||
@@ -16751,9 +16751,18 @@
|
|||||||
"format": "int64"
|
"format": "int64"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ObjectMatcher": {
|
||||||
|
"type": "array",
|
||||||
|
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ObjectMatchers": {
|
"ObjectMatchers": {
|
||||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed.",
|
"type": "array",
|
||||||
"$ref": "#/definitions/Matchers"
|
"items": {
|
||||||
|
"$ref": "#/definitions/ObjectMatcher"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"OpsGenieConfig": {
|
"OpsGenieConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -21454,6 +21463,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"alertGroup": {
|
"alertGroup": {
|
||||||
|
"description": "AlertGroup alert group",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"alerts",
|
"alerts",
|
||||||
@@ -21610,7 +21620,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gettableAlert": {
|
"gettableAlert": {
|
||||||
"description": "GettableAlert gettable alert",
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"labels",
|
"labels",
|
||||||
@@ -21720,13 +21729,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"integration": {
|
"integration": {
|
||||||
"description": "Integration integration",
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
|
|||||||
@@ -7275,8 +7275,18 @@
|
|||||||
"title": "An ObjectIdentifier represents an ASN.1 OBJECT IDENTIFIER.",
|
"title": "An ObjectIdentifier represents an ASN.1 OBJECT IDENTIFIER.",
|
||||||
"type": "array"
|
"type": "array"
|
||||||
},
|
},
|
||||||
|
"ObjectMatcher": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
"ObjectMatchers": {
|
"ObjectMatchers": {
|
||||||
"$ref": "#/components/schemas/Matchers"
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/ObjectMatcher"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
},
|
},
|
||||||
"OpsGenieConfig": {
|
"OpsGenieConfig": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -11976,6 +11986,7 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"alertGroup": {
|
"alertGroup": {
|
||||||
|
"description": "AlertGroup alert group",
|
||||||
"properties": {
|
"properties": {
|
||||||
"alerts": {
|
"alerts": {
|
||||||
"description": "alerts",
|
"description": "alerts",
|
||||||
@@ -12132,7 +12143,6 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableAlert": {
|
"gettableAlert": {
|
||||||
"description": "GettableAlert gettable alert",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"annotations": {
|
"annotations": {
|
||||||
"$ref": "#/components/schemas/labelSet"
|
"$ref": "#/components/schemas/labelSet"
|
||||||
@@ -12242,13 +12252,13 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/gettableSilence"
|
"$ref": "#/components/schemas/gettableSilence"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
},
|
},
|
||||||
"integration": {
|
"integration": {
|
||||||
"description": "Integration integration",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"lastNotifyAttempt": {
|
"lastNotifyAttempt": {
|
||||||
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
||||||
|
|||||||
Reference in New Issue
Block a user