Skip to content

Commit c3de9a1

Browse files
committed
DI-27070 renamed files and corrected format
1 parent bc5bc7e commit c3de9a1

File tree

4 files changed

+79
-102
lines changed

4 files changed

+79
-102
lines changed

alert_channels.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package linodego
2+
3+
import (
4+
"context"
5+
)
6+
7+
// AlertChannelEnvelope represents a single alert channel entry returned inside alert definition
8+
type AlertChannelEnvelope struct {
9+
ID int `json:"id"`
10+
Label string `json:"label"`
11+
Type string `json:"type"`
12+
URL string `json:"url"`
13+
}
14+
15+
// AlertChannel represents a Monitor Channel object.
16+
type AlertChannel struct {
17+
ID int `json:"id"`
18+
Alerts []AlertChannelEnvelope `json:"alerts"`
19+
Label string `json:"label"`
20+
Channel_type string `json:"channel_type"`
21+
Content ChannelContent `json:"content"`
22+
Type AlertType `json:"type"`
23+
Details AlertChannelDetail `json:"details"`
24+
Created string `json:"created"`
25+
Created_by string `json:"created_by"`
26+
Updated string `json:"updated"`
27+
Updated_by string `json:"updated_by"`
28+
}
29+
30+
// AlertChannelDetail represents the details of a Monitor Channel.
31+
type AlertChannelDetail struct {
32+
To string `json:"to,omitempty"`
33+
From string `json:"from,omitempty"`
34+
User string `json:"user,omitempty"`
35+
Token string `json:"token,omitempty"`
36+
URL string `json:"url,omitempty"`
37+
}
38+
39+
// AlertChannelCreateOptions are the options used to create a new Monitor Channel.
40+
type AlertChannelCreateOptions struct {
41+
Label string `json:"label"`
42+
Type string `json:"type"`
43+
Details AlertChannelDetailOptions `json:"details"`
44+
}
45+
46+
// AlertChannelDetailOptions are the options used to create the details of a new Monitor Channel.
47+
type AlertChannelDetailOptions struct {
48+
To string `json:"to,omitempty"`
49+
}
50+
51+
// Backwards-compat alias for older name
52+
type AlertingChannelCreateOptions = AlertChannelCreateOptions
53+
54+
type EmailChannelContent struct {
55+
EmailAddresses []string `json:"email_addresses"`
56+
}
57+
58+
// ChannelContent represents the content block for an AlertChannel, which varies by channel type.
59+
type ChannelContent struct {
60+
Email *EmailChannelContent `json:"email,omitempty"`
61+
// Other channel types like 'webhook', 'slack' could be added here as optional fields.
62+
}
63+
64+
// ListMonitorChannels gets a paginated list of Monitor Channels.
65+
func (c *Client) ListAlertChannels(ctx context.Context, opts *ListOptions) ([]AlertChannel, error) {
66+
endpoint := formatAPIV4BetaPath("monitor/channels")
67+
return getPaginatedResults[AlertChannel](ctx, c, endpoint, opts)
68+
}
69+
70+
// GetMonitorChannel gets a Monitor Channel by ID.
71+
func (c *Client) GetAlertChannel(ctx context.Context, channelID int) (*AlertChannel, error) {
72+
e := formatAPIV4BetaPath("monitor/channels/%d", channelID)
73+
return doGETRequest[AlertChannel](ctx, c, e)
74+
}
75+
76+
func (c *Client) GetAlertChannels(ctx context.Context) (*AlertChannel, error) {
77+
e := formatAPIV4BetaPath("monitor/alert-channels/")
78+
return doGETRequest[AlertChannel](ctx, c, e)
79+
}

monitor_alert_definitions.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ type DimensionFilter struct {
6565
Value interface{} `json:"value"`
6666
}
6767

68-
// AlertChannelEnvelope represents a single alert channel entry returned inside alert definition
69-
type AlertChannelEnvelope struct {
70-
ID int `json:"id"`
71-
Label string `json:"label"`
72-
Type string `json:"type"`
73-
URL string `json:"url"`
74-
}
75-
7668
// AlertType represents the type of alert: "user" or "system"
7769
type AlertType string
7870

monitor_channels.go

Lines changed: 0 additions & 91 deletions
This file was deleted.

test/integration/monitor_alert_definitions_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) {
7070
createOpts := linodego.AlertDefinitionCreateOptions{
7171
Label: "go-test-alert-definition-create",
7272
Severity: int(linodego.SeverityLow),
73-
Type: string(linodego.AlertTypeUser),
74-
Class: "test_class",
7573
Description: "Test alert definition creation",
7674
ChannelIDs: []int{channelID},
7775
EntityIDs: nil,
@@ -114,7 +112,6 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) {
114112
assert.NotNil(t, createdAlert)
115113
assert.Equal(t, createOpts.Label, createdAlert.Label)
116114
assert.Equal(t, createOpts.Severity, createdAlert.Severity)
117-
assert.Equal(t, createOpts.Type, createdAlert.Type)
118115
assert.Equal(t, createOpts.Description, createdAlert.Description)
119116
assert.ElementsMatch(t, createOpts.EntityIDs, createdAlert.EntityIDs)
120117
// assert.Equal(t, fetchedChannel.Label, createdAlert.AlertChannels[0].Label)

0 commit comments

Comments
 (0)