File size: 699 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package integrationkey

import (
	"github.com/target/goalert/validation/validate"
)

type IntegrationKey struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Type      Type   `json:"type"`
	ServiceID string `json:"service_id"`

	ExternalSystemName string
}

func (i IntegrationKey) Normalize() (*IntegrationKey, error) {
	err := validate.Many(
		validate.IDName("Name", i.Name),
		validate.UUID("ServiceID", i.ServiceID),
		validate.OneOf("Type", i.Type, TypeGrafana, TypeSite24x7, TypePrometheusAlertmanager, TypeGeneric, TypeEmail, TypeUniversal),
		validate.ASCII("ExternalSystemName", i.ExternalSystemName, 0, 255),
	)
	if err != nil {
		return nil, err
	}

	return &i, nil
}