Skip to content

Commit 80f03ec

Browse files
scaleway-botyfodil
andauthored
feat(webhosting): add new endpoint to migrate control panel (#1445)
Co-authored-by: Yacine Fodil <[email protected]>
1 parent ff0be9e commit 80f03ec

File tree

8 files changed

+182
-0
lines changed

8 files changed

+182
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
from .types import HostingApiGetHostingRequest
101101
from .types import HostingApiGetResourceSummaryRequest
102102
from .types import HostingApiListHostingsRequest
103+
from .types import HostingApiMigrateControlPanelRequest
103104
from .types import HostingApiRemoveCustomDomainRequest
104105
from .types import HostingApiResetHostingPasswordRequest
105106
from .types import HostingApiUpdateHostingRequest
@@ -242,6 +243,7 @@
242243
"HostingApiGetHostingRequest",
243244
"HostingApiGetResourceSummaryRequest",
244245
"HostingApiListHostingsRequest",
246+
"HostingApiMigrateControlPanelRequest",
245247
"HostingApiRemoveCustomDomainRequest",
246248
"HostingApiResetHostingPasswordRequest",
247249
"HostingApiUpdateHostingRequest",

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
Hosting,
5050
HostingApiAddCustomDomainRequest,
5151
HostingApiCreateHostingRequest,
52+
HostingApiMigrateControlPanelRequest,
5253
HostingApiRemoveCustomDomainRequest,
5354
HostingApiUpdateHostingRequest,
5455
HostingSummary,
@@ -131,6 +132,7 @@
131132
marshal_FtpAccountApiCreateFtpAccountRequest,
132133
marshal_HostingApiAddCustomDomainRequest,
133134
marshal_HostingApiCreateHostingRequest,
135+
marshal_HostingApiMigrateControlPanelRequest,
134136
marshal_HostingApiRemoveCustomDomainRequest,
135137
marshal_HostingApiUpdateHostingRequest,
136138
marshal_MailAccountApiChangeMailAccountPasswordRequest,
@@ -2032,6 +2034,54 @@ async def remove_custom_domain(
20322034
self._throw_on_error(res)
20332035
return unmarshal_HostingSummary(res.json())
20342036

2037+
async def migrate_control_panel(
2038+
self,
2039+
*,
2040+
hosting_id: str,
2041+
control_panel_name: str,
2042+
offer_id: str,
2043+
region: Optional[ScwRegion] = None,
2044+
) -> HostingSummary:
2045+
"""
2046+
Migrate a hosting to a new control panel.
2047+
:param hosting_id: Hosting ID to migrate to a new control panel.
2048+
:param control_panel_name: Control panel will migrate the hosting to a new server.
2049+
:param offer_id: Migration.
2050+
:param region: Region to target. If none is passed will use default region from the config.
2051+
:return: :class:`HostingSummary <HostingSummary>`
2052+
2053+
Usage:
2054+
::
2055+
2056+
result = await api.migrate_control_panel(
2057+
hosting_id="example",
2058+
control_panel_name="example",
2059+
offer_id="example",
2060+
)
2061+
"""
2062+
2063+
param_region = validate_path_param(
2064+
"region", region or self.client.default_region
2065+
)
2066+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
2067+
2068+
res = self._request(
2069+
"POST",
2070+
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/migrate-control-panel",
2071+
body=marshal_HostingApiMigrateControlPanelRequest(
2072+
HostingApiMigrateControlPanelRequest(
2073+
hosting_id=hosting_id,
2074+
control_panel_name=control_panel_name,
2075+
offer_id=offer_id,
2076+
region=region,
2077+
),
2078+
self.client,
2079+
),
2080+
)
2081+
2082+
self._throw_on_error(res)
2083+
return unmarshal_HostingSummary(res.json())
2084+
20352085

20362086
class WebhostingV1FreeDomainAPI(API):
20372087
"""

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
CreateHostingRequestDomainConfiguration,
9797
OfferOptionRequest,
9898
HostingApiCreateHostingRequest,
99+
HostingApiMigrateControlPanelRequest,
99100
HostingApiRemoveCustomDomainRequest,
100101
HostingApiUpdateHostingRequest,
101102
MailAccountApiChangeMailAccountPasswordRequest,
@@ -2074,6 +2075,21 @@ def marshal_HostingApiCreateHostingRequest(
20742075
return output
20752076

20762077

2078+
def marshal_HostingApiMigrateControlPanelRequest(
2079+
request: HostingApiMigrateControlPanelRequest,
2080+
defaults: ProfileDefaults,
2081+
) -> dict[str, Any]:
2082+
output: dict[str, Any] = {}
2083+
2084+
if request.control_panel_name is not None:
2085+
output["control_panel_name"] = request.control_panel_name
2086+
2087+
if request.offer_id is not None:
2088+
output["offer_id"] = request.offer_id
2089+
2090+
return output
2091+
2092+
20772093
def marshal_HostingApiRemoveCustomDomainRequest(
20782094
request: HostingApiRemoveCustomDomainRequest,
20792095
defaults: ProfileDefaults,

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,29 @@ class HostingApiListHostingsRequest:
19571957
"""
19581958

19591959

1960+
@dataclass
1961+
class HostingApiMigrateControlPanelRequest:
1962+
hosting_id: str
1963+
"""
1964+
Hosting ID to migrate to a new control panel.
1965+
"""
1966+
1967+
control_panel_name: str
1968+
"""
1969+
Control panel will migrate the hosting to a new server.
1970+
"""
1971+
1972+
offer_id: str
1973+
"""
1974+
Migration.
1975+
"""
1976+
1977+
region: Optional[ScwRegion] = None
1978+
"""
1979+
Region to target. If none is passed will use default region from the config.
1980+
"""
1981+
1982+
19601983
@dataclass
19611984
class HostingApiRemoveCustomDomainRequest:
19621985
hosting_id: str

scaleway/scaleway/webhosting/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
from .types import HostingApiGetHostingRequest
101101
from .types import HostingApiGetResourceSummaryRequest
102102
from .types import HostingApiListHostingsRequest
103+
from .types import HostingApiMigrateControlPanelRequest
103104
from .types import HostingApiRemoveCustomDomainRequest
104105
from .types import HostingApiResetHostingPasswordRequest
105106
from .types import HostingApiUpdateHostingRequest
@@ -242,6 +243,7 @@
242243
"HostingApiGetHostingRequest",
243244
"HostingApiGetResourceSummaryRequest",
244245
"HostingApiListHostingsRequest",
246+
"HostingApiMigrateControlPanelRequest",
245247
"HostingApiRemoveCustomDomainRequest",
246248
"HostingApiResetHostingPasswordRequest",
247249
"HostingApiUpdateHostingRequest",

scaleway/scaleway/webhosting/v1/api.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
Hosting,
5050
HostingApiAddCustomDomainRequest,
5151
HostingApiCreateHostingRequest,
52+
HostingApiMigrateControlPanelRequest,
5253
HostingApiRemoveCustomDomainRequest,
5354
HostingApiUpdateHostingRequest,
5455
HostingSummary,
@@ -131,6 +132,7 @@
131132
marshal_FtpAccountApiCreateFtpAccountRequest,
132133
marshal_HostingApiAddCustomDomainRequest,
133134
marshal_HostingApiCreateHostingRequest,
135+
marshal_HostingApiMigrateControlPanelRequest,
134136
marshal_HostingApiRemoveCustomDomainRequest,
135137
marshal_HostingApiUpdateHostingRequest,
136138
marshal_MailAccountApiChangeMailAccountPasswordRequest,
@@ -2032,6 +2034,54 @@ def remove_custom_domain(
20322034
self._throw_on_error(res)
20332035
return unmarshal_HostingSummary(res.json())
20342036

2037+
def migrate_control_panel(
2038+
self,
2039+
*,
2040+
hosting_id: str,
2041+
control_panel_name: str,
2042+
offer_id: str,
2043+
region: Optional[ScwRegion] = None,
2044+
) -> HostingSummary:
2045+
"""
2046+
Migrate a hosting to a new control panel.
2047+
:param hosting_id: Hosting ID to migrate to a new control panel.
2048+
:param control_panel_name: Control panel will migrate the hosting to a new server.
2049+
:param offer_id: Migration.
2050+
:param region: Region to target. If none is passed will use default region from the config.
2051+
:return: :class:`HostingSummary <HostingSummary>`
2052+
2053+
Usage:
2054+
::
2055+
2056+
result = api.migrate_control_panel(
2057+
hosting_id="example",
2058+
control_panel_name="example",
2059+
offer_id="example",
2060+
)
2061+
"""
2062+
2063+
param_region = validate_path_param(
2064+
"region", region or self.client.default_region
2065+
)
2066+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
2067+
2068+
res = self._request(
2069+
"POST",
2070+
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/migrate-control-panel",
2071+
body=marshal_HostingApiMigrateControlPanelRequest(
2072+
HostingApiMigrateControlPanelRequest(
2073+
hosting_id=hosting_id,
2074+
control_panel_name=control_panel_name,
2075+
offer_id=offer_id,
2076+
region=region,
2077+
),
2078+
self.client,
2079+
),
2080+
)
2081+
2082+
self._throw_on_error(res)
2083+
return unmarshal_HostingSummary(res.json())
2084+
20352085

20362086
class WebhostingV1FreeDomainAPI(API):
20372087
"""

scaleway/scaleway/webhosting/v1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
CreateHostingRequestDomainConfiguration,
9797
OfferOptionRequest,
9898
HostingApiCreateHostingRequest,
99+
HostingApiMigrateControlPanelRequest,
99100
HostingApiRemoveCustomDomainRequest,
100101
HostingApiUpdateHostingRequest,
101102
MailAccountApiChangeMailAccountPasswordRequest,
@@ -2074,6 +2075,21 @@ def marshal_HostingApiCreateHostingRequest(
20742075
return output
20752076

20762077

2078+
def marshal_HostingApiMigrateControlPanelRequest(
2079+
request: HostingApiMigrateControlPanelRequest,
2080+
defaults: ProfileDefaults,
2081+
) -> dict[str, Any]:
2082+
output: dict[str, Any] = {}
2083+
2084+
if request.control_panel_name is not None:
2085+
output["control_panel_name"] = request.control_panel_name
2086+
2087+
if request.offer_id is not None:
2088+
output["offer_id"] = request.offer_id
2089+
2090+
return output
2091+
2092+
20772093
def marshal_HostingApiRemoveCustomDomainRequest(
20782094
request: HostingApiRemoveCustomDomainRequest,
20792095
defaults: ProfileDefaults,

scaleway/scaleway/webhosting/v1/types.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,29 @@ class HostingApiListHostingsRequest:
19571957
"""
19581958

19591959

1960+
@dataclass
1961+
class HostingApiMigrateControlPanelRequest:
1962+
hosting_id: str
1963+
"""
1964+
Hosting ID to migrate to a new control panel.
1965+
"""
1966+
1967+
control_panel_name: str
1968+
"""
1969+
Control panel will migrate the hosting to a new server.
1970+
"""
1971+
1972+
offer_id: str
1973+
"""
1974+
Migration.
1975+
"""
1976+
1977+
region: Optional[ScwRegion] = None
1978+
"""
1979+
Region to target. If none is passed will use default region from the config.
1980+
"""
1981+
1982+
19601983
@dataclass
19611984
class HostingApiRemoveCustomDomainRequest:
19621985
hosting_id: str

0 commit comments

Comments
 (0)