From 85b5276bba8727520ec9f9b00db66160a7aeeb0a Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 30 May 2024 14:41:59 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/block/v1alpha1/api.gen.ts | 56 +++++++++++++++++++ .../src/api/block/v1alpha1/content.gen.ts | 1 + .../src/api/block/v1alpha1/index.gen.ts | 2 + .../src/api/block/v1alpha1/marshalling.gen.ts | 22 ++++++++ .../src/api/block/v1alpha1/types.gen.ts | 29 ++++++++++ .../block/v1alpha1/validation-rules.gen.ts | 6 ++ 6 files changed, 116 insertions(+) diff --git a/packages/clients/src/api/block/v1alpha1/api.gen.ts b/packages/clients/src/api/block/v1alpha1/api.gen.ts index d181d22b6..b5def346c 100644 --- a/packages/clients/src/api/block/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/api.gen.ts @@ -15,6 +15,8 @@ import { import { marshalCreateSnapshotRequest, marshalCreateVolumeRequest, + marshalExportSnapshotToObjectStorageRequest, + marshalImportSnapshotFromObjectStorageRequest, marshalImportSnapshotFromS3Request, marshalUpdateSnapshotRequest, marshalUpdateVolumeRequest, @@ -29,8 +31,10 @@ import type { CreateVolumeRequest, DeleteSnapshotRequest, DeleteVolumeRequest, + ExportSnapshotToObjectStorageRequest, GetSnapshotRequest, GetVolumeRequest, + ImportSnapshotFromObjectStorageRequest, ImportSnapshotFromS3Request, ListSnapshotsRequest, ListSnapshotsResponse, @@ -314,6 +318,7 @@ export class API extends ParentAPI { * 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. * + * @deprecated * @param request - The request {@link ImportSnapshotFromS3Request} * @returns A Promise of Snapshot */ @@ -330,6 +335,57 @@ 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 ImportSnapshotFromObjectStorageRequest} + * @returns A Promise of Snapshot + */ + importSnapshotFromObjectStorage = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalImportSnapshotFromObjectStorageRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/import-from-object-storage`, + }, + unmarshalSnapshot, + ) + + /** + * Export a snapshot to a Scaleway Object Storage bucket. The snapshot is + * exported in QCOW2 format. The snapshot must not be in transient state. + * + * @param request - The request {@link ExportSnapshotToObjectStorageRequest} + * @returns A Promise of Snapshot + */ + exportSnapshotToObjectStorage = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalExportSnapshotToObjectStorageRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/block/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}/export-to-object-storage`, + }, + 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/content.gen.ts b/packages/clients/src/api/block/v1alpha1/content.gen.ts index 846098bff..2e3e5f343 100644 --- a/packages/clients/src/api/block/v1alpha1/content.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/content.gen.ts @@ -13,6 +13,7 @@ export const REFERENCE_TRANSIENT_STATUSES: ReferenceStatus[] = [ export const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[] = [ 'creating', 'deleting', + 'exporting', ] /** Lists transient statutes of the enum {@link VolumeStatus}. */ diff --git a/packages/clients/src/api/block/v1alpha1/index.gen.ts b/packages/clients/src/api/block/v1alpha1/index.gen.ts index 11eae7786..ef3cace2e 100644 --- a/packages/clients/src/api/block/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/index.gen.ts @@ -9,8 +9,10 @@ export type { CreateVolumeRequestFromSnapshot, DeleteSnapshotRequest, DeleteVolumeRequest, + ExportSnapshotToObjectStorageRequest, GetSnapshotRequest, GetVolumeRequest, + ImportSnapshotFromObjectStorageRequest, ImportSnapshotFromS3Request, ListSnapshotsRequest, ListSnapshotsRequestOrderBy, diff --git a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts index e80739d57..6f2108dee 100644 --- a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts @@ -13,6 +13,8 @@ import type { CreateVolumeRequest, CreateVolumeRequestFromEmpty, CreateVolumeRequestFromSnapshot, + ExportSnapshotToObjectStorageRequest, + ImportSnapshotFromObjectStorageRequest, ImportSnapshotFromS3Request, ListSnapshotsResponse, ListVolumeTypesResponse, @@ -238,6 +240,26 @@ export const marshalCreateVolumeRequest = ( ...resolveOneOf([{ param: 'perf_iops', value: request.perfIops }]), }) +export const marshalExportSnapshotToObjectStorageRequest = ( + request: ExportSnapshotToObjectStorageRequest, + defaults: DefaultValues, +): Record => ({ + bucket: request.bucket, + key: request.key, +}) + +export const marshalImportSnapshotFromObjectStorageRequest = ( + request: ImportSnapshotFromObjectStorageRequest, + 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 marshalImportSnapshotFromS3Request = ( request: ImportSnapshotFromS3Request, 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 95edec0f1..94d11ca29 100644 --- a/packages/clients/src/api/block/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/types.gen.ts @@ -34,6 +34,7 @@ export type SnapshotStatus = | 'deleted' | 'in_use' | 'locked' + | 'exporting' export type StorageClass = | 'unknown_storage_class' @@ -241,6 +242,17 @@ export type DeleteVolumeRequest = { volumeId: string } +export type ExportSnapshotToObjectStorageRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the snapshot. */ + snapshotId: string + /** Scaleway Object Storage bucket where the object is stored. */ + bucket: string + /** The object key inside the given bucket. */ + key: string +} + export type GetSnapshotRequest = { /** Zone to target. If none is passed will use default zone from the config. */ zone?: Zone @@ -255,6 +267,23 @@ export type GetVolumeRequest = { volumeId: string } +export type ImportSnapshotFromObjectStorageRequest = { + /** 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 ImportSnapshotFromS3Request = { /** 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 13c581d8d..af4d98e80 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 ImportSnapshotFromObjectStorageRequest = { + name: { + minLength: 1, + }, +} + export const ImportSnapshotFromS3Request = { name: { minLength: 1,