Skip to content

Commit 1f991bb

Browse files
authored
feat(vpc_gw): support passing IPAM IP IDs (#343)
1 parent bb35735 commit 1f991bb

File tree

8 files changed

+160
-18
lines changed

8 files changed

+160
-18
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .types import ListIPsRequestOrderBy
1111
from .types import ListPATRulesRequestOrderBy
1212
from .types import PATRuleProtocol
13+
from .types import CreateGatewayNetworkRequestIpamConfig
1314
from .types import DHCP
1415
from .types import DHCPEntry
1516
from .types import Gateway
@@ -29,6 +30,7 @@
2930
from .types import SetDHCPEntriesResponse
3031
from .types import SetPATRulesRequestRule
3132
from .types import SetPATRulesResponse
33+
from .types import UpdateGatewayNetworkRequestIpamConfig
3234
from .content import GATEWAY_NETWORK_TRANSIENT_STATUSES
3335
from .content import GATEWAY_TRANSIENT_STATUSES
3436
from .api import VpcgwV1API
@@ -44,6 +46,7 @@
4446
"ListIPsRequestOrderBy",
4547
"ListPATRulesRequestOrderBy",
4648
"PATRuleProtocol",
49+
"CreateGatewayNetworkRequestIpamConfig",
4750
"DHCP",
4851
"DHCPEntry",
4952
"Gateway",
@@ -63,6 +66,7 @@
6366
"SetDHCPEntriesResponse",
6467
"SetPATRulesRequestRule",
6568
"SetPATRulesResponse",
69+
"UpdateGatewayNetworkRequestIpamConfig",
6670
"GATEWAY_NETWORK_TRANSIENT_STATUSES",
6771
"GATEWAY_TRANSIENT_STATUSES",
6872
"VpcgwV1API",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
ListIPsRequestOrderBy,
2626
ListPATRulesRequestOrderBy,
2727
PATRuleProtocol,
28+
CreateGatewayNetworkRequestIpamConfig,
2829
DHCP,
2930
DHCPEntry,
3031
Gateway,
3132
GatewayNetwork,
3233
IP,
33-
IpamConfig,
3434
ListDHCPEntriesResponse,
3535
ListDHCPsResponse,
3636
ListGatewayNetworksResponse,
@@ -43,6 +43,7 @@
4343
SetDHCPEntriesResponse,
4444
SetPATRulesRequestRule,
4545
SetPATRulesResponse,
46+
UpdateGatewayNetworkRequestIpamConfig,
4647
CreateGatewayRequest,
4748
UpdateGatewayRequest,
4849
CreateGatewayNetworkRequest,
@@ -654,7 +655,7 @@ async def create_gateway_network(
654655
dhcp_id: Optional[str] = None,
655656
dhcp: Optional[CreateDHCPRequest] = None,
656657
address: Optional[str] = None,
657-
ipam_config: Optional[IpamConfig] = None,
658+
ipam_config: Optional[CreateGatewayNetworkRequestIpamConfig] = None,
658659
) -> GatewayNetwork:
659660
"""
660661
Attach a Public Gateway to a Private Network.
@@ -725,7 +726,7 @@ async def update_gateway_network(
725726
enable_dhcp: Optional[bool] = None,
726727
dhcp_id: Optional[str] = None,
727728
address: Optional[str] = None,
728-
ipam_config: Optional[IpamConfig] = None,
729+
ipam_config: Optional[UpdateGatewayNetworkRequestIpamConfig] = None,
729730
) -> GatewayNetwork:
730731
"""
731732
Update a Public Gateway's connection to a Private Network.

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from dateutil import parser
1212
from .types import (
1313
PATRuleProtocol,
14+
CreateGatewayNetworkRequestIpamConfig,
1415
DHCP,
1516
DHCPEntry,
1617
Gateway,
@@ -30,6 +31,7 @@
3031
SetDHCPEntriesResponse,
3132
SetPATRulesRequestRule,
3233
SetPATRulesResponse,
34+
UpdateGatewayNetworkRequestIpamConfig,
3335
CreateGatewayRequest,
3436
UpdateGatewayRequest,
3537
CreateGatewayNetworkRequest,
@@ -123,6 +125,9 @@ def unmarshal_IpamConfig(data: Any) -> IpamConfig:
123125

124126
args: Dict[str, Any] = {}
125127

128+
field = data.get("ipam_ip_id", None)
129+
args["ipam_ip_id"] = field
130+
126131
field = data.get("push_default_route", None)
127132
args["push_default_route"] = field
128133

@@ -595,12 +600,15 @@ def marshal_CreateDHCPRequest(
595600
return output
596601

597602

598-
def marshal_IpamConfig(
599-
request: IpamConfig,
603+
def marshal_CreateGatewayNetworkRequestIpamConfig(
604+
request: CreateGatewayNetworkRequestIpamConfig,
600605
defaults: ProfileDefaults,
601606
) -> Dict[str, Any]:
602607
output: Dict[str, Any] = {}
603608

609+
if request.ipam_ip_id is not None:
610+
output["ipam_ip_id"] = request.ipam_ip_id
611+
604612
if request.push_default_route is not None:
605613
output["push_default_route"] = request.push_default_route
606614

@@ -643,6 +651,21 @@ def marshal_SetPATRulesRequestRule(
643651
return output
644652

645653

654+
def marshal_UpdateGatewayNetworkRequestIpamConfig(
655+
request: UpdateGatewayNetworkRequestIpamConfig,
656+
defaults: ProfileDefaults,
657+
) -> Dict[str, Any]:
658+
output: Dict[str, Any] = {}
659+
660+
if request.ipam_ip_id is not None:
661+
output["ipam_ip_id"] = request.ipam_ip_id
662+
663+
if request.push_default_route is not None:
664+
output["push_default_route"] = request.push_default_route
665+
666+
return output
667+
668+
646669
def marshal_CreateDHCPEntryRequest(
647670
request: CreateDHCPEntryRequest,
648671
defaults: ProfileDefaults,
@@ -683,7 +706,9 @@ def marshal_CreateGatewayNetworkRequest(
683706
),
684707
OneOfPossibility(
685708
"ipam_config",
686-
marshal_IpamConfig(request.ipam_config, defaults)
709+
marshal_CreateGatewayNetworkRequestIpamConfig(
710+
request.ipam_config, defaults
711+
)
687712
if request.ipam_config is not None
688713
else None,
689714
),
@@ -892,7 +917,9 @@ def marshal_UpdateGatewayNetworkRequest(
892917
),
893918
OneOfPossibility(
894919
"ipam_config",
895-
marshal_IpamConfig(request.ipam_config, defaults)
920+
marshal_UpdateGatewayNetworkRequestIpamConfig(
921+
request.ipam_config, defaults
922+
)
896923
if request.ipam_config is not None
897924
else None,
898925
),

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ def __str__(self) -> str:
131131
return str(self.value)
132132

133133

134+
@dataclass
135+
class CreateGatewayNetworkRequestIpamConfig:
136+
"""
137+
Create gateway network request. ipam config.
138+
"""
139+
140+
push_default_route: bool
141+
"""
142+
Enabling the default route also enables masquerading.
143+
"""
144+
145+
ipam_ip_id: Optional[str]
146+
"""
147+
Use this IPAM-booked IP ID as the Gateway's IP in this Private Network.
148+
"""
149+
150+
134151
@dataclass
135152
class DHCP:
136153
"""
@@ -549,6 +566,11 @@ class IpamConfig:
549566
Defines whether the default route is enabled on that Gateway Network.
550567
"""
551568

569+
ipam_ip_id: str
570+
"""
571+
IPAM-booked IP ID as the Gateway's IP in this Private Network.
572+
"""
573+
552574

553575
@dataclass
554576
class ListDHCPEntriesResponse:
@@ -786,6 +808,23 @@ class SetPATRulesResponse:
786808
"""
787809

788810

811+
@dataclass
812+
class UpdateGatewayNetworkRequestIpamConfig:
813+
"""
814+
Update gateway network request. ipam config.
815+
"""
816+
817+
push_default_route: Optional[bool]
818+
"""
819+
Enabling the default route also enables masquerading.
820+
"""
821+
822+
ipam_ip_id: Optional[str]
823+
"""
824+
Use this IPAM-booked IP ID as the Gateway's IP in this Private Network.
825+
"""
826+
827+
789828
@dataclass
790829
class ListGatewaysRequest:
791830
zone: Optional[Zone]
@@ -1096,7 +1135,7 @@ class CreateGatewayNetworkRequest:
10961135
One-of ('ip_config'): at most one of 'dhcp_id', 'dhcp', 'address', 'ipam_config' could be set.
10971136
"""
10981137

1099-
ipam_config: Optional[IpamConfig]
1138+
ipam_config: Optional[CreateGatewayNetworkRequestIpamConfig]
11001139
"""
11011140
Auto-configure the GatewayNetwork using Scaleway's IPAM (IP address management service).
11021141
Note: all or none of the GatewayNetworks for a single gateway can use the IPAM. DHCP and IPAM configurations cannot be mixed. Some products may require that the Public Gateway uses the IPAM, to ensure correct functionality.
@@ -1144,7 +1183,7 @@ class UpdateGatewayNetworkRequest:
11441183
One-of ('ip_config'): at most one of 'dhcp_id', 'address', 'ipam_config' could be set.
11451184
"""
11461185

1147-
ipam_config: Optional[IpamConfig]
1186+
ipam_config: Optional[UpdateGatewayNetworkRequestIpamConfig]
11481187
"""
11491188
Auto-configure the GatewayNetwork using Scaleway's IPAM (IP address management service).
11501189
Note: all or none of the GatewayNetworks for a single gateway can use the IPAM. DHCP and IPAM configurations cannot be mixed. Some products may require that the Public Gateway uses the IPAM, to ensure correct functionality.

scaleway/scaleway/vpcgw/v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .types import ListIPsRequestOrderBy
1111
from .types import ListPATRulesRequestOrderBy
1212
from .types import PATRuleProtocol
13+
from .types import CreateGatewayNetworkRequestIpamConfig
1314
from .types import DHCP
1415
from .types import DHCPEntry
1516
from .types import Gateway
@@ -29,6 +30,7 @@
2930
from .types import SetDHCPEntriesResponse
3031
from .types import SetPATRulesRequestRule
3132
from .types import SetPATRulesResponse
33+
from .types import UpdateGatewayNetworkRequestIpamConfig
3234
from .content import GATEWAY_NETWORK_TRANSIENT_STATUSES
3335
from .content import GATEWAY_TRANSIENT_STATUSES
3436
from .api import VpcgwV1API
@@ -44,6 +46,7 @@
4446
"ListIPsRequestOrderBy",
4547
"ListPATRulesRequestOrderBy",
4648
"PATRuleProtocol",
49+
"CreateGatewayNetworkRequestIpamConfig",
4750
"DHCP",
4851
"DHCPEntry",
4952
"Gateway",
@@ -63,6 +66,7 @@
6366
"SetDHCPEntriesResponse",
6467
"SetPATRulesRequestRule",
6568
"SetPATRulesResponse",
69+
"UpdateGatewayNetworkRequestIpamConfig",
6670
"GATEWAY_NETWORK_TRANSIENT_STATUSES",
6771
"GATEWAY_TRANSIENT_STATUSES",
6872
"VpcgwV1API",

scaleway/scaleway/vpcgw/v1/api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
ListIPsRequestOrderBy,
2626
ListPATRulesRequestOrderBy,
2727
PATRuleProtocol,
28+
CreateGatewayNetworkRequestIpamConfig,
2829
DHCP,
2930
DHCPEntry,
3031
Gateway,
3132
GatewayNetwork,
3233
IP,
33-
IpamConfig,
3434
ListDHCPEntriesResponse,
3535
ListDHCPsResponse,
3636
ListGatewayNetworksResponse,
@@ -43,6 +43,7 @@
4343
SetDHCPEntriesResponse,
4444
SetPATRulesRequestRule,
4545
SetPATRulesResponse,
46+
UpdateGatewayNetworkRequestIpamConfig,
4647
CreateGatewayRequest,
4748
UpdateGatewayRequest,
4849
CreateGatewayNetworkRequest,
@@ -652,7 +653,7 @@ def create_gateway_network(
652653
dhcp_id: Optional[str] = None,
653654
dhcp: Optional[CreateDHCPRequest] = None,
654655
address: Optional[str] = None,
655-
ipam_config: Optional[IpamConfig] = None,
656+
ipam_config: Optional[CreateGatewayNetworkRequestIpamConfig] = None,
656657
) -> GatewayNetwork:
657658
"""
658659
Attach a Public Gateway to a Private Network.
@@ -723,7 +724,7 @@ def update_gateway_network(
723724
enable_dhcp: Optional[bool] = None,
724725
dhcp_id: Optional[str] = None,
725726
address: Optional[str] = None,
726-
ipam_config: Optional[IpamConfig] = None,
727+
ipam_config: Optional[UpdateGatewayNetworkRequestIpamConfig] = None,
727728
) -> GatewayNetwork:
728729
"""
729730
Update a Public Gateway's connection to a Private Network.

scaleway/scaleway/vpcgw/v1/marshalling.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from dateutil import parser
1212
from .types import (
1313
PATRuleProtocol,
14+
CreateGatewayNetworkRequestIpamConfig,
1415
DHCP,
1516
DHCPEntry,
1617
Gateway,
@@ -30,6 +31,7 @@
3031
SetDHCPEntriesResponse,
3132
SetPATRulesRequestRule,
3233
SetPATRulesResponse,
34+
UpdateGatewayNetworkRequestIpamConfig,
3335
CreateGatewayRequest,
3436
UpdateGatewayRequest,
3537
CreateGatewayNetworkRequest,
@@ -123,6 +125,9 @@ def unmarshal_IpamConfig(data: Any) -> IpamConfig:
123125

124126
args: Dict[str, Any] = {}
125127

128+
field = data.get("ipam_ip_id", None)
129+
args["ipam_ip_id"] = field
130+
126131
field = data.get("push_default_route", None)
127132
args["push_default_route"] = field
128133

@@ -595,12 +600,15 @@ def marshal_CreateDHCPRequest(
595600
return output
596601

597602

598-
def marshal_IpamConfig(
599-
request: IpamConfig,
603+
def marshal_CreateGatewayNetworkRequestIpamConfig(
604+
request: CreateGatewayNetworkRequestIpamConfig,
600605
defaults: ProfileDefaults,
601606
) -> Dict[str, Any]:
602607
output: Dict[str, Any] = {}
603608

609+
if request.ipam_ip_id is not None:
610+
output["ipam_ip_id"] = request.ipam_ip_id
611+
604612
if request.push_default_route is not None:
605613
output["push_default_route"] = request.push_default_route
606614

@@ -643,6 +651,21 @@ def marshal_SetPATRulesRequestRule(
643651
return output
644652

645653

654+
def marshal_UpdateGatewayNetworkRequestIpamConfig(
655+
request: UpdateGatewayNetworkRequestIpamConfig,
656+
defaults: ProfileDefaults,
657+
) -> Dict[str, Any]:
658+
output: Dict[str, Any] = {}
659+
660+
if request.ipam_ip_id is not None:
661+
output["ipam_ip_id"] = request.ipam_ip_id
662+
663+
if request.push_default_route is not None:
664+
output["push_default_route"] = request.push_default_route
665+
666+
return output
667+
668+
646669
def marshal_CreateDHCPEntryRequest(
647670
request: CreateDHCPEntryRequest,
648671
defaults: ProfileDefaults,
@@ -683,7 +706,9 @@ def marshal_CreateGatewayNetworkRequest(
683706
),
684707
OneOfPossibility(
685708
"ipam_config",
686-
marshal_IpamConfig(request.ipam_config, defaults)
709+
marshal_CreateGatewayNetworkRequestIpamConfig(
710+
request.ipam_config, defaults
711+
)
687712
if request.ipam_config is not None
688713
else None,
689714
),
@@ -892,7 +917,9 @@ def marshal_UpdateGatewayNetworkRequest(
892917
),
893918
OneOfPossibility(
894919
"ipam_config",
895-
marshal_IpamConfig(request.ipam_config, defaults)
920+
marshal_UpdateGatewayNetworkRequestIpamConfig(
921+
request.ipam_config, defaults
922+
)
896923
if request.ipam_config is not None
897924
else None,
898925
),

0 commit comments

Comments
 (0)