diff --git a/packages/clients/src/api/block/v1alpha1/api.gen.ts b/packages/clients/src/api/block/v1alpha1/api.gen.ts index 2b11df41e..cb1523680 100644 --- a/packages/clients/src/api/block/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/api.gen.ts @@ -15,6 +15,7 @@ import { import { marshalCreateSnapshotRequest, marshalCreateVolumeRequest, + marshalImportSnapshotFromS3Request, marshalUpdateSnapshotRequest, marshalUpdateVolumeRequest, unmarshalListSnapshotsResponse, @@ -30,6 +31,7 @@ import type { DeleteVolumeRequest, GetSnapshotRequest, GetVolumeRequest, + ImportSnapshotFromS3Request, ListSnapshotsRequest, ListSnapshotsResponse, ListVolumeTypesRequest, @@ -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) => + this.client.fetch( + { + 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. diff --git a/packages/clients/src/api/block/v1alpha1/index.gen.ts b/packages/clients/src/api/block/v1alpha1/index.gen.ts index 99846c5e5..11eae7786 100644 --- a/packages/clients/src/api/block/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/index.gen.ts @@ -11,6 +11,7 @@ export type { DeleteVolumeRequest, GetSnapshotRequest, GetVolumeRequest, + ImportSnapshotFromS3Request, ListSnapshotsRequest, ListSnapshotsRequestOrderBy, ListSnapshotsResponse, diff --git a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts index e69aed495..e80739d57 100644 --- a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts @@ -13,6 +13,7 @@ import type { CreateVolumeRequest, CreateVolumeRequestFromEmpty, CreateVolumeRequestFromSnapshot, + ImportSnapshotFromS3Request, ListSnapshotsResponse, ListVolumeTypesResponse, ListVolumesResponse, @@ -237,6 +238,18 @@ export const marshalCreateVolumeRequest = ( ...resolveOneOf([{ param: 'perf_iops', value: request.perfIops }]), }) +export const marshalImportSnapshotFromS3Request = ( + request: ImportSnapshotFromS3Request, + defaults: DefaultValues, +): Record => ({ + 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, diff --git a/packages/clients/src/api/block/v1alpha1/types.gen.ts b/packages/clients/src/api/block/v1alpha1/types.gen.ts index 65186b8ef..1933d1940 100644 --- a/packages/clients/src/api/block/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/types.gen.ts @@ -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 diff --git a/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts index fef146df5..13c581d8d 100644 --- a/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts @@ -13,6 +13,12 @@ export const CreateVolumeRequest = { }, } +export const ImportSnapshotFromS3Request = { + name: { + minLength: 1, + }, +} + export const ListSnapshotsRequest = { page: { greaterThan: 0,