diff --git a/CHANGELOG.md b/CHANGELOG.md index 8560e1c..1a7557e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.12.2 (October 17th, 2024) + +BUG FIXES: + +* Allowing to wipe the record regions + ## 2.12.1 (Sep 23rd, 2024) BUG FIXES: diff --git a/rest/client.go b/rest/client.go index c583710..2ff6730 100644 --- a/rest/client.go +++ b/rest/client.go @@ -13,7 +13,7 @@ import ( ) const ( - clientVersion = "2.12.1" + clientVersion = "2.12.2" defaultEndpoint = "https://api.nsone.net/v1/" defaultShouldFollowPagination = true diff --git a/rest/model/dns/record.go b/rest/model/dns/record.go index 99fe1a1..4fcc744 100644 --- a/rest/model/dns/record.go +++ b/rest/model/dns/record.go @@ -28,7 +28,7 @@ type Record struct { // The records' filter chain. Filters []*filter.Filter `json:"filters"` // The records' regions. - Regions data.Regions `json:"regions,omitempty"` + Regions data.Regions `json:"regions"` // Contains the key/value tag information associated to the record Tags map[string]string `json:"tags,omitempty"` // Only relevant for DDI diff --git a/rest/model/dns/record_test.go b/rest/model/dns/record_test.go index ea68474..e95acfd 100644 --- a/rest/model/dns/record_test.go +++ b/rest/model/dns/record_test.go @@ -18,7 +18,13 @@ var marshalRecordCases = []struct { "marshalCAARecord", NewRecord("example.com", "caa.example.com", "CAA", nil, nil), []*Answer{NewCAAAnswer(0, "issue", "letsencrypt.org")}, - []byte(`{"meta":{},"zone":"example.com","domain":"caa.example.com","type":"CAA","answers":[{"meta":{},"answer":["0","issue","letsencrypt.org"]}],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"caa.example.com","type":"CAA","answers":[{"meta":{},"answer":["0","issue","letsencrypt.org"]}],"filters":[],"regions":{}}`), + }, + { + "marshalCAARecord manual", + &Record{Zone: "example.com", Domain: "caa.example.com", Type: "CAA"}, + []*Answer{NewCAAAnswer(0, "issue", "letsencrypt.org")}, + []byte(`{"zone":"example.com","domain":"caa.example.com","type":"CAA","answers":[{"meta":{},"answer":["0","issue","letsencrypt.org"]}],"filters":null,"regions":null}`), }, { "marshalURLFWDRecord", @@ -27,7 +33,7 @@ var marshalRecordCases = []struct { NewURLFWDAnswer("/net", "https://example.net", 301, 1, 1), NewURLFWDAnswer("/org", "https://example.org", 302, 2, 0), }, - []byte(`{"answers":[{"answer":["/net","https://example.net",301,1,1],"meta":{}},{"answer":["/org","https://example.org",302,2,0],"meta":{}}],"meta":{},"zone":"example.com","domain":"fwd.example.com","type":"URLFWD","filters":[]}`), + []byte(`{"answers":[{"answer":["/net","https://example.net",301,1,1],"meta":{}},{"answer":["/org","https://example.org",302,2,0],"meta":{}}],"meta":{},"zone":"example.com","domain":"fwd.example.com","type":"URLFWD","filters":[],"regions":{}}`), }, } @@ -60,19 +66,19 @@ func TestMarshalRecordsOverrideTTL(t *testing.T) { "marshalOverrideTTLNil", NewRecord("example.com", "example.com", "ALIAS", make(map[string]string), []string{}), nil, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[],"regions":{}}`), }, { "marshalOverrideTTLTrue", NewRecord("example.com", "example.com", "ALIAS", nil, nil), &trueb, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"answers":[],"filters":[],"regions":{}}`), }, { "marshalOverrideTTLFalse", NewRecord("example.com", "example.com", "ALIAS", nil, nil), &falseb, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"answers":[],"filters":[],"regions":{}}`), }, } for _, tt := range marshalALIASRecordCases { @@ -104,21 +110,21 @@ func TestMarshalRecordsOverrideAddressRecords(t *testing.T) { NewRecord("example.com", "example.com", "ALIAS", nil, nil), nil, nil, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[],"regions":{}}`), }, { "marshalOverrideAddressRecordsTrue", NewRecord("example.com", "example.com", "ALIAS", nil, nil), &trueb, &trueb, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"override_address_records":true,"answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"override_address_records":true,"answers":[],"filters":[],"regions":{}}`), }, { "marshalOverrideAddressRecordsFalse", NewRecord("example.com", "example.com", "ALIAS", nil, nil), &falseb, &falseb, - []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"override_address_records":false,"answers":[],"filters":[]}`), + []byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"override_address_records":false,"answers":[],"filters":[],"regions":{}}`), }, } for _, tt := range marshalALIASRecordCases { diff --git a/rest/record.go b/rest/record.go index 4aed429..364f078 100644 --- a/rest/record.go +++ b/rest/record.go @@ -25,9 +25,9 @@ func (s *RecordsService) Get(zone, domain, t string) (*dns.Record, *http.Respons var r dns.Record resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - if err.(*Error).Message == "record not found" { + if err.Message == "record not found" { return nil, resp, ErrRecordMissing } } @@ -52,9 +52,9 @@ func (s *RecordsService) Create(r *dns.Record) (*http.Response, error) { // Update record fields with data from api(ensure consistent) resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - switch err.(*Error).Message { + switch err.Message { case "zone not found": return resp, ErrZoneMissing case "record already exists": @@ -82,9 +82,9 @@ func (s *RecordsService) Update(r *dns.Record) (*http.Response, error) { // Update records fields with data from api(ensure consistent) resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - switch err.(*Error).Message { + switch err.Message { case "zone not found": return resp, ErrZoneMissing case "record not found": @@ -112,9 +112,9 @@ func (s *RecordsService) Delete(zone string, domain string, t string) (*http.Res resp, err := s.client.Do(req, nil) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - if err.(*Error).Message == "record not found" { + if err.Message == "record not found" { return resp, ErrRecordMissing } }