diff --git a/scaleway-async/scaleway_async/webhosting/v1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1/__init__.py index cf1d49e5c..f3faa9b01 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/__init__.py +++ b/scaleway-async/scaleway_async/webhosting/v1/__init__.py @@ -48,6 +48,7 @@ from .types import HostingApiCreateSessionRequest from .types import HostingApiDeleteHostingRequest from .types import HostingApiGetHostingRequest +from .types import HostingApiGetResourceSummaryRequest from .types import HostingApiListHostingsRequest from .types import HostingApiResetHostingPasswordRequest from .types import HostingApiUpdateHostingRequest @@ -65,6 +66,7 @@ from .types import MailAccountApiRemoveMailAccountRequest from .types import OfferApiListOffersRequest from .types import ResetHostingPasswordResponse +from .types import ResourceSummary from .types import Session from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1ControlPanelAPI @@ -124,6 +126,7 @@ "HostingApiCreateSessionRequest", "HostingApiDeleteHostingRequest", "HostingApiGetHostingRequest", + "HostingApiGetResourceSummaryRequest", "HostingApiListHostingsRequest", "HostingApiResetHostingPasswordRequest", "HostingApiUpdateHostingRequest", @@ -141,6 +144,7 @@ "MailAccountApiRemoveMailAccountRequest", "OfferApiListOffersRequest", "ResetHostingPasswordResponse", + "ResourceSummary", "Session", "WebsiteApiListWebsitesRequest", "WebhostingV1ControlPanelAPI", diff --git a/scaleway-async/scaleway_async/webhosting/v1/api.py b/scaleway-async/scaleway_async/webhosting/v1/api.py index 484bd68bd..9f1fc4e67 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/api.py +++ b/scaleway-async/scaleway_async/webhosting/v1/api.py @@ -53,6 +53,7 @@ Offer, OfferOptionRequest, ResetHostingPasswordResponse, + ResourceSummary, Session, Website, ) @@ -74,6 +75,7 @@ unmarshal_ListOffersResponse, unmarshal_ListWebsitesResponse, unmarshal_ResetHostingPasswordResponse, + unmarshal_ResourceSummary, unmarshal_Session, marshal_DatabaseApiAssignDatabaseUserRequest, marshal_DatabaseApiChangeDatabaseUserPasswordRequest, @@ -1228,6 +1230,39 @@ async def reset_hosting_password( self._throw_on_error(res) return unmarshal_ResetHostingPasswordResponse(res.json()) + async def get_resource_summary( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> ResourceSummary: + """ + Get the total counts of websites, databases, email accounts, and FTP accounts of a Web Hosting plan. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ResourceSummary ` + + Usage: + :: + + result = await api.get_resource_summary( + 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( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/resource-summary", + ) + + self._throw_on_error(res) + return unmarshal_ResourceSummary(res.json()) + class WebhostingV1FtpAccountAPI(API): """ diff --git a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py index 08b656084..0229ea20e 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py +++ b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py @@ -30,6 +30,7 @@ Website, ListWebsitesResponse, ResetHostingPasswordResponse, + ResourceSummary, Session, DatabaseApiAssignDatabaseUserRequest, DatabaseApiChangeDatabaseUserPasswordRequest, @@ -642,6 +643,33 @@ def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordRes return ResetHostingPasswordResponse(**args) +def unmarshal_ResourceSummary(data: Any) -> ResourceSummary: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ResourceSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("databases_count", None) + if field is not None: + args["databases_count"] = field + + field = data.get("mail_accounts_count", None) + if field is not None: + args["mail_accounts_count"] = field + + field = data.get("ftp_accounts_count", None) + if field is not None: + args["ftp_accounts_count"] = field + + field = data.get("websites_count", None) + if field is not None: + args["websites_count"] = field + + return ResourceSummary(**args) + + def unmarshal_Session(data: Any) -> Session: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway-async/scaleway_async/webhosting/v1/types.py b/scaleway-async/scaleway_async/webhosting/v1/types.py index 4304a8f54..f6b71d816 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/types.py +++ b/scaleway-async/scaleway_async/webhosting/v1/types.py @@ -963,6 +963,19 @@ class HostingApiGetHostingRequest: """ +@dataclass +class HostingApiGetResourceSummaryRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class HostingApiListHostingsRequest: region: Optional[Region] @@ -1324,6 +1337,29 @@ class ResetHostingPasswordResponse: """ +@dataclass +class ResourceSummary: + databases_count: int + """ + Total number of active databases in the Web Hosting plan. + """ + + mail_accounts_count: int + """ + Total number of active email accounts in the Web Hosting plan. + """ + + ftp_accounts_count: int + """ + Total number of active FTP accounts in the Web Hosting plan. + """ + + websites_count: int + """ + Total number of active domains in the the Web Hosting plan. + """ + + @dataclass class Session: url: str diff --git a/scaleway/scaleway/webhosting/v1/__init__.py b/scaleway/scaleway/webhosting/v1/__init__.py index cf1d49e5c..f3faa9b01 100644 --- a/scaleway/scaleway/webhosting/v1/__init__.py +++ b/scaleway/scaleway/webhosting/v1/__init__.py @@ -48,6 +48,7 @@ from .types import HostingApiCreateSessionRequest from .types import HostingApiDeleteHostingRequest from .types import HostingApiGetHostingRequest +from .types import HostingApiGetResourceSummaryRequest from .types import HostingApiListHostingsRequest from .types import HostingApiResetHostingPasswordRequest from .types import HostingApiUpdateHostingRequest @@ -65,6 +66,7 @@ from .types import MailAccountApiRemoveMailAccountRequest from .types import OfferApiListOffersRequest from .types import ResetHostingPasswordResponse +from .types import ResourceSummary from .types import Session from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1ControlPanelAPI @@ -124,6 +126,7 @@ "HostingApiCreateSessionRequest", "HostingApiDeleteHostingRequest", "HostingApiGetHostingRequest", + "HostingApiGetResourceSummaryRequest", "HostingApiListHostingsRequest", "HostingApiResetHostingPasswordRequest", "HostingApiUpdateHostingRequest", @@ -141,6 +144,7 @@ "MailAccountApiRemoveMailAccountRequest", "OfferApiListOffersRequest", "ResetHostingPasswordResponse", + "ResourceSummary", "Session", "WebsiteApiListWebsitesRequest", "WebhostingV1ControlPanelAPI", diff --git a/scaleway/scaleway/webhosting/v1/api.py b/scaleway/scaleway/webhosting/v1/api.py index a188e43a1..a60674a3d 100644 --- a/scaleway/scaleway/webhosting/v1/api.py +++ b/scaleway/scaleway/webhosting/v1/api.py @@ -53,6 +53,7 @@ Offer, OfferOptionRequest, ResetHostingPasswordResponse, + ResourceSummary, Session, Website, ) @@ -74,6 +75,7 @@ unmarshal_ListOffersResponse, unmarshal_ListWebsitesResponse, unmarshal_ResetHostingPasswordResponse, + unmarshal_ResourceSummary, unmarshal_Session, marshal_DatabaseApiAssignDatabaseUserRequest, marshal_DatabaseApiChangeDatabaseUserPasswordRequest, @@ -1228,6 +1230,39 @@ def reset_hosting_password( self._throw_on_error(res) return unmarshal_ResetHostingPasswordResponse(res.json()) + def get_resource_summary( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> ResourceSummary: + """ + Get the total counts of websites, databases, email accounts, and FTP accounts of a Web Hosting plan. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ResourceSummary ` + + Usage: + :: + + result = api.get_resource_summary( + 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( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/resource-summary", + ) + + self._throw_on_error(res) + return unmarshal_ResourceSummary(res.json()) + class WebhostingV1FtpAccountAPI(API): """ diff --git a/scaleway/scaleway/webhosting/v1/marshalling.py b/scaleway/scaleway/webhosting/v1/marshalling.py index 08b656084..0229ea20e 100644 --- a/scaleway/scaleway/webhosting/v1/marshalling.py +++ b/scaleway/scaleway/webhosting/v1/marshalling.py @@ -30,6 +30,7 @@ Website, ListWebsitesResponse, ResetHostingPasswordResponse, + ResourceSummary, Session, DatabaseApiAssignDatabaseUserRequest, DatabaseApiChangeDatabaseUserPasswordRequest, @@ -642,6 +643,33 @@ def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordRes return ResetHostingPasswordResponse(**args) +def unmarshal_ResourceSummary(data: Any) -> ResourceSummary: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ResourceSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("databases_count", None) + if field is not None: + args["databases_count"] = field + + field = data.get("mail_accounts_count", None) + if field is not None: + args["mail_accounts_count"] = field + + field = data.get("ftp_accounts_count", None) + if field is not None: + args["ftp_accounts_count"] = field + + field = data.get("websites_count", None) + if field is not None: + args["websites_count"] = field + + return ResourceSummary(**args) + + def unmarshal_Session(data: Any) -> Session: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway/scaleway/webhosting/v1/types.py b/scaleway/scaleway/webhosting/v1/types.py index 4304a8f54..f6b71d816 100644 --- a/scaleway/scaleway/webhosting/v1/types.py +++ b/scaleway/scaleway/webhosting/v1/types.py @@ -963,6 +963,19 @@ class HostingApiGetHostingRequest: """ +@dataclass +class HostingApiGetResourceSummaryRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class HostingApiListHostingsRequest: region: Optional[Region] @@ -1324,6 +1337,29 @@ class ResetHostingPasswordResponse: """ +@dataclass +class ResourceSummary: + databases_count: int + """ + Total number of active databases in the Web Hosting plan. + """ + + mail_accounts_count: int + """ + Total number of active email accounts in the Web Hosting plan. + """ + + ftp_accounts_count: int + """ + Total number of active FTP accounts in the Web Hosting plan. + """ + + websites_count: int + """ + Total number of active domains in the the Web Hosting plan. + """ + + @dataclass class Session: url: str