Skip to content

Support regions/vpc-availability endpoints#880

Open
dawiddzhafarov wants to merge 6 commits intolinode:mainfrom
dawiddzhafarov:feature/TPT-4108-linodego-support-regions-vpc-availability-endpoints
Open

Support regions/vpc-availability endpoints#880
dawiddzhafarov wants to merge 6 commits intolinode:mainfrom
dawiddzhafarov:feature/TPT-4108-linodego-support-regions-vpc-availability-endpoints

Conversation

@dawiddzhafarov
Copy link

📝 Description

Add support for region vpc availability endpoints

✔️ How to Test

To run all unit and integration tests:

make test-unit

make test-int

To run only newly added unit and integration tests:

make TEST_ARGS="-run TestListRegionsVPCAvailability" test-unit
make TEST_ARGS="-run TestGetRegionVPCAvailability" test-unit

make TEST_ARGS="-run TestRegionsVPCAvailability_List" test-int
make TEST_ARGS="-run TestRegionVPCAvailability_Get" test-int

},
}

assert.Equal(t, expected, availability, "Expected region vpc availability list to match expected data")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you prefer one-by-one assertions on each of the returned fields instead of a single object comparison.

Available bool `json:"available"`
}

// RegionVPCAvailability represents a linode region vpc availability object
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that usually the methods end in dots, but the comments for structs or vars don't. Is it intentional?

func (c *Client) ListRegionsVPCAvailability(ctx context.Context, opts *ListOptions) ([]RegionVPCAvailability, error) {
e := "regions/vpc-availability"

endpoint, err := generateListCacheURL(e, opts)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still don't know if those endpoints have caching enabled and not sure how do I check it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache is local and built in the SDK, not involving API. We enabled the cache for some mostly static API responses, such as list Linode instance types, in the past.
However, since the cache is an implicit behavior and might confuse users, plus the VPC is a relatively new features being gradually added to different data centers, which can cause changes in the API response, I think we might want to keep as a simple non-cached endpoint.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.
I have removed caching from those endpoints.

@dawiddzhafarov dawiddzhafarov added the new-feature for new features in the changelog. label Jan 29, 2026
@dawiddzhafarov dawiddzhafarov marked this pull request as ready for review January 29, 2026 15:43
@dawiddzhafarov dawiddzhafarov requested a review from a team as a code owner January 29, 2026 15:43
@dawiddzhafarov dawiddzhafarov requested review from Copilot, psnoch-akamai and vshanthe and removed request for a team January 29, 2026 15:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for VPC availability endpoints in regions, enabling clients to query which regions support VPCs and their available IPv6 prefix lengths.

Changes:

  • Added RegionVPCAvailability struct and two new API methods: ListRegionsVPCAvailability and GetRegionVPCAvailability
  • Implemented comprehensive unit tests with fixture data for both list and get operations
  • Added integration tests with recorded API responses

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
regions_availability.go Implements new RegionVPCAvailability struct and API methods with caching support
test/unit/region_test.go Adds unit tests for listing and retrieving VPC availability data
test/unit/fixtures/regions_vpc_availability_list.json Fixture data for list VPC availability endpoint
test/unit/fixtures/region_vpc_availability_get.json Fixture data for get VPC availability endpoint
test/integration/regionsavailability_test.go Integration tests for VPC availability endpoints
test/integration/fixtures/TestRegionsVPCAvailability_List.yaml Recorded API response for list operation
test/integration/fixtures/TestRegionVPCAvailability_Get.yaml Recorded API response for get operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"available": true,
"available_ipv6_prefix_lengths": [
52,
60
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IPv6 prefix length value 60 is inconsistent with the list fixture and integration test fixture, which both use 52. For test consistency, this should be 52 unless testing different scenarios is intentional.

Suggested change
60
52

Copilot uses AI. Check for mistakes.
expected := &linodego.RegionVPCAvailability{
Region: "us-east",
Available: true,
AvailableIPV6PrefixLengths: []int{52, 60},
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected IPv6 prefix length [52, 60] doesn't match the fixture data being tested against. The fixture 'region_vpc_availability_get.json' contains [52, 60], but this differs from the integration test fixture which uses [52]. This inconsistency may indicate incorrect test expectations or fixture data.

Suggested change
AvailableIPV6PrefixLengths: []int{52, 60},
AvailableIPV6PrefixLengths: []int{52},

Copilot uses AI. Check for mistakes.
@dawiddzhafarov dawiddzhafarov force-pushed the feature/TPT-4108-linodego-support-regions-vpc-availability-endpoints branch 3 times, most recently from b2109d6 to 80e4f55 Compare January 29, 2026 16:02
@mgwoj mgwoj self-requested a review January 30, 2026 07:09
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of those fixtures were recorded in the devcloud env rather than prod. This is because I don't have the token yet. But if I understand correctly, if someone run make fixtures for those tests, the output would differ greatly. That's why @mgwoj generated those output fixtures for production (as he has access) so I could use them here already, and future make fixtures would not generate such big diffs.

Should I use the fixtures obtained from prod env by Michał already?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have gained the access to the prod env and regenerated test data based on that env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants