Skip to content

Commit

Permalink
Support For Managing Reserved IP Addresses (#579)
Browse files Browse the repository at this point in the history
* added reserved field to InstanceIP struct for IP Reservation response

* Reserved IP resource for handling IP reservation API's

* Added integration test covering multiple scenarios of reserving IP addresses

* The fixture files for different scenarios of IP Reservation - EndToEnd, InsuffecientPermission, ReserveIP, GetReservedIP, getReservedIPs, DeleteReservedIPs

* Updated the fixture files with responses after the user has permissions to reserve IP

* Changed the error message to relay invalid token for insufficient permission tests

* Updated the error message for Insufficient Permission tests to display appropriate error message along with code

* Made changes to Delete, List, Get, Reserve, EndtoEnd fixtures to record user with adequate permissions

* changed variable name from id to address to keep it consistent with other functions

* Made changes to variable names, achanged logf statements to errorf and fatalf wherever necessary

* changed fixture file names to improve consistency, re-recorded fixtures with latest error messages

* removed debugging fmt statement

* Made changes to reserve IP addresses before listing them using fitler feature. Removed for loop to reserve IPs till limit is reached.

* uncommenting unaffected tests

* Made changes to error messages, added mandatory checks and re-recorded fixtures to reflect new error messages

* Added new middleware system (#571)

* build(deps): bump golang.org/x/oauth2 from 0.22.0 to 0.23.0 (#574)

* build(deps): bump golang.org/x/oauth2 from 0.22.0 to 0.23.0

Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.22.0 to 0.23.0.
- [Commits](golang/oauth2@v0.22.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Ran make tidy

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ezilber-akamai <ezilber@akamai.com>

* build(deps): bump golang.org/x/text from 0.17.0 to 0.18.0 (#575)

* build(deps): bump golang.org/x/text from 0.17.0 to 0.18.0

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* make tidy

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ye Chen <yechen@akamai.com>

* new: Add support LKE, Volume, NodeBalancer, and network transfer pricing endpoints  (#573)

* Add LKE types endpoints

* Support base struct; add NB types endpoints

* Add volume types

* Add network transfer prices

* Add price and region price structs

* Revert IPv6 fixtures

* Add missing fixtures

* Add test case for ip limit exceed

* add cleanup for TestReservedIPAddresses_ExceedLimit

* added interactions to fixture and changed the ecpected error message

* Added note indicating feature is currently not available to all users

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Erik Zilber <ezilber@akamai.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ye Chen <yechen@akamai.com>
Co-authored-by: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com>
Co-authored-by: ykim-1 <ykim@akamai.com>
  • Loading branch information
6 people authored Sep 17, 2024
1 parent 890ff1e commit 108afdf
Show file tree
Hide file tree
Showing 10 changed files with 2,648 additions and 0 deletions.
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

0 comments on commit 108afdf

Please sign in to comment.