Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support For Managing Reserved IP Addresses #579

Merged
merged 24 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1b87e78
added reserved field to InstanceIP struct for IP Reservation response
AniJ98 Aug 22, 2024
311ecfc
Reserved IP resource for handling IP reservation API's
AniJ98 Aug 22, 2024
7fb337e
Added integration test covering multiple scenarios of reserving IP ad…
AniJ98 Aug 22, 2024
1c6a8ab
The fixture files for different scenarios of IP Reservation - EndToEn…
AniJ98 Aug 22, 2024
fd426cc
Updated the fixture files with responses after the user has permissio…
AniJ98 Aug 26, 2024
bed7ce0
Changed the error message to relay invalid token for insufficient per…
AniJ98 Aug 26, 2024
4cc42a6
Updated the error message for Insufficient Permission tests to displa…
AniJ98 Aug 26, 2024
11fd3cb
Made changes to Delete, List, Get, Reserve, EndtoEnd fixtures to rec…
AniJ98 Aug 26, 2024
4d24fd1
changed variable name from id to address to keep it consistent with o…
AniJ98 Aug 29, 2024
a265fd4
Made changes to variable names, achanged logf statements to errorf an…
AniJ98 Aug 29, 2024
49d14a6
changed fixture file names to improve consistency, re-recorded fixtur…
AniJ98 Aug 29, 2024
bd106fa
removed debugging fmt statement
AniJ98 Aug 29, 2024
cd7fa48
Made changes to reserve IP addresses before listing them using fitler…
AniJ98 Sep 3, 2024
d52a33f
uncommenting unaffected tests
AniJ98 Sep 3, 2024
cb81bc2
Made changes to error messages, added mandatory checks and re-recorde…
AniJ98 Sep 5, 2024
456d0f2
Added new middleware system (#571)
ezilber-akamai Sep 3, 2024
1867029
build(deps): bump golang.org/x/oauth2 from 0.22.0 to 0.23.0 (#574)
dependabot[bot] Sep 5, 2024
af6a7bd
build(deps): bump golang.org/x/text from 0.17.0 to 0.18.0 (#575)
dependabot[bot] Sep 5, 2024
b25e83d
new: Add support LKE, Volume, NodeBalancer, and network transfer pric…
lgarber-akamai Sep 6, 2024
3bb8dc0
Add test case for ip limit exceed
AniJ98 Sep 16, 2024
ce34304
add cleanup for TestReservedIPAddresses_ExceedLimit
ykim-akamai Sep 16, 2024
8627e4f
added interactions to fixture and changed the ecpected error message
AniJ98 Sep 16, 2024
663e798
Added note indicating feature is currently not available to all users
AniJ98 Sep 16, 2024
5bb2bc1
Merge branch 'main' into main
AniJ98 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions instance_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type InstanceIP struct {
LinodeID int `json:"linode_id"`
Region string `json:"region"`
VPCNAT1To1 *InstanceIPNAT1To1 `json:"vpc_nat_1_1"`
Reserved bool `json:"reserved"`
}

// VPCIP represents a private IP address in a VPC subnet with additional networking details
Expand Down
54 changes: 54 additions & 0 deletions network_reserved_ips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package linodego

import (
"context"
)

// ReserveIPOptions represents the options for reserving an IP address
// NOTE: Reserved IP feature may not currently be available to all users.
type ReserveIPOptions struct {
Region string `json:"region"`
}

// ListReservedIPAddresses retrieves a list of reserved IP addresses
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) ListReservedIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error) {
e := formatAPIPath("networking/reserved/ips")
response, err := getPaginatedResults[InstanceIP](ctx, c, e, opts)
if err != nil {
return nil, err
}

return response, nil
}

// GetReservedIPAddress retrieves details of a specific reserved IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) GetReservedIPAddress(ctx context.Context, ipAddress string) (*InstanceIP, error) {
e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
response, err := doGETRequest[InstanceIP](ctx, c, e)
if err != nil {
return nil, err
}

return response, nil
}

// ReserveIPAddress reserves a new IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) ReserveIPAddress(ctx context.Context, opts ReserveIPOptions) (*InstanceIP, error) {
e := "networking/reserved/ips"
response, err := doPOSTRequest[InstanceIP](ctx, c, e, opts)
if err != nil {
return nil, err
}

return response, nil
}

// DeleteReservedIPAddress deletes a reserved IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) DeleteReservedIPAddress(ctx context.Context, ipAddress string) error {
e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
return doDELETERequest(ctx, c, e)
}
Loading