Skip to content

Commit

Permalink
Update for alert center GA.
Browse files Browse the repository at this point in the history
- Use alerting/v1 in REST calls.
- Update changelog and client version.
- Minor fix to example to create secondary zone correctly.
  • Loading branch information
hhellyer committed Dec 5, 2024
1 parent c522965 commit 0db7a6c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 2.13.0 (Oct 28th, 2024)
## 2.13.0 (Dec 5th, 2024)

FEATURES:

Expand Down
2 changes: 1 addition & 1 deletion mockns1/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type mockAlertListResponse struct {
TotalResults *int64 `json:"total_results,omitempty"`
}

const alertPath = "../alerting/v1beta1/alerts"
const alertPath = "../alerting/v1/alerts"

// AddAlertListTestCase sets up a test case for the api.Client.Alert.List()
// function
Expand Down
10 changes: 7 additions & 3 deletions rest/_examples/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func init() {

func prettyPrint(header string, v interface{}) {
fmt.Println(header)
fmt.Printf("%#v \n", v)
b, _ := json.MarshalIndent(v, "", " ")
fmt.Println(string(b))
}
Expand Down Expand Up @@ -66,6 +65,11 @@ func main() {

z := dns.NewZone(domain)
z.NxTTL = 3600
z.Secondary = &dns.ZoneSecondary{
Enabled: true,
PrimaryIP: "127.0.0.1",
PrimaryPort: 67,
}
_, err = client.Zones.Create(z)
if err != nil {
// Ignore if zone already exists
Expand All @@ -75,10 +79,10 @@ func main() {
log.Println("Zone already exists, continuing...")
}
}

prettyPrint("Zone:", z)
fmt.Printf("Creating alert...\n")

alert := alerting.NewZoneAlert("myalerttest.com - transfer failed", "transfer_failed", []string{webhookList.ID}, []string{domain})
prettyPrint("Creating alert: ", alert)
_, err = client.Alerts.Create(alert)
if err != nil {
if err == api.ErrAlertExists {
Expand Down
2 changes: 1 addition & 1 deletion rest/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AlertsService service

// The base for the alerting api relative to /v1
// client.NewRequest will call ResolveReference and remove /v1/../
const alertingRelativeBase = "../alerting/v1beta1"
const alertingRelativeBase = "../alerting/v1"

type alertListResponse struct {
Limit *int64 `json:"limit,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion rest/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAlert(t *testing.T) {
defer mock.ClearTestCases()

linkHeader := http.Header{}
linkHeader.Set("Link", `</alerting/v1beta1/alerts?next=`+*alertList[1].Name+`>; rel="next"`)
linkHeader.Set("Link", `</alerting/v1/alerts?next=`+*alertList[1].Name+`>; rel="next"`)
require.Nil(t, mock.AddAlertListTestCase("", nil, linkHeader, alertList[0:1]))
require.Nil(t, mock.AddAlertListTestCase("next="+*alertList[1].Name, nil, nil, alertList[2:3]))

Expand Down
4 changes: 2 additions & 2 deletions rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
)

const (
clientVersion = "2.12.2"
clientVersion = "2.13.0"

defaultBase = "http://localhost:80"
defaultBase = "https://api.nsone.net"
defaultEndpoint = defaultBase + "/v1/"
defaultShouldFollowPagination = true
defaultUserAgent = "go-ns1/" + clientVersion
Expand Down

0 comments on commit 0db7a6c

Please sign in to comment.