Skip to content

Commit 203a4d9

Browse files
Updated NATGatewayType to include region_prices and transfer
1 parent dd9c551 commit 203a4d9

4 files changed

Lines changed: 35 additions & 10 deletions

File tree

‎linode_api4/objects/networking.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,22 @@ class NATGatewayInterface(JSONObject):
548548
) # NOTE: This field may not be available to all users.
549549

550550

551-
@dataclass
552-
class NATGatewayType(JSONObject):
553-
id: str = ""
554-
label: str = ""
555-
price: Optional[Price] = None
551+
class NATGatewayType(Base):
552+
"""
553+
Represents a NAT Gateway type with pricing information.
556554
555+
NOTE: NAT Gateways may not currently be available to all users.
557556
558-
# TODO: replace with base once the region_prices and transfer fields are in use and returned by the API
557+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-natgateway-types
558+
"""
559+
560+
properties = {
561+
"id": Property(identifier=True),
562+
"label": Property(),
563+
"price": Property(json_object=Price),
564+
"region_prices": Property(json_object=RegionPrice),
565+
"transfer": Property(),
566+
}
559567

560568

561569
@dataclass

‎test/fixtures/networking_natgateways_types.json‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@
66
"price": {
77
"hourly": 0.035,
88
"monthly": 25
9-
}
9+
},
10+
"region_prices": [
11+
{
12+
"id": "us-east",
13+
"hourly": 0.036,
14+
"monthly": 26
15+
},
16+
{
17+
"id": "br-gru",
18+
"hourly": 0.041,
19+
"monthly": 30
20+
}
21+
],
22+
"transfer": 1000
1023
}
1124
],
1225
"page": 1,

‎test/integration/models/networking/test_networking.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,8 @@ def test_get_nat_gateway_types(test_linode_client):
758758
gateway_types[0].price.hourly >= 0
759759
or gateway_types[0].price.monthly >= 0
760760
)
761-
# TODO region_prices and transfer fields are not in use at the moment
762-
# assert isinstance(gateway_types[0].region_prices, list)
763-
# assert isinstance(gateway_types[0].transfer, int)
761+
assert isinstance(gateway_types[0].region_prices, list)
762+
assert isinstance(gateway_types[0].transfer, int)
764763

765764

766765
def test_get_nat_gateway_settings(test_linode_client):

‎test/unit/groups/networking_test.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ def test_natgateway_types(self):
313313
assert t.label == "NAT Gateway"
314314
assert t.price.hourly == 0.035
315315
assert t.price.monthly == 25
316+
assert len(t.region_prices) == 2
317+
assert t.region_prices[0].id == "us-east"
318+
assert t.region_prices[0].hourly == 0.036
319+
assert t.region_prices[0].monthly == 26
320+
assert t.transfer == 1000
316321

317322
def test_natgateway_settings(self):
318323
"""

0 commit comments

Comments
 (0)