add v2 integrations

This commit is contained in:
Yuri Tseretyan
2025-04-30 11:27:55 -04:00
parent d0644d081f
commit 335de805b7
11 changed files with 1361 additions and 3 deletions
@@ -2,6 +2,7 @@ package kinds
import (
"github.com/grafana/grafana/apps/alerting/notifications/kinds/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/kinds/v0alpha2"
)
receiver: {
@@ -24,5 +25,13 @@ receiver: {
"spec.title",
]
}
"v0alpha2": {
schema: {
spec: v0alpha2.ReceiverSpec
}
selectableFields: [
"spec.title",
]
}
}
}
@@ -0,0 +1,324 @@
package v0alpha2
BaseIntegration: {
uid?: string
disable_resolve_message?: bool
}
// A string that contain sensitive information.
#Secret: string
AlertmanagerIntegration: BaseIntegration & {
url: string
basicAuthUser?: string
basicAuthPassword?: #Secret
}
DingdingIntegration: BaseIntegration & {
url?: string
msgType?: string
title?: string
message?: string
}
DiscordIntegration: BaseIntegration & {
url: #Secret
title?: string
message?: string
avatar_url?: string
use_discord_username?: bool
}
EmailIntegration: BaseIntegration & {
addresses: [...string]
singleEmail?: bool
message?: string
subject?: string
}
GooglechatIntegration: BaseIntegration & {
url: #Secret
title?: string
message?: string
}
JiraIntegration: BaseIntegration & {
api_url: string
project: string
issue_type: string
summary?: string
description?: string
labels?: [...string]
priority?: string
reopen_transition?: string
resolve_transition?: string
wont_fix_resolution?: string
reopen_duration?: string
dedup_key_field?: string
fields?: {}
user?: #Secret
password?: #Secret
api_token?: #Secret
}
KafkaIntegration: BaseIntegration & {
kafkaRestProxy: #Secret
kafkaTopic: string
description?: string
details?: string
username?: string
password?: #Secret
apiVersion?: string
kafkaClusterId?: string
}
LineIntegration: BaseIntegration & {
token: #Secret
title?: string
description?: string
}
#TLSConfig: {
insecureSkipVerify?: bool
caCertificate?: #Secret
clientCertificate?: #Secret
clientKey?: #Secret
}
MqttIntegration: BaseIntegration & {
brokerUrl?: string
clientId?: string
topic?: string
message?: string
messageFormat?: string
username?: string
password?: #Secret
qos?: int64
retain?: bool
tlsConfig?: #TLSConfig
}
OnCallIntegration: BaseIntegration & {
url: string
httpMethod?: string
maxAlerts?: int64
authorization_scheme?: string
authorization_credentials?: #Secret
username?: string
password?: #Secret
title?: string
message?: string
}
OpsgenieIntegrationResponder: {
id?: string
name?: string
username?: string
type: string
}
OpsgenieIntegration: BaseIntegration & {
apiKey: #Secret
apiUrl?: string
message?: string
description?: string
autoClose?: bool
overridePriority?: bool
sendTagsAs?: string
responders?: [...OpsgenieIntegrationResponder]
}
PagerdutyIntegration: BaseIntegration & {
integrationKey: #Secret
severity?: string
class?: string
component?: string
group?: string
summary?: string
source?: string
client?: string
client_url?: string
details?: {[string]: string}
url?: string
}
PushoverIntegration: BaseIntegration & {
userKey: #Secret
apiToken: #Secret
priority?: int64
okPriority?: int64
retry?: int64
expire?: int64
device?: string
sound?: string
okSound?: string
title?: string
message?: string
uploadImage?: bool
}
SensugoIntegration: BaseIntegration & {
url: string
apikey: #Secret
entity?: string
check?: string
namespace?: string
handler?: string
message?: string
}
#SigV4Config: {
region?: string
access_key?: #Secret
secret_key?: #Secret
profile?: string
role_arn?: string
}
SnsIntegration: BaseIntegration & {
api_url?: string
sigv4: #SigV4Config
topic_arn?: string
phone_number?: string
target_arn?: string
subject?: string
message?: string
attributes?: {[string]: string}
}
SlackIntegration: BaseIntegration & {
endpointUrl?: string
url?: #Secret
token?: #Secret
recipient?: string
text?: string
title?: string
username?: string
icon_emoji?: string
icon_url?: string
mentionChannel?: string
mentionUsers?: string
mentionGroups?: string
color?: string
}
TelegramIntegration: BaseIntegration & {
bottoken: #Secret
chatid: string
message_thread_id: string
message?: string
parse_mode?: string
disable_web_page_preview?: bool
protect_content?: bool
disable_notifications?: bool
}
TeamsIntegration: BaseIntegration & {
url: #Secret
message?: string
title?: string
sectiontitle?: string
}
ThreemaIntegration: BaseIntegration & {
gateway_id: string
recipient_id: string
api_secret: #Secret
title?: string
description?: string
}
VictoropsIntegration: BaseIntegration & {
url: #Secret
messageType?: string
title?: string
description?: string
}
WebexIntegration: BaseIntegration & {
bot_token: #Secret
api_url?: string
message?: string
room_id?: string
}
#CustomPayload: {
template?: string
vars?: {[string]: string}
}
#HMACConfig: {
secret?: #Secret
header: string
timestampHeader: string
}
WebhookIntegration: BaseIntegration & {
url: string
httpMethod?: string
maxAlerts?: int64
authorization_scheme?: string
authorization_credentials?: #Secret
username?: string
password?: #Secret
headers?: {[string]: string}
title?: string
message?: string
tlsConfig?: #TLSConfig
hmacConfig?: #HMACConfig
payload?: #CustomPayload
}
WecomIntegration: BaseIntegration & {
endpointUrl?: string
url?: #Secret
secret?: #Secret
agent_id?: string
corp_id?: string
message?: string
title?: string
msgtype?: string
touser?: string
}
ReceiverSpec: {
title: string
alertmanager?: [...AlertmanagerIntegration]
dingding?: [...DingdingIntegration]
discord?: [...DiscordIntegration]
email?: [...EmailIntegration]
googlechat?: [...GooglechatIntegration]
jira?: [...JiraIntegration]
kafka?: [...KafkaIntegration]
line?: [...LineIntegration]
mqtt?: [...MqttIntegration]
opsgenie?: [...OpsgenieIntegration]
pagerduty?: [...PagerdutyIntegration]
oncall?: [...OnCallIntegration]
pushover?: [...PushoverIntegration]
sensugo?: [...SensugoIntegration]
slack?: [...SlackIntegration]
sns?: [...SnsIntegration]
teams?: [...TeamsIntegration]
telegram?: [...TelegramIntegration]
threema?: [...ThreemaIntegration]
victorops?: [...VictoropsIntegration]
webhook?: [...WebhookIntegration]
wecom?: [...WecomIntegration]
webex?: [...WebexIntegration]
}
@@ -28,6 +28,13 @@ var appManifestData = app.ManifestData{
"spec.title",
},
},
{
Name: "v0alpha2",
SelectableFields: []string{
"spec.title",
},
},
},
},
@@ -0,0 +1,18 @@
package v0alpha2
import "k8s.io/apimachinery/pkg/runtime/schema"
const (
// Group is the API group used by all kinds in this package
Group = "notifications.alerting.grafana.app"
// Version is the API version used by all kinds in this package
Version = "v0alpha2"
)
var (
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
GroupVersion = schema.GroupVersion{
Group: Group,
Version: Version,
}
)
@@ -0,0 +1,28 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v0alpha2
import (
"encoding/json"
"io"
"github.com/grafana/grafana-app-sdk/resource"
)
// JSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type JSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*JSONCodec) Read(reader io.Reader, into resource.Object) error {
return json.NewDecoder(reader).Decode(into)
}
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
func (*JSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &JSONCodec{}
@@ -0,0 +1,28 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha2
import (
time "time"
)
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type Metadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
CreationTimestamp time.Time `json:"creationTimestamp"`
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
Finalizers []string `json:"finalizers"`
ResourceVersion string `json:"resourceVersion"`
Generation int64 `json:"generation"`
UpdatedBy string `json:"updatedBy"`
Labels map[string]string `json:"labels"`
}
// NewMetadata creates a new Metadata object.
func NewMetadata() *Metadata {
return &Metadata{}
}
@@ -0,0 +1,319 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v0alpha2
import (
"fmt"
"github.com/grafana/grafana-app-sdk/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"time"
)
// +k8s:openapi-gen=true
type Receiver struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the Receiver
Spec Spec `json:"spec" yaml:"spec"`
Status Status `json:"status" yaml:"status"`
}
func (o *Receiver) GetSpec() any {
return o.Spec
}
func (o *Receiver) SetSpec(spec any) error {
cast, ok := spec.(Spec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
o.Spec = cast
return nil
}
func (o *Receiver) GetSubresources() map[string]any {
return map[string]any{
"status": o.Status,
}
}
func (o *Receiver) GetSubresource(name string) (any, bool) {
switch name {
case "status":
return o.Status, true
default:
return nil, false
}
}
func (o *Receiver) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(Status)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type Status", value)
}
o.Status = cast
return nil
default:
return fmt.Errorf("subresource '%s' does not exist", name)
}
}
func (o *Receiver) GetStaticMetadata() resource.StaticMetadata {
gvk := o.GroupVersionKind()
return resource.StaticMetadata{
Name: o.ObjectMeta.Name,
Namespace: o.ObjectMeta.Namespace,
Group: gvk.Group,
Version: gvk.Version,
Kind: gvk.Kind,
}
}
func (o *Receiver) SetStaticMetadata(metadata resource.StaticMetadata) {
o.Name = metadata.Name
o.Namespace = metadata.Namespace
o.SetGroupVersionKind(schema.GroupVersionKind{
Group: metadata.Group,
Version: metadata.Version,
Kind: metadata.Kind,
})
}
func (o *Receiver) GetCommonMetadata() resource.CommonMetadata {
dt := o.DeletionTimestamp
var deletionTimestamp *time.Time
if dt != nil {
deletionTimestamp = &dt.Time
}
// Legacy ExtraFields support
extraFields := make(map[string]any)
if o.Annotations != nil {
extraFields["annotations"] = o.Annotations
}
if o.ManagedFields != nil {
extraFields["managedFields"] = o.ManagedFields
}
if o.OwnerReferences != nil {
extraFields["ownerReferences"] = o.OwnerReferences
}
return resource.CommonMetadata{
UID: string(o.UID),
ResourceVersion: o.ResourceVersion,
Generation: o.Generation,
Labels: o.Labels,
CreationTimestamp: o.CreationTimestamp.Time,
DeletionTimestamp: deletionTimestamp,
Finalizers: o.Finalizers,
UpdateTimestamp: o.GetUpdateTimestamp(),
CreatedBy: o.GetCreatedBy(),
UpdatedBy: o.GetUpdatedBy(),
ExtraFields: extraFields,
}
}
func (o *Receiver) SetCommonMetadata(metadata resource.CommonMetadata) {
o.UID = types.UID(metadata.UID)
o.ResourceVersion = metadata.ResourceVersion
o.Generation = metadata.Generation
o.Labels = metadata.Labels
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp)
if metadata.DeletionTimestamp != nil {
dt := metav1.NewTime(*metadata.DeletionTimestamp)
o.DeletionTimestamp = &dt
} else {
o.DeletionTimestamp = nil
}
o.Finalizers = metadata.Finalizers
if o.Annotations == nil {
o.Annotations = make(map[string]string)
}
if !metadata.UpdateTimestamp.IsZero() {
o.SetUpdateTimestamp(metadata.UpdateTimestamp)
}
if metadata.CreatedBy != "" {
o.SetCreatedBy(metadata.CreatedBy)
}
if metadata.UpdatedBy != "" {
o.SetUpdatedBy(metadata.UpdatedBy)
}
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
if metadata.ExtraFields != nil {
if annotations, ok := metadata.ExtraFields["annotations"]; ok {
if cast, ok := annotations.(map[string]string); ok {
o.Annotations = cast
}
}
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok {
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok {
o.ManagedFields = cast
}
}
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok {
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok {
o.OwnerReferences = cast
}
}
}
}
func (o *Receiver) GetCreatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
return o.ObjectMeta.Annotations["grafana.com/createdBy"]
}
func (o *Receiver) SetCreatedBy(createdBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy
}
func (o *Receiver) GetUpdateTimestamp() time.Time {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"])
return parsed
}
func (o *Receiver) SetUpdateTimestamp(updateTimestamp time.Time) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339)
}
func (o *Receiver) GetUpdatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
return o.ObjectMeta.Annotations["grafana.com/updatedBy"]
}
func (o *Receiver) SetUpdatedBy(updatedBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy
}
func (o *Receiver) Copy() resource.Object {
return resource.CopyObject(o)
}
func (o *Receiver) DeepCopyObject() runtime.Object {
return o.Copy()
}
func (o *Receiver) DeepCopy() *Receiver {
cpy := &Receiver{}
o.DeepCopyInto(cpy)
return cpy
}
func (o *Receiver) DeepCopyInto(dst *Receiver) {
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
dst.TypeMeta.Kind = o.TypeMeta.Kind
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
o.Spec.DeepCopyInto(&dst.Spec)
o.Status.DeepCopyInto(&dst.Status)
}
// Interface compliance compile-time check
var _ resource.Object = &Receiver{}
// +k8s:openapi-gen=true
type ReceiverList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []Receiver `json:"items" yaml:"items"`
}
func (o *ReceiverList) DeepCopyObject() runtime.Object {
return o.Copy()
}
func (o *ReceiverList) Copy() resource.ListObject {
cpy := &ReceiverList{
TypeMeta: o.TypeMeta,
Items: make([]Receiver, len(o.Items)),
}
o.ListMeta.DeepCopyInto(&cpy.ListMeta)
for i := 0; i < len(o.Items); i++ {
if item, ok := o.Items[i].Copy().(*Receiver); ok {
cpy.Items[i] = *item
}
}
return cpy
}
func (o *ReceiverList) GetItems() []resource.Object {
items := make([]resource.Object, len(o.Items))
for i := 0; i < len(o.Items); i++ {
items[i] = &o.Items[i]
}
return items
}
func (o *ReceiverList) SetItems(items []resource.Object) {
o.Items = make([]Receiver, len(items))
for i := 0; i < len(items); i++ {
o.Items[i] = *items[i].(*Receiver)
}
}
func (o *ReceiverList) DeepCopy() *ReceiverList {
cpy := &ReceiverList{}
o.DeepCopyInto(cpy)
return cpy
}
func (o *ReceiverList) DeepCopyInto(dst *ReceiverList) {
resource.CopyObjectInto(dst, o)
}
// Interface compliance compile-time check
var _ resource.ListObject = &ReceiverList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *Spec) DeepCopy() *Spec {
cpy := &Spec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *Spec) DeepCopyInto(dst *Spec) {
resource.CopyObjectInto(dst, s)
}
// DeepCopy creates a full deep copy of Status
func (s *Status) DeepCopy() *Status {
cpy := &Status{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Status into another Status object
func (s *Status) DeepCopyInto(dst *Status) {
resource.CopyObjectInto(dst, s)
}
@@ -0,0 +1,46 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v0alpha2
import (
"fmt"
"github.com/grafana/grafana-app-sdk/resource"
)
// schema is unexported to prevent accidental overwrites
var (
schemaReceiver = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha2", &Receiver{}, &ReceiverList{}, resource.WithKind("Receiver"),
resource.WithPlural("receivers"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
FieldSelector: "spec.title",
FieldValueFunc: func(o resource.Object) (string, error) {
cast, ok := o.(*Receiver)
if !ok {
return "", fmt.Errorf("provided object must be of type *Receiver")
}
return cast.Spec.Title, nil
},
},
}))
kindReceiver = resource.Kind{
Schema: schemaReceiver,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &JSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func Kind() resource.Kind {
return kindReceiver
}
// Schema returns a resource.SimpleSchema representation of Receiver
func Schema() *resource.SimpleSchema {
return schemaReceiver
}
// Interface compliance checks
var _ resource.Schema = kindReceiver
@@ -0,0 +1,529 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha2
// +k8s:openapi-gen=true
type AlertmanagerIntegration struct {
Uid *string `json:"uid,omitempty"`
Url string `json:"url"`
BasicAuthUser *string `json:"basicAuthUser,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
BasicAuthPassword *Secret `json:"basicAuthPassword,omitempty"`
}
// NewAlertmanagerIntegration creates a new AlertmanagerIntegration object.
func NewAlertmanagerIntegration() *AlertmanagerIntegration {
return &AlertmanagerIntegration{}
}
// A string that contain sensitive information.
// +k8s:openapi-gen=true
type Secret string
// +k8s:openapi-gen=true
type DingdingIntegration struct {
Uid *string `json:"uid,omitempty"`
Url *string `json:"url,omitempty"`
MsgType *string `json:"msgType,omitempty"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Message *string `json:"message,omitempty"`
}
// NewDingdingIntegration creates a new DingdingIntegration object.
func NewDingdingIntegration() *DingdingIntegration {
return &DingdingIntegration{}
}
// +k8s:openapi-gen=true
type DiscordIntegration struct {
Uid *string `json:"uid,omitempty"`
Url Secret `json:"url"`
Title *string `json:"title,omitempty"`
Message *string `json:"message,omitempty"`
AvatarUrl *string `json:"avatar_url,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
UseDiscordUsername *bool `json:"use_discord_username,omitempty"`
}
// NewDiscordIntegration creates a new DiscordIntegration object.
func NewDiscordIntegration() *DiscordIntegration {
return &DiscordIntegration{}
}
// +k8s:openapi-gen=true
type EmailIntegration struct {
Uid *string `json:"uid,omitempty"`
Addresses []string `json:"addresses"`
SingleEmail *bool `json:"singleEmail,omitempty"`
Message *string `json:"message,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Subject *string `json:"subject,omitempty"`
}
// NewEmailIntegration creates a new EmailIntegration object.
func NewEmailIntegration() *EmailIntegration {
return &EmailIntegration{}
}
// +k8s:openapi-gen=true
type GooglechatIntegration struct {
Uid *string `json:"uid,omitempty"`
Url Secret `json:"url"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Message *string `json:"message,omitempty"`
}
// NewGooglechatIntegration creates a new GooglechatIntegration object.
func NewGooglechatIntegration() *GooglechatIntegration {
return &GooglechatIntegration{}
}
// +k8s:openapi-gen=true
type JiraIntegration struct {
Uid *string `json:"uid,omitempty"`
ApiUrl string `json:"api_url"`
Project string `json:"project"`
IssueType string `json:"issue_type"`
Summary *string `json:"summary,omitempty"`
Description *string `json:"description,omitempty"`
Labels []string `json:"labels,omitempty"`
Priority *string `json:"priority,omitempty"`
ReopenTransition *string `json:"reopen_transition,omitempty"`
ResolveTransition *string `json:"resolve_transition,omitempty"`
WontFixResolution *string `json:"wont_fix_resolution,omitempty"`
ReopenDuration *string `json:"reopen_duration,omitempty"`
DedupKeyField *string `json:"dedup_key_field,omitempty"`
Fields interface{} `json:"fields,omitempty"`
User *Secret `json:"user,omitempty"`
Password *Secret `json:"password,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
ApiToken *Secret `json:"api_token,omitempty"`
}
// NewJiraIntegration creates a new JiraIntegration object.
func NewJiraIntegration() *JiraIntegration {
return &JiraIntegration{}
}
// +k8s:openapi-gen=true
type KafkaIntegration struct {
Uid *string `json:"uid,omitempty"`
KafkaRestProxy Secret `json:"kafkaRestProxy"`
KafkaTopic string `json:"kafkaTopic"`
Description *string `json:"description,omitempty"`
Details *string `json:"details,omitempty"`
Username *string `json:"username,omitempty"`
Password *Secret `json:"password,omitempty"`
ApiVersion *string `json:"apiVersion,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
KafkaClusterId *string `json:"kafkaClusterId,omitempty"`
}
// NewKafkaIntegration creates a new KafkaIntegration object.
func NewKafkaIntegration() *KafkaIntegration {
return &KafkaIntegration{}
}
// +k8s:openapi-gen=true
type LineIntegration struct {
Uid *string `json:"uid,omitempty"`
Token Secret `json:"token"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Description *string `json:"description,omitempty"`
}
// NewLineIntegration creates a new LineIntegration object.
func NewLineIntegration() *LineIntegration {
return &LineIntegration{}
}
// +k8s:openapi-gen=true
type MqttIntegration struct {
Uid *string `json:"uid,omitempty"`
BrokerUrl *string `json:"brokerUrl,omitempty"`
ClientId *string `json:"clientId,omitempty"`
Topic *string `json:"topic,omitempty"`
Message *string `json:"message,omitempty"`
MessageFormat *string `json:"messageFormat,omitempty"`
Username *string `json:"username,omitempty"`
Password *Secret `json:"password,omitempty"`
Qos *int64 `json:"qos,omitempty"`
Retain *bool `json:"retain,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
TlsConfig *TLSConfig `json:"tlsConfig,omitempty"`
}
// NewMqttIntegration creates a new MqttIntegration object.
func NewMqttIntegration() *MqttIntegration {
return &MqttIntegration{}
}
// +k8s:openapi-gen=true
type TLSConfig struct {
InsecureSkipVerify *bool `json:"insecureSkipVerify,omitempty"`
CaCertificate *Secret `json:"caCertificate,omitempty"`
ClientCertificate *Secret `json:"clientCertificate,omitempty"`
ClientKey *Secret `json:"clientKey,omitempty"`
}
// NewTLSConfig creates a new TLSConfig object.
func NewTLSConfig() *TLSConfig {
return &TLSConfig{}
}
// +k8s:openapi-gen=true
type OpsgenieIntegration struct {
Uid *string `json:"uid,omitempty"`
ApiKey Secret `json:"apiKey"`
ApiUrl *string `json:"apiUrl,omitempty"`
Message *string `json:"message,omitempty"`
Description *string `json:"description,omitempty"`
AutoClose *bool `json:"autoClose,omitempty"`
OverridePriority *bool `json:"overridePriority,omitempty"`
SendTagsAs *string `json:"sendTagsAs,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Responders []OpsgenieIntegrationResponder `json:"responders,omitempty"`
}
// NewOpsgenieIntegration creates a new OpsgenieIntegration object.
func NewOpsgenieIntegration() *OpsgenieIntegration {
return &OpsgenieIntegration{}
}
// +k8s:openapi-gen=true
type OpsgenieIntegrationResponder struct {
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Username *string `json:"username,omitempty"`
Type string `json:"type"`
}
// NewOpsgenieIntegrationResponder creates a new OpsgenieIntegrationResponder object.
func NewOpsgenieIntegrationResponder() *OpsgenieIntegrationResponder {
return &OpsgenieIntegrationResponder{}
}
// +k8s:openapi-gen=true
type PagerdutyIntegration struct {
Uid *string `json:"uid,omitempty"`
IntegrationKey Secret `json:"integrationKey"`
Severity *string `json:"severity,omitempty"`
Class *string `json:"class,omitempty"`
Component *string `json:"component,omitempty"`
Group *string `json:"group,omitempty"`
Summary *string `json:"summary,omitempty"`
Source *string `json:"source,omitempty"`
Client *string `json:"client,omitempty"`
ClientUrl *string `json:"client_url,omitempty"`
Details map[string]string `json:"details,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Url *string `json:"url,omitempty"`
}
// NewPagerdutyIntegration creates a new PagerdutyIntegration object.
func NewPagerdutyIntegration() *PagerdutyIntegration {
return &PagerdutyIntegration{}
}
// +k8s:openapi-gen=true
type OnCallIntegration struct {
Uid *string `json:"uid,omitempty"`
Url string `json:"url"`
HttpMethod *string `json:"httpMethod,omitempty"`
MaxAlerts *int64 `json:"maxAlerts,omitempty"`
AuthorizationScheme *string `json:"authorization_scheme,omitempty"`
AuthorizationCredentials *Secret `json:"authorization_credentials,omitempty"`
Username *string `json:"username,omitempty"`
Password *Secret `json:"password,omitempty"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Message *string `json:"message,omitempty"`
}
// NewOnCallIntegration creates a new OnCallIntegration object.
func NewOnCallIntegration() *OnCallIntegration {
return &OnCallIntegration{}
}
// +k8s:openapi-gen=true
type PushoverIntegration struct {
Uid *string `json:"uid,omitempty"`
UserKey Secret `json:"userKey"`
ApiToken Secret `json:"apiToken"`
Priority *int64 `json:"priority,omitempty"`
OkPriority *int64 `json:"okPriority,omitempty"`
Retry *int64 `json:"retry,omitempty"`
Expire *int64 `json:"expire,omitempty"`
Device *string `json:"device,omitempty"`
Sound *string `json:"sound,omitempty"`
OkSound *string `json:"okSound,omitempty"`
Title *string `json:"title,omitempty"`
Message *string `json:"message,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
UploadImage *bool `json:"uploadImage,omitempty"`
}
// NewPushoverIntegration creates a new PushoverIntegration object.
func NewPushoverIntegration() *PushoverIntegration {
return &PushoverIntegration{}
}
// +k8s:openapi-gen=true
type SensugoIntegration struct {
Uid *string `json:"uid,omitempty"`
Url string `json:"url"`
Apikey Secret `json:"apikey"`
Entity *string `json:"entity,omitempty"`
Check *string `json:"check,omitempty"`
Namespace *string `json:"namespace,omitempty"`
Handler *string `json:"handler,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Message *string `json:"message,omitempty"`
}
// NewSensugoIntegration creates a new SensugoIntegration object.
func NewSensugoIntegration() *SensugoIntegration {
return &SensugoIntegration{}
}
// +k8s:openapi-gen=true
type SlackIntegration struct {
Uid *string `json:"uid,omitempty"`
EndpointUrl *string `json:"endpointUrl,omitempty"`
Url *Secret `json:"url,omitempty"`
Token *Secret `json:"token,omitempty"`
Recipient *string `json:"recipient,omitempty"`
Text *string `json:"text,omitempty"`
Title *string `json:"title,omitempty"`
Username *string `json:"username,omitempty"`
IconEmoji *string `json:"icon_emoji,omitempty"`
IconUrl *string `json:"icon_url,omitempty"`
MentionChannel *string `json:"mentionChannel,omitempty"`
MentionUsers *string `json:"mentionUsers,omitempty"`
MentionGroups *string `json:"mentionGroups,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Color *string `json:"color,omitempty"`
}
// NewSlackIntegration creates a new SlackIntegration object.
func NewSlackIntegration() *SlackIntegration {
return &SlackIntegration{}
}
// +k8s:openapi-gen=true
type SnsIntegration struct {
Uid *string `json:"uid,omitempty"`
ApiUrl *string `json:"api_url,omitempty"`
Sigv4 SigV4Config `json:"sigv4"`
TopicArn *string `json:"topic_arn,omitempty"`
PhoneNumber *string `json:"phone_number,omitempty"`
TargetArn *string `json:"target_arn,omitempty"`
Subject *string `json:"subject,omitempty"`
Message *string `json:"message,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
}
// NewSnsIntegration creates a new SnsIntegration object.
func NewSnsIntegration() *SnsIntegration {
return &SnsIntegration{
Sigv4: *NewSigV4Config(),
}
}
// +k8s:openapi-gen=true
type SigV4Config struct {
Region *string `json:"region,omitempty"`
AccessKey *Secret `json:"access_key,omitempty"`
SecretKey *Secret `json:"secret_key,omitempty"`
Profile *string `json:"profile,omitempty"`
RoleArn *string `json:"role_arn,omitempty"`
}
// NewSigV4Config creates a new SigV4Config object.
func NewSigV4Config() *SigV4Config {
return &SigV4Config{}
}
// +k8s:openapi-gen=true
type TeamsIntegration struct {
Uid *string `json:"uid,omitempty"`
Url Secret `json:"url"`
Message *string `json:"message,omitempty"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Sectiontitle *string `json:"sectiontitle,omitempty"`
}
// NewTeamsIntegration creates a new TeamsIntegration object.
func NewTeamsIntegration() *TeamsIntegration {
return &TeamsIntegration{}
}
// +k8s:openapi-gen=true
type TelegramIntegration struct {
Uid *string `json:"uid,omitempty"`
Bottoken Secret `json:"bottoken"`
Chatid string `json:"chatid"`
MessageThreadId string `json:"message_thread_id"`
Message *string `json:"message,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
DisableWebPagePreview *bool `json:"disable_web_page_preview,omitempty"`
ProtectContent *bool `json:"protect_content,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
DisableNotifications *bool `json:"disable_notifications,omitempty"`
}
// NewTelegramIntegration creates a new TelegramIntegration object.
func NewTelegramIntegration() *TelegramIntegration {
return &TelegramIntegration{}
}
// +k8s:openapi-gen=true
type ThreemaIntegration struct {
Uid *string `json:"uid,omitempty"`
GatewayId string `json:"gateway_id"`
RecipientId string `json:"recipient_id"`
ApiSecret Secret `json:"api_secret"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Description *string `json:"description,omitempty"`
}
// NewThreemaIntegration creates a new ThreemaIntegration object.
func NewThreemaIntegration() *ThreemaIntegration {
return &ThreemaIntegration{}
}
// +k8s:openapi-gen=true
type VictoropsIntegration struct {
Uid *string `json:"uid,omitempty"`
Url Secret `json:"url"`
MessageType *string `json:"messageType,omitempty"`
Title *string `json:"title,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Description *string `json:"description,omitempty"`
}
// NewVictoropsIntegration creates a new VictoropsIntegration object.
func NewVictoropsIntegration() *VictoropsIntegration {
return &VictoropsIntegration{}
}
// +k8s:openapi-gen=true
type WebhookIntegration struct {
Uid *string `json:"uid,omitempty"`
Url string `json:"url"`
HttpMethod *string `json:"httpMethod,omitempty"`
MaxAlerts *int64 `json:"maxAlerts,omitempty"`
AuthorizationScheme *string `json:"authorization_scheme,omitempty"`
AuthorizationCredentials *Secret `json:"authorization_credentials,omitempty"`
Username *string `json:"username,omitempty"`
Password *Secret `json:"password,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Title *string `json:"title,omitempty"`
Message *string `json:"message,omitempty"`
TlsConfig *TLSConfig `json:"tlsConfig,omitempty"`
HmacConfig *HMACConfig `json:"hmacConfig,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Payload *CustomPayload `json:"payload,omitempty"`
}
// NewWebhookIntegration creates a new WebhookIntegration object.
func NewWebhookIntegration() *WebhookIntegration {
return &WebhookIntegration{}
}
// +k8s:openapi-gen=true
type HMACConfig struct {
Secret *Secret `json:"secret,omitempty"`
Header string `json:"header"`
TimestampHeader string `json:"timestampHeader"`
}
// NewHMACConfig creates a new HMACConfig object.
func NewHMACConfig() *HMACConfig {
return &HMACConfig{}
}
// +k8s:openapi-gen=true
type CustomPayload struct {
Template *string `json:"template,omitempty"`
Vars map[string]string `json:"vars,omitempty"`
}
// NewCustomPayload creates a new CustomPayload object.
func NewCustomPayload() *CustomPayload {
return &CustomPayload{}
}
// +k8s:openapi-gen=true
type WecomIntegration struct {
Uid *string `json:"uid,omitempty"`
EndpointUrl *string `json:"endpointUrl,omitempty"`
Url *Secret `json:"url,omitempty"`
Secret *Secret `json:"secret,omitempty"`
AgentId *string `json:"agent_id,omitempty"`
CorpId *string `json:"corp_id,omitempty"`
Message *string `json:"message,omitempty"`
Title *string `json:"title,omitempty"`
Msgtype *string `json:"msgtype,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
Touser *string `json:"touser,omitempty"`
}
// NewWecomIntegration creates a new WecomIntegration object.
func NewWecomIntegration() *WecomIntegration {
return &WecomIntegration{}
}
// +k8s:openapi-gen=true
type WebexIntegration struct {
Uid *string `json:"uid,omitempty"`
BotToken Secret `json:"bot_token"`
ApiUrl *string `json:"api_url,omitempty"`
Message *string `json:"message,omitempty"`
DisableResolveMessage *bool `json:"disable_resolve_message,omitempty"`
RoomId *string `json:"room_id,omitempty"`
}
// NewWebexIntegration creates a new WebexIntegration object.
func NewWebexIntegration() *WebexIntegration {
return &WebexIntegration{}
}
// +k8s:openapi-gen=true
type Spec struct {
Title string `json:"title"`
Alertmanager []AlertmanagerIntegration `json:"alertmanager,omitempty"`
Dingding []DingdingIntegration `json:"dingding,omitempty"`
Discord []DiscordIntegration `json:"discord,omitempty"`
Email []EmailIntegration `json:"email,omitempty"`
Googlechat []GooglechatIntegration `json:"googlechat,omitempty"`
Jira []JiraIntegration `json:"jira,omitempty"`
Kafka []KafkaIntegration `json:"kafka,omitempty"`
Line []LineIntegration `json:"line,omitempty"`
Mqtt []MqttIntegration `json:"mqtt,omitempty"`
Opsgenie []OpsgenieIntegration `json:"opsgenie,omitempty"`
Pagerduty []PagerdutyIntegration `json:"pagerduty,omitempty"`
Oncall []OnCallIntegration `json:"oncall,omitempty"`
Pushover []PushoverIntegration `json:"pushover,omitempty"`
Sensugo []SensugoIntegration `json:"sensugo,omitempty"`
Slack []SlackIntegration `json:"slack,omitempty"`
Sns []SnsIntegration `json:"sns,omitempty"`
Teams []TeamsIntegration `json:"teams,omitempty"`
Telegram []TelegramIntegration `json:"telegram,omitempty"`
Threema []ThreemaIntegration `json:"threema,omitempty"`
Victorops []VictoropsIntegration `json:"victorops,omitempty"`
Webhook []WebhookIntegration `json:"webhook,omitempty"`
Wecom []WecomIntegration `json:"wecom,omitempty"`
Webex []WebexIntegration `json:"webex,omitempty"`
}
// NewSpec creates a new Spec object.
func NewSpec() *Spec {
return &Spec{}
}
@@ -0,0 +1,44 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha2
// +k8s:openapi-gen=true
type StatusOperatorState struct {
// lastEvaluation is the ResourceVersion last evaluated
LastEvaluation string `json:"lastEvaluation"`
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State StatusOperatorStateState `json:"state"`
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
// details contains any extra information that is operator-specific
Details map[string]interface{} `json:"details,omitempty"`
}
// NewStatusOperatorState creates a new StatusOperatorState object.
func NewStatusOperatorState() *StatusOperatorState {
return &StatusOperatorState{}
}
// +k8s:openapi-gen=true
type Status struct {
// operatorStates is a map of operator ID to operator state evaluations.
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
OperatorStates map[string]StatusOperatorState `json:"operatorStates,omitempty"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}
// NewStatus creates a new Status object.
func NewStatus() *Status {
return &Status{}
}
// +k8s:openapi-gen=true
type StatusOperatorStateState string
const (
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
)
+9 -3
View File
@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
receiverv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
receiverv0alpha2 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha2"
routingtreev0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
templategroupv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
timeintervalv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
@@ -17,12 +18,14 @@ import (
func GetOpenAPIDefinitions(c common.ReferenceCallback) map[string]common.OpenAPIDefinition {
tmpl := templategroupv0alpha1.GetOpenAPIDefinitions(c)
tin := timeintervalv0alpha1.GetOpenAPIDefinitions(c)
recv := receiverv0alpha1.GetOpenAPIDefinitions(c)
recv1 := receiverv0alpha1.GetOpenAPIDefinitions(c)
recv2 := receiverv0alpha2.GetOpenAPIDefinitions(c)
rest := routingtreev0alpha1.GetOpenAPIDefinitions(c)
result := make(map[string]common.OpenAPIDefinition, len(tmpl)+len(tin)+len(recv)+len(rest))
result := make(map[string]common.OpenAPIDefinition, len(tmpl)+len(tin)+len(recv1)+len(rest)+len(recv2))
maps.Copy(result, tmpl)
maps.Copy(result, tin)
maps.Copy(result, recv)
maps.Copy(result, recv1)
maps.Copy(result, recv2)
maps.Copy(result, rest)
return result
}
@@ -35,6 +38,9 @@ func GetKinds() map[schema.GroupVersion][]sdkResource.Kind {
templategroupv0alpha1.Kind(),
timeintervalv0alpha1.Kind(),
},
receiverv0alpha2.GroupVersion: {
receiverv0alpha2.Kind(),
},
}
return result
}