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
56 changes: 56 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,8 @@ import {
import {
marshalCreateSnapshotRequest,
marshalCreateVolumeRequest,
marshalExportSnapshotToObjectStorageRequest,
marshalImportSnapshotFromObjectStorageRequest,
marshalImportSnapshotFromS3Request,
marshalUpdateSnapshotRequest,
marshalUpdateVolumeRequest,
Expand All @@ -29,8 +31,10 @@ import type {
CreateVolumeRequest,
DeleteSnapshotRequest,
DeleteVolumeRequest,
ExportSnapshotToObjectStorageRequest,
GetSnapshotRequest,
GetVolumeRequest,
ImportSnapshotFromObjectStorageRequest,
ImportSnapshotFromS3Request,
ListSnapshotsRequest,
ListSnapshotsResponse,
Expand Down Expand Up @@ -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
*/
Expand All @@ -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<ImportSnapshotFromObjectStorageRequest>,
) =>
this.client.fetch<Snapshot>(
{
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<ExportSnapshotToObjectStorageRequest>,
) =>
this.client.fetch<Snapshot>(
{
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.
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/block/v1alpha1/content.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}. */
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/block/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export type {
CreateVolumeRequestFromSnapshot,
DeleteSnapshotRequest,
DeleteVolumeRequest,
ExportSnapshotToObjectStorageRequest,
GetSnapshotRequest,
GetVolumeRequest,
ImportSnapshotFromObjectStorageRequest,
ImportSnapshotFromS3Request,
ListSnapshotsRequest,
ListSnapshotsRequestOrderBy,
Expand Down
22 changes: 22 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,8 @@ import type {
CreateVolumeRequest,
CreateVolumeRequestFromEmpty,
CreateVolumeRequestFromSnapshot,
ExportSnapshotToObjectStorageRequest,
ImportSnapshotFromObjectStorageRequest,
ImportSnapshotFromS3Request,
ListSnapshotsResponse,
ListVolumeTypesResponse,
Expand Down Expand Up @@ -238,6 +240,26 @@ export const marshalCreateVolumeRequest = (
...resolveOneOf([{ param: 'perf_iops', value: request.perfIops }]),
})

export const marshalExportSnapshotToObjectStorageRequest = (
request: ExportSnapshotToObjectStorageRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
bucket: request.bucket,
key: request.key,
})

export const marshalImportSnapshotFromObjectStorageRequest = (
request: ImportSnapshotFromObjectStorageRequest,
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 marshalImportSnapshotFromS3Request = (
request: ImportSnapshotFromS3Request,
defaults: DefaultValues,
Expand Down
29 changes: 29 additions & 0 deletions packages/clients/src/api/block/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type SnapshotStatus =
| 'deleted'
| 'in_use'
| 'locked'
| 'exporting'

export type StorageClass =
| 'unknown_storage_class'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export const CreateVolumeRequest = {
},
}

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

export const ImportSnapshotFromS3Request = {
name: {
minLength: 1,
Expand Down