Skip to content

feat(block): add snapshot import #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023
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
18 changes: 18 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 @@ -327,6 +329,22 @@ export class API extends ParentAPI {
unmarshalSnapshot,
)

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
12 changes: 12 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 @@ -255,6 +256,17 @@ export const marshalCreateVolumeRequest = (
),
})

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,
tags: request.tags,
})

export const marshalUpdateSnapshotRequest = (
request: UpdateSnapshotRequest,
defaults: DefaultValues,
Expand Down
10 changes: 10 additions & 0 deletions packages/clients/src/api/block/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,16 @@ export type CreateSnapshotRequest = {
tags?: string[]
}

export type ImportSnapshotFromS3Request = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
bucket: string
key: string
name: string
projectId?: string
tags?: string[]
}

export type DeleteSnapshotRequest = {
/** 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