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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .types import OfferOptionName
from .types import OfferOptionWarning
from .types import PlatformPlatformGroup
from .types import ProgressStatus
from .types import AutoConfigDomainDns
from .types import PlatformControlPanelUrls
from .types import HostingDomainCustomDomain
Expand All @@ -54,11 +55,14 @@
from .types import FtpAccount
from .types import HostingSummary
from .types import MailAccount
from .types import ProgressSummary
from .types import Website
from .types import DomainAvailability
from .types import BackupApiGetBackupRequest
from .types import BackupApiGetProgressRequest
from .types import BackupApiListBackupItemsRequest
from .types import BackupApiListBackupsRequest
from .types import BackupApiListRecentProgressesRequest
from .types import BackupApiRestoreBackupItemsRequest
from .types import BackupApiRestoreBackupRequest
from .types import CheckFreeDomainAvailabilityResponse
Expand Down Expand Up @@ -109,12 +113,14 @@
from .types import ListHostingsResponse
from .types import ListMailAccountsResponse
from .types import ListOffersResponse
from .types import ListRecentProgressesResponse
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 Progress
from .types import ResetHostingPasswordResponse
from .types import ResourceSummary
from .types import RestoreBackupItemsResponse
Expand Down Expand Up @@ -163,6 +169,7 @@
"OfferOptionName",
"OfferOptionWarning",
"PlatformPlatformGroup",
"ProgressStatus",
"AutoConfigDomainDns",
"PlatformControlPanelUrls",
"HostingDomainCustomDomain",
Expand All @@ -188,11 +195,14 @@
"FtpAccount",
"HostingSummary",
"MailAccount",
"ProgressSummary",
"Website",
"DomainAvailability",
"BackupApiGetBackupRequest",
"BackupApiGetProgressRequest",
"BackupApiListBackupItemsRequest",
"BackupApiListBackupsRequest",
"BackupApiListRecentProgressesRequest",
"BackupApiRestoreBackupItemsRequest",
"BackupApiRestoreBackupRequest",
"CheckFreeDomainAvailabilityResponse",
Expand Down Expand Up @@ -243,12 +253,14 @@
"ListHostingsResponse",
"ListMailAccountsResponse",
"ListOffersResponse",
"ListRecentProgressesResponse",
"ListWebsitesResponse",
"MailAccountApiChangeMailAccountPasswordRequest",
"MailAccountApiCreateMailAccountRequest",
"MailAccountApiListMailAccountsRequest",
"MailAccountApiRemoveMailAccountRequest",
"OfferApiListOffersRequest",
"Progress",
"ResetHostingPasswordResponse",
"ResourceSummary",
"RestoreBackupItemsResponse",
Expand Down
74 changes: 74 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@
ListHostingsResponse,
ListMailAccountsResponse,
ListOffersResponse,
ListRecentProgressesResponse,
ListWebsitesResponse,
MailAccount,
MailAccountApiChangeMailAccountPasswordRequest,
MailAccountApiCreateMailAccountRequest,
MailAccountApiRemoveMailAccountRequest,
Offer,
OfferOptionRequest,
Progress,
ResetHostingPasswordResponse,
ResourceSummary,
RestoreBackupItemsResponse,
Expand Down Expand Up @@ -105,7 +107,9 @@
unmarshal_ListHostingsResponse,
unmarshal_ListMailAccountsResponse,
unmarshal_ListOffersResponse,
unmarshal_ListRecentProgressesResponse,
unmarshal_ListWebsitesResponse,
unmarshal_Progress,
unmarshal_ResetHostingPasswordResponse,
unmarshal_ResourceSummary,
unmarshal_RestoreBackupItemsResponse,
Expand Down Expand Up @@ -421,6 +425,76 @@ async def restore_backup_items(
self._throw_on_error(res)
return unmarshal_RestoreBackupItemsResponse(res.json())

async def get_progress(
self,
*,
hosting_id: str,
progress_id: str,
region: Optional[ScwRegion] = None,
) -> Progress:
"""
Retrieve detailed information about a specific progress by its ID.
:param hosting_id: ID of the hosting associated with the progress.
:param progress_id: ID of the progress to retrieve.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Progress <Progress>`

Usage:
::

result = await api.get_progress(
hosting_id="example",
progress_id="example",
)
"""

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

res = self._request(
"GET",
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/progresses/{param_progress_id}",
)

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

async def list_recent_progresses(
self,
*,
hosting_id: str,
region: Optional[ScwRegion] = None,
) -> ListRecentProgressesResponse:
"""
List recent progresses associated with a specific backup, grouped by type.
:param hosting_id: ID of the hosting linked to the progress.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`ListRecentProgressesResponse <ListRecentProgressesResponse>`

Usage:
::

result = await api.list_recent_progresses(
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}/progresses",
)

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


class WebhostingV1ControlPanelAPI(API):
"""
Expand Down
107 changes: 107 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
OfferOptionName,
OfferOptionWarning,
PlatformPlatformGroup,
ProgressStatus,
Backup,
DatabaseUser,
Database,
Expand Down Expand Up @@ -66,8 +67,11 @@
ListHostingsResponse,
ListMailAccountsResponse,
ListOffersResponse,
ProgressSummary,
ListRecentProgressesResponse,
Website,
ListWebsitesResponse,
Progress,
ResetHostingPasswordResponse,
ResourceSummary,
RestoreBackupItemsResponse,
Expand Down Expand Up @@ -1401,6 +1405,60 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse:
return ListOffersResponse(**args)


def unmarshal_ProgressSummary(data: Any) -> ProgressSummary:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ProgressSummary' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("id", None)
if field is not None:
args["id"] = field
else:
args["id"] = None

field = data.get("backup_items_count", None)
if field is not None:
args["backup_items_count"] = field
else:
args["backup_items_count"] = 0

field = data.get("percentage", None)
if field is not None:
args["percentage"] = field
else:
args["percentage"] = 0

field = data.get("status", None)
if field is not None:
args["status"] = field
else:
args["status"] = ProgressStatus.UNKNOWN_STATUS

return ProgressSummary(**args)


def unmarshal_ListRecentProgressesResponse(data: Any) -> ListRecentProgressesResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ListRecentProgressesResponse' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("progresses", None)
if field is not None:
args["progresses"] = (
[unmarshal_ProgressSummary(v) for v in field] if field is not None else None
)
else:
args["progresses"] = []

return ListRecentProgressesResponse(**args)


def unmarshal_Website(data: Any) -> Website:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -1455,6 +1513,43 @@ def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse:
return ListWebsitesResponse(**args)


def unmarshal_Progress(data: Any) -> Progress:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'Progress' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("id", None)
if field is not None:
args["id"] = field
else:
args["id"] = None

field = data.get("backup_item_groups", None)
if field is not None:
args["backup_item_groups"] = (
[unmarshal_BackupItemGroup(v) for v in field] if field is not None else None
)
else:
args["backup_item_groups"] = []

field = data.get("percentage", None)
if field is not None:
args["percentage"] = field
else:
args["percentage"] = 0

field = data.get("status", None)
if field is not None:
args["status"] = field
else:
args["status"] = ProgressStatus.UNKNOWN_STATUS

return Progress(**args)


def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -1521,6 +1616,12 @@ def unmarshal_RestoreBackupItemsResponse(data: Any) -> RestoreBackupItemsRespons

args: dict[str, Any] = {}

field = data.get("progress_id", None)
if field is not None:
args["progress_id"] = field
else:
args["progress_id"] = None

return RestoreBackupItemsResponse(**args)


Expand All @@ -1532,6 +1633,12 @@ def unmarshal_RestoreBackupResponse(data: Any) -> RestoreBackupResponse:

args: dict[str, Any] = {}

field = data.get("progress_id", None)
if field is not None:
args["progress_id"] = field
else:
args["progress_id"] = None

return RestoreBackupResponse(**args)


Expand Down
Loading