Skip to content

Commit

Permalink
feat(vpc_gw): add a call to migrate a V1 gateway to V2 (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Feb 21, 2025
1 parent dade839 commit 2f2d13c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/vpcgw/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .types import ListIPsResponse
from .types import ListPATRulesRequest
from .types import ListPATRulesResponse
from .types import MigrateToV2Request
from .types import RefreshSSHKeysRequest
from .types import SetDHCPEntriesRequest
from .types import SetDHCPEntriesResponse
Expand Down Expand Up @@ -129,6 +130,7 @@
"ListIPsResponse",
"ListPATRulesRequest",
"ListPATRulesResponse",
"MigrateToV2Request",
"RefreshSSHKeysRequest",
"SetDHCPEntriesRequest",
"SetDHCPEntriesResponse",
Expand Down
29 changes: 29 additions & 0 deletions scaleway-async/scaleway_async/vpcgw/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2080,3 +2080,32 @@ async def refresh_ssh_keys(

self._throw_on_error(res)
return unmarshal_Gateway(res.json())

async def migrate_to_v2(
self,
*,
gateway_id: str,
zone: Optional[ScwZone] = None,
) -> None:
"""
:param gateway_id:
:param zone: Zone to target. If none is passed will use default zone from the config.
Usage:
::
result = await api.migrate_to_v2(
gateway_id="example",
)
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
param_gateway_id = validate_path_param("gateway_id", gateway_id)

res = self._request(
"POST",
f"/vpc-gw/v1/zones/{param_zone}/gateways/{param_gateway_id}/migrate-to-v2",
body={},
)

self._throw_on_error(res)
10 changes: 10 additions & 0 deletions scaleway-async/scaleway_async/vpcgw/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,16 @@ class ListPATRulesResponse:
"""


@dataclass
class MigrateToV2Request:
gateway_id: str

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
"""


@dataclass
class RefreshSSHKeysRequest:
gateway_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/vpcgw/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .types import ListIPsResponse
from .types import ListPATRulesRequest
from .types import ListPATRulesResponse
from .types import MigrateToV2Request
from .types import RefreshSSHKeysRequest
from .types import SetDHCPEntriesRequest
from .types import SetDHCPEntriesResponse
Expand Down Expand Up @@ -129,6 +130,7 @@
"ListIPsResponse",
"ListPATRulesRequest",
"ListPATRulesResponse",
"MigrateToV2Request",
"RefreshSSHKeysRequest",
"SetDHCPEntriesRequest",
"SetDHCPEntriesResponse",
Expand Down
29 changes: 29 additions & 0 deletions scaleway/scaleway/vpcgw/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2078,3 +2078,32 @@ def refresh_ssh_keys(

self._throw_on_error(res)
return unmarshal_Gateway(res.json())

def migrate_to_v2(
self,
*,
gateway_id: str,
zone: Optional[ScwZone] = None,
) -> None:
"""
:param gateway_id:
:param zone: Zone to target. If none is passed will use default zone from the config.
Usage:
::
result = api.migrate_to_v2(
gateway_id="example",
)
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
param_gateway_id = validate_path_param("gateway_id", gateway_id)

res = self._request(
"POST",
f"/vpc-gw/v1/zones/{param_zone}/gateways/{param_gateway_id}/migrate-to-v2",
body={},
)

self._throw_on_error(res)
10 changes: 10 additions & 0 deletions scaleway/scaleway/vpcgw/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,16 @@ class ListPATRulesResponse:
"""


@dataclass
class MigrateToV2Request:
gateway_id: str

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
"""


@dataclass
class RefreshSSHKeysRequest:
gateway_id: str
Expand Down

0 comments on commit 2f2d13c

Please sign in to comment.