Skip to content

Commit 0951c34

Browse files
authored
new: Add site_type to Region (#386)
* add site_type * lint
1 parent cb1e30a commit 0951c34

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

linode_api4/objects/region.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Region(Base):
2222
"status": Property(),
2323
"resolvers": Property(),
2424
"label": Property(),
25+
"site_type": Property(),
2526
}
2627

2728
@property

test/fixtures/regions.json

+22-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"ipv4": "172.105.34.5,172.105.35.5,172.105.36.5,172.105.37.5,172.105.38.5,172.105.39.5,172.105.40.5,172.105.41.5,172.105.42.5,172.105.43.5",
1414
"ipv6": "2400:8904::f03c:91ff:fea5:659,2400:8904::f03c:91ff:fea5:9282,2400:8904::f03c:91ff:fea5:b9b3,2400:8904::f03c:91ff:fea5:925a,2400:8904::f03c:91ff:fea5:22cb,2400:8904::f03c:91ff:fea5:227a,2400:8904::f03c:91ff:fea5:924c,2400:8904::f03c:91ff:fea5:f7e2,2400:8904::f03c:91ff:fea5:2205,2400:8904::f03c:91ff:fea5:9207"
1515
},
16-
"label": "label1"
16+
"label": "label1",
17+
"site_type": "core"
1718
},
1819
{
1920
"id": "ca-central",
@@ -28,7 +29,8 @@
2829
"ipv4": "172.105.0.5,172.105.3.5,172.105.4.5,172.105.5.5,172.105.6.5,172.105.7.5,172.105.8.5,172.105.9.5,172.105.10.5,172.105.11.5",
2930
"ipv6": "2600:3c04::f03c:91ff:fea9:f63,2600:3c04::f03c:91ff:fea9:f6d,2600:3c04::f03c:91ff:fea9:f80,2600:3c04::f03c:91ff:fea9:f0f,2600:3c04::f03c:91ff:fea9:f99,2600:3c04::f03c:91ff:fea9:fbd,2600:3c04::f03c:91ff:fea9:fdd,2600:3c04::f03c:91ff:fea9:fe2,2600:3c04::f03c:91ff:fea9:f68,2600:3c04::f03c:91ff:fea9:f4a"
3031
},
31-
"label": "label2"
32+
"label": "label2",
33+
"site_type": "core"
3234
},
3335
{
3436
"id": "ap-southeast",
@@ -43,7 +45,8 @@
4345
"ipv4": "172.105.166.5,172.105.169.5,172.105.168.5,172.105.172.5,172.105.162.5,172.105.170.5,172.105.167.5,172.105.171.5,172.105.181.5,172.105.161.5",
4446
"ipv6": "2400:8907::f03c:92ff:fe6e:ec8,2400:8907::f03c:92ff:fe6e:98e4,2400:8907::f03c:92ff:fe6e:1c58,2400:8907::f03c:92ff:fe6e:c299,2400:8907::f03c:92ff:fe6e:c210,2400:8907::f03c:92ff:fe6e:c219,2400:8907::f03c:92ff:fe6e:1c5c,2400:8907::f03c:92ff:fe6e:c24e,2400:8907::f03c:92ff:fe6e:e6b,2400:8907::f03c:92ff:fe6e:e3d"
4547
},
46-
"label": "label3"
48+
"label": "label3",
49+
"site_type": "core"
4750
},
4851
{
4952
"id": "us-central",
@@ -58,7 +61,8 @@
5861
"ipv4": "72.14.179.5,72.14.188.5,173.255.199.5,66.228.53.5,96.126.122.5,96.126.124.5,96.126.127.5,198.58.107.5,198.58.111.5,23.239.24.5",
5962
"ipv6": "2600:3c00::2,2600:3c00::9,2600:3c00::7,2600:3c00::5,2600:3c00::3,2600:3c00::8,2600:3c00::6,2600:3c00::4,2600:3c00::c,2600:3c00::b"
6063
},
61-
"label": "label4"
64+
"label": "label4",
65+
"site_type": "core"
6266
},
6367
{
6468
"id": "us-west",
@@ -73,7 +77,8 @@
7377
"ipv4": "173.230.145.5,173.230.147.5,173.230.155.5,173.255.212.5,173.255.219.5,173.255.241.5,173.255.243.5,173.255.244.5,74.207.241.5,74.207.242.5",
7478
"ipv6": "2600:3c01::2,2600:3c01::9,2600:3c01::5,2600:3c01::7,2600:3c01::3,2600:3c01::8,2600:3c01::4,2600:3c01::b,2600:3c01::c,2600:3c01::6"
7579
},
76-
"label": "label5"
80+
"label": "label5",
81+
"site_type": "core"
7782
},
7883
{
7984
"id": "us-southeast",
@@ -88,7 +93,8 @@
8893
"ipv4": "74.207.231.5,173.230.128.5,173.230.129.5,173.230.136.5,173.230.140.5,66.228.59.5,66.228.62.5,50.116.35.5,50.116.41.5,23.239.18.5",
8994
"ipv6": "2600:3c02::3,2600:3c02::5,2600:3c02::4,2600:3c02::6,2600:3c02::c,2600:3c02::7,2600:3c02::2,2600:3c02::9,2600:3c02::8,2600:3c02::b"
9095
},
91-
"label": "label6"
96+
"label": "label6",
97+
"site_type": "core"
9298
},
9399
{
94100
"id": "us-east",
@@ -104,7 +110,8 @@
104110
"ipv4": "66.228.42.5,96.126.106.5,50.116.53.5,50.116.58.5,50.116.61.5,50.116.62.5,66.175.211.5,97.107.133.4,207.192.69.4,207.192.69.5",
105111
"ipv6": "2600:3c03::7,2600:3c03::4,2600:3c03::9,2600:3c03::6,2600:3c03::3,2600:3c03::c,2600:3c03::5,2600:3c03::b,2600:3c03::2,2600:3c03::8"
106112
},
107-
"label": "label7"
113+
"label": "label7",
114+
"site_type": "core"
108115
},
109116
{
110117
"id": "eu-west",
@@ -119,7 +126,8 @@
119126
"ipv4": "178.79.182.5,176.58.107.5,176.58.116.5,176.58.121.5,151.236.220.5,212.71.252.5,212.71.253.5,109.74.192.20,109.74.193.20,109.74.194.20",
120127
"ipv6": "2a01:7e00::9,2a01:7e00::3,2a01:7e00::c,2a01:7e00::5,2a01:7e00::6,2a01:7e00::8,2a01:7e00::b,2a01:7e00::4,2a01:7e00::7,2a01:7e00::2"
121128
},
122-
"label": "label8"
129+
"label": "label8",
130+
"site_type": "core"
123131
},
124132
{
125133
"id": "ap-south",
@@ -135,7 +143,8 @@
135143
"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20",
136144
"ipv6": "2400:8901::5,2400:8901::4,2400:8901::b,2400:8901::3,2400:8901::9,2400:8901::2,2400:8901::8,2400:8901::7,2400:8901::c,2400:8901::6"
137145
},
138-
"label": "label9"
146+
"label": "label9",
147+
"site_type": "core"
139148
},
140149
{
141150
"id": "eu-central",
@@ -151,7 +160,8 @@
151160
"ipv4": "139.162.130.5,139.162.131.5,139.162.132.5,139.162.133.5,139.162.134.5,139.162.135.5,139.162.136.5,139.162.137.5,139.162.138.5,139.162.139.5",
152161
"ipv6": "2a01:7e01::5,2a01:7e01::9,2a01:7e01::7,2a01:7e01::c,2a01:7e01::2,2a01:7e01::4,2a01:7e01::3,2a01:7e01::6,2a01:7e01::b,2a01:7e01::8"
153162
},
154-
"label": "label10"
163+
"label": "label10",
164+
"site_type": "core"
155165
},
156166
{
157167
"id": "ap-northeast",
@@ -166,7 +176,8 @@
166176
"ipv4": "139.162.66.5,139.162.67.5,139.162.68.5,139.162.69.5,139.162.70.5,139.162.71.5,139.162.72.5,139.162.73.5,139.162.74.5,139.162.75.5",
167177
"ipv6": "2400:8902::3,2400:8902::6,2400:8902::c,2400:8902::4,2400:8902::2,2400:8902::8,2400:8902::7,2400:8902::5,2400:8902::b,2400:8902::9"
168178
},
169-
"label": "label11"
179+
"label": "label11",
180+
"site_type": "core"
170181
}
171182
],
172183
"page": 1,

