Skip to content

Commit fefcd3e

Browse files
new: Introduce UpdateIPAddressV2; deprecate UpdateIPAddress (#641)
* Introduce UpdateIPAddressV2; deprecate UpdateIPAddress * Update fixtures
1 parent 6b41317 commit fefcd3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2641
-4320
lines changed

network_ips.go

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ import (
44
"context"
55
)
66

7-
// IPAddressUpdateOptions fields are those accepted by UpdateToken
8-
type IPAddressUpdateOptions struct {
7+
// IPAddressUpdateOptionsV2 fields are those accepted by UpdateIPAddress.
8+
// NOTE: An IP's RDNS can be reset to default using the following pattern:
9+
//
10+
// IPAddressUpdateOptionsV2{
11+
// RDNS: linodego.Pointer[*string](nil),
12+
// }
13+
type IPAddressUpdateOptionsV2 struct {
914
// The reverse DNS assigned to this address. For public IPv4 addresses, this will be set to a default value provided by Linode if set to nil.
10-
Reserved *bool `json:"reserved,omitempty"`
11-
RDNS *string `json:"rdns,omitempty"`
15+
Reserved *bool `json:"reserved,omitempty"`
16+
RDNS **string `json:"rdns,omitempty"`
17+
}
18+
19+
// IPAddressUpdateOptions fields are those accepted by UpdateIPAddress.
20+
// Deprecated: Please use IPAddressUpdateOptionsV2 for all new implementations.
21+
type IPAddressUpdateOptions struct {
22+
RDNS *string `json:"rdns"`
1223
}
1324

1425
// LinodeIPAssignment stores an assignment between an IP address and a Linode instance.
@@ -44,13 +55,24 @@ type ListIPAddressesQuery struct {
4455
SkipIPv6RDNS bool `query:"skip_ipv6_rdns"`
4556
}
4657

47-
// GetUpdateOptions converts a IPAddress to IPAddressUpdateOptions for use in UpdateIPAddress
58+
// GetUpdateOptionsV2 converts a IPAddress to IPAddressUpdateOptionsV2 for use in UpdateIPAddressV2.
59+
func (i InstanceIP) GetUpdateOptionsV2() IPAddressUpdateOptionsV2 {
60+
rdns := copyString(&i.RDNS)
61+
62+
return IPAddressUpdateOptionsV2{
63+
RDNS: &rdns,
64+
Reserved: copyBool(&i.Reserved),
65+
}
66+
}
67+
68+
// GetUpdateOptions converts a IPAddress to IPAddressUpdateOptions for use in UpdateIPAddress.
69+
// Deprecated: Please use GetUpdateOptionsV2 for all new implementations.
4870
func (i InstanceIP) GetUpdateOptions() (o IPAddressUpdateOptions) {
4971
o.RDNS = copyString(&i.RDNS)
5072
return
5173
}
5274

53-
// ListIPAddresses lists IPAddresses
75+
// ListIPAddresses lists IPAddresses.
5476
func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error) {
5577
response, err := getPaginatedResults[InstanceIP](ctx, c, "networking/ips", opts)
5678
if err != nil {
@@ -60,7 +82,7 @@ func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]Inst
6082
return response, nil
6183
}
6284

63-
// GetIPAddress gets the IPAddress with the provided IP
85+
// GetIPAddress gets the IPAddress with the provided IP.
6486
func (c *Client) GetIPAddress(ctx context.Context, id string) (*InstanceIP, error) {
6587
e := formatAPIPath("networking/ips/%s", id)
6688
response, err := doGETRequest[InstanceIP](ctx, c, e)
@@ -71,7 +93,19 @@ func (c *Client) GetIPAddress(ctx context.Context, id string) (*InstanceIP, erro
7193
return response, nil
7294
}
7395

74-
// UpdateIPAddress updates the IPAddress with the specified id
96+
// UpdateIPAddressV2 updates the IP address with the specified address.
97+
func (c *Client) UpdateIPAddressV2(ctx context.Context, address string, opts IPAddressUpdateOptionsV2) (*InstanceIP, error) {
98+
e := formatAPIPath("networking/ips/%s", address)
99+
response, err := doPUTRequest[InstanceIP](ctx, c, e, opts)
100+
if err != nil {
101+
return nil, err
102+
}
103+
104+
return response, nil
105+
}
106+
107+
// UpdateIPAddress updates the IP address with the specified id.
108+
// Deprecated: Please use UpdateIPAddressV2 for all new implementation.
75109
func (c *Client) UpdateIPAddress(ctx context.Context, id string, opts IPAddressUpdateOptions) (*InstanceIP, error) {
76110
e := formatAPIPath("networking/ips/%s", id)
77111
response, err := doPUTRequest[InstanceIP](ctx, c, e, opts)

test/integration/account_oauth_client_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package integration
22

33
import (
44
"context"
5-
"github.com/stretchr/testify/assert"
65
"testing"
76

7+
"github.com/stretchr/testify/assert"
8+
89
"github.com/linode/linodego"
910
. "github.com/linode/linodego"
1011
)

test/integration/domains_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func setupDomain(t *testing.T, fixturesYaml string) (*linodego.Client, *linodego
110110

111111
func TestDomain_Clone_smoke(t *testing.T) {
112112
client, domainToClone, teardown, err := setupDomain(t, "fixtures/TestDomain_Clone")
113-
114113
if err != nil {
115114
t.Errorf("Error creating domain: %v", err)
116115
}

test/integration/fixtures/TestIPAddress_GetFound.yaml

Lines changed: 229 additions & 267 deletions
Large diffs are not rendered by default.

test/integration/fixtures/TestIPAddress_GetMissing.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ interactions:
2222
- HEAD, GET, OPTIONS, POST, PUT, DELETE
2323
Access-Control-Allow-Origin:
2424
- '*'
25+
Akamai-Internal-Account:
26+
- '*'
2527
Cache-Control:
2628
- max-age=0, no-cache, no-store
2729
Connection:
@@ -31,7 +33,7 @@ interactions:
3133
Content-Type:
3234
- application/json
3335
Expires:
34-
- Mon, 08 Jul 2024 13:31:44 GMT
36+
- Wed, 11 Dec 2024 19:17:27 GMT
3537
Pragma:
3638
- no-cache
3739
Vary:
@@ -43,7 +45,7 @@ interactions:
4345
X-Oauth-Scopes:
4446
- '*'
4547
X-Ratelimit-Limit:
46-
- "400"
48+
- "1600"
4749
status: 404 Not Found
4850
code: 404
4951
duration: ""

0 commit comments

Comments
 (0)