From e3fc254de591389edb4571264ed1d3113fba87f6 Mon Sep 17 00:00:00 2001 From: Yacine Fodil <105779815+yfodil@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:42:16 +0200 Subject: [PATCH] feat(webhosting): add support for v1 API (#662) --- .../scaleway_async/webhosting/v1/__init__.py | 153 ++ .../scaleway_async/webhosting/v1/api.py | 1794 +++++++++++++++++ .../scaleway_async/webhosting/v1/content.py | 25 + .../webhosting/v1/marshalling.py | 902 +++++++++ .../scaleway_async/webhosting/v1/types.py | 1355 +++++++++++++ scaleway/scaleway/webhosting/v1/__init__.py | 153 ++ scaleway/scaleway/webhosting/v1/api.py | 1794 +++++++++++++++++ scaleway/scaleway/webhosting/v1/content.py | 25 + .../scaleway/webhosting/v1/marshalling.py | 902 +++++++++ scaleway/scaleway/webhosting/v1/types.py | 1355 +++++++++++++ 10 files changed, 8458 insertions(+) create mode 100644 scaleway-async/scaleway_async/webhosting/v1/__init__.py create mode 100644 scaleway-async/scaleway_async/webhosting/v1/api.py create mode 100644 scaleway-async/scaleway_async/webhosting/v1/content.py create mode 100644 scaleway-async/scaleway_async/webhosting/v1/marshalling.py create mode 100644 scaleway-async/scaleway_async/webhosting/v1/types.py create mode 100644 scaleway/scaleway/webhosting/v1/__init__.py create mode 100644 scaleway/scaleway/webhosting/v1/api.py create mode 100644 scaleway/scaleway/webhosting/v1/content.py create mode 100644 scaleway/scaleway/webhosting/v1/marshalling.py create mode 100644 scaleway/scaleway/webhosting/v1/types.py diff --git a/scaleway-async/scaleway_async/webhosting/v1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1/__init__.py new file mode 100644 index 00000000..cf1d49e5 --- /dev/null +++ b/scaleway-async/scaleway_async/webhosting/v1/__init__.py @@ -0,0 +1,153 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import HostingDnsStatus +from .types import HostingStatus +from .content import HOSTING_TRANSIENT_STATUSES +from .types import HostingSummaryStatus +from .content import HOSTING_SUMMARY_TRANSIENT_STATUSES +from .types import ListDatabaseUsersRequestOrderBy +from .types import ListDatabasesRequestOrderBy +from .types import ListFtpAccountsRequestOrderBy +from .types import ListHostingsRequestOrderBy +from .types import ListMailAccountsRequestOrderBy +from .types import ListOffersRequestOrderBy +from .types import ListWebsitesRequestOrderBy +from .types import OfferOptionName +from .types import OfferOptionWarning +from .types import OfferOption +from .types import CreateHostingRequestDomainConfiguration +from .types import OfferOptionRequest +from .types import HostingCpanelUrls +from .types import HostingOption +from .types import ControlPanel +from .types import DatabaseUser +from .types import Database +from .types import FtpAccount +from .types import HostingSummary +from .types import MailAccount +from .types import Offer +from .types import Website +from .types import ControlPanelApiListControlPanelsRequest +from .types import DatabaseApiAssignDatabaseUserRequest +from .types import DatabaseApiChangeDatabaseUserPasswordRequest +from .types import DatabaseApiCreateDatabaseRequest +from .types import DatabaseApiCreateDatabaseUserRequest +from .types import DatabaseApiDeleteDatabaseRequest +from .types import DatabaseApiDeleteDatabaseUserRequest +from .types import DatabaseApiGetDatabaseRequest +from .types import DatabaseApiGetDatabaseUserRequest +from .types import DatabaseApiListDatabaseUsersRequest +from .types import DatabaseApiListDatabasesRequest +from .types import DatabaseApiUnassignDatabaseUserRequest +from .types import FtpAccountApiChangeFtpAccountPasswordRequest +from .types import FtpAccountApiCreateFtpAccountRequest +from .types import FtpAccountApiListFtpAccountsRequest +from .types import FtpAccountApiRemoveFtpAccountRequest +from .types import Hosting +from .types import HostingApiCreateHostingRequest +from .types import HostingApiCreateSessionRequest +from .types import HostingApiDeleteHostingRequest +from .types import HostingApiGetHostingRequest +from .types import HostingApiListHostingsRequest +from .types import HostingApiResetHostingPasswordRequest +from .types import HostingApiUpdateHostingRequest +from .types import ListControlPanelsResponse +from .types import ListDatabaseUsersResponse +from .types import ListDatabasesResponse +from .types import ListFtpAccountsResponse +from .types import ListHostingsResponse +from .types import ListMailAccountsResponse +from .types import ListOffersResponse +from .types import ListWebsitesResponse +from .types import MailAccountApiChangeMailAccountPasswordRequest +from .types import MailAccountApiCreateMailAccountRequest +from .types import MailAccountApiListMailAccountsRequest +from .types import MailAccountApiRemoveMailAccountRequest +from .types import OfferApiListOffersRequest +from .types import ResetHostingPasswordResponse +from .types import Session +from .types import WebsiteApiListWebsitesRequest +from .api import WebhostingV1ControlPanelAPI +from .api import WebhostingV1DatabaseAPI +from .api import WebhostingV1OfferAPI +from .api import WebhostingV1HostingAPI +from .api import WebhostingV1FtpAccountAPI +from .api import WebhostingV1MailAccountAPI +from .api import WebhostingV1WebsiteAPI + +__all__ = [ + "HostingDnsStatus", + "HostingStatus", + "HOSTING_TRANSIENT_STATUSES", + "HostingSummaryStatus", + "HOSTING_SUMMARY_TRANSIENT_STATUSES", + "ListDatabaseUsersRequestOrderBy", + "ListDatabasesRequestOrderBy", + "ListFtpAccountsRequestOrderBy", + "ListHostingsRequestOrderBy", + "ListMailAccountsRequestOrderBy", + "ListOffersRequestOrderBy", + "ListWebsitesRequestOrderBy", + "OfferOptionName", + "OfferOptionWarning", + "OfferOption", + "CreateHostingRequestDomainConfiguration", + "OfferOptionRequest", + "HostingCpanelUrls", + "HostingOption", + "ControlPanel", + "DatabaseUser", + "Database", + "FtpAccount", + "HostingSummary", + "MailAccount", + "Offer", + "Website", + "ControlPanelApiListControlPanelsRequest", + "DatabaseApiAssignDatabaseUserRequest", + "DatabaseApiChangeDatabaseUserPasswordRequest", + "DatabaseApiCreateDatabaseRequest", + "DatabaseApiCreateDatabaseUserRequest", + "DatabaseApiDeleteDatabaseRequest", + "DatabaseApiDeleteDatabaseUserRequest", + "DatabaseApiGetDatabaseRequest", + "DatabaseApiGetDatabaseUserRequest", + "DatabaseApiListDatabaseUsersRequest", + "DatabaseApiListDatabasesRequest", + "DatabaseApiUnassignDatabaseUserRequest", + "FtpAccountApiChangeFtpAccountPasswordRequest", + "FtpAccountApiCreateFtpAccountRequest", + "FtpAccountApiListFtpAccountsRequest", + "FtpAccountApiRemoveFtpAccountRequest", + "Hosting", + "HostingApiCreateHostingRequest", + "HostingApiCreateSessionRequest", + "HostingApiDeleteHostingRequest", + "HostingApiGetHostingRequest", + "HostingApiListHostingsRequest", + "HostingApiResetHostingPasswordRequest", + "HostingApiUpdateHostingRequest", + "ListControlPanelsResponse", + "ListDatabaseUsersResponse", + "ListDatabasesResponse", + "ListFtpAccountsResponse", + "ListHostingsResponse", + "ListMailAccountsResponse", + "ListOffersResponse", + "ListWebsitesResponse", + "MailAccountApiChangeMailAccountPasswordRequest", + "MailAccountApiCreateMailAccountRequest", + "MailAccountApiListMailAccountsRequest", + "MailAccountApiRemoveMailAccountRequest", + "OfferApiListOffersRequest", + "ResetHostingPasswordResponse", + "Session", + "WebsiteApiListWebsitesRequest", + "WebhostingV1ControlPanelAPI", + "WebhostingV1DatabaseAPI", + "WebhostingV1OfferAPI", + "WebhostingV1HostingAPI", + "WebhostingV1FtpAccountAPI", + "WebhostingV1MailAccountAPI", + "WebhostingV1WebsiteAPI", +] diff --git a/scaleway-async/scaleway_async/webhosting/v1/api.py b/scaleway-async/scaleway_async/webhosting/v1/api.py new file mode 100644 index 00000000..7ebd1953 --- /dev/null +++ b/scaleway-async/scaleway_async/webhosting/v1/api.py @@ -0,0 +1,1794 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Awaitable, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + HostingStatus, + ListDatabaseUsersRequestOrderBy, + ListDatabasesRequestOrderBy, + ListFtpAccountsRequestOrderBy, + ListHostingsRequestOrderBy, + ListMailAccountsRequestOrderBy, + ListOffersRequestOrderBy, + ListWebsitesRequestOrderBy, + ControlPanel, + CreateHostingRequestDomainConfiguration, + Database, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiUnassignDatabaseUserRequest, + DatabaseUser, + FtpAccount, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + Hosting, + HostingApiCreateHostingRequest, + HostingApiUpdateHostingRequest, + HostingSummary, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + ListHostingsResponse, + ListMailAccountsResponse, + ListOffersResponse, + ListWebsitesResponse, + MailAccount, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiRemoveMailAccountRequest, + Offer, + OfferOptionRequest, + ResetHostingPasswordResponse, + Session, + Website, +) +from .content import ( + HOSTING_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_DatabaseUser, + unmarshal_Database, + unmarshal_FtpAccount, + unmarshal_MailAccount, + unmarshal_Hosting, + unmarshal_ListControlPanelsResponse, + unmarshal_ListDatabaseUsersResponse, + unmarshal_ListDatabasesResponse, + unmarshal_ListFtpAccountsResponse, + unmarshal_ListHostingsResponse, + unmarshal_ListMailAccountsResponse, + unmarshal_ListOffersResponse, + unmarshal_ListWebsitesResponse, + unmarshal_ResetHostingPasswordResponse, + unmarshal_Session, + marshal_DatabaseApiAssignDatabaseUserRequest, + marshal_DatabaseApiChangeDatabaseUserPasswordRequest, + marshal_DatabaseApiCreateDatabaseRequest, + marshal_DatabaseApiCreateDatabaseUserRequest, + marshal_DatabaseApiUnassignDatabaseUserRequest, + marshal_FtpAccountApiChangeFtpAccountPasswordRequest, + marshal_FtpAccountApiCreateFtpAccountRequest, + marshal_HostingApiCreateHostingRequest, + marshal_HostingApiUpdateHostingRequest, + marshal_MailAccountApiChangeMailAccountPasswordRequest, + marshal_MailAccountApiCreateMailAccountRequest, + marshal_MailAccountApiRemoveMailAccountRequest, +) +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +class WebhostingV1ControlPanelAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + async def list_control_panels( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListControlPanelsResponse: + """ + "List the control panels type: cpanel or plesk.". + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of control panels to return (must be a positive integer lower or equal to 100). + :return: :class:`ListControlPanelsResponse ` + + Usage: + :: + + result = await api.list_control_panels() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/control-panels", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListControlPanelsResponse(res.json()) + + async def list_control_panels_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ControlPanel]: + """ + "List the control panels type: cpanel or plesk.". + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of control panels to return (must be a positive integer lower or equal to 100). + :return: :class:`List[ControlPanel] ` + + Usage: + :: + + result = await api.list_control_panels_all() + """ + + return await fetch_all_pages_async( + type=ListControlPanelsResponse, + key="control_panels", + fetcher=self.list_control_panels, + args={ + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + +class WebhostingV1DatabaseAPI(API): + """ + This API allows you to manage your databases and database users for your Web Hosting services. + """ + + async def create_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Create a new database within your hosting plan". + :param hosting_id: UUID of the hosting plan where the database will be created. + :param database_name: Name of the database to be created. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = await api.create_database( + hosting_id="example", + database_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}/databases", + body=marshal_DatabaseApiCreateDatabaseRequest( + DatabaseApiCreateDatabaseRequest( + hosting_id=hosting_id, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + async def list_databases( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabasesRequestOrderBy] = None, + ) -> ListDatabasesResponse: + """ + "List all databases within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of databases to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of databases in the response. + :return: :class:`ListDatabasesResponse ` + + Usage: + :: + + result = await api.list_databases( + 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}/databases", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDatabasesResponse(res.json()) + + async def list_databases_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabasesRequestOrderBy] = None, + ) -> List[Database]: + """ + "List all databases within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of databases to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of databases in the response. + :return: :class:`List[Database] ` + + Usage: + :: + + result = await api.list_databases_all( + hosting_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListDatabasesResponse, + key="databases", + fetcher=self.list_databases, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + async def get_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Get details of a database within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param database_name: Name of the database. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = await api.get_database( + hosting_id="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}", + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + async def delete_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Delete a database within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param database_name: Name of the database to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = await api.delete_database( + hosting_id="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}", + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + async def create_database_user( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Create a new database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to create. + :param password: Password of the user to create. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.create_database_user( + hosting_id="example", + username="example", + password="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}/databases-users", + body=marshal_DatabaseApiCreateDatabaseUserRequest( + DatabaseApiCreateDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + async def list_database_users( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabaseUsersRequestOrderBy] = None, + ) -> ListDatabaseUsersResponse: + """ + "List all database users". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of database users to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of database users in the response. + :return: :class:`ListDatabaseUsersResponse ` + + Usage: + :: + + result = await api.list_database_users( + 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}/database-users", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDatabaseUsersResponse(res.json()) + + async def list_database_users_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabaseUsersRequestOrderBy] = None, + ) -> List[DatabaseUser]: + """ + "List all database users". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of database users to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of database users in the response. + :return: :class:`List[DatabaseUser] ` + + Usage: + :: + + result = await api.list_database_users_all( + hosting_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListDatabaseUsersResponse, + key="users", + fetcher=self.list_database_users, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + async def get_database_user( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Get details of a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the database user to retrieve details. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.get_database_user( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases-users/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + async def delete_database_user( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Delete a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the database user to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.delete_database_user( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/database-users/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + async def change_database_user_password( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Change the password of a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to update. + :param password: New password. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.change_database_user_password( + hosting_id="example", + username="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases-users/{param_username}/change-password", + body=marshal_DatabaseApiChangeDatabaseUserPasswordRequest( + DatabaseApiChangeDatabaseUserPasswordRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + async def assign_database_user( + self, + *, + hosting_id: str, + username: str, + database_name: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Assign a database user to a database". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to assign. + :param database_name: Name of the database to be assigned. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.assign_database_user( + hosting_id="example", + username="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}/assign-user", + body=marshal_DatabaseApiAssignDatabaseUserRequest( + DatabaseApiAssignDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + async def unassign_database_user( + self, + *, + hosting_id: str, + username: str, + database_name: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Unassign a database user from a database". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to unassign. + :param database_name: Name of the database to be unassigned. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = await api.unassign_database_user( + hosting_id="example", + username="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}/unassign-user", + body=marshal_DatabaseApiUnassignDatabaseUserRequest( + DatabaseApiUnassignDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + +class WebhostingV1OfferAPI(API): + """ + This API allows you to manage your offer for your Web Hosting services. + """ + + async def list_offers( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListOffersRequestOrderBy] = None, + hosting_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> ListOffersResponse: + """ + List all available hosting offers along with their specific options. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting offers in the response. + :param hosting_id: UUID of the hosting plan. + :param control_panels: Name of the control panel(s) to filter for. + :return: :class:`ListOffersResponse ` + + Usage: + :: + + result = await api.list_offers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/offers", + params={ + "control_panels": control_panels, + "hosting_id": hosting_id, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListOffersResponse(res.json()) + + async def list_offers_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListOffersRequestOrderBy] = None, + hosting_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> List[Offer]: + """ + List all available hosting offers along with their specific options. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting offers in the response. + :param hosting_id: UUID of the hosting plan. + :param control_panels: Name of the control panel(s) to filter for. + :return: :class:`List[Offer] ` + + Usage: + :: + + result = await api.list_offers_all() + """ + + return await fetch_all_pages_async( + type=ListOffersResponse, + key="offers", + fetcher=self.list_offers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "hosting_id": hosting_id, + "control_panels": control_panels, + }, + ) + + +class WebhostingV1HostingAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + async def create_hosting( + self, + *, + offer_id: str, + email: str, + domain: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + offer_options: Optional[List[OfferOptionRequest]] = None, + language: Optional[StdLanguageCode] = None, + domain_configuration: Optional[CreateHostingRequestDomainConfiguration] = None, + ) -> Hosting: + """ + Order a Web Hosting plan. + Order a Web Hosting plan, specifying the offer type required via the `offer_id` parameter. + :param offer_id: ID of the selected offer for the Web Hosting plan. + :param email: Contact email for the Web Hosting client. + :param domain: Domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Scaleway Project in which to create the Web Hosting plan. + :param tags: List of tags for the Web Hosting plan. + :param offer_options: List of the Web Hosting plan options IDs with their quantities. + :param language: Default language for the control panel interface. + :param domain_configuration: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements. + :return: :class:`Hosting ` + + Usage: + :: + + result = await api.create_hosting( + offer_id="example", + email="example", + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings", + body=marshal_HostingApiCreateHostingRequest( + HostingApiCreateHostingRequest( + offer_id=offer_id, + email=email, + domain=domain, + region=region, + project_id=project_id, + tags=tags, + offer_options=offer_options, + language=language, + domain_configuration=domain_configuration, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + async def list_hostings( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListHostingsRequestOrderBy] = None, + tags: Optional[List[str]] = None, + statuses: Optional[List[HostingStatus]] = None, + domain: Optional[str] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> ListHostingsResponse: + """ + List all Web Hosting plans. + List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return, from the paginated results (must be a positive integer). + :param page_size: Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting plans in the response. + :param tags: Tags to filter for, only Web Hosting plans with matching tags will be returned. + :param statuses: Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + :param domain: Domain to filter for, only Web Hosting plans associated with this domain will be returned. + :param project_id: Project ID to filter for, only Web Hosting plans from this Project will be returned. + :param organization_id: Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + :param control_panels: Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + :return: :class:`ListHostingsResponse ` + + Usage: + :: + + result = await api.list_hostings() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings", + params={ + "control_panels": control_panels, + "domain": domain, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "statuses": statuses, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListHostingsResponse(res.json()) + + async def list_hostings_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListHostingsRequestOrderBy] = None, + tags: Optional[List[str]] = None, + statuses: Optional[List[HostingStatus]] = None, + domain: Optional[str] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> List[HostingSummary]: + """ + List all Web Hosting plans. + List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return, from the paginated results (must be a positive integer). + :param page_size: Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting plans in the response. + :param tags: Tags to filter for, only Web Hosting plans with matching tags will be returned. + :param statuses: Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + :param domain: Domain to filter for, only Web Hosting plans associated with this domain will be returned. + :param project_id: Project ID to filter for, only Web Hosting plans from this Project will be returned. + :param organization_id: Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + :param control_panels: Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + :return: :class:`List[HostingSummary] ` + + Usage: + :: + + result = await api.list_hostings_all() + """ + + return await fetch_all_pages_async( + type=ListHostingsResponse, + key="hostings", + fetcher=self.list_hostings, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "tags": tags, + "statuses": statuses, + "domain": domain, + "project_id": project_id, + "organization_id": organization_id, + "control_panels": control_panels, + }, + ) + + async def get_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Hosting: + """ + Get a Web Hosting plan. + Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = await api.get_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( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + async def wait_for_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Hosting, Union[bool, Awaitable[bool]]]] = None, + ) -> Hosting: + """ + Get a Web Hosting plan. + Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = await api.get_hosting( + hosting_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in HOSTING_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_hosting, + options=options, + args={ + "hosting_id": hosting_id, + "region": region, + }, + ) + + async def update_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + email: Optional[str] = None, + tags: Optional[List[str]] = None, + offer_options: Optional[List[OfferOptionRequest]] = None, + offer_id: Optional[str] = None, + protected: Optional[bool] = None, + ) -> Hosting: + """ + Update a Web Hosting plan. + Update the details of one of your existing Web Hosting plans, specified by its `hosting_id`. You can update parameters including the contact email address, tags, options and offer. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :param email: New contact email for the Web Hosting plan. + :param tags: New tags for the Web Hosting plan. + :param offer_options: List of the Web Hosting plan options IDs with their quantities. + :param offer_id: ID of the new offer for the Web Hosting plan. + :param protected: Whether the hosting is protected or not. + :return: :class:`Hosting ` + + Usage: + :: + + result = await api.update_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( + "PATCH", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + body=marshal_HostingApiUpdateHostingRequest( + HostingApiUpdateHostingRequest( + hosting_id=hosting_id, + region=region, + email=email, + tags=tags, + offer_options=offer_options, + offer_id=offer_id, + protected=protected, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + async def delete_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Hosting: + """ + Delete a Web Hosting plan. + Delete a Web Hosting plan, specified by its `hosting_id`. Note that deletion is not immediate: it will take place at the end of the calendar month, after which time your Web Hosting plan and all its data (files and emails) will be irreversibly lost. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = await api.delete_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( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + async def create_session( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Session: + """ + Create a user session. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Session ` + + Usage: + :: + + result = await api.create_session( + 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}/sessions", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Session(res.json()) + + async def reset_hosting_password( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> ResetHostingPasswordResponse: + """ + Reset a Web Hosting plan password. + :param hosting_id: UUID of the hosting. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ResetHostingPasswordResponse ` + + Usage: + :: + + result = await api.reset_hosting_password( + 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-password", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_ResetHostingPasswordResponse(res.json()) + + +class WebhostingV1FtpAccountAPI(API): + """ + This API allows you to manage your FTP accounts for your Web Hosting services. + """ + + async def create_ftp_account( + self, + *, + hosting_id: str, + username: str, + path: str, + password: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + Create a new FTP account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param username: Username for the new FTP account. + :param path: Path for the new FTP account. + :param password: Password for the new FTP account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = await api.create_ftp_account( + hosting_id="example", + username="example", + path="example", + password="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}/ftp-accounts", + body=marshal_FtpAccountApiCreateFtpAccountRequest( + FtpAccountApiCreateFtpAccountRequest( + hosting_id=hosting_id, + username=username, + path=path, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + async def list_ftp_accounts( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListFtpAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> ListFtpAccountsResponse: + """ + List all FTP accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of FTP accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of FTP accounts in the response. + :param domain: Domain to filter the FTP accounts. + :return: :class:`ListFtpAccountsResponse ` + + Usage: + :: + + result = await api.list_ftp_accounts( + 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}/ftp-accounts", + params={ + "domain": domain, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListFtpAccountsResponse(res.json()) + + async def list_ftp_accounts_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListFtpAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> List[FtpAccount]: + """ + List all FTP accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of FTP accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of FTP accounts in the response. + :param domain: Domain to filter the FTP accounts. + :return: :class:`List[FtpAccount] ` + + Usage: + :: + + result = await api.list_ftp_accounts_all( + hosting_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListFtpAccountsResponse, + key="ftp_accounts", + fetcher=self.list_ftp_accounts, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "domain": domain, + }, + ) + + async def remove_ftp_account( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + Delete a specific FTP account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param username: Username of the FTP account to be deleted. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = await api.remove_ftp_account( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/ftp-accounts/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + async def change_ftp_account_password( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + :param hosting_id: UUID of the hosting plan. + :param username: Username of the FTP account. + :param password: New password for the FTP account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = await api.change_ftp_account_password( + hosting_id="example", + username="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/ftp-accounts/{param_username}/change-password", + body=marshal_FtpAccountApiChangeFtpAccountPasswordRequest( + FtpAccountApiChangeFtpAccountPasswordRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + +class WebhostingV1MailAccountAPI(API): + """ + This API allows you to manage your mail accounts for your Web Hosting services. + """ + + async def create_mail_account( + self, + *, + hosting_id: str, + domain: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Create a new mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part address of the mail account address. + :param password: Password for the new mail account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = await api.create_mail_account( + hosting_id="example", + domain="example", + username="example", + password="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}/mail-accounts", + body=marshal_MailAccountApiCreateMailAccountRequest( + MailAccountApiCreateMailAccountRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + async def list_mail_accounts( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListMailAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> ListMailAccountsResponse: + """ + List all mail accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of mail accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of mail accounts in the response. + :param domain: Domain to filter the mail accounts. + :return: :class:`ListMailAccountsResponse ` + + Usage: + :: + + result = await api.list_mail_accounts( + 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}/mail-accounts", + params={ + "domain": domain, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListMailAccountsResponse(res.json()) + + async def list_mail_accounts_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListMailAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> List[MailAccount]: + """ + List all mail accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of mail accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of mail accounts in the response. + :param domain: Domain to filter the mail accounts. + :return: :class:`List[MailAccount] ` + + Usage: + :: + + result = await api.list_mail_accounts_all( + hosting_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListMailAccountsResponse, + key="mail_accounts", + fetcher=self.list_mail_accounts, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "domain": domain, + }, + ) + + async def remove_mail_account( + self, + *, + hosting_id: str, + domain: str, + username: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Delete a mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part of the mail account address. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = await api.remove_mail_account( + hosting_id="example", + domain="example", + username="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}/remove-mail-account", + body=marshal_MailAccountApiRemoveMailAccountRequest( + MailAccountApiRemoveMailAccountRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + async def change_mail_account_password( + self, + *, + hosting_id: str, + domain: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Update the password of a mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part of the mail account address. + :param password: New password for the mail account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = await api.change_mail_account_password( + hosting_id="example", + domain="example", + username="example", + password="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}/change-mail-password", + body=marshal_MailAccountApiChangeMailAccountPasswordRequest( + MailAccountApiChangeMailAccountPasswordRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + +class WebhostingV1WebsiteAPI(API): + """ + This API allows you to manage your websites for your Web Hosting services. + """ + + async def list_websites( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListWebsitesRequestOrderBy] = None, + ) -> ListWebsitesResponse: + """ + List all websites for a specific hosting. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting websites in the response. + :return: :class:`ListWebsitesResponse ` + + Usage: + :: + + result = await api.list_websites( + 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}/websites", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListWebsitesResponse(res.json()) + + async def list_websites_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListWebsitesRequestOrderBy] = None, + ) -> List[Website]: + """ + List all websites for a specific hosting. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting websites in the response. + :return: :class:`List[Website] ` + + Usage: + :: + + result = await api.list_websites_all( + hosting_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListWebsitesResponse, + key="websites", + fetcher=self.list_websites, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) diff --git a/scaleway-async/scaleway_async/webhosting/v1/content.py b/scaleway-async/scaleway_async/webhosting/v1/content.py new file mode 100644 index 00000000..0d24b738 --- /dev/null +++ b/scaleway-async/scaleway_async/webhosting/v1/content.py @@ -0,0 +1,25 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + HostingStatus, + HostingSummaryStatus, +) + +HOSTING_TRANSIENT_STATUSES: List[HostingStatus] = [ + HostingStatus.DELIVERING, + HostingStatus.DELETING, + HostingStatus.MIGRATING, +] +""" +Lists transient statutes of the enum :class:`HostingStatus `. +""" +HOSTING_SUMMARY_TRANSIENT_STATUSES: List[HostingSummaryStatus] = [ + HostingSummaryStatus.DELIVERING, + HostingSummaryStatus.DELETING, + HostingSummaryStatus.MIGRATING, +] +""" +Lists transient statutes of the enum :class:`HostingSummaryStatus `. +""" diff --git a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py new file mode 100644 index 00000000..c8ade0bf --- /dev/null +++ b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py @@ -0,0 +1,902 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from .types import ( + DatabaseUser, + Database, + FtpAccount, + MailAccount, + HostingCpanelUrls, + HostingOption, + Hosting, + ControlPanel, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + HostingSummary, + ListHostingsResponse, + ListMailAccountsResponse, + OfferOption, + Offer, + ListOffersResponse, + Website, + ListWebsitesResponse, + ResetHostingPasswordResponse, + Session, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiUnassignDatabaseUserRequest, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + CreateHostingRequestDomainConfiguration, + OfferOptionRequest, + HostingApiCreateHostingRequest, + HostingApiUpdateHostingRequest, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiRemoveMailAccountRequest, +) +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +def unmarshal_DatabaseUser(data: Any) -> DatabaseUser: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DatabaseUser' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("databases", None) + if field is not None: + args["databases"] = field + + return DatabaseUser(**args) + + +def unmarshal_Database(data: Any) -> Database: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Database' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("database_name", None) + if field is not None: + args["database_name"] = field + + field = data.get("users", None) + if field is not None: + args["users"] = field + + return Database(**args) + + +def unmarshal_FtpAccount(data: Any) -> FtpAccount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'FtpAccount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return FtpAccount(**args) + + +def unmarshal_MailAccount(data: Any) -> MailAccount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'MailAccount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + return MailAccount(**args) + + +def unmarshal_HostingCpanelUrls(data: Any) -> HostingCpanelUrls: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dashboard", None) + if field is not None: + args["dashboard"] = field + + field = data.get("webmail", None) + if field is not None: + args["webmail"] = field + + return HostingCpanelUrls(**args) + + +def unmarshal_HostingOption(data: Any) -> HostingOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingOption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("quantity", None) + if field is not None: + args["quantity"] = field + + return HostingOption(**args) + + +def unmarshal_Hosting(data: Any) -> Hosting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Hosting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("platform_hostname", None) + if field is not None: + args["platform_hostname"] = field + + field = data.get("platform_number", None) + if field is not None: + args["platform_number"] = field + + field = data.get("offer_id", None) + if field is not None: + args["offer_id"] = field + + field = data.get("offer_name", None) + if field is not None: + args["offer_name"] = field + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("options", None) + if field is not None: + args["options"] = ( + [unmarshal_HostingOption(v) for v in field] if field is not None else None + ) + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("dns_status", None) + if field is not None: + args["dns_status"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("offer_end_of_life", None) + if field is not None: + args["offer_end_of_life"] = field + + field = data.get("control_panel_name", None) + if field is not None: + args["control_panel_name"] = field + + field = data.get("platform_group", None) + if field is not None: + args["platform_group"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = field + + field = data.get("ipv6", None) + if field is not None: + args["ipv6"] = field + + field = data.get("protected", None) + if field is not None: + args["protected"] = field + + field = data.get("one_time_password", None) + if field is not None: + args["one_time_password"] = field + + field = data.get("contact_email", None) + if field is not None: + args["contact_email"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("cpanel_urls", None) + if field is not None: + args["cpanel_urls"] = unmarshal_HostingCpanelUrls(field) + else: + args["cpanel_urls"] = None + + return Hosting(**args) + + +def unmarshal_ControlPanel(data: Any) -> ControlPanel: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ControlPanel' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("available", None) + if field is not None: + args["available"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("available_languages", None) + if field is not None: + args["available_languages"] = ( + [StdLanguageCode(v) for v in field] if field is not None else None + ) + + return ControlPanel(**args) + + +def unmarshal_ListControlPanelsResponse(data: Any) -> ListControlPanelsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListControlPanelsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("control_panels", None) + if field is not None: + args["control_panels"] = ( + [unmarshal_ControlPanel(v) for v in field] if field is not None else None + ) + + return ListControlPanelsResponse(**args) + + +def unmarshal_ListDatabaseUsersResponse(data: Any) -> ListDatabaseUsersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDatabaseUsersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("users", None) + if field is not None: + args["users"] = ( + [unmarshal_DatabaseUser(v) for v in field] if field is not None else None + ) + + return ListDatabaseUsersResponse(**args) + + +def unmarshal_ListDatabasesResponse(data: Any) -> ListDatabasesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("databases", None) + if field is not None: + args["databases"] = ( + [unmarshal_Database(v) for v in field] if field is not None else None + ) + + return ListDatabasesResponse(**args) + + +def unmarshal_ListFtpAccountsResponse(data: Any) -> ListFtpAccountsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListFtpAccountsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("ftp_accounts", None) + if field is not None: + args["ftp_accounts"] = ( + [unmarshal_FtpAccount(v) for v in field] if field is not None else None + ) + + return ListFtpAccountsResponse(**args) + + +def unmarshal_HostingSummary(data: Any) -> HostingSummary: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("protected", None) + if field is not None: + args["protected"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return HostingSummary(**args) + + +def unmarshal_ListHostingsResponse(data: Any) -> ListHostingsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("hostings", None) + if field is not None: + args["hostings"] = ( + [unmarshal_HostingSummary(v) for v in field] if field is not None else None + ) + + return ListHostingsResponse(**args) + + +def unmarshal_ListMailAccountsResponse(data: Any) -> ListMailAccountsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListMailAccountsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("mail_accounts", None) + if field is not None: + args["mail_accounts"] = ( + [unmarshal_MailAccount(v) for v in field] if field is not None else None + ) + + return ListMailAccountsResponse(**args) + + +def unmarshal_OfferOption(data: Any) -> OfferOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'OfferOption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("billing_operation_path", None) + if field is not None: + args["billing_operation_path"] = field + + field = data.get("min_value", None) + if field is not None: + args["min_value"] = field + + field = data.get("current_value", None) + if field is not None: + args["current_value"] = field + + field = data.get("max_value", None) + if field is not None: + args["max_value"] = field + + field = data.get("quota_warning", None) + if field is not None: + args["quota_warning"] = field + + return OfferOption(**args) + + +def unmarshal_Offer(data: Any) -> Offer: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Offer' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("billing_operation_path", None) + if field is not None: + args["billing_operation_path"] = field + + field = data.get("options", None) + if field is not None: + args["options"] = ( + [unmarshal_OfferOption(v) for v in field] if field is not None else None + ) + + field = data.get("available", None) + if field is not None: + args["available"] = field + + field = data.get("control_panel_name", None) + if field is not None: + args["control_panel_name"] = field + + field = data.get("end_of_life", None) + if field is not None: + args["end_of_life"] = field + + field = data.get("price", None) + if field is not None: + args["price"] = unmarshal_Money(field) + else: + args["price"] = None + + return Offer(**args) + + +def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("offers", None) + if field is not None: + args["offers"] = ( + [unmarshal_Offer(v) for v in field] if field is not None else None + ) + + return ListOffersResponse(**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 + + field = data.get("path", None) + if field is not None: + args["path"] = field + + field = data.get("ssl_status", None) + if field is not None: + args["ssl_status"] = field + + return Website(**args) + + +def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListWebsitesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("websites", None) + if field is not None: + args["websites"] = ( + [unmarshal_Website(v) for v in field] if field is not None else None + ) + + return ListWebsitesResponse(**args) + + +def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("one_time_password", None) + if field is not None: + args["one_time_password"] = field + + return ResetHostingPasswordResponse(**args) + + +def unmarshal_Session(data: Any) -> Session: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Session' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("url", None) + if field is not None: + args["url"] = field + + return Session(**args) + + +def marshal_DatabaseApiAssignDatabaseUserRequest( + request: DatabaseApiAssignDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + return output + + +def marshal_DatabaseApiChangeDatabaseUserPasswordRequest( + request: DatabaseApiChangeDatabaseUserPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_DatabaseApiCreateDatabaseRequest( + request: DatabaseApiCreateDatabaseRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.database_name is not None: + output["database_name"] = request.database_name + + return output + + +def marshal_DatabaseApiCreateDatabaseUserRequest( + request: DatabaseApiCreateDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_DatabaseApiUnassignDatabaseUserRequest( + request: DatabaseApiUnassignDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + return output + + +def marshal_FtpAccountApiChangeFtpAccountPasswordRequest( + request: FtpAccountApiChangeFtpAccountPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_FtpAccountApiCreateFtpAccountRequest( + request: FtpAccountApiCreateFtpAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + if request.path is not None: + output["path"] = request.path + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_CreateHostingRequestDomainConfiguration( + request: CreateHostingRequestDomainConfiguration, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.update_nameservers is not None: + output["update_nameservers"] = request.update_nameservers + + if request.update_web_record is not None: + output["update_web_record"] = request.update_web_record + + if request.update_mail_record is not None: + output["update_mail_record"] = request.update_mail_record + + if request.update_all_records is not None: + output["update_all_records"] = request.update_all_records + + return output + + +def marshal_OfferOptionRequest( + request: OfferOptionRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.id is not None: + output["id"] = request.id + + if request.quantity is not None: + output["quantity"] = request.quantity + + return output + + +def marshal_HostingApiCreateHostingRequest( + request: HostingApiCreateHostingRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.offer_id is not None: + output["offer_id"] = request.offer_id + + if request.email is not None: + output["email"] = request.email + + if request.domain is not None: + output["domain"] = request.domain + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.offer_options is not None: + output["offer_options"] = [ + marshal_OfferOptionRequest(item, defaults) for item in request.offer_options + ] + + if request.language is not None: + output["language"] = str(request.language) + + if request.domain_configuration is not None: + output["domain_configuration"] = ( + marshal_CreateHostingRequestDomainConfiguration( + request.domain_configuration, defaults + ) + ) + + return output + + +def marshal_HostingApiUpdateHostingRequest( + request: HostingApiUpdateHostingRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.email is not None: + output["email"] = request.email + + if request.tags is not None: + output["tags"] = request.tags + + if request.offer_options is not None: + output["offer_options"] = [ + marshal_OfferOptionRequest(item, defaults) for item in request.offer_options + ] + + if request.offer_id is not None: + output["offer_id"] = request.offer_id + + if request.protected is not None: + output["protected"] = request.protected + + return output + + +def marshal_MailAccountApiChangeMailAccountPasswordRequest( + request: MailAccountApiChangeMailAccountPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_MailAccountApiCreateMailAccountRequest( + request: MailAccountApiCreateMailAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_MailAccountApiRemoveMailAccountRequest( + request: MailAccountApiRemoveMailAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + return output diff --git a/scaleway-async/scaleway_async/webhosting/v1/types.py b/scaleway-async/scaleway_async/webhosting/v1/types.py new file mode 100644 index 00000000..16f5a9da --- /dev/null +++ b/scaleway-async/scaleway_async/webhosting/v1/types.py @@ -0,0 +1,1355 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +class HostingDnsStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_DNS_STATUS = "unknown_dns_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + +class HostingStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DELIVERING = "delivering" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + MIGRATING = "migrating" + + def __str__(self) -> str: + return str(self.value) + + +class HostingSummaryStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DELIVERING = "delivering" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + MIGRATING = "migrating" + + def __str__(self) -> str: + return str(self.value) + + +class ListDatabaseUsersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDatabasesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DATABASE_NAME_ASC = "database_name_asc" + DATABASE_NAME_DESC = "database_name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListFtpAccountsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListHostingsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListMailAccountsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + DOMAIN_ASC = "domain_asc" + DOMAIN_DESC = "domain_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListOffersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + PRICE_ASC = "price_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListWebsitesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DOMAIN_ASC = "domain_asc" + DOMAIN_DESC = "domain_desc" + + def __str__(self) -> str: + return str(self.value) + + +class OfferOptionName(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_NAME = "unknown_name" + DOMAIN_COUNT = "domain_count" + EMAIL_COUNT = "email_count" + STORAGE_GB = "storage_gb" + VCPU_COUNT = "vcpu_count" + RAM_GB = "ram_gb" + BACKUP = "backup" + DEDICATED_IP = "dedicated_ip" + + def __str__(self) -> str: + return str(self.value) + + +class OfferOptionWarning(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_WARNING = "unknown_warning" + QUOTA_EXCEEDED_WARNING = "quota_exceeded_warning" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class OfferOption: + id: str + """ + Option ID. + """ + + name: OfferOptionName + """ + Name of the option. + """ + + billing_operation_path: str + """ + Unique identifier used for billing. + """ + + min_value: int + """ + Minimum value for the option in the offer. + """ + + current_value: int + """ + If a hosting_id was specified in the call, defines the current value of the option in the hosting. + """ + + max_value: int + """ + Maximum value for the option in the offer. + """ + + quota_warning: OfferOptionWarning + """ + Defines a warning if the maximum value for the option has been reached. + """ + + +@dataclass +class CreateHostingRequestDomainConfiguration: + update_nameservers: bool + + update_web_record: bool + + update_mail_record: bool + + update_all_records: bool + + +@dataclass +class OfferOptionRequest: + id: str + """ + Offer option ID. + """ + + quantity: int + """ + The option requested quantity to set for the Web Hosting plan. + """ + + +@dataclass +class HostingCpanelUrls: + dashboard: str + + webmail: str + + +@dataclass +class HostingOption: + id: str + """ + Option ID. + """ + + name: OfferOptionName + """ + Option name. + """ + + quantity: int + """ + Option quantity. + """ + + +@dataclass +class ControlPanel: + name: str + """ + Control panel name. + """ + + available: bool + """ + Define if the control panel type is available to order. + """ + + logo_url: str + """ + URL of the control panel's logo. + """ + + available_languages: List[StdLanguageCode] + """ + List of available languages for the control panel. + """ + + +@dataclass +class DatabaseUser: + username: str + """ + Name of the database user. + """ + + databases: List[str] + """ + List of databases accessible by the user. + """ + + +@dataclass +class Database: + database_name: str + """ + Name of the database. + """ + + users: List[str] + """ + List of users who have access to the database. + """ + + +@dataclass +class FtpAccount: + username: str + """ + The username of the FTP account. + """ + + path: str + """ + The path associated with the FTP account. + """ + + +@dataclass +class HostingSummary: + id: str + """ + ID of the Web Hosting plan. + """ + + project_id: str + """ + ID of the Scaleway Project the Web Hosting plan belongs to. + """ + + status: HostingSummaryStatus + """ + Status of the Web Hosting plan. + """ + + domain: str + """ + Main domain associated with the Web Hosting plan. + """ + + protected: bool + """ + Whether the hosting is protected or not. + """ + + region: Region + """ + Region where the Web Hosting plan is hosted. + """ + + updated_at: Optional[datetime] + """ + Date on which the Web Hosting plan was last updated. + """ + + +@dataclass +class MailAccount: + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part address of the mail account address. + """ + + +@dataclass +class Offer: + id: str + """ + Offer ID. + """ + + billing_operation_path: str + """ + Unique identifier used for billing. + """ + + options: List[OfferOption] + """ + Options available for the offer. + """ + + available: bool + """ + If a hosting_id was specified in the call, defines whether the offer is available for a specified hosting plan to migrate (update) to. + """ + + control_panel_name: str + """ + Name of the control panel. + """ + + end_of_life: bool + """ + Indicates if the offer has reached its end of life. + """ + + price: Optional[Money] + """ + Price of the offer. + """ + + +@dataclass +class Website: + domain: str + """ + The domain of the website. + """ + + path: str + """ + The directory path of the website. + """ + + ssl_status: bool + """ + The SSL status of the website. + """ + + +@dataclass +class ControlPanelApiListControlPanelsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of control panels to return (must be a positive integer lower or equal to 100). + """ + + +@dataclass +class DatabaseApiAssignDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to assign. + """ + + database_name: str + """ + Name of the database to be assigned. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiChangeDatabaseUserPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to update. + """ + + password: str + """ + New password. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiCreateDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan where the database will be created. + """ + + database_name: str + """ + Name of the database to be created. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiCreateDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to create. + """ + + password: str + """ + Password of the user to create. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiDeleteDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + database_name: str + """ + Name of the database to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiDeleteDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the database user to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiGetDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + database_name: str + """ + Name of the database. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiGetDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the database user to retrieve details. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiListDatabaseUsersRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of database users to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListDatabaseUsersRequestOrderBy] + """ + Sort order of database users in the response. + """ + + +@dataclass +class DatabaseApiListDatabasesRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of databases to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListDatabasesRequestOrderBy] + """ + Sort order of databases in the response. + """ + + +@dataclass +class DatabaseApiUnassignDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to unassign. + """ + + database_name: str + """ + Name of the database to be unassigned. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiChangeFtpAccountPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username of the FTP account. + """ + + password: str + """ + New password for the FTP account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiCreateFtpAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username for the new FTP account. + """ + + path: str + """ + Path for the new FTP account. + """ + + password: str + """ + Password for the new FTP account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiListFtpAccountsRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of FTP accounts to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListFtpAccountsRequestOrderBy] + """ + Sort order of FTP accounts in the response. + """ + + domain: Optional[str] + """ + Domain to filter the FTP accounts. + """ + + +@dataclass +class FtpAccountApiRemoveFtpAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username of the FTP account to be deleted. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class Hosting: + id: str + """ + ID of the Web Hosting plan. + """ + + project_id: str + """ + ID of the Scaleway Project the Web Hosting plan belongs to. + """ + + status: HostingStatus + """ + Status of the Web Hosting plan. + """ + + platform_hostname: str + """ + Hostname of the host platform. + """ + + platform_number: int + """ + Number of the host platform. + """ + + offer_id: str + """ + ID of the active offer for the Web Hosting plan. + """ + + offer_name: str + """ + Name of the active offer for the Web Hosting plan. + """ + + domain: str + """ + Main domain associated with the Web Hosting plan. + """ + + tags: List[str] + """ + List of tags associated with the Web Hosting plan. + """ + + options: List[HostingOption] + """ + List of the Web Hosting plan options. + """ + + updated_at: Optional[datetime] + """ + Date on which the Web Hosting plan was last updated. + """ + + created_at: Optional[datetime] + """ + Date on which the Web Hosting plan was created. + """ + + dns_status: HostingDnsStatus + """ + DNS status of the Web Hosting plan. + """ + + username: str + """ + Main Web Hosting cPanel username. + """ + + offer_end_of_life: bool + """ + Indicates if the hosting offer has reached its end of life. + """ + + control_panel_name: str + """ + Name of the control panel. + """ + + platform_group: str + """ + Group of the hosting's host server/platform. + """ + + ipv4: str + """ + IPv4 address of the hosting's host server. + """ + + ipv6: str + """ + IPv6 address of the hosting's host server. + """ + + protected: bool + """ + Whether the hosting is protected or not. + """ + + one_time_password: str + """ + One-time-password used for the first login or reset password, empty after first use. + """ + + contact_email: str + """ + Contact email used for the hosting. + """ + + region: Region + """ + Region where the Web Hosting plan is hosted. + """ + + cpanel_urls: Optional[HostingCpanelUrls] + """ + URL to connect to cPanel dashboard and to Webmail interface. + """ + + +@dataclass +class HostingApiCreateHostingRequest: + offer_id: str + """ + ID of the selected offer for the Web Hosting plan. + """ + + email: str + """ + Contact email for the Web Hosting client. + """ + + domain: str + """ + Domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Scaleway Project in which to create the Web Hosting plan. + """ + + tags: Optional[List[str]] + """ + List of tags for the Web Hosting plan. + """ + + offer_options: Optional[List[OfferOptionRequest]] + """ + List of the Web Hosting plan options IDs with their quantities. + """ + + language: Optional[StdLanguageCode] + """ + Default language for the control panel interface. + """ + + domain_configuration: Optional[CreateHostingRequestDomainConfiguration] + """ + Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements. + """ + + +@dataclass +class HostingApiCreateSessionRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiDeleteHostingRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiGetHostingRequest: + 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] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListHostingsRequestOrderBy] + """ + Sort order for Web Hosting plans in the response. + """ + + tags: Optional[List[str]] + """ + Tags to filter for, only Web Hosting plans with matching tags will be returned. + """ + + statuses: Optional[List[HostingStatus]] + """ + Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + """ + + domain: Optional[str] + """ + Domain to filter for, only Web Hosting plans associated with this domain will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for, only Web Hosting plans from this Project will be returned. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + """ + + control_panels: Optional[List[str]] + """ + Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + """ + + +@dataclass +class HostingApiResetHostingPasswordRequest: + hosting_id: str + """ + UUID of the hosting. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiUpdateHostingRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + email: Optional[str] + """ + New contact email for the Web Hosting plan. + """ + + tags: Optional[List[str]] + """ + New tags for the Web Hosting plan. + """ + + offer_options: Optional[List[OfferOptionRequest]] + """ + List of the Web Hosting plan options IDs with their quantities. + """ + + offer_id: Optional[str] + """ + ID of the new offer for the Web Hosting plan. + """ + + protected: Optional[bool] + """ + Whether the hosting is protected or not. + """ + + +@dataclass +class ListControlPanelsResponse: + total_count: int + """ + Number of control panels returned. + """ + + control_panels: List[ControlPanel] + """ + List of control panels. + """ + + +@dataclass +class ListDatabaseUsersResponse: + total_count: int + """ + Total number of database users. + """ + + users: List[DatabaseUser] + """ + List of database users. + """ + + +@dataclass +class ListDatabasesResponse: + total_count: int + """ + Total number of databases. + """ + + databases: List[Database] + """ + List of databases. + """ + + +@dataclass +class ListFtpAccountsResponse: + total_count: int + """ + Total number of FTP accounts. + """ + + ftp_accounts: List[FtpAccount] + """ + List of FTP accounts. + """ + + +@dataclass +class ListHostingsResponse: + total_count: int + """ + Number of Web Hosting plans returned. + """ + + hostings: List[HostingSummary] + """ + List of Web Hosting plans. + """ + + +@dataclass +class ListMailAccountsResponse: + total_count: int + """ + Total number of mail accounts. + """ + + mail_accounts: List[MailAccount] + """ + List of mail accounts. + """ + + +@dataclass +class ListOffersResponse: + total_count: int + """ + Total number of offers. + """ + + offers: List[Offer] + """ + List of offers. + """ + + +@dataclass +class ListWebsitesResponse: + total_count: int + """ + Total number of websites. + """ + + websites: List[Website] + """ + List of websites. + """ + + +@dataclass +class MailAccountApiChangeMailAccountPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part of the mail account address. + """ + + password: str + """ + New password for the mail account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class MailAccountApiCreateMailAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part address of the mail account address. + """ + + password: str + """ + Password for the new mail account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class MailAccountApiListMailAccountsRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of mail accounts to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListMailAccountsRequestOrderBy] + """ + Sort order of mail accounts in the response. + """ + + domain: Optional[str] + """ + Domain to filter the mail accounts. + """ + + +@dataclass +class MailAccountApiRemoveMailAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part of the mail account address. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class OfferApiListOffersRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of websites to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListOffersRequestOrderBy] + """ + Sort order for Web Hosting offers in the response. + """ + + hosting_id: Optional[str] + """ + UUID of the hosting plan. + """ + + control_panels: Optional[List[str]] + """ + Name of the control panel(s) to filter for. + """ + + +@dataclass +class ResetHostingPasswordResponse: + one_time_password: str + """ + New temporary password. + """ + + +@dataclass +class Session: + url: str + """ + Logged user's session URL. + """ + + +@dataclass +class WebsiteApiListWebsitesRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of websites to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListWebsitesRequestOrderBy] + """ + Sort order for Web Hosting websites in the response. + """ diff --git a/scaleway/scaleway/webhosting/v1/__init__.py b/scaleway/scaleway/webhosting/v1/__init__.py new file mode 100644 index 00000000..cf1d49e5 --- /dev/null +++ b/scaleway/scaleway/webhosting/v1/__init__.py @@ -0,0 +1,153 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import HostingDnsStatus +from .types import HostingStatus +from .content import HOSTING_TRANSIENT_STATUSES +from .types import HostingSummaryStatus +from .content import HOSTING_SUMMARY_TRANSIENT_STATUSES +from .types import ListDatabaseUsersRequestOrderBy +from .types import ListDatabasesRequestOrderBy +from .types import ListFtpAccountsRequestOrderBy +from .types import ListHostingsRequestOrderBy +from .types import ListMailAccountsRequestOrderBy +from .types import ListOffersRequestOrderBy +from .types import ListWebsitesRequestOrderBy +from .types import OfferOptionName +from .types import OfferOptionWarning +from .types import OfferOption +from .types import CreateHostingRequestDomainConfiguration +from .types import OfferOptionRequest +from .types import HostingCpanelUrls +from .types import HostingOption +from .types import ControlPanel +from .types import DatabaseUser +from .types import Database +from .types import FtpAccount +from .types import HostingSummary +from .types import MailAccount +from .types import Offer +from .types import Website +from .types import ControlPanelApiListControlPanelsRequest +from .types import DatabaseApiAssignDatabaseUserRequest +from .types import DatabaseApiChangeDatabaseUserPasswordRequest +from .types import DatabaseApiCreateDatabaseRequest +from .types import DatabaseApiCreateDatabaseUserRequest +from .types import DatabaseApiDeleteDatabaseRequest +from .types import DatabaseApiDeleteDatabaseUserRequest +from .types import DatabaseApiGetDatabaseRequest +from .types import DatabaseApiGetDatabaseUserRequest +from .types import DatabaseApiListDatabaseUsersRequest +from .types import DatabaseApiListDatabasesRequest +from .types import DatabaseApiUnassignDatabaseUserRequest +from .types import FtpAccountApiChangeFtpAccountPasswordRequest +from .types import FtpAccountApiCreateFtpAccountRequest +from .types import FtpAccountApiListFtpAccountsRequest +from .types import FtpAccountApiRemoveFtpAccountRequest +from .types import Hosting +from .types import HostingApiCreateHostingRequest +from .types import HostingApiCreateSessionRequest +from .types import HostingApiDeleteHostingRequest +from .types import HostingApiGetHostingRequest +from .types import HostingApiListHostingsRequest +from .types import HostingApiResetHostingPasswordRequest +from .types import HostingApiUpdateHostingRequest +from .types import ListControlPanelsResponse +from .types import ListDatabaseUsersResponse +from .types import ListDatabasesResponse +from .types import ListFtpAccountsResponse +from .types import ListHostingsResponse +from .types import ListMailAccountsResponse +from .types import ListOffersResponse +from .types import ListWebsitesResponse +from .types import MailAccountApiChangeMailAccountPasswordRequest +from .types import MailAccountApiCreateMailAccountRequest +from .types import MailAccountApiListMailAccountsRequest +from .types import MailAccountApiRemoveMailAccountRequest +from .types import OfferApiListOffersRequest +from .types import ResetHostingPasswordResponse +from .types import Session +from .types import WebsiteApiListWebsitesRequest +from .api import WebhostingV1ControlPanelAPI +from .api import WebhostingV1DatabaseAPI +from .api import WebhostingV1OfferAPI +from .api import WebhostingV1HostingAPI +from .api import WebhostingV1FtpAccountAPI +from .api import WebhostingV1MailAccountAPI +from .api import WebhostingV1WebsiteAPI + +__all__ = [ + "HostingDnsStatus", + "HostingStatus", + "HOSTING_TRANSIENT_STATUSES", + "HostingSummaryStatus", + "HOSTING_SUMMARY_TRANSIENT_STATUSES", + "ListDatabaseUsersRequestOrderBy", + "ListDatabasesRequestOrderBy", + "ListFtpAccountsRequestOrderBy", + "ListHostingsRequestOrderBy", + "ListMailAccountsRequestOrderBy", + "ListOffersRequestOrderBy", + "ListWebsitesRequestOrderBy", + "OfferOptionName", + "OfferOptionWarning", + "OfferOption", + "CreateHostingRequestDomainConfiguration", + "OfferOptionRequest", + "HostingCpanelUrls", + "HostingOption", + "ControlPanel", + "DatabaseUser", + "Database", + "FtpAccount", + "HostingSummary", + "MailAccount", + "Offer", + "Website", + "ControlPanelApiListControlPanelsRequest", + "DatabaseApiAssignDatabaseUserRequest", + "DatabaseApiChangeDatabaseUserPasswordRequest", + "DatabaseApiCreateDatabaseRequest", + "DatabaseApiCreateDatabaseUserRequest", + "DatabaseApiDeleteDatabaseRequest", + "DatabaseApiDeleteDatabaseUserRequest", + "DatabaseApiGetDatabaseRequest", + "DatabaseApiGetDatabaseUserRequest", + "DatabaseApiListDatabaseUsersRequest", + "DatabaseApiListDatabasesRequest", + "DatabaseApiUnassignDatabaseUserRequest", + "FtpAccountApiChangeFtpAccountPasswordRequest", + "FtpAccountApiCreateFtpAccountRequest", + "FtpAccountApiListFtpAccountsRequest", + "FtpAccountApiRemoveFtpAccountRequest", + "Hosting", + "HostingApiCreateHostingRequest", + "HostingApiCreateSessionRequest", + "HostingApiDeleteHostingRequest", + "HostingApiGetHostingRequest", + "HostingApiListHostingsRequest", + "HostingApiResetHostingPasswordRequest", + "HostingApiUpdateHostingRequest", + "ListControlPanelsResponse", + "ListDatabaseUsersResponse", + "ListDatabasesResponse", + "ListFtpAccountsResponse", + "ListHostingsResponse", + "ListMailAccountsResponse", + "ListOffersResponse", + "ListWebsitesResponse", + "MailAccountApiChangeMailAccountPasswordRequest", + "MailAccountApiCreateMailAccountRequest", + "MailAccountApiListMailAccountsRequest", + "MailAccountApiRemoveMailAccountRequest", + "OfferApiListOffersRequest", + "ResetHostingPasswordResponse", + "Session", + "WebsiteApiListWebsitesRequest", + "WebhostingV1ControlPanelAPI", + "WebhostingV1DatabaseAPI", + "WebhostingV1OfferAPI", + "WebhostingV1HostingAPI", + "WebhostingV1FtpAccountAPI", + "WebhostingV1MailAccountAPI", + "WebhostingV1WebsiteAPI", +] diff --git a/scaleway/scaleway/webhosting/v1/api.py b/scaleway/scaleway/webhosting/v1/api.py new file mode 100644 index 00000000..a1ce27df --- /dev/null +++ b/scaleway/scaleway/webhosting/v1/api.py @@ -0,0 +1,1794 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + HostingStatus, + ListDatabaseUsersRequestOrderBy, + ListDatabasesRequestOrderBy, + ListFtpAccountsRequestOrderBy, + ListHostingsRequestOrderBy, + ListMailAccountsRequestOrderBy, + ListOffersRequestOrderBy, + ListWebsitesRequestOrderBy, + ControlPanel, + CreateHostingRequestDomainConfiguration, + Database, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiUnassignDatabaseUserRequest, + DatabaseUser, + FtpAccount, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + Hosting, + HostingApiCreateHostingRequest, + HostingApiUpdateHostingRequest, + HostingSummary, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + ListHostingsResponse, + ListMailAccountsResponse, + ListOffersResponse, + ListWebsitesResponse, + MailAccount, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiRemoveMailAccountRequest, + Offer, + OfferOptionRequest, + ResetHostingPasswordResponse, + Session, + Website, +) +from .content import ( + HOSTING_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_DatabaseUser, + unmarshal_Database, + unmarshal_FtpAccount, + unmarshal_MailAccount, + unmarshal_Hosting, + unmarshal_ListControlPanelsResponse, + unmarshal_ListDatabaseUsersResponse, + unmarshal_ListDatabasesResponse, + unmarshal_ListFtpAccountsResponse, + unmarshal_ListHostingsResponse, + unmarshal_ListMailAccountsResponse, + unmarshal_ListOffersResponse, + unmarshal_ListWebsitesResponse, + unmarshal_ResetHostingPasswordResponse, + unmarshal_Session, + marshal_DatabaseApiAssignDatabaseUserRequest, + marshal_DatabaseApiChangeDatabaseUserPasswordRequest, + marshal_DatabaseApiCreateDatabaseRequest, + marshal_DatabaseApiCreateDatabaseUserRequest, + marshal_DatabaseApiUnassignDatabaseUserRequest, + marshal_FtpAccountApiChangeFtpAccountPasswordRequest, + marshal_FtpAccountApiCreateFtpAccountRequest, + marshal_HostingApiCreateHostingRequest, + marshal_HostingApiUpdateHostingRequest, + marshal_MailAccountApiChangeMailAccountPasswordRequest, + marshal_MailAccountApiCreateMailAccountRequest, + marshal_MailAccountApiRemoveMailAccountRequest, +) +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +class WebhostingV1ControlPanelAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + def list_control_panels( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListControlPanelsResponse: + """ + "List the control panels type: cpanel or plesk.". + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of control panels to return (must be a positive integer lower or equal to 100). + :return: :class:`ListControlPanelsResponse ` + + Usage: + :: + + result = api.list_control_panels() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/control-panels", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListControlPanelsResponse(res.json()) + + def list_control_panels_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ControlPanel]: + """ + "List the control panels type: cpanel or plesk.". + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of control panels to return (must be a positive integer lower or equal to 100). + :return: :class:`List[ControlPanel] ` + + Usage: + :: + + result = api.list_control_panels_all() + """ + + return fetch_all_pages( + type=ListControlPanelsResponse, + key="control_panels", + fetcher=self.list_control_panels, + args={ + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + +class WebhostingV1DatabaseAPI(API): + """ + This API allows you to manage your databases and database users for your Web Hosting services. + """ + + def create_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Create a new database within your hosting plan". + :param hosting_id: UUID of the hosting plan where the database will be created. + :param database_name: Name of the database to be created. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = api.create_database( + hosting_id="example", + database_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}/databases", + body=marshal_DatabaseApiCreateDatabaseRequest( + DatabaseApiCreateDatabaseRequest( + hosting_id=hosting_id, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + def list_databases( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabasesRequestOrderBy] = None, + ) -> ListDatabasesResponse: + """ + "List all databases within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of databases to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of databases in the response. + :return: :class:`ListDatabasesResponse ` + + Usage: + :: + + result = api.list_databases( + 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}/databases", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDatabasesResponse(res.json()) + + def list_databases_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabasesRequestOrderBy] = None, + ) -> List[Database]: + """ + "List all databases within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of databases to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of databases in the response. + :return: :class:`List[Database] ` + + Usage: + :: + + result = api.list_databases_all( + hosting_id="example", + ) + """ + + return fetch_all_pages( + type=ListDatabasesResponse, + key="databases", + fetcher=self.list_databases, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + def get_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Get details of a database within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param database_name: Name of the database. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = api.get_database( + hosting_id="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}", + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + def delete_database( + self, + *, + hosting_id: str, + database_name: str, + region: Optional[Region] = None, + ) -> Database: + """ + "Delete a database within your hosting plan". + :param hosting_id: UUID of the hosting plan. + :param database_name: Name of the database to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Database ` + + Usage: + :: + + result = api.delete_database( + hosting_id="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}", + ) + + self._throw_on_error(res) + return unmarshal_Database(res.json()) + + def create_database_user( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Create a new database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to create. + :param password: Password of the user to create. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.create_database_user( + hosting_id="example", + username="example", + password="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}/databases-users", + body=marshal_DatabaseApiCreateDatabaseUserRequest( + DatabaseApiCreateDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + def list_database_users( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabaseUsersRequestOrderBy] = None, + ) -> ListDatabaseUsersResponse: + """ + "List all database users". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of database users to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of database users in the response. + :return: :class:`ListDatabaseUsersResponse ` + + Usage: + :: + + result = api.list_database_users( + 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}/database-users", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDatabaseUsersResponse(res.json()) + + def list_database_users_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDatabaseUsersRequestOrderBy] = None, + ) -> List[DatabaseUser]: + """ + "List all database users". + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of database users to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of database users in the response. + :return: :class:`List[DatabaseUser] ` + + Usage: + :: + + result = api.list_database_users_all( + hosting_id="example", + ) + """ + + return fetch_all_pages( + type=ListDatabaseUsersResponse, + key="users", + fetcher=self.list_database_users, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + def get_database_user( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Get details of a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the database user to retrieve details. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.get_database_user( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases-users/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + def delete_database_user( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Delete a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the database user to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.delete_database_user( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/database-users/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + def change_database_user_password( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Change the password of a database user". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to update. + :param password: New password. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.change_database_user_password( + hosting_id="example", + username="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases-users/{param_username}/change-password", + body=marshal_DatabaseApiChangeDatabaseUserPasswordRequest( + DatabaseApiChangeDatabaseUserPasswordRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + def assign_database_user( + self, + *, + hosting_id: str, + username: str, + database_name: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Assign a database user to a database". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to assign. + :param database_name: Name of the database to be assigned. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.assign_database_user( + hosting_id="example", + username="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}/assign-user", + body=marshal_DatabaseApiAssignDatabaseUserRequest( + DatabaseApiAssignDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + def unassign_database_user( + self, + *, + hosting_id: str, + username: str, + database_name: str, + region: Optional[Region] = None, + ) -> DatabaseUser: + """ + "Unassign a database user from a database". + :param hosting_id: UUID of the hosting plan. + :param username: Name of the user to unassign. + :param database_name: Name of the database to be unassigned. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DatabaseUser ` + + Usage: + :: + + result = api.unassign_database_user( + hosting_id="example", + username="example", + database_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_database_name = validate_path_param("database_name", database_name) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/databases/{param_database_name}/unassign-user", + body=marshal_DatabaseApiUnassignDatabaseUserRequest( + DatabaseApiUnassignDatabaseUserRequest( + hosting_id=hosting_id, + username=username, + database_name=database_name, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DatabaseUser(res.json()) + + +class WebhostingV1OfferAPI(API): + """ + This API allows you to manage your offer for your Web Hosting services. + """ + + def list_offers( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListOffersRequestOrderBy] = None, + hosting_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> ListOffersResponse: + """ + List all available hosting offers along with their specific options. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting offers in the response. + :param hosting_id: UUID of the hosting plan. + :param control_panels: Name of the control panel(s) to filter for. + :return: :class:`ListOffersResponse ` + + Usage: + :: + + result = api.list_offers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/offers", + params={ + "control_panels": control_panels, + "hosting_id": hosting_id, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListOffersResponse(res.json()) + + def list_offers_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListOffersRequestOrderBy] = None, + hosting_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> List[Offer]: + """ + List all available hosting offers along with their specific options. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting offers in the response. + :param hosting_id: UUID of the hosting plan. + :param control_panels: Name of the control panel(s) to filter for. + :return: :class:`List[Offer] ` + + Usage: + :: + + result = api.list_offers_all() + """ + + return fetch_all_pages( + type=ListOffersResponse, + key="offers", + fetcher=self.list_offers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "hosting_id": hosting_id, + "control_panels": control_panels, + }, + ) + + +class WebhostingV1HostingAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + def create_hosting( + self, + *, + offer_id: str, + email: str, + domain: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + offer_options: Optional[List[OfferOptionRequest]] = None, + language: Optional[StdLanguageCode] = None, + domain_configuration: Optional[CreateHostingRequestDomainConfiguration] = None, + ) -> Hosting: + """ + Order a Web Hosting plan. + Order a Web Hosting plan, specifying the offer type required via the `offer_id` parameter. + :param offer_id: ID of the selected offer for the Web Hosting plan. + :param email: Contact email for the Web Hosting client. + :param domain: Domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Scaleway Project in which to create the Web Hosting plan. + :param tags: List of tags for the Web Hosting plan. + :param offer_options: List of the Web Hosting plan options IDs with their quantities. + :param language: Default language for the control panel interface. + :param domain_configuration: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements. + :return: :class:`Hosting ` + + Usage: + :: + + result = api.create_hosting( + offer_id="example", + email="example", + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings", + body=marshal_HostingApiCreateHostingRequest( + HostingApiCreateHostingRequest( + offer_id=offer_id, + email=email, + domain=domain, + region=region, + project_id=project_id, + tags=tags, + offer_options=offer_options, + language=language, + domain_configuration=domain_configuration, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + def list_hostings( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListHostingsRequestOrderBy] = None, + tags: Optional[List[str]] = None, + statuses: Optional[List[HostingStatus]] = None, + domain: Optional[str] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> ListHostingsResponse: + """ + List all Web Hosting plans. + List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return, from the paginated results (must be a positive integer). + :param page_size: Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting plans in the response. + :param tags: Tags to filter for, only Web Hosting plans with matching tags will be returned. + :param statuses: Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + :param domain: Domain to filter for, only Web Hosting plans associated with this domain will be returned. + :param project_id: Project ID to filter for, only Web Hosting plans from this Project will be returned. + :param organization_id: Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + :param control_panels: Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + :return: :class:`ListHostingsResponse ` + + Usage: + :: + + result = api.list_hostings() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings", + params={ + "control_panels": control_panels, + "domain": domain, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "statuses": statuses, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListHostingsResponse(res.json()) + + def list_hostings_all( + self, + *, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListHostingsRequestOrderBy] = None, + tags: Optional[List[str]] = None, + statuses: Optional[List[HostingStatus]] = None, + domain: Optional[str] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + control_panels: Optional[List[str]] = None, + ) -> List[HostingSummary]: + """ + List all Web Hosting plans. + List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return, from the paginated results (must be a positive integer). + :param page_size: Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting plans in the response. + :param tags: Tags to filter for, only Web Hosting plans with matching tags will be returned. + :param statuses: Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + :param domain: Domain to filter for, only Web Hosting plans associated with this domain will be returned. + :param project_id: Project ID to filter for, only Web Hosting plans from this Project will be returned. + :param organization_id: Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + :param control_panels: Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + :return: :class:`List[HostingSummary] ` + + Usage: + :: + + result = api.list_hostings_all() + """ + + return fetch_all_pages( + type=ListHostingsResponse, + key="hostings", + fetcher=self.list_hostings, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "tags": tags, + "statuses": statuses, + "domain": domain, + "project_id": project_id, + "organization_id": organization_id, + "control_panels": control_panels, + }, + ) + + def get_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Hosting: + """ + Get a Web Hosting plan. + Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = api.get_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( + "GET", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + def wait_for_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Hosting, bool]] = None, + ) -> Hosting: + """ + Get a Web Hosting plan. + Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = api.get_hosting( + hosting_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in HOSTING_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_hosting, + options=options, + args={ + "hosting_id": hosting_id, + "region": region, + }, + ) + + def update_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + email: Optional[str] = None, + tags: Optional[List[str]] = None, + offer_options: Optional[List[OfferOptionRequest]] = None, + offer_id: Optional[str] = None, + protected: Optional[bool] = None, + ) -> Hosting: + """ + Update a Web Hosting plan. + Update the details of one of your existing Web Hosting plans, specified by its `hosting_id`. You can update parameters including the contact email address, tags, options and offer. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :param email: New contact email for the Web Hosting plan. + :param tags: New tags for the Web Hosting plan. + :param offer_options: List of the Web Hosting plan options IDs with their quantities. + :param offer_id: ID of the new offer for the Web Hosting plan. + :param protected: Whether the hosting is protected or not. + :return: :class:`Hosting ` + + Usage: + :: + + result = api.update_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( + "PATCH", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + body=marshal_HostingApiUpdateHostingRequest( + HostingApiUpdateHostingRequest( + hosting_id=hosting_id, + region=region, + email=email, + tags=tags, + offer_options=offer_options, + offer_id=offer_id, + protected=protected, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + def delete_hosting( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Hosting: + """ + Delete a Web Hosting plan. + Delete a Web Hosting plan, specified by its `hosting_id`. Note that deletion is not immediate: it will take place at the end of the calendar month, after which time your Web Hosting plan and all its data (files and emails) will be irreversibly lost. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Hosting ` + + Usage: + :: + + result = api.delete_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( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}", + ) + + self._throw_on_error(res) + return unmarshal_Hosting(res.json()) + + def create_session( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Session: + """ + Create a user session. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Session ` + + Usage: + :: + + result = api.create_session( + 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}/sessions", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Session(res.json()) + + def reset_hosting_password( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> ResetHostingPasswordResponse: + """ + Reset a Web Hosting plan password. + :param hosting_id: UUID of the hosting. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ResetHostingPasswordResponse ` + + Usage: + :: + + result = api.reset_hosting_password( + 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-password", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_ResetHostingPasswordResponse(res.json()) + + +class WebhostingV1FtpAccountAPI(API): + """ + This API allows you to manage your FTP accounts for your Web Hosting services. + """ + + def create_ftp_account( + self, + *, + hosting_id: str, + username: str, + path: str, + password: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + Create a new FTP account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param username: Username for the new FTP account. + :param path: Path for the new FTP account. + :param password: Password for the new FTP account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = api.create_ftp_account( + hosting_id="example", + username="example", + path="example", + password="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}/ftp-accounts", + body=marshal_FtpAccountApiCreateFtpAccountRequest( + FtpAccountApiCreateFtpAccountRequest( + hosting_id=hosting_id, + username=username, + path=path, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + def list_ftp_accounts( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListFtpAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> ListFtpAccountsResponse: + """ + List all FTP accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of FTP accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of FTP accounts in the response. + :param domain: Domain to filter the FTP accounts. + :return: :class:`ListFtpAccountsResponse ` + + Usage: + :: + + result = api.list_ftp_accounts( + 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}/ftp-accounts", + params={ + "domain": domain, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListFtpAccountsResponse(res.json()) + + def list_ftp_accounts_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListFtpAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> List[FtpAccount]: + """ + List all FTP accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of FTP accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of FTP accounts in the response. + :param domain: Domain to filter the FTP accounts. + :return: :class:`List[FtpAccount] ` + + Usage: + :: + + result = api.list_ftp_accounts_all( + hosting_id="example", + ) + """ + + return fetch_all_pages( + type=ListFtpAccountsResponse, + key="ftp_accounts", + fetcher=self.list_ftp_accounts, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "domain": domain, + }, + ) + + def remove_ftp_account( + self, + *, + hosting_id: str, + username: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + Delete a specific FTP account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param username: Username of the FTP account to be deleted. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = api.remove_ftp_account( + hosting_id="example", + username="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "DELETE", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/ftp-accounts/{param_username}", + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + def change_ftp_account_password( + self, + *, + hosting_id: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> FtpAccount: + """ + :param hosting_id: UUID of the hosting plan. + :param username: Username of the FTP account. + :param password: New password for the FTP account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`FtpAccount ` + + Usage: + :: + + result = api.change_ftp_account_password( + hosting_id="example", + username="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + param_username = validate_path_param("username", username) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/ftp-accounts/{param_username}/change-password", + body=marshal_FtpAccountApiChangeFtpAccountPasswordRequest( + FtpAccountApiChangeFtpAccountPasswordRequest( + hosting_id=hosting_id, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_FtpAccount(res.json()) + + +class WebhostingV1MailAccountAPI(API): + """ + This API allows you to manage your mail accounts for your Web Hosting services. + """ + + def create_mail_account( + self, + *, + hosting_id: str, + domain: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Create a new mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part address of the mail account address. + :param password: Password for the new mail account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = api.create_mail_account( + hosting_id="example", + domain="example", + username="example", + password="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}/mail-accounts", + body=marshal_MailAccountApiCreateMailAccountRequest( + MailAccountApiCreateMailAccountRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + def list_mail_accounts( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListMailAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> ListMailAccountsResponse: + """ + List all mail accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of mail accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of mail accounts in the response. + :param domain: Domain to filter the mail accounts. + :return: :class:`ListMailAccountsResponse ` + + Usage: + :: + + result = api.list_mail_accounts( + 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}/mail-accounts", + params={ + "domain": domain, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListMailAccountsResponse(res.json()) + + def list_mail_accounts_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListMailAccountsRequestOrderBy] = None, + domain: Optional[str] = None, + ) -> List[MailAccount]: + """ + List all mail accounts within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of mail accounts to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order of mail accounts in the response. + :param domain: Domain to filter the mail accounts. + :return: :class:`List[MailAccount] ` + + Usage: + :: + + result = api.list_mail_accounts_all( + hosting_id="example", + ) + """ + + return fetch_all_pages( + type=ListMailAccountsResponse, + key="mail_accounts", + fetcher=self.list_mail_accounts, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "domain": domain, + }, + ) + + def remove_mail_account( + self, + *, + hosting_id: str, + domain: str, + username: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Delete a mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part of the mail account address. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = api.remove_mail_account( + hosting_id="example", + domain="example", + username="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}/remove-mail-account", + body=marshal_MailAccountApiRemoveMailAccountRequest( + MailAccountApiRemoveMailAccountRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + def change_mail_account_password( + self, + *, + hosting_id: str, + domain: str, + username: str, + password: str, + region: Optional[Region] = None, + ) -> MailAccount: + """ + Update the password of a mail account within your hosting plan. + :param hosting_id: UUID of the hosting plan. + :param domain: Domain part of the mail account address. + :param username: Username part of the mail account address. + :param password: New password for the mail account. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`MailAccount ` + + Usage: + :: + + result = api.change_mail_account_password( + hosting_id="example", + domain="example", + username="example", + password="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}/change-mail-password", + body=marshal_MailAccountApiChangeMailAccountPasswordRequest( + MailAccountApiChangeMailAccountPasswordRequest( + hosting_id=hosting_id, + domain=domain, + username=username, + password=password, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_MailAccount(res.json()) + + +class WebhostingV1WebsiteAPI(API): + """ + This API allows you to manage your websites for your Web Hosting services. + """ + + def list_websites( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListWebsitesRequestOrderBy] = None, + ) -> ListWebsitesResponse: + """ + List all websites for a specific hosting. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting websites in the response. + :return: :class:`ListWebsitesResponse ` + + Usage: + :: + + result = api.list_websites( + 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}/websites", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListWebsitesResponse(res.json()) + + def list_websites_all( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListWebsitesRequestOrderBy] = None, + ) -> List[Website]: + """ + List all websites for a specific hosting. + :param hosting_id: UUID of the hosting plan. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number (must be a positive integer). + :param page_size: Number of websites to return (must be a positive integer lower or equal to 100). + :param order_by: Sort order for Web Hosting websites in the response. + :return: :class:`List[Website] ` + + Usage: + :: + + result = api.list_websites_all( + hosting_id="example", + ) + """ + + return fetch_all_pages( + type=ListWebsitesResponse, + key="websites", + fetcher=self.list_websites, + args={ + "hosting_id": hosting_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) diff --git a/scaleway/scaleway/webhosting/v1/content.py b/scaleway/scaleway/webhosting/v1/content.py new file mode 100644 index 00000000..0d24b738 --- /dev/null +++ b/scaleway/scaleway/webhosting/v1/content.py @@ -0,0 +1,25 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + HostingStatus, + HostingSummaryStatus, +) + +HOSTING_TRANSIENT_STATUSES: List[HostingStatus] = [ + HostingStatus.DELIVERING, + HostingStatus.DELETING, + HostingStatus.MIGRATING, +] +""" +Lists transient statutes of the enum :class:`HostingStatus `. +""" +HOSTING_SUMMARY_TRANSIENT_STATUSES: List[HostingSummaryStatus] = [ + HostingSummaryStatus.DELIVERING, + HostingSummaryStatus.DELETING, + HostingSummaryStatus.MIGRATING, +] +""" +Lists transient statutes of the enum :class:`HostingSummaryStatus `. +""" diff --git a/scaleway/scaleway/webhosting/v1/marshalling.py b/scaleway/scaleway/webhosting/v1/marshalling.py new file mode 100644 index 00000000..c8ade0bf --- /dev/null +++ b/scaleway/scaleway/webhosting/v1/marshalling.py @@ -0,0 +1,902 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from .types import ( + DatabaseUser, + Database, + FtpAccount, + MailAccount, + HostingCpanelUrls, + HostingOption, + Hosting, + ControlPanel, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + HostingSummary, + ListHostingsResponse, + ListMailAccountsResponse, + OfferOption, + Offer, + ListOffersResponse, + Website, + ListWebsitesResponse, + ResetHostingPasswordResponse, + Session, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiUnassignDatabaseUserRequest, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + CreateHostingRequestDomainConfiguration, + OfferOptionRequest, + HostingApiCreateHostingRequest, + HostingApiUpdateHostingRequest, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiRemoveMailAccountRequest, +) +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +def unmarshal_DatabaseUser(data: Any) -> DatabaseUser: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DatabaseUser' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("databases", None) + if field is not None: + args["databases"] = field + + return DatabaseUser(**args) + + +def unmarshal_Database(data: Any) -> Database: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Database' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("database_name", None) + if field is not None: + args["database_name"] = field + + field = data.get("users", None) + if field is not None: + args["users"] = field + + return Database(**args) + + +def unmarshal_FtpAccount(data: Any) -> FtpAccount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'FtpAccount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return FtpAccount(**args) + + +def unmarshal_MailAccount(data: Any) -> MailAccount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'MailAccount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + return MailAccount(**args) + + +def unmarshal_HostingCpanelUrls(data: Any) -> HostingCpanelUrls: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dashboard", None) + if field is not None: + args["dashboard"] = field + + field = data.get("webmail", None) + if field is not None: + args["webmail"] = field + + return HostingCpanelUrls(**args) + + +def unmarshal_HostingOption(data: Any) -> HostingOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingOption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("quantity", None) + if field is not None: + args["quantity"] = field + + return HostingOption(**args) + + +def unmarshal_Hosting(data: Any) -> Hosting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Hosting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("platform_hostname", None) + if field is not None: + args["platform_hostname"] = field + + field = data.get("platform_number", None) + if field is not None: + args["platform_number"] = field + + field = data.get("offer_id", None) + if field is not None: + args["offer_id"] = field + + field = data.get("offer_name", None) + if field is not None: + args["offer_name"] = field + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("options", None) + if field is not None: + args["options"] = ( + [unmarshal_HostingOption(v) for v in field] if field is not None else None + ) + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("dns_status", None) + if field is not None: + args["dns_status"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("offer_end_of_life", None) + if field is not None: + args["offer_end_of_life"] = field + + field = data.get("control_panel_name", None) + if field is not None: + args["control_panel_name"] = field + + field = data.get("platform_group", None) + if field is not None: + args["platform_group"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = field + + field = data.get("ipv6", None) + if field is not None: + args["ipv6"] = field + + field = data.get("protected", None) + if field is not None: + args["protected"] = field + + field = data.get("one_time_password", None) + if field is not None: + args["one_time_password"] = field + + field = data.get("contact_email", None) + if field is not None: + args["contact_email"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("cpanel_urls", None) + if field is not None: + args["cpanel_urls"] = unmarshal_HostingCpanelUrls(field) + else: + args["cpanel_urls"] = None + + return Hosting(**args) + + +def unmarshal_ControlPanel(data: Any) -> ControlPanel: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ControlPanel' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("available", None) + if field is not None: + args["available"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("available_languages", None) + if field is not None: + args["available_languages"] = ( + [StdLanguageCode(v) for v in field] if field is not None else None + ) + + return ControlPanel(**args) + + +def unmarshal_ListControlPanelsResponse(data: Any) -> ListControlPanelsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListControlPanelsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("control_panels", None) + if field is not None: + args["control_panels"] = ( + [unmarshal_ControlPanel(v) for v in field] if field is not None else None + ) + + return ListControlPanelsResponse(**args) + + +def unmarshal_ListDatabaseUsersResponse(data: Any) -> ListDatabaseUsersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDatabaseUsersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("users", None) + if field is not None: + args["users"] = ( + [unmarshal_DatabaseUser(v) for v in field] if field is not None else None + ) + + return ListDatabaseUsersResponse(**args) + + +def unmarshal_ListDatabasesResponse(data: Any) -> ListDatabasesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("databases", None) + if field is not None: + args["databases"] = ( + [unmarshal_Database(v) for v in field] if field is not None else None + ) + + return ListDatabasesResponse(**args) + + +def unmarshal_ListFtpAccountsResponse(data: Any) -> ListFtpAccountsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListFtpAccountsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("ftp_accounts", None) + if field is not None: + args["ftp_accounts"] = ( + [unmarshal_FtpAccount(v) for v in field] if field is not None else None + ) + + return ListFtpAccountsResponse(**args) + + +def unmarshal_HostingSummary(data: Any) -> HostingSummary: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HostingSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("domain", None) + if field is not None: + args["domain"] = field + + field = data.get("protected", None) + if field is not None: + args["protected"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return HostingSummary(**args) + + +def unmarshal_ListHostingsResponse(data: Any) -> ListHostingsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("hostings", None) + if field is not None: + args["hostings"] = ( + [unmarshal_HostingSummary(v) for v in field] if field is not None else None + ) + + return ListHostingsResponse(**args) + + +def unmarshal_ListMailAccountsResponse(data: Any) -> ListMailAccountsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListMailAccountsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("mail_accounts", None) + if field is not None: + args["mail_accounts"] = ( + [unmarshal_MailAccount(v) for v in field] if field is not None else None + ) + + return ListMailAccountsResponse(**args) + + +def unmarshal_OfferOption(data: Any) -> OfferOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'OfferOption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("billing_operation_path", None) + if field is not None: + args["billing_operation_path"] = field + + field = data.get("min_value", None) + if field is not None: + args["min_value"] = field + + field = data.get("current_value", None) + if field is not None: + args["current_value"] = field + + field = data.get("max_value", None) + if field is not None: + args["max_value"] = field + + field = data.get("quota_warning", None) + if field is not None: + args["quota_warning"] = field + + return OfferOption(**args) + + +def unmarshal_Offer(data: Any) -> Offer: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Offer' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("billing_operation_path", None) + if field is not None: + args["billing_operation_path"] = field + + field = data.get("options", None) + if field is not None: + args["options"] = ( + [unmarshal_OfferOption(v) for v in field] if field is not None else None + ) + + field = data.get("available", None) + if field is not None: + args["available"] = field + + field = data.get("control_panel_name", None) + if field is not None: + args["control_panel_name"] = field + + field = data.get("end_of_life", None) + if field is not None: + args["end_of_life"] = field + + field = data.get("price", None) + if field is not None: + args["price"] = unmarshal_Money(field) + else: + args["price"] = None + + return Offer(**args) + + +def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("offers", None) + if field is not None: + args["offers"] = ( + [unmarshal_Offer(v) for v in field] if field is not None else None + ) + + return ListOffersResponse(**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 + + field = data.get("path", None) + if field is not None: + args["path"] = field + + field = data.get("ssl_status", None) + if field is not None: + args["ssl_status"] = field + + return Website(**args) + + +def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListWebsitesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("websites", None) + if field is not None: + args["websites"] = ( + [unmarshal_Website(v) for v in field] if field is not None else None + ) + + return ListWebsitesResponse(**args) + + +def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("one_time_password", None) + if field is not None: + args["one_time_password"] = field + + return ResetHostingPasswordResponse(**args) + + +def unmarshal_Session(data: Any) -> Session: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Session' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("url", None) + if field is not None: + args["url"] = field + + return Session(**args) + + +def marshal_DatabaseApiAssignDatabaseUserRequest( + request: DatabaseApiAssignDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + return output + + +def marshal_DatabaseApiChangeDatabaseUserPasswordRequest( + request: DatabaseApiChangeDatabaseUserPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_DatabaseApiCreateDatabaseRequest( + request: DatabaseApiCreateDatabaseRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.database_name is not None: + output["database_name"] = request.database_name + + return output + + +def marshal_DatabaseApiCreateDatabaseUserRequest( + request: DatabaseApiCreateDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_DatabaseApiUnassignDatabaseUserRequest( + request: DatabaseApiUnassignDatabaseUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + return output + + +def marshal_FtpAccountApiChangeFtpAccountPasswordRequest( + request: FtpAccountApiChangeFtpAccountPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_FtpAccountApiCreateFtpAccountRequest( + request: FtpAccountApiCreateFtpAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.username is not None: + output["username"] = request.username + + if request.path is not None: + output["path"] = request.path + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_CreateHostingRequestDomainConfiguration( + request: CreateHostingRequestDomainConfiguration, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.update_nameservers is not None: + output["update_nameservers"] = request.update_nameservers + + if request.update_web_record is not None: + output["update_web_record"] = request.update_web_record + + if request.update_mail_record is not None: + output["update_mail_record"] = request.update_mail_record + + if request.update_all_records is not None: + output["update_all_records"] = request.update_all_records + + return output + + +def marshal_OfferOptionRequest( + request: OfferOptionRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.id is not None: + output["id"] = request.id + + if request.quantity is not None: + output["quantity"] = request.quantity + + return output + + +def marshal_HostingApiCreateHostingRequest( + request: HostingApiCreateHostingRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.offer_id is not None: + output["offer_id"] = request.offer_id + + if request.email is not None: + output["email"] = request.email + + if request.domain is not None: + output["domain"] = request.domain + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.offer_options is not None: + output["offer_options"] = [ + marshal_OfferOptionRequest(item, defaults) for item in request.offer_options + ] + + if request.language is not None: + output["language"] = str(request.language) + + if request.domain_configuration is not None: + output["domain_configuration"] = ( + marshal_CreateHostingRequestDomainConfiguration( + request.domain_configuration, defaults + ) + ) + + return output + + +def marshal_HostingApiUpdateHostingRequest( + request: HostingApiUpdateHostingRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.email is not None: + output["email"] = request.email + + if request.tags is not None: + output["tags"] = request.tags + + if request.offer_options is not None: + output["offer_options"] = [ + marshal_OfferOptionRequest(item, defaults) for item in request.offer_options + ] + + if request.offer_id is not None: + output["offer_id"] = request.offer_id + + if request.protected is not None: + output["protected"] = request.protected + + return output + + +def marshal_MailAccountApiChangeMailAccountPasswordRequest( + request: MailAccountApiChangeMailAccountPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_MailAccountApiCreateMailAccountRequest( + request: MailAccountApiCreateMailAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_MailAccountApiRemoveMailAccountRequest( + request: MailAccountApiRemoveMailAccountRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.domain is not None: + output["domain"] = request.domain + + if request.username is not None: + output["username"] = request.username + + return output diff --git a/scaleway/scaleway/webhosting/v1/types.py b/scaleway/scaleway/webhosting/v1/types.py new file mode 100644 index 00000000..16f5a9da --- /dev/null +++ b/scaleway/scaleway/webhosting/v1/types.py @@ -0,0 +1,1355 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + +from ...std.types import ( + LanguageCode as StdLanguageCode, +) + + +class HostingDnsStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_DNS_STATUS = "unknown_dns_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + +class HostingStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DELIVERING = "delivering" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + MIGRATING = "migrating" + + def __str__(self) -> str: + return str(self.value) + + +class HostingSummaryStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DELIVERING = "delivering" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + MIGRATING = "migrating" + + def __str__(self) -> str: + return str(self.value) + + +class ListDatabaseUsersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDatabasesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DATABASE_NAME_ASC = "database_name_asc" + DATABASE_NAME_DESC = "database_name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListFtpAccountsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListHostingsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListMailAccountsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + USERNAME_ASC = "username_asc" + USERNAME_DESC = "username_desc" + DOMAIN_ASC = "domain_asc" + DOMAIN_DESC = "domain_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListOffersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + PRICE_ASC = "price_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListWebsitesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DOMAIN_ASC = "domain_asc" + DOMAIN_DESC = "domain_desc" + + def __str__(self) -> str: + return str(self.value) + + +class OfferOptionName(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_NAME = "unknown_name" + DOMAIN_COUNT = "domain_count" + EMAIL_COUNT = "email_count" + STORAGE_GB = "storage_gb" + VCPU_COUNT = "vcpu_count" + RAM_GB = "ram_gb" + BACKUP = "backup" + DEDICATED_IP = "dedicated_ip" + + def __str__(self) -> str: + return str(self.value) + + +class OfferOptionWarning(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_WARNING = "unknown_warning" + QUOTA_EXCEEDED_WARNING = "quota_exceeded_warning" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class OfferOption: + id: str + """ + Option ID. + """ + + name: OfferOptionName + """ + Name of the option. + """ + + billing_operation_path: str + """ + Unique identifier used for billing. + """ + + min_value: int + """ + Minimum value for the option in the offer. + """ + + current_value: int + """ + If a hosting_id was specified in the call, defines the current value of the option in the hosting. + """ + + max_value: int + """ + Maximum value for the option in the offer. + """ + + quota_warning: OfferOptionWarning + """ + Defines a warning if the maximum value for the option has been reached. + """ + + +@dataclass +class CreateHostingRequestDomainConfiguration: + update_nameservers: bool + + update_web_record: bool + + update_mail_record: bool + + update_all_records: bool + + +@dataclass +class OfferOptionRequest: + id: str + """ + Offer option ID. + """ + + quantity: int + """ + The option requested quantity to set for the Web Hosting plan. + """ + + +@dataclass +class HostingCpanelUrls: + dashboard: str + + webmail: str + + +@dataclass +class HostingOption: + id: str + """ + Option ID. + """ + + name: OfferOptionName + """ + Option name. + """ + + quantity: int + """ + Option quantity. + """ + + +@dataclass +class ControlPanel: + name: str + """ + Control panel name. + """ + + available: bool + """ + Define if the control panel type is available to order. + """ + + logo_url: str + """ + URL of the control panel's logo. + """ + + available_languages: List[StdLanguageCode] + """ + List of available languages for the control panel. + """ + + +@dataclass +class DatabaseUser: + username: str + """ + Name of the database user. + """ + + databases: List[str] + """ + List of databases accessible by the user. + """ + + +@dataclass +class Database: + database_name: str + """ + Name of the database. + """ + + users: List[str] + """ + List of users who have access to the database. + """ + + +@dataclass +class FtpAccount: + username: str + """ + The username of the FTP account. + """ + + path: str + """ + The path associated with the FTP account. + """ + + +@dataclass +class HostingSummary: + id: str + """ + ID of the Web Hosting plan. + """ + + project_id: str + """ + ID of the Scaleway Project the Web Hosting plan belongs to. + """ + + status: HostingSummaryStatus + """ + Status of the Web Hosting plan. + """ + + domain: str + """ + Main domain associated with the Web Hosting plan. + """ + + protected: bool + """ + Whether the hosting is protected or not. + """ + + region: Region + """ + Region where the Web Hosting plan is hosted. + """ + + updated_at: Optional[datetime] + """ + Date on which the Web Hosting plan was last updated. + """ + + +@dataclass +class MailAccount: + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part address of the mail account address. + """ + + +@dataclass +class Offer: + id: str + """ + Offer ID. + """ + + billing_operation_path: str + """ + Unique identifier used for billing. + """ + + options: List[OfferOption] + """ + Options available for the offer. + """ + + available: bool + """ + If a hosting_id was specified in the call, defines whether the offer is available for a specified hosting plan to migrate (update) to. + """ + + control_panel_name: str + """ + Name of the control panel. + """ + + end_of_life: bool + """ + Indicates if the offer has reached its end of life. + """ + + price: Optional[Money] + """ + Price of the offer. + """ + + +@dataclass +class Website: + domain: str + """ + The domain of the website. + """ + + path: str + """ + The directory path of the website. + """ + + ssl_status: bool + """ + The SSL status of the website. + """ + + +@dataclass +class ControlPanelApiListControlPanelsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of control panels to return (must be a positive integer lower or equal to 100). + """ + + +@dataclass +class DatabaseApiAssignDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to assign. + """ + + database_name: str + """ + Name of the database to be assigned. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiChangeDatabaseUserPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to update. + """ + + password: str + """ + New password. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiCreateDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan where the database will be created. + """ + + database_name: str + """ + Name of the database to be created. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiCreateDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to create. + """ + + password: str + """ + Password of the user to create. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiDeleteDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + database_name: str + """ + Name of the database to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiDeleteDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the database user to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiGetDatabaseRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + database_name: str + """ + Name of the database. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiGetDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the database user to retrieve details. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DatabaseApiListDatabaseUsersRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of database users to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListDatabaseUsersRequestOrderBy] + """ + Sort order of database users in the response. + """ + + +@dataclass +class DatabaseApiListDatabasesRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of databases to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListDatabasesRequestOrderBy] + """ + Sort order of databases in the response. + """ + + +@dataclass +class DatabaseApiUnassignDatabaseUserRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Name of the user to unassign. + """ + + database_name: str + """ + Name of the database to be unassigned. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiChangeFtpAccountPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username of the FTP account. + """ + + password: str + """ + New password for the FTP account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiCreateFtpAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username for the new FTP account. + """ + + path: str + """ + Path for the new FTP account. + """ + + password: str + """ + Password for the new FTP account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class FtpAccountApiListFtpAccountsRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of FTP accounts to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListFtpAccountsRequestOrderBy] + """ + Sort order of FTP accounts in the response. + """ + + domain: Optional[str] + """ + Domain to filter the FTP accounts. + """ + + +@dataclass +class FtpAccountApiRemoveFtpAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + username: str + """ + Username of the FTP account to be deleted. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class Hosting: + id: str + """ + ID of the Web Hosting plan. + """ + + project_id: str + """ + ID of the Scaleway Project the Web Hosting plan belongs to. + """ + + status: HostingStatus + """ + Status of the Web Hosting plan. + """ + + platform_hostname: str + """ + Hostname of the host platform. + """ + + platform_number: int + """ + Number of the host platform. + """ + + offer_id: str + """ + ID of the active offer for the Web Hosting plan. + """ + + offer_name: str + """ + Name of the active offer for the Web Hosting plan. + """ + + domain: str + """ + Main domain associated with the Web Hosting plan. + """ + + tags: List[str] + """ + List of tags associated with the Web Hosting plan. + """ + + options: List[HostingOption] + """ + List of the Web Hosting plan options. + """ + + updated_at: Optional[datetime] + """ + Date on which the Web Hosting plan was last updated. + """ + + created_at: Optional[datetime] + """ + Date on which the Web Hosting plan was created. + """ + + dns_status: HostingDnsStatus + """ + DNS status of the Web Hosting plan. + """ + + username: str + """ + Main Web Hosting cPanel username. + """ + + offer_end_of_life: bool + """ + Indicates if the hosting offer has reached its end of life. + """ + + control_panel_name: str + """ + Name of the control panel. + """ + + platform_group: str + """ + Group of the hosting's host server/platform. + """ + + ipv4: str + """ + IPv4 address of the hosting's host server. + """ + + ipv6: str + """ + IPv6 address of the hosting's host server. + """ + + protected: bool + """ + Whether the hosting is protected or not. + """ + + one_time_password: str + """ + One-time-password used for the first login or reset password, empty after first use. + """ + + contact_email: str + """ + Contact email used for the hosting. + """ + + region: Region + """ + Region where the Web Hosting plan is hosted. + """ + + cpanel_urls: Optional[HostingCpanelUrls] + """ + URL to connect to cPanel dashboard and to Webmail interface. + """ + + +@dataclass +class HostingApiCreateHostingRequest: + offer_id: str + """ + ID of the selected offer for the Web Hosting plan. + """ + + email: str + """ + Contact email for the Web Hosting client. + """ + + domain: str + """ + Domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Scaleway Project in which to create the Web Hosting plan. + """ + + tags: Optional[List[str]] + """ + List of tags for the Web Hosting plan. + """ + + offer_options: Optional[List[OfferOptionRequest]] + """ + List of the Web Hosting plan options IDs with their quantities. + """ + + language: Optional[StdLanguageCode] + """ + Default language for the control panel interface. + """ + + domain_configuration: Optional[CreateHostingRequestDomainConfiguration] + """ + Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements. + """ + + +@dataclass +class HostingApiCreateSessionRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiDeleteHostingRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiGetHostingRequest: + 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] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of Web Hosting plans to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListHostingsRequestOrderBy] + """ + Sort order for Web Hosting plans in the response. + """ + + tags: Optional[List[str]] + """ + Tags to filter for, only Web Hosting plans with matching tags will be returned. + """ + + statuses: Optional[List[HostingStatus]] + """ + Statuses to filter for, only Web Hosting plans with matching statuses will be returned. + """ + + domain: Optional[str] + """ + Domain to filter for, only Web Hosting plans associated with this domain will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for, only Web Hosting plans from this Project will be returned. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for, only Web Hosting plans from this Organization will be returned. + """ + + control_panels: Optional[List[str]] + """ + Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. + """ + + +@dataclass +class HostingApiResetHostingPasswordRequest: + hosting_id: str + """ + UUID of the hosting. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class HostingApiUpdateHostingRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + email: Optional[str] + """ + New contact email for the Web Hosting plan. + """ + + tags: Optional[List[str]] + """ + New tags for the Web Hosting plan. + """ + + offer_options: Optional[List[OfferOptionRequest]] + """ + List of the Web Hosting plan options IDs with their quantities. + """ + + offer_id: Optional[str] + """ + ID of the new offer for the Web Hosting plan. + """ + + protected: Optional[bool] + """ + Whether the hosting is protected or not. + """ + + +@dataclass +class ListControlPanelsResponse: + total_count: int + """ + Number of control panels returned. + """ + + control_panels: List[ControlPanel] + """ + List of control panels. + """ + + +@dataclass +class ListDatabaseUsersResponse: + total_count: int + """ + Total number of database users. + """ + + users: List[DatabaseUser] + """ + List of database users. + """ + + +@dataclass +class ListDatabasesResponse: + total_count: int + """ + Total number of databases. + """ + + databases: List[Database] + """ + List of databases. + """ + + +@dataclass +class ListFtpAccountsResponse: + total_count: int + """ + Total number of FTP accounts. + """ + + ftp_accounts: List[FtpAccount] + """ + List of FTP accounts. + """ + + +@dataclass +class ListHostingsResponse: + total_count: int + """ + Number of Web Hosting plans returned. + """ + + hostings: List[HostingSummary] + """ + List of Web Hosting plans. + """ + + +@dataclass +class ListMailAccountsResponse: + total_count: int + """ + Total number of mail accounts. + """ + + mail_accounts: List[MailAccount] + """ + List of mail accounts. + """ + + +@dataclass +class ListOffersResponse: + total_count: int + """ + Total number of offers. + """ + + offers: List[Offer] + """ + List of offers. + """ + + +@dataclass +class ListWebsitesResponse: + total_count: int + """ + Total number of websites. + """ + + websites: List[Website] + """ + List of websites. + """ + + +@dataclass +class MailAccountApiChangeMailAccountPasswordRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part of the mail account address. + """ + + password: str + """ + New password for the mail account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class MailAccountApiCreateMailAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part address of the mail account address. + """ + + password: str + """ + Password for the new mail account. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class MailAccountApiListMailAccountsRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of mail accounts to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListMailAccountsRequestOrderBy] + """ + Sort order of mail accounts in the response. + """ + + domain: Optional[str] + """ + Domain to filter the mail accounts. + """ + + +@dataclass +class MailAccountApiRemoveMailAccountRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + domain: str + """ + Domain part of the mail account address. + """ + + username: str + """ + Username part of the mail account address. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class OfferApiListOffersRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of websites to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListOffersRequestOrderBy] + """ + Sort order for Web Hosting offers in the response. + """ + + hosting_id: Optional[str] + """ + UUID of the hosting plan. + """ + + control_panels: Optional[List[str]] + """ + Name of the control panel(s) to filter for. + """ + + +@dataclass +class ResetHostingPasswordResponse: + one_time_password: str + """ + New temporary password. + """ + + +@dataclass +class Session: + url: str + """ + Logged user's session URL. + """ + + +@dataclass +class WebsiteApiListWebsitesRequest: + hosting_id: str + """ + UUID of the hosting plan. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number (must be a positive integer). + """ + + page_size: Optional[int] + """ + Number of websites to return (must be a positive integer lower or equal to 100). + """ + + order_by: Optional[ListWebsitesRequestOrderBy] + """ + Sort order for Web Hosting websites in the response. + """