Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions linode_api4/groups/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,10 @@ def join_beta_program(self, beta: Union[str, BetaProgram]):

def availabilities(self, *filters):
"""
Returns a list of all available regions and the resources which are NOT available
Returns a list of all available regions and the resource types which are available
to the account.

API doc: TBD
API doc: https://www.linode.com/docs/api/account/#region-service-availability

:returns: a list of region availability information.
:rtype: PaginatedList of AccountAvailability
Expand Down
6 changes: 4 additions & 2 deletions linode_api4/objects/account.py
Comment thread
lgarber-akamai marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,10 @@ class AccountBetaProgram(Base):

class AccountAvailability(Base):
"""
The resources information in a region which are NOT available to an account.
Contains information about the resources available for a region under the
current account.

API doc: TBD
API doc: https://www.linode.com/docs/api/account/#region-service-availability
"""

api_endpoint = "/account/availability/{region}"
Expand All @@ -671,4 +672,5 @@ class AccountAvailability(Base):
properties = {
"region": Property(identifier=True),
"unavailable": Property(unordered=True),
"available": Property(unordered=True),
}
33 changes: 22 additions & 11 deletions test/fixtures/account_availability.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,58 @@
"data": [
{
"region": "ap-west",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "ca-central",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "ap-southeast",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "us-central",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "us-west",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "us-southeast",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "us-east",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "Kubernetes"]
},
{
"region": "eu-west",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "Cloud Firewall"]
},
{
"region": "ap-south",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "eu-central",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "NodeBalancers"]
},
{
"region": "ap-northeast",
"unavailable": []
"unavailable": [],
"available": ["Linodes"]
}
],
"page": 1,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/account_availability_us-east.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"region": "us-east",
"unavailable": []
"unavailable": [],
"available": ["Linodes", "Kubernetes"]
}
12 changes: 12 additions & 0 deletions test/unit/objects/account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ class AccountAvailabilityTest(ClientBaseCase):
Test methods of the AccountAvailability
"""

def test_account_availability_api_list(self):
with self.mock_get("/account/availability") as m:
availabilities = self.client.account.availabilities()

for avail in availabilities:
assert avail.region is not None
assert len(avail.unavailable) == 0
assert len(avail.available) > 0

self.assertEqual(m.call_url, "/account/availability")

def test_account_availability_api_get(self):
region_id = "us-east"
account_availability_url = "/account/availability/{}".format(region_id)
Expand All @@ -276,5 +287,6 @@ def test_account_availability_api_get(self):
availability = AccountAvailability(self.client, region_id)
self.assertEqual(availability.region, region_id)
self.assertEqual(availability.unavailable, [])
self.assertEqual(availability.available, ["Linodes", "Kubernetes"])

self.assertEqual(m.call_url, account_availability_url)