-
Notifications
You must be signed in to change notification settings - Fork 85
python-sdk: Support regions/vpc-availability endpoints #646
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
Changes from 1 commit
fc5d5b0
37ad44e
eb78f05
77b40ce
bf632a6
9dbab80
fddd785
07d15bb
d09596f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| from linode_api4.groups import Group | ||
| from linode_api4.objects import Region | ||
| from linode_api4.objects.region import RegionAvailabilityEntry | ||
| from linode_api4.objects.region import ( | ||
| RegionAvailabilityEntry, | ||
| RegionVPCAvailability, | ||
| ) | ||
|
|
||
|
|
||
| class RegionGroup(Group): | ||
|
|
@@ -43,3 +46,74 @@ def availability(self, *filters): | |
| return self.client._get_and_filter( | ||
| RegionAvailabilityEntry, *filters, endpoint="/regions/availability" | ||
| ) | ||
|
|
||
| def availability_get(self, region_id): | ||
| """ | ||
| Returns availability data for a specific region. | ||
|
|
||
| API Documentation: https://techdocs.akamai.com/linode-api/reference/get-region-availability | ||
|
|
||
| :param region_id: The ID of the region to retrieve availability for. | ||
| :type region_id: str | ||
|
|
||
| :returns: A list of availability entries for the specified region. | ||
| :rtype: list of RegionAvailabilityEntry | ||
| """ | ||
|
|
||
| result = self.client.get(f"/regions/{region_id}/availability") | ||
|
|
||
| if result is None: | ||
| return [] | ||
|
|
||
| return [RegionAvailabilityEntry.from_json(v) for v in result] | ||
|
|
||
| def vpc_availability(self, *filters): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: vpc_availabilities. Normally we use plural forms to indicate it's an list endpoints.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but then it will be inconsistent with the naming of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, it's probably an overlook when making the availability method. Agree that we keep them consistent. |
||
| """ | ||
| Returns VPC availability data for all regions. | ||
|
|
||
| NOTE: IPv6 VPCs may not currently be available to all users. | ||
|
|
||
| This endpoint supports pagination with the following parameters: | ||
| - page: Page number (>= 1) | ||
| - page_size: Number of items per page (25-500) | ||
|
|
||
| Pagination is handled automatically by PaginatedList. To configure page_size, | ||
| set it when creating the LinodeClient: | ||
|
|
||
| client = LinodeClient(token, page_size=100) | ||
|
|
||
| API Documentation: https://techdocs.akamai.com/linode-api/reference/get-regions-vpc-availability | ||
|
|
||
| :param filters: Any number of filters to apply to this query. | ||
| See :doc:`Filtering Collections</linode_api4/objects/filtering>` | ||
| for more details on filtering. | ||
|
|
||
| :returns: A list of VPC availability data for regions. | ||
| :rtype: PaginatedList of RegionVPCAvailability | ||
| """ | ||
|
|
||
| return self.client._get_and_filter( | ||
| RegionVPCAvailability, *filters, endpoint="/regions/vpc-availability" | ||
| ) | ||
|
|
||
| def vpc_availability_get(self, region_id): | ||
|
yec-akamai marked this conversation as resolved.
Outdated
|
||
| """ | ||
| Returns VPC availability data for a specific region. | ||
|
|
||
| NOTE: IPv6 VPCs may not currently be available to all users. | ||
|
|
||
| API Documentation: https://techdocs.akamai.com/linode-api/reference/get-region-vpc-availability | ||
|
|
||
| :param region_id: The ID of the region to retrieve VPC availability for. | ||
| :type region_id: str | ||
|
|
||
| :returns: VPC availability data for the specified region. | ||
| :rtype: RegionVPCAvailability | ||
| """ | ||
|
|
||
| result = self.client.get(f"/regions/{region_id}/vpc-availability") | ||
|
|
||
| if result is None: | ||
| return None | ||
|
|
||
| return RegionVPCAvailability.from_json(result) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "region": "us-east", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [52, 60] | ||
|
yec-akamai marked this conversation as resolved.
Outdated
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "region": "us-east", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [52, 48] | ||
| }, | ||
| { | ||
| "region": "us-west", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [56, 52, 48] | ||
| }, | ||
| { | ||
| "region": "nl-ams", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "us-ord", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "us-iad", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "fr-par", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "us-sea", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "br-gru", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "se-sto", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "es-mad", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "in-maa", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "jp-osa", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "it-mil", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "us-mia", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "id-cgk", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "us-lax", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "gb-lon", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "au-mel", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "in-bom-2", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "de-fra-2", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "sg-sin-2", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "jp-tyo-3", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "fr-par-2", | ||
| "available": true, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "ca-central", | ||
| "available": false, | ||
| "available_ipv6_prefix_lengths": [] | ||
| }, | ||
| { | ||
| "region": "ap-southeast", | ||
| "available": false, | ||
| "available_ipv6_prefix_lengths": [] | ||
| } | ||
| ], | ||
| "page": 1, | ||
| "pages": 2, | ||
| "results": 50 | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.