Skip to content

Commit 23abe58

Browse files
authored
feat(block): publish endpoint ImportSnapshotFromS3 (#1256)
1 parent 845204d commit 23abe58

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

packages/clients/src/api/block/v1alpha1/api.gen.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import {
1616
marshalCreateSnapshotRequest,
1717
marshalCreateVolumeRequest,
18+
marshalImportSnapshotFromS3Request,
1819
marshalUpdateSnapshotRequest,
1920
marshalUpdateVolumeRequest,
2021
unmarshalListSnapshotsResponse,
@@ -30,6 +31,7 @@ import type {
3031
DeleteVolumeRequest,
3132
GetSnapshotRequest,
3233
GetVolumeRequest,
34+
ImportSnapshotFromS3Request,
3335
ListSnapshotsRequest,
3436
ListSnapshotsResponse,
3537
ListVolumeTypesRequest,
@@ -307,6 +309,27 @@ export class API extends ParentAPI {
307309
unmarshalSnapshot,
308310
)
309311

312+
/**
313+
* Import a snapshot from a Scaleway Object Storage bucket. The bucket must
314+
* contain a QCOW2 image. The bucket can be imported into any Availability
315+
* Zone as long as it is in the same region as the bucket.
316+
*
317+
* @param request - The request {@link ImportSnapshotFromS3Request}
318+
* @returns A Promise of Snapshot
319+
*/
320+
importSnapshotFromS3 = (request: Readonly<ImportSnapshotFromS3Request>) =>
321+
this.client.fetch<Snapshot>(
322+
{
323+
body: JSON.stringify(
324+
marshalImportSnapshotFromS3Request(request, this.client.settings),
325+
),
326+
headers: jsonContentHeaders,
327+
method: 'POST',
328+
path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/import-from-s3`,
329+
},
330+
unmarshalSnapshot,
331+
)
332+
310333
/**
311334
* Delete a snapshot. You must specify the `snapshot_id` of the snapshot you
312335
* want to delete. The snapshot must not be in use.

packages/clients/src/api/block/v1alpha1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type {
1111
DeleteVolumeRequest,
1212
GetSnapshotRequest,
1313
GetVolumeRequest,
14+
ImportSnapshotFromS3Request,
1415
ListSnapshotsRequest,
1516
ListSnapshotsRequestOrderBy,
1617
ListSnapshotsResponse,

packages/clients/src/api/block/v1alpha1/marshalling.gen.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
CreateVolumeRequest,
1414
CreateVolumeRequestFromEmpty,
1515
CreateVolumeRequestFromSnapshot,
16+
ImportSnapshotFromS3Request,
1617
ListSnapshotsResponse,
1718
ListVolumeTypesResponse,
1819
ListVolumesResponse,
@@ -237,6 +238,18 @@ export const marshalCreateVolumeRequest = (
237238
...resolveOneOf([{ param: 'perf_iops', value: request.perfIops }]),
238239
})
239240

241+
export const marshalImportSnapshotFromS3Request = (
242+
request: ImportSnapshotFromS3Request,
243+
defaults: DefaultValues,
244+
): Record<string, unknown> => ({
245+
bucket: request.bucket,
246+
key: request.key,
247+
name: request.name,
248+
project_id: request.projectId ?? defaults.defaultProjectId,
249+
size: request.size,
250+
tags: request.tags,
251+
})
252+
240253
export const marshalUpdateSnapshotRequest = (
241254
request: UpdateSnapshotRequest,
242255
defaults: DefaultValues,

packages/clients/src/api/block/v1alpha1/types.gen.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ export type GetVolumeRequest = {
254254
volumeId: string
255255
}
256256

257+
export type ImportSnapshotFromS3Request = {
258+
/** Zone to target. If none is passed will use default zone from the config. */
259+
zone?: Zone
260+
/** Scaleway Object Storage bucket where the object is stored. */
261+
bucket: string
262+
/** The object key inside the given bucket. */
263+
key: string
264+
/** Name of the snapshot. */
265+
name: string
266+
/** UUID of the Project to which the volume and the snapshot belong. */
267+
projectId?: string
268+
/** List of tags assigned to the snapshot. */
269+
tags?: string[]
270+
/** Size of the snapshot. */
271+
size?: number
272+
}
273+
257274
export type ListSnapshotsRequest = {
258275
/** Zone to target. If none is passed will use default zone from the config. */
259276
zone?: Zone

packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export const CreateVolumeRequest = {
1313
},
1414
}
1515

16+
export const ImportSnapshotFromS3Request = {
17+
name: {
18+
minLength: 1,
19+
},
20+
}
21+
1622
export const ListSnapshotsRequest = {
1723
page: {
1824
greaterThan: 0,

0 commit comments

Comments
 (0)