Skip to content

Commit 1a2fb70

Browse files
authored
feat(vpc_gw): add ability to upgrade Public Gateway to a specific commercial offer type (#607)
1 parent 85918c4 commit 1a2fb70

File tree

6 files changed

+64
-6
lines changed

6 files changed

+64
-6
lines changed

scaleway-async/scaleway_async/vpcgw/v1/api.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
UpdateGatewayRequest,
5959
UpdateIPRequest,
6060
UpdatePATRuleRequest,
61+
UpgradeGatewayRequest,
6162
)
6263
from .content import (
6364
GATEWAY_NETWORK_TRANSIENT_STATUSES,
@@ -93,6 +94,7 @@
9394
marshal_UpdateGatewayRequest,
9495
marshal_UpdateIPRequest,
9596
marshal_UpdatePATRuleRequest,
97+
marshal_UpgradeGatewayRequest,
9698
)
9799

98100

@@ -448,12 +450,14 @@ async def upgrade_gateway(
448450
*,
449451
gateway_id: str,
450452
zone: Optional[Zone] = None,
453+
type_: Optional[str] = None,
451454
) -> Gateway:
452455
"""
453-
Upgrade a Public Gateway to the latest version.
454-
Upgrade a given Public Gateway to the newest software version. This applies the latest bugfixes and features to your Public Gateway, but its service will be interrupted during the update.
456+
Upgrade a Public Gateway to the latest version and/or to a different commercial offer type.
457+
Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.
455458
:param gateway_id: ID of the gateway to upgrade.
456459
:param zone: Zone to target. If none is passed will use default zone from the config.
460+
:param type_: Gateway type (commercial offer).
457461
:return: :class:`Gateway <Gateway>`
458462
459463
Usage:
@@ -470,7 +474,14 @@ async def upgrade_gateway(
470474
res = self._request(
471475
"POST",
472476
f"/vpc-gw/v1/zones/{param_zone}/gateways/{param_gateway_id}/upgrade",
473-
body={},
477+
body=marshal_UpgradeGatewayRequest(
478+
UpgradeGatewayRequest(
479+
gateway_id=gateway_id,
480+
zone=zone,
481+
type_=type_,
482+
),
483+
self.client,
484+
),
474485
)
475486

476487
self._throw_on_error(res)

scaleway-async/scaleway_async/vpcgw/v1/marshalling.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
UpdateGatewayRequest,
4646
UpdateIPRequest,
4747
UpdatePATRuleRequest,
48+
UpgradeGatewayRequest,
4849
)
4950

5051

@@ -1127,3 +1128,15 @@ def marshal_UpdatePATRuleRequest(
11271128
output["protocol"] = str(request.protocol)
11281129

11291130
return output
1131+
1132+
1133+
def marshal_UpgradeGatewayRequest(
1134+
request: UpgradeGatewayRequest,
1135+
defaults: ProfileDefaults,
1136+
) -> Dict[str, Any]:
1137+
output: Dict[str, Any] = {}
1138+
1139+
if request.type_ is not None:
1140+
output["type"] = request.type_
1141+
1142+
return output

scaleway-async/scaleway_async/vpcgw/v1/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,3 +1746,8 @@ class UpgradeGatewayRequest:
17461746
"""
17471747
Zone to target. If none is passed will use default zone from the config.
17481748
"""
1749+
1750+
type_: Optional[str]
1751+
"""
1752+
Gateway type (commercial offer).
1753+
"""

scaleway/scaleway/vpcgw/v1/api.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
UpdateGatewayRequest,
5959
UpdateIPRequest,
6060
UpdatePATRuleRequest,
61+
UpgradeGatewayRequest,
6162
)
6263
from .content import (
6364
GATEWAY_NETWORK_TRANSIENT_STATUSES,
@@ -93,6 +94,7 @@
9394
marshal_UpdateGatewayRequest,
9495
marshal_UpdateIPRequest,
9596
marshal_UpdatePATRuleRequest,
97+
marshal_UpgradeGatewayRequest,
9698
)
9799

98100

@@ -448,12 +450,14 @@ def upgrade_gateway(
448450
*,
449451
gateway_id: str,
450452
zone: Optional[Zone] = None,
453+
type_: Optional[str] = None,
451454
) -> Gateway:
452455
"""
453-
Upgrade a Public Gateway to the latest version.
454-
Upgrade a given Public Gateway to the newest software version. This applies the latest bugfixes and features to your Public Gateway, but its service will be interrupted during the update.
456+
Upgrade a Public Gateway to the latest version and/or to a different commercial offer type.
457+
Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.
455458
:param gateway_id: ID of the gateway to upgrade.
456459
:param zone: Zone to target. If none is passed will use default zone from the config.
460+
:param type_: Gateway type (commercial offer).
457461
:return: :class:`Gateway <Gateway>`
458462
459463
Usage:
@@ -470,7 +474,14 @@ def upgrade_gateway(
470474
res = self._request(
471475
"POST",
472476
f"/vpc-gw/v1/zones/{param_zone}/gateways/{param_gateway_id}/upgrade",
473-
body={},
477+
body=marshal_UpgradeGatewayRequest(
478+
UpgradeGatewayRequest(
479+
gateway_id=gateway_id,
480+
zone=zone,
481+
type_=type_,
482+
),
483+
self.client,
484+
),
474485
)
475486

476487
self._throw_on_error(res)

scaleway/scaleway/vpcgw/v1/marshalling.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
UpdateGatewayRequest,
4646
UpdateIPRequest,
4747
UpdatePATRuleRequest,
48+
UpgradeGatewayRequest,
4849
)
4950

5051

@@ -1127,3 +1128,15 @@ def marshal_UpdatePATRuleRequest(
11271128
output["protocol"] = str(request.protocol)
11281129

11291130
return output
1131+
1132+
1133+
def marshal_UpgradeGatewayRequest(
1134+
request: UpgradeGatewayRequest,
1135+
defaults: ProfileDefaults,
1136+
) -> Dict[str, Any]:
1137+
output: Dict[str, Any] = {}
1138+
1139+
if request.type_ is not None:
1140+
output["type"] = request.type_
1141+
1142+
return output

scaleway/scaleway/vpcgw/v1/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,3 +1746,8 @@ class UpgradeGatewayRequest:
17461746
"""
17471747
Zone to target. If none is passed will use default zone from the config.
17481748
"""
1749+
1750+
type_: Optional[str]
1751+
"""
1752+
Gateway type (commercial offer).
1753+
"""

0 commit comments

Comments
 (0)