Skip to content

Commit a4d6650

Browse files
authored
feat(webhosting): add fields to backup api (#1317)
1 parent 2c02f6b commit a4d6650

File tree

8 files changed

+600
-4
lines changed

8 files changed

+600
-4
lines changed

scaleway-async/scaleway_async/webhosting/v1/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from .types import OfferOptionName
3030
from .types import OfferOptionWarning
3131
from .types import PlatformPlatformGroup
32+
from .types import ProgressStatus
3233
from .types import AutoConfigDomainDns
3334
from .types import PlatformControlPanelUrls
3435
from .types import HostingDomainCustomDomain
@@ -54,11 +55,14 @@
5455
from .types import FtpAccount
5556
from .types import HostingSummary
5657
from .types import MailAccount
58+
from .types import ProgressSummary
5759
from .types import Website
5860
from .types import DomainAvailability
5961
from .types import BackupApiGetBackupRequest
62+
from .types import BackupApiGetProgressRequest
6063
from .types import BackupApiListBackupItemsRequest
6164
from .types import BackupApiListBackupsRequest
65+
from .types import BackupApiListRecentProgressesRequest
6266
from .types import BackupApiRestoreBackupItemsRequest
6367
from .types import BackupApiRestoreBackupRequest
6468
from .types import CheckFreeDomainAvailabilityResponse
@@ -109,12 +113,14 @@
109113
from .types import ListHostingsResponse
110114
from .types import ListMailAccountsResponse
111115
from .types import ListOffersResponse
116+
from .types import ListRecentProgressesResponse
112117
from .types import ListWebsitesResponse
113118
from .types import MailAccountApiChangeMailAccountPasswordRequest
114119
from .types import MailAccountApiCreateMailAccountRequest
115120
from .types import MailAccountApiListMailAccountsRequest
116121
from .types import MailAccountApiRemoveMailAccountRequest
117122
from .types import OfferApiListOffersRequest
123+
from .types import Progress
118124
from .types import ResetHostingPasswordResponse
119125
from .types import ResourceSummary
120126
from .types import RestoreBackupItemsResponse
@@ -163,6 +169,7 @@
163169
"OfferOptionName",
164170
"OfferOptionWarning",
165171
"PlatformPlatformGroup",
172+
"ProgressStatus",
166173
"AutoConfigDomainDns",
167174
"PlatformControlPanelUrls",
168175
"HostingDomainCustomDomain",
@@ -188,11 +195,14 @@
188195
"FtpAccount",
189196
"HostingSummary",
190197
"MailAccount",
198+
"ProgressSummary",
191199
"Website",
192200
"DomainAvailability",
193201
"BackupApiGetBackupRequest",
202+
"BackupApiGetProgressRequest",
194203
"BackupApiListBackupItemsRequest",
195204
"BackupApiListBackupsRequest",
205+
"BackupApiListRecentProgressesRequest",
196206
"BackupApiRestoreBackupItemsRequest",
197207
"BackupApiRestoreBackupRequest",
198208
"CheckFreeDomainAvailabilityResponse",
@@ -243,12 +253,14 @@
243253
"ListHostingsResponse",
244254
"ListMailAccountsResponse",
245255
"ListOffersResponse",
256+
"ListRecentProgressesResponse",
246257
"ListWebsitesResponse",
247258
"MailAccountApiChangeMailAccountPasswordRequest",
248259
"MailAccountApiCreateMailAccountRequest",
249260
"MailAccountApiListMailAccountsRequest",
250261
"MailAccountApiRemoveMailAccountRequest",
251262
"OfferApiListOffersRequest",
263+
"Progress",
252264
"ResetHostingPasswordResponse",
253265
"ResourceSummary",
254266
"RestoreBackupItemsResponse",

scaleway-async/scaleway_async/webhosting/v1/api.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@
6262
ListHostingsResponse,
6363
ListMailAccountsResponse,
6464
ListOffersResponse,
65+
ListRecentProgressesResponse,
6566
ListWebsitesResponse,
6667
MailAccount,
6768
MailAccountApiChangeMailAccountPasswordRequest,
6869
MailAccountApiCreateMailAccountRequest,
6970
MailAccountApiRemoveMailAccountRequest,
7071
Offer,
7172
OfferOptionRequest,
73+
Progress,
7274
ResetHostingPasswordResponse,
7375
ResourceSummary,
7476
RestoreBackupItemsResponse,
@@ -105,7 +107,9 @@
105107
unmarshal_ListHostingsResponse,
106108
unmarshal_ListMailAccountsResponse,
107109
unmarshal_ListOffersResponse,
110+
unmarshal_ListRecentProgressesResponse,
108111
unmarshal_ListWebsitesResponse,
112+
unmarshal_Progress,
109113
unmarshal_ResetHostingPasswordResponse,
110114
unmarshal_ResourceSummary,
111115
unmarshal_RestoreBackupItemsResponse,
@@ -421,6 +425,76 @@ async def restore_backup_items(
421425
self._throw_on_error(res)
422426
return unmarshal_RestoreBackupItemsResponse(res.json())
423427

428+
async def get_progress(
429+
self,
430+
*,
431+
hosting_id: str,
432+
progress_id: str,
433+
region: Optional[ScwRegion] = None,
434+
) -> Progress:
435+
"""
436+
Retrieve detailed information about a specific progress by its ID.
437+
:param hosting_id: ID of the hosting associated with the progress.
438+
:param progress_id: ID of the progress to retrieve.
439+
:param region: Region to target. If none is passed will use default region from the config.
440+
:return: :class:`Progress <Progress>`
441+
442+
Usage:
443+
::
444+
445+
result = await api.get_progress(
446+
hosting_id="example",
447+
progress_id="example",
448+
)
449+
"""
450+
451+
param_region = validate_path_param(
452+
"region", region or self.client.default_region
453+
)
454+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
455+
param_progress_id = validate_path_param("progress_id", progress_id)
456+
457+
res = self._request(
458+
"GET",
459+
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/progresses/{param_progress_id}",
460+
)
461+
462+
self._throw_on_error(res)
463+
return unmarshal_Progress(res.json())
464+
465+
async def list_recent_progresses(
466+
self,
467+
*,
468+
hosting_id: str,
469+
region: Optional[ScwRegion] = None,
470+
) -> ListRecentProgressesResponse:
471+
"""
472+
List recent progresses associated with a specific backup, grouped by type.
473+
:param hosting_id: ID of the hosting linked to the progress.
474+
:param region: Region to target. If none is passed will use default region from the config.
475+
:return: :class:`ListRecentProgressesResponse <ListRecentProgressesResponse>`
476+
477+
Usage:
478+
::
479+
480+
result = await api.list_recent_progresses(
481+
hosting_id="example",
482+
)
483+
"""
484+
485+
param_region = validate_path_param(
486+
"region", region or self.client.default_region
487+
)
488+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
489+
490+
res = self._request(
491+
"GET",
492+
f"/webhosting/v1/regions/{param_region}/hostings/{param_hosting_id}/progresses",
493+
)
494+
495+
self._throw_on_error(res)
496+
return unmarshal_ListRecentProgressesResponse(res.json())
497+
424498

425499
class WebhostingV1ControlPanelAPI(API):
426500
"""

scaleway-async/scaleway_async/webhosting/v1/marshalling.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
OfferOptionName,
3131
OfferOptionWarning,
3232
PlatformPlatformGroup,
33+
ProgressStatus,
3334
Backup,
3435
DatabaseUser,
3536
Database,
@@ -66,8 +67,11 @@
6667
ListHostingsResponse,
6768
ListMailAccountsResponse,
6869
ListOffersResponse,
70+
ProgressSummary,
71+
ListRecentProgressesResponse,
6972
Website,
7073
ListWebsitesResponse,
74+
Progress,
7175
ResetHostingPasswordResponse,
7276
ResourceSummary,
7377
RestoreBackupItemsResponse,
@@ -1401,6 +1405,60 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse:
14011405
return ListOffersResponse(**args)
14021406

14031407

1408+
def unmarshal_ProgressSummary(data: Any) -> ProgressSummary:
1409+
if not isinstance(data, dict):
1410+
raise TypeError(
1411+
"Unmarshalling the type 'ProgressSummary' failed as data isn't a dictionary."
1412+
)
1413+
1414+
args: dict[str, Any] = {}
1415+
1416+
field = data.get("id", None)
1417+
if field is not None:
1418+
args["id"] = field
1419+
else:
1420+
args["id"] = None
1421+
1422+
field = data.get("backup_items_count", None)
1423+
if field is not None:
1424+
args["backup_items_count"] = field
1425+
else:
1426+
args["backup_items_count"] = 0
1427+
1428+
field = data.get("percentage", None)
1429+
if field is not None:
1430+
args["percentage"] = field
1431+
else:
1432+
args["percentage"] = 0
1433+
1434+
field = data.get("status", None)
1435+
if field is not None:
1436+
args["status"] = field
1437+
else:
1438+
args["status"] = ProgressStatus.UNKNOWN_STATUS
1439+
1440+
return ProgressSummary(**args)
1441+
1442+
1443+
def unmarshal_ListRecentProgressesResponse(data: Any) -> ListRecentProgressesResponse:
1444+
if not isinstance(data, dict):
1445+
raise TypeError(
1446+
"Unmarshalling the type 'ListRecentProgressesResponse' failed as data isn't a dictionary."
1447+
)
1448+
1449+
args: dict[str, Any] = {}
1450+
1451+
field = data.get("progresses", None)
1452+
if field is not None:
1453+
args["progresses"] = (
1454+
[unmarshal_ProgressSummary(v) for v in field] if field is not None else None
1455+
)
1456+
else:
1457+
args["progresses"] = []
1458+
1459+
return ListRecentProgressesResponse(**args)
1460+
1461+
14041462
def unmarshal_Website(data: Any) -> Website:
14051463
if not isinstance(data, dict):
14061464
raise TypeError(
@@ -1455,6 +1513,43 @@ def unmarshal_ListWebsitesResponse(data: Any) -> ListWebsitesResponse:
14551513
return ListWebsitesResponse(**args)
14561514

14571515

1516+
def unmarshal_Progress(data: Any) -> Progress:
1517+
if not isinstance(data, dict):
1518+
raise TypeError(
1519+
"Unmarshalling the type 'Progress' failed as data isn't a dictionary."
1520+
)
1521+
1522+
args: dict[str, Any] = {}
1523+
1524+
field = data.get("id", None)
1525+
if field is not None:
1526+
args["id"] = field
1527+
else:
1528+
args["id"] = None
1529+
1530+
field = data.get("backup_item_groups", None)
1531+
if field is not None:
1532+
args["backup_item_groups"] = (
1533+
[unmarshal_BackupItemGroup(v) for v in field] if field is not None else None
1534+
)
1535+
else:
1536+
args["backup_item_groups"] = []
1537+
1538+
field = data.get("percentage", None)
1539+
if field is not None:
1540+
args["percentage"] = field
1541+
else:
1542+
args["percentage"] = 0
1543+
1544+
field = data.get("status", None)
1545+
if field is not None:
1546+
args["status"] = field
1547+
else:
1548+
args["status"] = ProgressStatus.UNKNOWN_STATUS
1549+
1550+
return Progress(**args)
1551+
1552+
14581553
def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse:
14591554
if not isinstance(data, dict):
14601555
raise TypeError(
@@ -1521,6 +1616,12 @@ def unmarshal_RestoreBackupItemsResponse(data: Any) -> RestoreBackupItemsRespons
15211616

15221617
args: dict[str, Any] = {}
15231618

1619+
field = data.get("progress_id", None)
1620+
if field is not None:
1621+
args["progress_id"] = field
1622+
else:
1623+
args["progress_id"] = None
1624+
15241625
return RestoreBackupItemsResponse(**args)
15251626

15261627

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

15331634
args: dict[str, Any] = {}
15341635

1636+
field = data.get("progress_id", None)
1637+
if field is not None:
1638+
args["progress_id"] = field
1639+
else:
1640+
args["progress_id"] = None
1641+
15351642
return RestoreBackupResponse(**args)
15361643

15371644

0 commit comments

Comments
 (0)