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:
parent
91e747d8ab
commit
40312c527b
@ -2270,9 +2270,18 @@
|
||||
"title": "OAuth2 is the oauth2 client configuration.",
|
||||
"type": "object"
|
||||
},
|
||||
"ObjectMatcher": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||
"type": "array"
|
||||
},
|
||||
"ObjectMatchers": {
|
||||
"$ref": "#/definitions/Matchers",
|
||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed."
|
||||
"items": {
|
||||
"$ref": "#/definitions/ObjectMatcher"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"OpsGenieConfig": {
|
||||
"properties": {
|
||||
@ -4414,6 +4423,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@ -4542,7 +4552,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"$ref": "#/definitions/labelSet"
|
||||
@ -4652,13 +4661,13 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"properties": {
|
||||
"lastNotifyAttempt": {
|
||||
"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)
|
||||
|
||||
// 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
|
||||
// that have already been parsed.
|
||||
type ObjectMatchers labels.Matchers
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.
|
||||
func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var rawMatchers [][3]string
|
||||
var rawMatchers ObjectMatchersAPIModel
|
||||
if err := unmarshal(&rawMatchers); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1326,7 +1335,7 @@ func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface for Matchers.
|
||||
func (m *ObjectMatchers) UnmarshalJSON(data []byte) error {
|
||||
var rawMatchers [][3]string
|
||||
var rawMatchers ObjectMatchersAPIModel
|
||||
if err := json.Unmarshal(data, &rawMatchers); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1360,9 +1369,9 @@ func (m *ObjectMatchers) UnmarshalJSON(data []byte) error {
|
||||
|
||||
// MarshalYAML implements the yaml.Marshaler interface for Matchers.
|
||||
func (m ObjectMatchers) MarshalYAML() (interface{}, error) {
|
||||
result := make([][3]string, len(m))
|
||||
result := make(ObjectMatchersAPIModel, len(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
|
||||
}
|
||||
@ -1372,9 +1381,9 @@ func (m ObjectMatchers) MarshalJSON() ([]byte, error) {
|
||||
if len(m) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
result := make([][3]string, len(m))
|
||||
result := make(ObjectMatchersAPIModel, len(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)
|
||||
}
|
||||
|
@ -2270,9 +2270,18 @@
|
||||
"title": "OAuth2 is the oauth2 client configuration.",
|
||||
"type": "object"
|
||||
},
|
||||
"ObjectMatcher": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||
"type": "array"
|
||||
},
|
||||
"ObjectMatchers": {
|
||||
"$ref": "#/definitions/Matchers",
|
||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed."
|
||||
"items": {
|
||||
"$ref": "#/definitions/ObjectMatcher"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"OpsGenieConfig": {
|
||||
"properties": {
|
||||
@ -4603,7 +4612,6 @@
|
||||
"type": "array"
|
||||
},
|
||||
"gettableSilence": {
|
||||
"description": "GettableSilence gettable silence",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"description": "comment",
|
||||
@ -4652,6 +4660,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$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": {
|
||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed.",
|
||||
"$ref": "#/definitions/Matchers"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ObjectMatcher"
|
||||
}
|
||||
},
|
||||
"OpsGenieConfig": {
|
||||
"type": "object",
|
||||
@ -8032,7 +8041,6 @@
|
||||
"$ref": "#/definitions/gettableAlerts"
|
||||
},
|
||||
"gettableSilence": {
|
||||
"description": "GettableSilence gettable silence",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"comment",
|
||||
@ -8082,6 +8090,7 @@
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
|
@ -16751,9 +16751,18 @@
|
||||
"format": "int64"
|
||||
}
|
||||
},
|
||||
"ObjectMatcher": {
|
||||
"type": "array",
|
||||
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"ObjectMatchers": {
|
||||
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed.",
|
||||
"$ref": "#/definitions/Matchers"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ObjectMatcher"
|
||||
}
|
||||
},
|
||||
"OpsGenieConfig": {
|
||||
"type": "object",
|
||||
@ -21454,6 +21463,7 @@
|
||||
}
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"alerts",
|
||||
@ -21610,7 +21620,6 @@
|
||||
}
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"labels",
|
||||
@ -21720,13 +21729,13 @@
|
||||
}
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
}
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
|
@ -7275,8 +7275,18 @@
|
||||
"title": "An ObjectIdentifier represents an ASN.1 OBJECT IDENTIFIER.",
|
||||
"type": "array"
|
||||
},
|
||||
"ObjectMatcher": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "ObjectMatcher is a matcher that can be used to filter alerts.",
|
||||
"type": "array"
|
||||
},
|
||||
"ObjectMatchers": {
|
||||
"$ref": "#/components/schemas/Matchers"
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ObjectMatcher"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"OpsGenieConfig": {
|
||||
"properties": {
|
||||
@ -11976,6 +11986,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@ -12132,7 +12143,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"$ref": "#/components/schemas/labelSet"
|
||||
@ -12242,13 +12252,13 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/gettableSilence"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"properties": {
|
||||
"lastNotifyAttempt": {
|
||||
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
||||
|
Loading…
Reference in New Issue
Block a user