Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@
from .types import HostingApiAddCustomDomainRequest
from .types import HostingApiCreateHostingRequest
from .types import HostingApiCreateSessionRequest
from .types import HostingApiDeleteHostingDomainsRequest
from .types import HostingApiDeleteHostingRequest
from .types import HostingApiGetHostingRequest
from .types import HostingApiGetResourceSummaryRequest
from .types import HostingApiListHostingsRequest
from .types import HostingApiMigrateControlPanelRequest
from .types import HostingApiRemoveCustomDomainRequest
from .types import HostingApiResetHostingPasswordRequest
from .types import HostingApiResetHostingRequest
from .types import HostingApiUpdateHostingFreeDomainRequest
from .types import HostingApiUpdateHostingRequest
from .types import ListBackupItemsResponse
from .types import ListBackupsResponse
Expand Down Expand Up @@ -239,13 +242,16 @@
"HostingApiAddCustomDomainRequest",
"HostingApiCreateHostingRequest",
"HostingApiCreateSessionRequest",
"HostingApiDeleteHostingDomainsRequest",
"HostingApiDeleteHostingRequest",
"HostingApiGetHostingRequest",
"HostingApiGetResourceSummaryRequest",
"HostingApiListHostingsRequest",
"HostingApiMigrateControlPanelRequest",
"HostingApiRemoveCustomDomainRequest",
"HostingApiResetHostingPasswordRequest",
"HostingApiResetHostingRequest",
"HostingApiUpdateHostingFreeDomainRequest",
"HostingApiUpdateHostingRequest",
"ListBackupItemsResponse",
"ListBackupsResponse",
Expand Down
128 changes: 128 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
Hosting,
HostingApiAddCustomDomainRequest,
HostingApiCreateHostingRequest,
HostingApiDeleteHostingDomainsRequest,
HostingApiMigrateControlPanelRequest,
HostingApiRemoveCustomDomainRequest,
HostingApiUpdateHostingFreeDomainRequest,
HostingApiUpdateHostingRequest,
HostingSummary,
ListBackupItemsResponse,
Expand Down Expand Up @@ -132,8 +134,10 @@
marshal_FtpAccountApiCreateFtpAccountRequest,
marshal_HostingApiAddCustomDomainRequest,
marshal_HostingApiCreateHostingRequest,
marshal_HostingApiDeleteHostingDomainsRequest,
marshal_HostingApiMigrateControlPanelRequest,
marshal_HostingApiRemoveCustomDomainRequest,
marshal_HostingApiUpdateHostingFreeDomainRequest,
marshal_HostingApiUpdateHostingRequest,
marshal_MailAccountApiChangeMailAccountPasswordRequest,
marshal_MailAccountApiCreateMailAccountRequest,
Expand Down Expand Up @@ -2082,6 +2086,130 @@ async def migrate_control_panel(
self._throw_on_error(res)
return unmarshal_HostingSummary(res.json())

async def reset_hosting(
self,
*,
hosting_id: str,
region: Optional[ScwRegion] = None,
) -> Hosting:
"""
Reset a Web Hosting plan.
Reset a Web Hosting plan to its initial state, specified by its `hosting_id`. This permanently deletes all hosting data including files, databases and emails. The hosting will be re-provisioned.
:param hosting_id: Hosting ID of the Web Hosting plan to reset.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Hosting <Hosting>`

Usage:
::

result = await api.reset_hosting(
hosting_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_hosting_id = validate_path_param("hosting_id", hosting_id)

res = self._request(
"POST",
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/reset",
body={},
)

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

async def delete_hosting_domains(
self,
*,
hosting_id: str,
region: Optional[ScwRegion] = None,
domains: Optional[list[str]] = None,
) -> Hosting:
"""
Delete domains from a Web Hosting plan.
Remove one or more domains from a Web Hosting plan, specified by its `hosting_id`. This permanently deletes the domains and all services tied to them, including mailboxes, FTP accounts and DNS zones.
:param hosting_id: Hosting ID of the Web Hosting plan from which to delete domains.
:param region: Region to target. If none is passed will use default region from the config.
:param domains: List of domains to delete from the Web Hosting plan.
:return: :class:`Hosting <Hosting>`

Usage:
::

result = await api.delete_hosting_domains(
hosting_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_hosting_id = validate_path_param("hosting_id", hosting_id)

res = self._request(
"POST",
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/delete-domains",
body=marshal_HostingApiDeleteHostingDomainsRequest(
HostingApiDeleteHostingDomainsRequest(
hosting_id=hosting_id,
region=region,
domains=domains,
),
self.client,
),
)

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

async def update_hosting_free_domain(
self,
*,
hosting_id: str,
free_domain: str,
region: Optional[ScwRegion] = None,
) -> Hosting:
"""
Update the free domain of a Web Hosting plan.
Change the free domain associated with a Web Hosting plan, specified by its `hosting_id`.
:param hosting_id: Hosting ID of the Web Hosting plan to update.
:param free_domain: New free domain to associate with the Web Hosting plan.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Hosting <Hosting>`

Usage:
::

result = await api.update_hosting_free_domain(
hosting_id="example",
free_domain="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_hosting_id = validate_path_param("hosting_id", hosting_id)

res = self._request(
"PATCH",
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/update-free-domain",
body=marshal_HostingApiUpdateHostingFreeDomainRequest(
HostingApiUpdateHostingFreeDomainRequest(
hosting_id=hosting_id,
free_domain=free_domain,
region=region,
),
self.client,
),
)

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


class WebhostingV1FreeDomainAPI(API):
"""
Expand Down
26 changes: 26 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@
CreateHostingRequestDomainConfiguration,
OfferOptionRequest,
HostingApiCreateHostingRequest,
HostingApiDeleteHostingDomainsRequest,
HostingApiMigrateControlPanelRequest,
HostingApiRemoveCustomDomainRequest,
HostingApiUpdateHostingFreeDomainRequest,
HostingApiUpdateHostingRequest,
MailAccountApiChangeMailAccountPasswordRequest,
MailAccountApiCreateMailAccountRequest,
Expand Down Expand Up @@ -2075,6 +2077,18 @@ def marshal_HostingApiCreateHostingRequest(
return output


def marshal_HostingApiDeleteHostingDomainsRequest(
request: HostingApiDeleteHostingDomainsRequest,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

if request.domains is not None:
output["domains"] = request.domains

return output


def marshal_HostingApiMigrateControlPanelRequest(
request: HostingApiMigrateControlPanelRequest,
defaults: ProfileDefaults,
Expand Down Expand Up @@ -2102,6 +2116,18 @@ def marshal_HostingApiRemoveCustomDomainRequest(
return output


def marshal_HostingApiUpdateHostingFreeDomainRequest(
request: HostingApiUpdateHostingFreeDomainRequest,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

if request.free_domain is not None:
output["free_domain"] = request.free_domain

return output


def marshal_HostingApiUpdateHostingRequest(
request: HostingApiUpdateHostingRequest,
defaults: ProfileDefaults,
Expand Down
49 changes: 49 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,24 @@ class HostingApiCreateSessionRequest:
"""


@dataclass
class HostingApiDeleteHostingDomainsRequest:
hosting_id: str
"""
Hosting ID of the Web Hosting plan from which to delete domains.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""

domains: Optional[list[str]] = field(default_factory=list)
"""
List of domains to delete from the Web Hosting plan.
"""


@dataclass
class HostingApiDeleteHostingRequest:
hosting_id: str
Expand Down Expand Up @@ -2011,6 +2029,37 @@ class HostingApiResetHostingPasswordRequest:
"""


@dataclass
class HostingApiResetHostingRequest:
hosting_id: str
"""
Hosting ID of the Web Hosting plan to reset.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class HostingApiUpdateHostingFreeDomainRequest:
hosting_id: str
"""
Hosting ID of the Web Hosting plan to update.
"""

free_domain: str
"""
New free domain to associate with the Web Hosting plan.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class HostingApiUpdateHostingRequest:
hosting_id: str
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@
from .types import HostingApiAddCustomDomainRequest
from .types import HostingApiCreateHostingRequest
from .types import HostingApiCreateSessionRequest
from .types import HostingApiDeleteHostingDomainsRequest
from .types import HostingApiDeleteHostingRequest
from .types import HostingApiGetHostingRequest
from .types import HostingApiGetResourceSummaryRequest
from .types import HostingApiListHostingsRequest
from .types import HostingApiMigrateControlPanelRequest
from .types import HostingApiRemoveCustomDomainRequest
from .types import HostingApiResetHostingPasswordRequest
from .types import HostingApiResetHostingRequest
from .types import HostingApiUpdateHostingFreeDomainRequest
from .types import HostingApiUpdateHostingRequest
from .types import ListBackupItemsResponse
from .types import ListBackupsResponse
Expand Down Expand Up @@ -239,13 +242,16 @@
"HostingApiAddCustomDomainRequest",
"HostingApiCreateHostingRequest",
"HostingApiCreateSessionRequest",
"HostingApiDeleteHostingDomainsRequest",
"HostingApiDeleteHostingRequest",
"HostingApiGetHostingRequest",
"HostingApiGetResourceSummaryRequest",
"HostingApiListHostingsRequest",
"HostingApiMigrateControlPanelRequest",
"HostingApiRemoveCustomDomainRequest",
"HostingApiResetHostingPasswordRequest",
"HostingApiResetHostingRequest",
"HostingApiUpdateHostingFreeDomainRequest",
"HostingApiUpdateHostingRequest",
"ListBackupItemsResponse",
"ListBackupsResponse",
Expand Down
Loading
Loading