@@ -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.
4870func (i InstanceIP ) GetUpdateOptions () (o IPAddressUpdateOptions ) {
4971 o .RDNS = copyString (& i .RDNS )
5072 return
5173}
5274
53- // ListIPAddresses lists IPAddresses
75+ // ListIPAddresses lists IPAddresses.
5476func (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.
6486func (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.
75109func (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 )
0 commit comments