alert.go raw

   1  package alerting
   2  
   3  import "encoding/json"
   4  
   5  type Alert struct {
   6  	ID              *string         `json:"id,omitempty"`
   7  	CreatedAt       *int64          `json:"created_at,omitempty"`
   8  	CreatedBy       *string         `json:"created_by,omitempty"`
   9  	Data            json.RawMessage `json:"data,omitempty"`
  10  	Name            *string         `json:"name,omitempty"`
  11  	NotifierListIds []string        `json:"notifier_list_ids"`
  12  	RecordIds       []string        `json:"record_ids"`
  13  	Subtype         *string         `json:"subtype,omitempty"`
  14  	Type            *string         `json:"type,omitempty"`
  15  	UpdatedAt       *int64          `json:"updated_at,omitempty"`
  16  	UpdatedBy       *string         `json:"updated_by,omitempty"`
  17  	ZoneNames       []string        `json:"zone_names"`
  18  }
  19  
  20  var (
  21  	zoneAlertType     string = "zone"
  22  	recordAlertType   string = "record"
  23  	ssoAlertType      string = "account"
  24  	redirectAlertType string = "redirects"
  25  )
  26  
  27  var (
  28  	ssoAlertSubtype      string = "saml_certificate_expired"
  29  	redirectAlertSubtype string = "certificate_renewal_failed"
  30  )
  31  
  32  func NewZoneAlert(alertName string, subtype string, notifierListIds []string, zoneNames []string) *Alert {
  33  	return &Alert{
  34  		Name:            &alertName,
  35  		Type:            &zoneAlertType,
  36  		Subtype:         &subtype,
  37  		Data:            nil,
  38  		NotifierListIds: notifierListIds,
  39  		ZoneNames:       zoneNames,
  40  	}
  41  }
  42  
  43  func NewRecordAlert(notifierListIds []string, recordIds []string, subtype string) *Alert {
  44  	return &Alert{
  45  		Type:            &recordAlertType,
  46  		Subtype:         &subtype,
  47  		Data:            nil,
  48  		NotifierListIds: notifierListIds,
  49  		RecordIds:       recordIds,
  50  	}
  51  }
  52  
  53  func NewSSOAlert(alertName string, notifierListIds []string) *Alert {
  54  	return &Alert{
  55  		Name:            &alertName,
  56  		Type:            &ssoAlertType,
  57  		Subtype:         &ssoAlertSubtype,
  58  		Data:            nil,
  59  		NotifierListIds: notifierListIds,
  60  	}
  61  }
  62  
  63  func NewRedirectAlert(alertName string, notifierListIds []string) *Alert {
  64  	return &Alert{
  65  		Name:            &alertName,
  66  		Type:            &redirectAlertType,
  67  		Subtype:         &redirectAlertSubtype,
  68  		Data:            nil,
  69  		NotifierListIds: notifierListIds,
  70  	}
  71  }
  72