test/integration/linode_client/test_linode_client.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from linode_api4 import ApiError, LinodeClient
8-
from linode_api4.objects import ConfigInterface, ObjectStorageKeys
8+
from linode_api4.objects import ConfigInterface, ObjectStorageKeys, Region
99

1010

1111
@pytest.fixture(scope="session", autouse=True)
@@ -66,6 +66,19 @@ def test_get_domains(test_linode_client, test_domain):
6666
assert domain.domain in dom_list
6767

6868

69+
@pytest.mark.smoke
70+
def test_get_regions(test_linode_client):
71+
client = test_linode_client
72+
regions = client.regions()
73+
74+
region_list = [r.id for r in regions]
75+
76+
test_region = Region(client, "us-east")
77+
78+
assert test_region.id in region_list
79+
assert test_region.site_type in ["core", "edge"]
80+
81+
6982
@pytest.mark.smoke
7083
def test_image_create(setup_client_and_linode):
7184
client = setup_client_and_linode[0]

test/unit/linode_client_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_get_regions(self):
7474
self.assertIsNotNone(region.resolvers)
7575
self.assertIsNotNone(region.resolvers.ipv4)
7676
self.assertIsNotNone(region.resolvers.ipv6)
77+
self.assertEqual(region.site_type, "core")
7778

7879
def test_get_images(self):
7980
r = self.client.images()

test/unit/objects/region_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_get_region(self):
2222
self.assertEqual(region.label, "label7")
2323
self.assertEqual(region.status, "ok")
2424
self.assertIsNotNone(region.resolvers)
25+
self.assertEqual(region.site_type, "core")
2526

2627
def test_list_availability(self):
2728
"""

0 commit comments

Comments
 (0)