From 0f6b3bb828427a2c6a22b3b9217fc87627fba3ef Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Thu, 31 Oct 2024 16:41:32 -0400 Subject: [PATCH 1/2] Support `created` and `updated` for domain records --- domain_records.go | 58 ++++++++++-------- test/integration/domain_records_test.go | 6 ++ .../fixtures/TestDomainRecord_Create.yaml | 46 ++++++--------- .../fixtures/TestDomainRecord_Get.yaml | 59 +++++++------------ .../fixtures/TestDomainRecord_Update.yaml | 59 +++++++------------ .../fixtures/TestDomainRecords_List.yaml | 59 +++++++------------ .../TestDomainRecords_ListMultiplePages.yaml | 59 +++++++------------ test/unit/base.go | 5 +- 8 files changed, 146 insertions(+), 205 deletions(-) diff --git a/domain_records.go b/domain_records.go index 11e246d22..cfb209335 100644 --- a/domain_records.go +++ b/domain_records.go @@ -2,6 +2,10 @@ package linodego import ( "context" + "encoding/json" + "time" + + "github.com/linode/linodego/internal/parseabletime" ) // DomainRecord represents a DomainRecord object @@ -17,6 +21,8 @@ type DomainRecord struct { Protocol *string `json:"protocol"` TTLSec int `json:"ttl_sec"` Tag *string `json:"tag"` + Created *time.Time `json:"-"` + Updated *time.Time `json:"-"` } // DomainRecordCreateOptions fields are those accepted by CreateDomainRecord @@ -63,6 +69,27 @@ const ( RecordTypeCAA DomainRecordType = "CAA" ) +// UnmarshalJSON for DomainRecord responses +func (dr *DomainRecord) UnmarshalJSON(b []byte) error { + type Mask DomainRecord + + p := struct { + *Mask + Created *parseabletime.ParseableTime `json:"created"` + Updated *parseabletime.ParseableTime `json:"updated"` + }{ + Mask: (*Mask)(dr), + } + + if err := json.Unmarshal(b, &p); err != nil { + return err + } + + dr.Created = (*time.Time)(p.Created) + dr.Updated = (*time.Time)(p.Updated) + return nil +} + // GetUpdateOptions converts a DomainRecord to DomainRecordUpdateOptions for use in UpdateDomainRecord func (d DomainRecord) GetUpdateOptions() (du DomainRecordUpdateOptions) { du.Type = d.Type @@ -81,50 +108,29 @@ func (d DomainRecord) GetUpdateOptions() (du DomainRecordUpdateOptions) { // ListDomainRecords lists DomainRecords func (c *Client) ListDomainRecords(ctx context.Context, domainID int, opts *ListOptions) ([]DomainRecord, error) { - response, err := getPaginatedResults[DomainRecord](ctx, c, formatAPIPath("domains/%d/records", domainID), opts) - if err != nil { - return nil, err - } - - return response, nil + return getPaginatedResults[DomainRecord](ctx, c, formatAPIPath("domains/%d/records", domainID), opts) } // GetDomainRecord gets the domainrecord with the provided ID func (c *Client) GetDomainRecord(ctx context.Context, domainID int, recordID int) (*DomainRecord, error) { e := formatAPIPath("domains/%d/records/%d", domainID, recordID) - response, err := doGETRequest[DomainRecord](ctx, c, e) - if err != nil { - return nil, err - } - - return response, nil + return doGETRequest[DomainRecord](ctx, c, e) } // CreateDomainRecord creates a DomainRecord func (c *Client) CreateDomainRecord(ctx context.Context, domainID int, opts DomainRecordCreateOptions) (*DomainRecord, error) { e := formatAPIPath("domains/%d/records", domainID) - response, err := doPOSTRequest[DomainRecord](ctx, c, e, opts) - if err != nil { - return nil, err - } - - return response, nil + return doPOSTRequest[DomainRecord](ctx, c, e, opts) } // UpdateDomainRecord updates the DomainRecord with the specified id func (c *Client) UpdateDomainRecord(ctx context.Context, domainID int, recordID int, opts DomainRecordUpdateOptions) (*DomainRecord, error) { e := formatAPIPath("domains/%d/records/%d", domainID, recordID) - response, err := doPUTRequest[DomainRecord](ctx, c, e, opts) - if err != nil { - return nil, err - } - - return response, nil + return doPUTRequest[DomainRecord](ctx, c, e, opts) } // DeleteDomainRecord deletes the DomainRecord with the specified id func (c *Client) DeleteDomainRecord(ctx context.Context, domainID int, recordID int) error { e := formatAPIPath("domains/%d/records/%d", domainID, recordID) - err := doDELETERequest(ctx, c, e) - return err + return doDELETERequest(ctx, c, e) } diff --git a/test/integration/domain_records_test.go b/test/integration/domain_records_test.go index 5ae1eabaa..6e9bb2d8e 100644 --- a/test/integration/domain_records_test.go +++ b/test/integration/domain_records_test.go @@ -22,6 +22,9 @@ func TestDomainRecord_Create_smoke(t *testing.T) { t.Errorf("Error creating domain record, got error %v", err) } + assertDateSet(t, record.Created) + assertDateSet(t, record.Updated) + expected := testDomainRecordCreateOpts // cant compare Target, fixture IPs are sanitized @@ -37,6 +40,9 @@ func TestDomainRecord_Update(t *testing.T) { t.Error(err) } + assertDateSet(t, record.Created) + assertDateSet(t, record.Updated) + updateOpts := linodego.DomainRecordUpdateOptions{ Name: "renamed", } diff --git a/test/integration/fixtures/TestDomainRecord_Create.yaml b/test/integration/fixtures/TestDomainRecord_Create.yaml index 7c42607f6..99eba8817 100644 --- a/test/integration/fixtures/TestDomainRecord_Create.yaml +++ b/test/integration/fixtures/TestDomainRecord_Create.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3041953, "type": "master", "domain": "linodego-blue-test.com", "tags": + body: '{"id": 3153528, "type": "master", "domain": "linodego-blue-test.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:22 GMT + - Thu, 31 Oct 2024 20:38:28 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,12 +58,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041953/records + url: https://api.linode.com/v4beta/domains/3153528/records method: POST response: - body: '{"id": 35694150, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666864, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -109,7 +106,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:22 GMT + - Thu, 31 Oct 2024 20:38:28 GMT Pragma: - no-cache Strict-Transport-Security: @@ -124,12 +121,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -145,7 +139,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041953/records/35694150 + url: https://api.linode.com/v4beta/domains/3153528/records/36666864 method: DELETE response: body: '{}' @@ -173,7 +167,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:22 GMT + - Thu, 31 Oct 2024 20:38:29 GMT Pragma: - no-cache Strict-Transport-Security: @@ -188,12 +182,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -209,7 +200,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041953 + url: https://api.linode.com/v4beta/domains/3153528 method: DELETE response: body: '{}' @@ -237,7 +228,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:22 GMT + - Thu, 31 Oct 2024 20:38:29 GMT Pragma: - no-cache Strict-Transport-Security: @@ -252,12 +243,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestDomainRecord_Get.yaml b/test/integration/fixtures/TestDomainRecord_Get.yaml index f88f57b22..8fd129dc3 100644 --- a/test/integration/fixtures/TestDomainRecord_Get.yaml +++ b/test/integration/fixtures/TestDomainRecord_Get.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3041957, "type": "master", "domain": "linodego-blue-test.com", "tags": + body: '{"id": 3153532, "type": "master", "domain": "linodego-blue-test.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:30 GMT + - Thu, 31 Oct 2024 20:38:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,12 +58,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041957/records + url: https://api.linode.com/v4beta/domains/3153532/records method: POST response: - body: '{"id": 35694155, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666868, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -109,7 +106,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:30 GMT + - Thu, 31 Oct 2024 20:38:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -124,12 +121,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -145,10 +139,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041957/records/35694155 + url: https://api.linode.com/v4beta/domains/3153532/records/36666868 method: GET response: - body: '{"id": 35694155, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666868, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -175,7 +169,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:30 GMT + - Thu, 31 Oct 2024 20:38:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -191,12 +185,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -212,7 +203,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041957/records/35694155 + url: https://api.linode.com/v4beta/domains/3153532/records/36666868 method: DELETE response: body: '{}' @@ -240,7 +231,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:30 GMT + - Thu, 31 Oct 2024 20:38:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -255,12 +246,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -276,7 +264,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041957 + url: https://api.linode.com/v4beta/domains/3153532 method: DELETE response: body: '{}' @@ -304,7 +292,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:31 GMT + - Thu, 31 Oct 2024 20:38:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -319,12 +307,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestDomainRecord_Update.yaml b/test/integration/fixtures/TestDomainRecord_Update.yaml index 720340b69..370565f22 100644 --- a/test/integration/fixtures/TestDomainRecord_Update.yaml +++ b/test/integration/fixtures/TestDomainRecord_Update.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3041954, "type": "master", "domain": "linodego-blue-test.com", "tags": + body: '{"id": 3153529, "type": "master", "domain": "linodego-blue-test.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:24 GMT + - Thu, 31 Oct 2024 20:38:30 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,12 +58,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041954/records + url: https://api.linode.com/v4beta/domains/3153529/records method: POST response: - body: '{"id": 35694151, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666865, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -109,7 +106,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:24 GMT + - Thu, 31 Oct 2024 20:38:31 GMT Pragma: - no-cache Strict-Transport-Security: @@ -124,12 +121,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -145,10 +139,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041954/records/35694151 + url: https://api.linode.com/v4beta/domains/3153529/records/36666865 method: PUT response: - body: '{"id": 35694151, "type": "A", "name": "renamed", "target": "127.0.0.1", + body: '{"id": 36666865, "type": "A", "name": "renamed", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -175,7 +169,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:24 GMT + - Thu, 31 Oct 2024 20:38:31 GMT Pragma: - no-cache Strict-Transport-Security: @@ -190,12 +184,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -211,7 +202,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041954/records/35694151 + url: https://api.linode.com/v4beta/domains/3153529/records/36666865 method: DELETE response: body: '{}' @@ -239,7 +230,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:24 GMT + - Thu, 31 Oct 2024 20:38:31 GMT Pragma: - no-cache Strict-Transport-Security: @@ -254,12 +245,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -275,7 +263,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041954 + url: https://api.linode.com/v4beta/domains/3153529 method: DELETE response: body: '{}' @@ -303,7 +291,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:24 GMT + - Thu, 31 Oct 2024 20:38:31 GMT Pragma: - no-cache Strict-Transport-Security: @@ -318,12 +306,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestDomainRecords_List.yaml b/test/integration/fixtures/TestDomainRecords_List.yaml index 1a2ca7d59..7ec9f1e9f 100644 --- a/test/integration/fixtures/TestDomainRecords_List.yaml +++ b/test/integration/fixtures/TestDomainRecords_List.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3041955, "type": "master", "domain": "linodego-blue-test.com", "tags": + body: '{"id": 3153530, "type": "master", "domain": "linodego-blue-test.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:26 GMT + - Thu, 31 Oct 2024 20:38:33 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,12 +58,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041955/records + url: https://api.linode.com/v4beta/domains/3153530/records method: POST response: - body: '{"id": 35694152, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666866, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -109,7 +106,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:26 GMT + - Thu, 31 Oct 2024 20:38:33 GMT Pragma: - no-cache Strict-Transport-Security: @@ -124,12 +121,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -147,10 +141,10 @@ interactions: - linodego/dev https://github.com/linode/linodego X-Filter: - '{"name":"a"}' - url: https://api.linode.com/v4beta/domains/3041955/records?page=1 + url: https://api.linode.com/v4beta/domains/3153530/records?page=1 method: GET response: - body: '{"data": [{"id": 35694152, "type": "A", "name": "a", "target": "127.0.0.1", + body: '{"data": [{"id": 36666866, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}], "page": 1, "pages": 1, "results": 1}' @@ -178,7 +172,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:26 GMT + - Thu, 31 Oct 2024 20:38:33 GMT Pragma: - no-cache Strict-Transport-Security: @@ -194,12 +188,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -215,7 +206,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041955/records/35694152 + url: https://api.linode.com/v4beta/domains/3153530/records/36666866 method: DELETE response: body: '{}' @@ -243,7 +234,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:26 GMT + - Thu, 31 Oct 2024 20:38:33 GMT Pragma: - no-cache Strict-Transport-Security: @@ -258,12 +249,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -279,7 +267,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041955 + url: https://api.linode.com/v4beta/domains/3153530 method: DELETE response: body: '{}' @@ -307,7 +295,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:26 GMT + - Thu, 31 Oct 2024 20:38:33 GMT Pragma: - no-cache Strict-Transport-Security: @@ -322,12 +310,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestDomainRecords_ListMultiplePages.yaml b/test/integration/fixtures/TestDomainRecords_ListMultiplePages.yaml index 40a6d09af..aaf28f39c 100644 --- a/test/integration/fixtures/TestDomainRecords_ListMultiplePages.yaml +++ b/test/integration/fixtures/TestDomainRecords_ListMultiplePages.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3041956, "type": "master", "domain": "linodego-blue-test.com", "tags": + body: '{"id": 3153531, "type": "master", "domain": "linodego-blue-test.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:28 GMT + - Thu, 31 Oct 2024 20:38:35 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,12 +58,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041956/records + url: https://api.linode.com/v4beta/domains/3153531/records method: POST response: - body: '{"id": 35694153, "type": "A", "name": "a", "target": "127.0.0.1", "priority": + body: '{"id": 36666867, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -109,7 +106,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:28 GMT + - Thu, 31 Oct 2024 20:38:35 GMT Pragma: - no-cache Strict-Transport-Security: @@ -124,12 +121,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -147,10 +141,10 @@ interactions: - linodego/dev https://github.com/linode/linodego X-Filter: - '{"name":"a"}' - url: https://api.linode.com/v4beta/domains/3041956/records?page=1 + url: https://api.linode.com/v4beta/domains/3153531/records?page=1 method: GET response: - body: '{"data": [{"id": 35694153, "type": "A", "name": "a", "target": "127.0.0.1", + body: '{"data": [{"id": 36666867, "type": "A", "name": "a", "target": "127.0.0.1", "priority": 0, "weight": 0, "port": 0, "service": null, "protocol": null, "ttl_sec": 0, "tag": null, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}], "page": 1, "pages": 1, "results": 1}' @@ -178,7 +172,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:28 GMT + - Thu, 31 Oct 2024 20:38:36 GMT Pragma: - no-cache Strict-Transport-Security: @@ -194,12 +188,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -215,7 +206,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041956/records/35694153 + url: https://api.linode.com/v4beta/domains/3153531/records/36666867 method: DELETE response: body: '{}' @@ -243,7 +234,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:28 GMT + - Thu, 31 Oct 2024 20:38:36 GMT Pragma: - no-cache Strict-Transport-Security: @@ -258,12 +249,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -279,7 +267,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3041956 + url: https://api.linode.com/v4beta/domains/3153531 method: DELETE response: body: '{}' @@ -307,7 +295,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 25 Jul 2024 17:44:28 GMT + - Thu, 31 Oct 2024 20:38:36 GMT Pragma: - no-cache Strict-Transport-Security: @@ -322,12 +310,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "400" + - "800" X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/unit/base.go b/test/unit/base.go index 1fb2f8248..078579322 100644 --- a/test/unit/base.go +++ b/test/unit/base.go @@ -1,12 +1,13 @@ package unit import ( + "net/http" + "testing" + "github.com/jarcoal/httpmock" "github.com/linode/linodego" "github.com/linode/linodego/internal/testutil" "github.com/stretchr/testify/mock" - "net/http" - "testing" ) type MockResponse struct { From b09c65471187378647d1ef2ffd4af7aa468dcea6 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Thu, 31 Oct 2024 17:31:18 -0400 Subject: [PATCH 2/2] fix lint --- domain_records.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domain_records.go b/domain_records.go index cfb209335..073dccb8e 100644 --- a/domain_records.go +++ b/domain_records.go @@ -70,7 +70,7 @@ const ( ) // UnmarshalJSON for DomainRecord responses -func (dr *DomainRecord) UnmarshalJSON(b []byte) error { +func (d *DomainRecord) UnmarshalJSON(b []byte) error { type Mask DomainRecord p := struct { @@ -78,15 +78,15 @@ func (dr *DomainRecord) UnmarshalJSON(b []byte) error { Created *parseabletime.ParseableTime `json:"created"` Updated *parseabletime.ParseableTime `json:"updated"` }{ - Mask: (*Mask)(dr), + Mask: (*Mask)(d), } if err := json.Unmarshal(b, &p); err != nil { return err } - dr.Created = (*time.Time)(p.Created) - dr.Updated = (*time.Time)(p.Updated) + d.Created = (*time.Time)(p.Created) + d.Updated = (*time.Time)(p.Updated) return nil }