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
23 changes: 23 additions & 0 deletions packages/clients/src/api/block/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
marshalCreateSnapshotRequest,
marshalCreateVolumeRequest,
marshalImportSnapshotFromS3Request,
marshalUpdateSnapshotRequest,
marshalUpdateVolumeRequest,
unmarshalListSnapshotsResponse,
Expand All @@ -30,6 +31,7 @@ import type {
DeleteVolumeRequest,
GetSnapshotRequest,
GetVolumeRequest,
ImportSnapshotFromS3Request,
ListSnapshotsRequest,
ListSnapshotsResponse,
ListVolumeTypesRequest,
Expand Down Expand Up @@ -307,6 +309,27 @@ export class API extends ParentAPI {
unmarshalSnapshot,
)

/**
* Import a snapshot from a Scaleway Object Storage bucket. The bucket must
* contain a QCOW2 image. The bucket can be imported into any Availability
* Zone as long as it is in the same region as the bucket.
*
* @param request - The request {@link ImportSnapshotFromS3Request}
* @returns A Promise of Snapshot
*/
importSnapshotFromS3 = (request: Readonly<ImportSnapshotFromS3Request>) =>
this.client.fetch<Snapshot>(
{
body: JSON.stringify(
marshalImportSnapshotFromS3Request(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/import-from-s3`,
},
unmarshalSnapshot,
)

/**
* Delete a snapshot. You must specify the `snapshot_id` of the snapshot you
* want to delete. The snapshot must not be in use.
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/block/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
DeleteVolumeRequest,
GetSnapshotRequest,
GetVolumeRequest,
ImportSnapshotFromS3Request,
ListSnapshotsRequest,
ListSnapshotsRequestOrderBy,
ListSnapshotsResponse,
Expand Down
13 changes: 13 additions & 0 deletions packages/clients/src/api/block/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
CreateVolumeRequest,
CreateVolumeRequestFromEmpty,
CreateVolumeRequestFromSnapshot,
ImportSnapshotFromS3Request,
ListSnapshotsResponse,
ListVolumeTypesResponse,
ListVolumesResponse,
Expand Down Expand Up @@ -237,6 +238,18 @@ export const marshalCreateVolumeRequest = (
...resolveOneOf([{ param: 'perf_iops', value: request.perfIops }]),
})

export const marshalImportSnapshotFromS3Request = (
request: ImportSnapshotFromS3Request,
defaults: DefaultValues,
): Record<string, unknown> => ({
bucket: request.bucket,
key: request.key,
name: request.name,
project_id: request.projectId ?? defaults.defaultProjectId,
size: request.size,
tags: request.tags,
})

export const marshalUpdateSnapshotRequest = (
request: UpdateSnapshotRequest,
defaults: DefaultValues,
Expand Down
17 changes: 17 additions & 0 deletions packages/clients/src/api/block/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,23 @@ export type GetVolumeRequest = {
volumeId: string
}

export type ImportSnapshotFromS3Request = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
/** Scaleway Object Storage bucket where the object is stored. */
bucket: string
/** The object key inside the given bucket. */
key: string
/** Name of the snapshot. */
name: string
/** UUID of the Project to which the volume and the snapshot belong. */
projectId?: string
/** List of tags assigned to the snapshot. */
tags?: string[]
/** Size of the snapshot. */
size?: number
}

export type ListSnapshotsRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export const CreateVolumeRequest = {
},
}

export const ImportSnapshotFromS3Request = {
name: {
minLength: 1,
},
}

export const ListSnapshotsRequest = {
page: {
greaterThan: 0,
Expand Down