Skip to content

Commit 23d41fd

Browse files
new: Add available field to AccountAvailability class (#395)
* Add available field to account availabilities response * Update docs
1 parent b1c56a6 commit 23d41fd

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

linode_api4/groups/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,10 @@ def join_beta_program(self, beta: Union[str, BetaProgram]):
487487

488488
def availabilities(self, *filters):
489489
"""
490-
Returns a list of all available regions and the resources which are NOT available
490+
Returns a list of all available regions and the resource types which are available
491491
to the account.
492492
493-
API doc: TBD
493+
API doc: https://www.linode.com/docs/api/account/#region-service-availability
494494
495495
:returns: a list of region availability information.
496496
:rtype: PaginatedList of AccountAvailability

linode_api4/objects/account.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,10 @@ class AccountBetaProgram(Base):
660660

661661
class AccountAvailability(Base):
662662
"""
663-
The resources information in a region which are NOT available to an account.
663+
Contains information about the resources available for a region under the
664+
current account.
664665
665-
API doc: TBD
666+
API doc: https://www.linode.com/docs/api/account/#region-service-availability
666667
"""
667668

668669
api_endpoint = "/account/availability/{region}"
@@ -671,4 +672,5 @@ class AccountAvailability(Base):
671672
properties = {
672673
"region": Property(identifier=True),
673674
"unavailable": Property(unordered=True),
675+
"available": Property(unordered=True),
674676
}

test/fixtures/account_availability.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,58 @@
22
"data": [
33
{
44
"region": "ap-west",
5-
"unavailable": []
5+
"unavailable": [],
6+
"available": ["Linodes", "NodeBalancers"]
67
},
78
{
89
"region": "ca-central",
9-
"unavailable": []
10+
"unavailable": [],
11+
"available": ["Linodes", "NodeBalancers"]
1012
},
1113
{
1214
"region": "ap-southeast",
13-
"unavailable": []
15+
"unavailable": [],
16+
"available": ["Linodes", "NodeBalancers"]
1417
},
1518
{
1619
"region": "us-central",
17-
"unavailable": []
20+
"unavailable": [],
21+
"available": ["Linodes", "NodeBalancers"]
1822
},
1923
{
2024
"region": "us-west",
21-
"unavailable": []
25+
"unavailable": [],
26+
"available": ["Linodes", "NodeBalancers"]
2227
},
2328
{
2429
"region": "us-southeast",
25-
"unavailable": []
30+
"unavailable": [],
31+
"available": ["Linodes", "NodeBalancers"]
2632
},
2733
{
2834
"region": "us-east",
29-
"unavailable": []
35+
"unavailable": [],
36+
"available": ["Linodes", "Kubernetes"]
3037
},
3138
{
3239
"region": "eu-west",
33-
"unavailable": []
40+
"unavailable": [],
41+
"available": ["Linodes", "Cloud Firewall"]
3442
},
3543
{
3644
"region": "ap-south",
37-
"unavailable": []
45+
"unavailable": [],
46+
"available": ["Linodes", "NodeBalancers"]
3847
},
3948
{
4049
"region": "eu-central",
41-
"unavailable": []
50+
"unavailable": [],
51+
"available": ["Linodes", "NodeBalancers"]
4252
},
4353
{
4454
"region": "ap-northeast",
45-
"unavailable": []
55+
"unavailable": [],
56+
"available": ["Linodes"]
4657
}
4758
],
4859
"page": 1,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"region": "us-east",
3-
"unavailable": []
3+
"unavailable": [],
4+
"available": ["Linodes", "Kubernetes"]
45
}

test/unit/objects/account_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,17 @@ class AccountAvailabilityTest(ClientBaseCase):
268268
Test methods of the AccountAvailability
269269
"""
270270

271+
def test_account_availability_api_list(self):
272+
with self.mock_get("/account/availability") as m:
273+
availabilities = self.client.account.availabilities()
274+
275+
for avail in availabilities:
276+
assert avail.region is not None
277+
assert len(avail.unavailable) == 0
278+
assert len(avail.available) > 0
279+
280+
self.assertEqual(m.call_url, "/account/availability")
281+
271282
def test_account_availability_api_get(self):
272283
region_id = "us-east"
273284
account_availability_url = "/account/availability/{}".format(region_id)
@@ -276,5 +287,6 @@ def test_account_availability_api_get(self):
276287
availability = AccountAvailability(self.client, region_id)
277288
self.assertEqual(availability.region, region_id)
278289
self.assertEqual(availability.unavailable, [])
290+
self.assertEqual(availability.available, ["Linodes", "Kubernetes"])
279291

280292
self.assertEqual(m.call_url, account_availability_url)

0 commit comments

Comments
 (0)