Skip to content

Commit 106f645

Browse files
authored
Merge branch 'main' into v1.6872.0
2 parents 6e5afd9 + 1cf1b8f commit 106f645

File tree

5 files changed

+475
-0
lines changed

5 files changed

+475
-0
lines changed

packages_generated/webhosting/src/v1/api.gen.ts

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {
1111
waitForResource,
1212
} from '@scaleway/sdk-client'
1313
import {
14+
BACKUP_TRANSIENT_STATUSES as BACKUP_TRANSIENT_STATUSES_WEBHOSTING,
1415
DOMAIN_TRANSIENT_STATUSES as DOMAIN_TRANSIENT_STATUSES_WEBHOSTING,
1516
HOSTING_TRANSIENT_STATUSES as HOSTING_TRANSIENT_STATUSES_WEBHOSTING,
1617
} from './content.gen'
1718
import {
19+
marshalBackupApiRestoreBackupItemsRequest,
1820
marshalDatabaseApiAssignDatabaseUserRequest,
1921
marshalDatabaseApiChangeDatabaseUserPasswordRequest,
2022
marshalDatabaseApiCreateDatabaseRequest,
@@ -29,13 +31,16 @@ import {
2931
marshalMailAccountApiChangeMailAccountPasswordRequest,
3032
marshalMailAccountApiCreateMailAccountRequest,
3133
marshalMailAccountApiRemoveMailAccountRequest,
34+
unmarshalBackup,
3235
unmarshalCheckUserOwnsDomainResponse,
3336
unmarshalDatabase,
3437
unmarshalDatabaseUser,
3538
unmarshalDnsRecords,
3639
unmarshalDomain,
3740
unmarshalFtpAccount,
3841
unmarshalHosting,
42+
unmarshalListBackupItemsResponse,
43+
unmarshalListBackupsResponse,
3944
unmarshalListControlPanelsResponse,
4045
unmarshalListDatabasesResponse,
4146
unmarshalListDatabaseUsersResponse,
@@ -47,10 +52,18 @@ import {
4752
unmarshalMailAccount,
4853
unmarshalResetHostingPasswordResponse,
4954
unmarshalResourceSummary,
55+
unmarshalRestoreBackupItemsResponse,
56+
unmarshalRestoreBackupResponse,
5057
unmarshalSearchDomainsResponse,
5158
unmarshalSession,
5259
} from './marshalling.gen'
5360
import type {
61+
Backup,
62+
BackupApiGetBackupRequest,
63+
BackupApiListBackupItemsRequest,
64+
BackupApiListBackupsRequest,
65+
BackupApiRestoreBackupItemsRequest,
66+
BackupApiRestoreBackupRequest,
5467
CheckUserOwnsDomainResponse,
5568
ControlPanelApiListControlPanelsRequest,
5669
Database,
@@ -87,6 +100,8 @@ import type {
87100
HostingApiListHostingsRequest,
88101
HostingApiResetHostingPasswordRequest,
89102
HostingApiUpdateHostingRequest,
103+
ListBackupItemsResponse,
104+
ListBackupsResponse,
90105
ListControlPanelsResponse,
91106
ListDatabasesResponse,
92107
ListDatabaseUsersResponse,
@@ -103,6 +118,8 @@ import type {
103118
OfferApiListOffersRequest,
104119
ResetHostingPasswordResponse,
105120
ResourceSummary,
121+
RestoreBackupItemsResponse,
122+
RestoreBackupResponse,
106123
SearchDomainsResponse,
107124
Session,
108125
WebsiteApiListWebsitesRequest,
@@ -112,6 +129,143 @@ const jsonContentHeaders = {
112129
'Content-Type': 'application/json; charset=utf-8',
113130
}
114131

132+
/**
133+
* Web Hosting backup API.
134+
135+
This API allows you to list and restore backups for your cPanel and WordPress Web Hosting service.
136+
*/
137+
export class BackupAPI extends ParentAPI {
138+
/**
139+
* Locality of this API.
140+
* type ∈ {'zone','region','global','unspecified'}
141+
*/
142+
public static readonly LOCALITY: ApiLocality = toApiLocality({
143+
regions: ['fr-par', 'nl-ams', 'pl-waw'],
144+
})
145+
146+
protected pageOfListBackups = (
147+
request: Readonly<BackupApiListBackupsRequest>,
148+
) =>
149+
this.client.fetch<ListBackupsResponse>(
150+
{
151+
method: 'GET',
152+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/backups`,
153+
urlParams: urlParams(
154+
['order_by', request.orderBy],
155+
['page', request.page],
156+
[
157+
'page_size',
158+
request.pageSize ?? this.client.settings.defaultPageSize,
159+
],
160+
),
161+
},
162+
unmarshalListBackupsResponse,
163+
)
164+
165+
/**
166+
* List all available backups for a hosting account.. List all available backups for a hosting account.
167+
*
168+
* @param request - The request {@link BackupApiListBackupsRequest}
169+
* @returns A Promise of ListBackupsResponse
170+
*/
171+
listBackups = (request: Readonly<BackupApiListBackupsRequest>) =>
172+
enrichForPagination('backups', this.pageOfListBackups, request)
173+
174+
/**
175+
* Get info about a backup specified by the backup ID.. Get info about a backup specified by the backup ID.
176+
*
177+
* @param request - The request {@link BackupApiGetBackupRequest}
178+
* @returns A Promise of Backup
179+
*/
180+
getBackup = (request: Readonly<BackupApiGetBackupRequest>) =>
181+
this.client.fetch<Backup>(
182+
{
183+
method: 'GET',
184+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/backups/${validatePathParam('backupId', request.backupId)}`,
185+
},
186+
unmarshalBackup,
187+
)
188+
189+
/**
190+
* Waits for {@link Backup} to be in a final state.
191+
*
192+
* @param request - The request {@link BackupApiGetBackupRequest}
193+
* @param options - The waiting options
194+
* @returns A Promise of Backup
195+
*/
196+
waitForBackup = (
197+
request: Readonly<BackupApiGetBackupRequest>,
198+
options?: Readonly<WaitForOptions<Backup>>,
199+
) =>
200+
waitForResource(
201+
options?.stop ??
202+
(res =>
203+
Promise.resolve(
204+
!BACKUP_TRANSIENT_STATUSES_WEBHOSTING.includes(res.status),
205+
)),
206+
this.getBackup,
207+
request,
208+
options,
209+
)
210+
211+
/**
212+
* Restore an entire backup to your hosting environment.. Restore an entire backup to your hosting environment.
213+
*
214+
* @param request - The request {@link BackupApiRestoreBackupRequest}
215+
* @returns A Promise of RestoreBackupResponse
216+
*/
217+
restoreBackup = (request: Readonly<BackupApiRestoreBackupRequest>) =>
218+
this.client.fetch<RestoreBackupResponse>(
219+
{
220+
body: '{}',
221+
headers: jsonContentHeaders,
222+
method: 'POST',
223+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/backups/${validatePathParam('backupId', request.backupId)}/restore`,
224+
},
225+
unmarshalRestoreBackupResponse,
226+
)
227+
228+
/**
229+
* List items within a specific backup, grouped by type.. List items within a specific backup, grouped by type.
230+
*
231+
* @param request - The request {@link BackupApiListBackupItemsRequest}
232+
* @returns A Promise of ListBackupItemsResponse
233+
*/
234+
listBackupItems = (request: Readonly<BackupApiListBackupItemsRequest>) =>
235+
this.client.fetch<ListBackupItemsResponse>(
236+
{
237+
method: 'GET',
238+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/backup-items`,
239+
urlParams: urlParams(['backup_id', request.backupId]),
240+
},
241+
unmarshalListBackupItemsResponse,
242+
)
243+
244+
/**
245+
* Restore specific items from a backup (e.g., a database or mailbox).. Restore specific items from a backup (e.g., a database or mailbox).
246+
*
247+
* @param request - The request {@link BackupApiRestoreBackupItemsRequest}
248+
* @returns A Promise of RestoreBackupItemsResponse
249+
*/
250+
restoreBackupItems = (
251+
request: Readonly<BackupApiRestoreBackupItemsRequest>,
252+
) =>
253+
this.client.fetch<RestoreBackupItemsResponse>(
254+
{
255+
body: JSON.stringify(
256+
marshalBackupApiRestoreBackupItemsRequest(
257+
request,
258+
this.client.settings,
259+
),
260+
),
261+
headers: jsonContentHeaders,
262+
method: 'POST',
263+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/restore-backup-items`,
264+
},
265+
unmarshalRestoreBackupItemsResponse,
266+
)
267+
}
268+
115269
/**
116270
* Web Hosting Control Panel API.
117271

packages_generated/webhosting/src/v1/content.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import type {
4+
BackupStatus,
45
DomainAvailabilityStatus,
56
DomainStatus,
67
HostingStatus,
78
} from './types.gen'
89

10+
/** Lists transient statutes of the enum {@link BackupStatus}. */
11+
export const BACKUP_TRANSIENT_STATUSES: BackupStatus[] = ['restoring']
12+
913
/** Lists transient statutes of the enum {@link DomainAvailabilityStatus}. */
1014
export const DOMAIN_AVAILABILITY_TRANSIENT_STATUSES: DomainAvailabilityStatus[] =
1115
['validating']

packages_generated/webhosting/src/v1/marshalling.gen.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import {
1111
} from '@scaleway/sdk-client'
1212
import type {
1313
AutoConfigDomainDns,
14+
Backup,
15+
BackupApiRestoreBackupItemsRequest,
16+
BackupItem,
17+
BackupItemGroup,
1418
CheckUserOwnsDomainResponse,
1519
ControlPanel,
1620
CreateDatabaseRequestUser,
@@ -38,6 +42,8 @@ import type {
3842
HostingDomainCustomDomain,
3943
HostingSummary,
4044
HostingUser,
45+
ListBackupItemsResponse,
46+
ListBackupsResponse,
4147
ListControlPanelsResponse,
4248
ListDatabasesResponse,
4349
ListDatabaseUsersResponse,
@@ -59,12 +65,30 @@ import type {
5965
PlatformControlPanelUrls,
6066
ResetHostingPasswordResponse,
6167
ResourceSummary,
68+
RestoreBackupItemsResponse,
69+
RestoreBackupResponse,
6270
SearchDomainsResponse,
6371
Session,
6472
SyncDomainDnsRecordsRequestRecord,
6573
Website,
6674
} from './types.gen'
6775

76+
export const unmarshalBackup = (data: unknown): Backup => {
77+
if (!isJSONObject(data)) {
78+
throw new TypeError(
79+
`Unmarshalling the type 'Backup' failed as data isn't a dictionary.`,
80+
)
81+
}
82+
83+
return {
84+
createdAt: unmarshalDate(data.created_at),
85+
id: data.id,
86+
size: data.size,
87+
status: data.status,
88+
totalItems: data.total_items,
89+
} as Backup
90+
}
91+
6892
export const unmarshalDatabaseUser = (data: unknown): DatabaseUser => {
6993
if (!isJSONObject(data)) {
7094
throw new TypeError(
@@ -383,6 +407,66 @@ export const unmarshalHosting = (data: unknown): Hosting => {
383407
} as Hosting
384408
}
385409

410+
const unmarshalBackupItem = (data: unknown): BackupItem => {
411+
if (!isJSONObject(data)) {
412+
throw new TypeError(
413+
`Unmarshalling the type 'BackupItem' failed as data isn't a dictionary.`,
414+
)
415+
}
416+
417+
return {
418+
createdAt: unmarshalDate(data.created_at),
419+
id: data.id,
420+
name: data.name,
421+
size: data.size,
422+
status: data.status,
423+
type: data.type,
424+
} as BackupItem
425+
}
426+
427+
const unmarshalBackupItemGroup = (data: unknown): BackupItemGroup => {
428+
if (!isJSONObject(data)) {
429+
throw new TypeError(
430+
`Unmarshalling the type 'BackupItemGroup' failed as data isn't a dictionary.`,
431+
)
432+
}
433+
434+
return {
435+
items: unmarshalArrayOfObject(data.items, unmarshalBackupItem),
436+
type: data.type,
437+
} as BackupItemGroup
438+
}
439+
440+
export const unmarshalListBackupItemsResponse = (
441+
data: unknown,
442+
): ListBackupItemsResponse => {
443+
if (!isJSONObject(data)) {
444+
throw new TypeError(
445+
`Unmarshalling the type 'ListBackupItemsResponse' failed as data isn't a dictionary.`,
446+
)
447+
}
448+
449+
return {
450+
groups: unmarshalArrayOfObject(data.groups, unmarshalBackupItemGroup),
451+
totalCount: data.total_count,
452+
} as ListBackupItemsResponse
453+
}
454+
455+
export const unmarshalListBackupsResponse = (
456+
data: unknown,
457+
): ListBackupsResponse => {
458+
if (!isJSONObject(data)) {
459+
throw new TypeError(
460+
`Unmarshalling the type 'ListBackupsResponse' failed as data isn't a dictionary.`,
461+
)
462+
}
463+
464+
return {
465+
backups: unmarshalArrayOfObject(data.backups, unmarshalBackup),
466+
totalCount: data.total_count,
467+
} as ListBackupsResponse
468+
}
469+
386470
const unmarshalControlPanel = (data: unknown): ControlPanel => {
387471
if (!isJSONObject(data)) {
388472
throw new TypeError(
@@ -593,6 +677,30 @@ export const unmarshalResourceSummary = (data: unknown): ResourceSummary => {
593677
} as ResourceSummary
594678
}
595679

680+
export const unmarshalRestoreBackupItemsResponse = (
681+
data: unknown,
682+
): RestoreBackupItemsResponse => {
683+
if (!isJSONObject(data)) {
684+
throw new TypeError(
685+
`Unmarshalling the type 'RestoreBackupItemsResponse' failed as data isn't a dictionary.`,
686+
)
687+
}
688+
689+
return {} as RestoreBackupItemsResponse
690+
}
691+
692+
export const unmarshalRestoreBackupResponse = (
693+
data: unknown,
694+
): RestoreBackupResponse => {
695+
if (!isJSONObject(data)) {
696+
throw new TypeError(
697+
`Unmarshalling the type 'RestoreBackupResponse' failed as data isn't a dictionary.`,
698+
)
699+
}
700+
701+
return {} as RestoreBackupResponse
702+
}
703+
596704
const unmarshalDomainAvailability = (data: unknown): DomainAvailability => {
597705
if (!isJSONObject(data)) {
598706
throw new TypeError(
@@ -639,6 +747,13 @@ export const unmarshalSession = (data: unknown): Session => {
639747
} as Session
640748
}
641749

750+
export const marshalBackupApiRestoreBackupItemsRequest = (
751+
request: BackupApiRestoreBackupItemsRequest,
752+
defaults: DefaultValues,
753+
): Record<string, unknown> => ({
754+
item_ids: request.itemIds,
755+
})
756+
642757
export const marshalDatabaseApiAssignDatabaseUserRequest = (
643758
request: DatabaseApiAssignDatabaseUserRequest,
644759
defaults: DefaultValues,

0 commit comments

Comments
 (0)