Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions alert_channels.go

This file was deleted.

76 changes: 76 additions & 0 deletions monitor_alert_channels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package linodego

// @TODO: disable alert channel for now because API made breaking changes.
// type AlertNotificationType string
//
// const (
// EmailAlertNotification AlertNotificationType = "email"
//)
//
// type AlertChannelType string
//
// const (
// SystemAlertChannel AlertChannelType = "system"
// UserAlertChannel AlertChannelType = "user"
//)
//
//// AlertChannelEnvelope represents a single alert channel entry returned inside alert definition
// type AlertChannelEnvelope struct {
// ID int `json:"id"`
// Label string `json:"label"`
// Type string `json:"type"`
// URL string `json:"url"`
//}
//
//// AlertChannel represents a Monitor Channel object.
// type AlertChannel struct {
// Alerts []AlertChannelEnvelope `json:"alerts"`
// ChannelType AlertNotificationType `json:"channel_type"`
// Content ChannelContent `json:"content"`
// Created *time.Time `json:"-"`
// CreatedBy string `json:"created_by"`
// Updated *time.Time `json:"-"`
// UpdatedBy string `json:"updated_by"`
// ID int `json:"id"`
// Label string `json:"label"`
// Type AlertChannelType `json:"type"`
// }
//
// type EmailChannelContent struct {
// EmailAddresses []string `json:"email_addresses"`
// }
//
//// ChannelContent represents the content block for an AlertChannel, which varies by channel type.
// type ChannelContent struct {
// Email *EmailChannelContent `json:"email"`
// // Other channel types like 'webhook', 'slack' could be added here as optional fields.
// }
//
//// UnmarshalJSON implements the json.Unmarshaler interface
// func (a *AlertChannel) UnmarshalJSON(b []byte) error {
// type Mask AlertChannel
//
// p := struct {
// *Mask
//
// Updated *parseabletime.ParseableTime `json:"updated"`
// Created *parseabletime.ParseableTime `json:"created"`
// }{
// Mask: (*Mask)(a),
// }
//
// if err := json.Unmarshal(b, &p); err != nil {
// return err
// }
//
// a.Updated = (*time.Time)(p.Updated)
// a.Created = (*time.Time)(p.Created)
//
// return nil
// }

//// ListAlertChannels gets a paginated list of Alert Channels.
// func (c *Client) ListAlertChannels(ctx context.Context, opts *ListOptions) ([]AlertChannel, error) {
// endpoint := formatAPIPath("monitor/alert-channels")
// return getPaginatedResults[AlertChannel](ctx, c, endpoint, opts)
// }
36 changes: 27 additions & 9 deletions monitor_alert_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@ import (
"github.com/linode/linodego/internal/parseabletime"
)

type AlertDefinitionStatus string

const (
AlertDefinitionStatusEnabled AlertDefinitionStatus = "enabled"
AlertDefinitionStatusDisabled AlertDefinitionStatus = "disabled"
AlertDefinitionStatusInProgress AlertDefinitionStatus = "in_progress"
AlertDefinitionStatusFailed AlertDefinitionStatus = "failed"
)

// AlertDefinition represents an ACLP Alert Definition object
type AlertDefinition struct {
ID int `json:"id"`
Label string `json:"label"`
Severity int `json:"severity"`
Type string `json:"type"`
ServiceType string `json:"service_type"`
Status string `json:"status"`
Status AlertDefinitionStatus `json:"status"`
HasMoreResources bool `json:"has_more_resources"`
RuleCriteria RuleCriteria `json:"rule_criteria"`
TriggerConditions TriggerConditions `json:"trigger_conditions"`
Expand All @@ -24,7 +33,7 @@ type AlertDefinition struct {
Updated *time.Time `json:"-"`
UpdatedBy string `json:"updated_by"`
CreatedBy string `json:"created_by"`
EntityIDs []any `json:"entity_ids"`
EntityIDs []string `json:"entity_ids"`
Description string `json:"description"`
Class string `json:"class"`
}
Expand Down Expand Up @@ -89,6 +98,14 @@ type DimensionFilterOptions struct {
Value string `json:"value,omitempty"`
}

// AlertChannelEnvelope represents a single alert channel entry returned inside alert definition
type AlertChannelEnvelope struct {
ID int `json:"id"`
Label string `json:"label"`
Type string `json:"type"`
URL string `json:"url"`
}

// AlertType represents the type of alert: "user" or "system"
type AlertType string

Expand Down Expand Up @@ -128,13 +145,14 @@ type AlertDefinitionCreateOptions struct {

// AlertDefinitionUpdateOptions are the options used to update an alert definition.
type AlertDefinitionUpdateOptions struct {
Label string `json:"label"`
Severity int `json:"severity"`
ChannelIDs []int `json:"channel_ids"`
RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"`
TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"`
EntityIDs []string `json:"entity_ids,omitempty"`
Description *string `json:"description,omitempty"`
Label string `json:"label"`
Severity int `json:"severity"`
ChannelIDs []int `json:"channel_ids"`
RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"`
TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"`
EntityIDs []string `json:"entity_ids,omitempty"`
Description *string `json:"description,omitempty"`
Status *AlertDefinitionStatus `json:"status,omitempty"`
}

// UnmarshalJSON implements the json.Unmarshaler interface
Expand Down
113 changes: 0 additions & 113 deletions test/integration/fixtures/TestMonitorAlertChannels_List.yaml

This file was deleted.

Loading