From 1b0b6ffd7ca55279b822d18eb22e3a5abdbe1c87 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 28 Oct 2025 14:42:17 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/webhosting/v1/__init__.py | 4 + .../scaleway_async/webhosting/v1/api.py | 84 ++++++++++++++++++- .../webhosting/v1/marshalling.py | 73 +++++++++------- .../scaleway_async/webhosting/v1/types.py | 36 ++++++++ scaleway/scaleway/webhosting/v1/__init__.py | 4 + scaleway/scaleway/webhosting/v1/api.py | 84 ++++++++++++++++++- .../scaleway/webhosting/v1/marshalling.py | 73 +++++++++------- scaleway/scaleway/webhosting/v1/types.py | 36 ++++++++ 8 files changed, 332 insertions(+), 62 deletions(-) diff --git a/scaleway-async/scaleway_async/webhosting/v1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1/__init__.py index 797369354..826fc5db2 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/__init__.py +++ b/scaleway-async/scaleway_async/webhosting/v1/__init__.py @@ -127,6 +127,8 @@ from .types import RestoreBackupResponse from .types import SearchDomainsResponse from .types import Session +from .types import WebsiteApiCreateWebsiteRequest +from .types import WebsiteApiDeleteWebsiteRequest from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1BackupAPI from .api import WebhostingV1ControlPanelAPI @@ -267,6 +269,8 @@ "RestoreBackupResponse", "SearchDomainsResponse", "Session", + "WebsiteApiCreateWebsiteRequest", + "WebsiteApiDeleteWebsiteRequest", "WebsiteApiListWebsitesRequest", "WebhostingV1BackupAPI", "WebhostingV1ControlPanelAPI", diff --git a/scaleway-async/scaleway_async/webhosting/v1/api.py b/scaleway-async/scaleway_async/webhosting/v1/api.py index 3dabe73c4..899e2a8f0 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/api.py +++ b/scaleway-async/scaleway_async/webhosting/v1/api.py @@ -79,6 +79,7 @@ Session, SyncDomainDnsRecordsRequestRecord, Website, + WebsiteApiCreateWebsiteRequest, ) from .content import ( BACKUP_TRANSIENT_STATUSES, @@ -92,6 +93,7 @@ unmarshal_FtpAccount, unmarshal_HostingSummary, unmarshal_MailAccount, + unmarshal_Website, unmarshal_CheckFreeDomainAvailabilityResponse, unmarshal_CheckUserOwnsDomainResponse, unmarshal_DnsRecords, @@ -134,6 +136,7 @@ marshal_MailAccountApiChangeMailAccountPasswordRequest, marshal_MailAccountApiCreateMailAccountRequest, marshal_MailAccountApiRemoveMailAccountRequest, + marshal_WebsiteApiCreateWebsiteRequest, ) from ...std.types import ( LanguageCode as StdLanguageCode, @@ -1949,7 +1952,7 @@ async def add_custom_domain( region: Optional[ScwRegion] = None, ) -> HostingSummary: """ - Attach a custom domain to a webhosting. + Attach a custom domain to a webhosting as an alias to the main domain. :param hosting_id: Hosting ID to which the custom domain is attached to. :param domain_name: The custom domain name to attach to the hosting. :param region: Region to target. If none is passed will use default region from the config. @@ -2712,3 +2715,82 @@ async def list_websites_all( "order_by": order_by, }, ) + + async def create_website( + self, + *, + hosting_id: str, + domain_name: str, + region: Optional[ScwRegion] = None, + ) -> Website: + """ + Create a new website and attach it to a webhosting. + :param hosting_id: Hosting ID to which the website is attached to. + :param domain_name: The new domain name or subdomain to use for the website. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Website ` + + Usage: + :: + + result = await api.create_website( + hosting_id="example", + domain_name="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}/websites", + body=marshal_WebsiteApiCreateWebsiteRequest( + WebsiteApiCreateWebsiteRequest( + hosting_id=hosting_id, + domain_name=domain_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Website(res.json()) + + async def delete_website( + self, + *, + hosting_id: str, + domain_name: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a website from a webhosting. + :param hosting_id: Hosting ID to which the website is detached from. + :param domain_name: The new domain name or subdomain attached to the website. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_website( + hosting_id="example", + domain_name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_domain_name = validate_path_param("domain_name", domain_name) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/websites/{param_domain_name}", + ) + + self._throw_on_error(res) diff --git a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py index 4a569d7f4..a530aa9f9 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py +++ b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py @@ -40,6 +40,7 @@ HostingDomain, HostingSummary, MailAccount, + Website, FreeDomain, CheckFreeDomainAvailabilityResponse, CheckUserOwnsDomainResponse, @@ -69,7 +70,6 @@ ListOffersResponse, ProgressSummary, ListRecentProgressesResponse, - Website, ListWebsitesResponse, Progress, ResetHostingPasswordResponse, @@ -101,6 +101,7 @@ MailAccountApiChangeMailAccountPasswordRequest, MailAccountApiCreateMailAccountRequest, MailAccountApiRemoveMailAccountRequest, + WebsiteApiCreateWebsiteRequest, ) from ...std.types import ( LanguageCode as StdLanguageCode, @@ -422,6 +423,35 @@ def unmarshal_MailAccount(data: Any) -> MailAccount: return MailAccount(**args) +def unmarshal_Website(data: Any) -> Website: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Website' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + else: + args["domain"] = None + + field = data.get("path", None) + if field is not None: + args["path"] = field + else: + args["path"] = None + + field = data.get("ssl_status", None) + if field is not None: + args["ssl_status"] = field + else: + args["ssl_status"] = False + + return Website(**args) + + def unmarshal_FreeDomain(data: Any) -> FreeDomain: if not isinstance(data, dict): raise TypeError( @@ -1459,35 +1489,6 @@ def unmarshal_ListRecentProgressesResponse(data: Any) -> ListRecentProgressesRes return ListRecentProgressesResponse(**args) -def unmarshal_Website(data: Any) -> Website: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Website' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("domain", None) - if field is not None: - args["domain"] = field - else: - args["domain"] = None - - field = data.get("path", None) - if field is not None: - args["path"] = field - else: - args["path"] = None - - field = data.get("ssl_status", None) - if field is not None: - args["ssl_status"] = field - else: - args["ssl_status"] = False - - return Website(**args) - - def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse: if not isinstance(data, dict): raise TypeError( @@ -2152,3 +2153,15 @@ def marshal_MailAccountApiRemoveMailAccountRequest( output["username"] = request.username return output + + +def marshal_WebsiteApiCreateWebsiteRequest( + request: WebsiteApiCreateWebsiteRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.domain_name is not None: + output["domain_name"] = request.domain_name + + return output diff --git a/scaleway-async/scaleway_async/webhosting/v1/types.py b/scaleway-async/scaleway_async/webhosting/v1/types.py index b3ef08f04..0749a3df5 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/types.py +++ b/scaleway-async/scaleway_async/webhosting/v1/types.py @@ -2409,6 +2409,42 @@ class Session: """ +@dataclass +class WebsiteApiCreateWebsiteRequest: + hosting_id: str + """ + Hosting ID to which the website is attached to. + """ + + domain_name: str + """ + The new domain name or subdomain to use for the website. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class WebsiteApiDeleteWebsiteRequest: + hosting_id: str + """ + Hosting ID to which the website is detached from. + """ + + domain_name: str + """ + The new domain name or subdomain attached to the website. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class WebsiteApiListWebsitesRequest: hosting_id: str diff --git a/scaleway/scaleway/webhosting/v1/__init__.py b/scaleway/scaleway/webhosting/v1/__init__.py index 797369354..826fc5db2 100644 --- a/scaleway/scaleway/webhosting/v1/__init__.py +++ b/scaleway/scaleway/webhosting/v1/__init__.py @@ -127,6 +127,8 @@ from .types import RestoreBackupResponse from .types import SearchDomainsResponse from .types import Session +from .types import WebsiteApiCreateWebsiteRequest +from .types import WebsiteApiDeleteWebsiteRequest from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1BackupAPI from .api import WebhostingV1ControlPanelAPI @@ -267,6 +269,8 @@ "RestoreBackupResponse", "SearchDomainsResponse", "Session", + "WebsiteApiCreateWebsiteRequest", + "WebsiteApiDeleteWebsiteRequest", "WebsiteApiListWebsitesRequest", "WebhostingV1BackupAPI", "WebhostingV1ControlPanelAPI", diff --git a/scaleway/scaleway/webhosting/v1/api.py b/scaleway/scaleway/webhosting/v1/api.py index 19a5c25a4..815e17446 100644 --- a/scaleway/scaleway/webhosting/v1/api.py +++ b/scaleway/scaleway/webhosting/v1/api.py @@ -79,6 +79,7 @@ Session, SyncDomainDnsRecordsRequestRecord, Website, + WebsiteApiCreateWebsiteRequest, ) from .content import ( BACKUP_TRANSIENT_STATUSES, @@ -92,6 +93,7 @@ unmarshal_FtpAccount, unmarshal_HostingSummary, unmarshal_MailAccount, + unmarshal_Website, unmarshal_CheckFreeDomainAvailabilityResponse, unmarshal_CheckUserOwnsDomainResponse, unmarshal_DnsRecords, @@ -134,6 +136,7 @@ marshal_MailAccountApiChangeMailAccountPasswordRequest, marshal_MailAccountApiCreateMailAccountRequest, marshal_MailAccountApiRemoveMailAccountRequest, + marshal_WebsiteApiCreateWebsiteRequest, ) from ...std.types import ( LanguageCode as StdLanguageCode, @@ -1949,7 +1952,7 @@ def add_custom_domain( region: Optional[ScwRegion] = None, ) -> HostingSummary: """ - Attach a custom domain to a webhosting. + Attach a custom domain to a webhosting as an alias to the main domain. :param hosting_id: Hosting ID to which the custom domain is attached to. :param domain_name: The custom domain name to attach to the hosting. :param region: Region to target. If none is passed will use default region from the config. @@ -2712,3 +2715,82 @@ def list_websites_all( "order_by": order_by, }, ) + + def create_website( + self, + *, + hosting_id: str, + domain_name: str, + region: Optional[ScwRegion] = None, + ) -> Website: + """ + Create a new website and attach it to a webhosting. + :param hosting_id: Hosting ID to which the website is attached to. + :param domain_name: The new domain name or subdomain to use for the website. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Website ` + + Usage: + :: + + result = api.create_website( + hosting_id="example", + domain_name="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}/websites", + body=marshal_WebsiteApiCreateWebsiteRequest( + WebsiteApiCreateWebsiteRequest( + hosting_id=hosting_id, + domain_name=domain_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Website(res.json()) + + def delete_website( + self, + *, + hosting_id: str, + domain_name: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a website from a webhosting. + :param hosting_id: Hosting ID to which the website is detached from. + :param domain_name: The new domain name or subdomain attached to the website. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_website( + hosting_id="example", + domain_name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_domain_name = validate_path_param("domain_name", domain_name) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/websites/{param_domain_name}", + ) + + self._throw_on_error(res) diff --git a/scaleway/scaleway/webhosting/v1/marshalling.py b/scaleway/scaleway/webhosting/v1/marshalling.py index 4a569d7f4..a530aa9f9 100644 --- a/scaleway/scaleway/webhosting/v1/marshalling.py +++ b/scaleway/scaleway/webhosting/v1/marshalling.py @@ -40,6 +40,7 @@ HostingDomain, HostingSummary, MailAccount, + Website, FreeDomain, CheckFreeDomainAvailabilityResponse, CheckUserOwnsDomainResponse, @@ -69,7 +70,6 @@ ListOffersResponse, ProgressSummary, ListRecentProgressesResponse, - Website, ListWebsitesResponse, Progress, ResetHostingPasswordResponse, @@ -101,6 +101,7 @@ MailAccountApiChangeMailAccountPasswordRequest, MailAccountApiCreateMailAccountRequest, MailAccountApiRemoveMailAccountRequest, + WebsiteApiCreateWebsiteRequest, ) from ...std.types import ( LanguageCode as StdLanguageCode, @@ -422,6 +423,35 @@ def unmarshal_MailAccount(data: Any) -> MailAccount: return MailAccount(**args) +def unmarshal_Website(data: Any) -> Website: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Website' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + else: + args["domain"] = None + + field = data.get("path", None) + if field is not None: + args["path"] = field + else: + args["path"] = None + + field = data.get("ssl_status", None) + if field is not None: + args["ssl_status"] = field + else: + args["ssl_status"] = False + + return Website(**args) + + def unmarshal_FreeDomain(data: Any) -> FreeDomain: if not isinstance(data, dict): raise TypeError( @@ -1459,35 +1489,6 @@ def unmarshal_ListRecentProgressesResponse(data: Any) -> ListRecentProgressesRes return ListRecentProgressesResponse(**args) -def unmarshal_Website(data: Any) -> Website: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Website' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("domain", None) - if field is not None: - args["domain"] = field - else: - args["domain"] = None - - field = data.get("path", None) - if field is not None: - args["path"] = field - else: - args["path"] = None - - field = data.get("ssl_status", None) - if field is not None: - args["ssl_status"] = field - else: - args["ssl_status"] = False - - return Website(**args) - - def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse: if not isinstance(data, dict): raise TypeError( @@ -2152,3 +2153,15 @@ def marshal_MailAccountApiRemoveMailAccountRequest( output["username"] = request.username return output + + +def marshal_WebsiteApiCreateWebsiteRequest( + request: WebsiteApiCreateWebsiteRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.domain_name is not None: + output["domain_name"] = request.domain_name + + return output diff --git a/scaleway/scaleway/webhosting/v1/types.py b/scaleway/scaleway/webhosting/v1/types.py index b3ef08f04..0749a3df5 100644 --- a/scaleway/scaleway/webhosting/v1/types.py +++ b/scaleway/scaleway/webhosting/v1/types.py @@ -2409,6 +2409,42 @@ class Session: """ +@dataclass +class WebsiteApiCreateWebsiteRequest: + hosting_id: str + """ + Hosting ID to which the website is attached to. + """ + + domain_name: str + """ + The new domain name or subdomain to use for the website. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class WebsiteApiDeleteWebsiteRequest: + hosting_id: str + """ + Hosting ID to which the website is detached from. + """ + + domain_name: str + """ + The new domain name or subdomain attached to the website. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class WebsiteApiListWebsitesRequest: hosting_id: str