@@ -4,11 +4,22 @@ import (
4
4
"context"
5
5
)
6
6
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 {
9
14
// 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"`
12
23
}
13
24
14
25
// LinodeIPAssignment stores an assignment between an IP address and a Linode instance.
@@ -44,13 +55,24 @@ type ListIPAddressesQuery struct {
44
55
SkipIPv6RDNS bool `query:"skip_ipv6_rdns"`
45
56
}
46
57
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.
48
70
func (i InstanceIP ) GetUpdateOptions () (o IPAddressUpdateOptions ) {
49
71
o .RDNS = copyString (& i .RDNS )
50
72
return
51
73
}
52
74
53
- // ListIPAddresses lists IPAddresses
75
+ // ListIPAddresses lists IPAddresses.
54
76
func (c * Client ) ListIPAddresses (ctx context.Context , opts * ListOptions ) ([]InstanceIP , error ) {
55
77
response , err := getPaginatedResults [InstanceIP ](ctx , c , "networking/ips" , opts )
56
78
if err != nil {
@@ -60,7 +82,7 @@ func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]Inst
60
82
return response , nil
61
83
}
62
84
63
- // GetIPAddress gets the IPAddress with the provided IP
85
+ // GetIPAddress gets the IPAddress with the provided IP.
64
86
func (c * Client ) GetIPAddress (ctx context.Context , id string ) (* InstanceIP , error ) {
65
87
e := formatAPIPath ("networking/ips/%s" , id )
66
88
response , err := doGETRequest [InstanceIP ](ctx , c , e )
@@ -71,7 +93,19 @@ func (c *Client) GetIPAddress(ctx context.Context, id string) (*InstanceIP, erro
71
93
return response , nil
72
94
}
73
95
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.
75
109
func (c * Client ) UpdateIPAddress (ctx context.Context , id string , opts IPAddressUpdateOptions ) (* InstanceIP , error ) {
76
110
e := formatAPIPath ("networking/ips/%s" , id )
77
111
response , err := doPUTRequest [InstanceIP ](ctx , c , e , opts )
0 commit comments