diff --git a/packages/clients/src/api/block/v1alpha1/api.gen.ts b/packages/clients/src/api/block/v1alpha1/api.gen.ts new file mode 100644 index 000000000..4cab2aeb0 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/api.gen.ts @@ -0,0 +1,367 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + API as ParentAPI, + enrichForPagination, + urlParams, + validatePathParam, + waitForResource, +} from '../../../bridge' +import type { WaitForOptions, Zone } from '../../../bridge' +import { + SNAPSHOT_TRANSIENT_STATUSES, + VOLUME_TRANSIENT_STATUSES, +} from './content.gen' +import { + marshalCreateSnapshotRequest, + marshalCreateVolumeRequest, + marshalUpdateSnapshotRequest, + marshalUpdateVolumeRequest, + unmarshalListSnapshotsResponse, + unmarshalListVolumeTypesResponse, + unmarshalListVolumesResponse, + unmarshalSnapshot, + unmarshalVolume, +} from './marshalling.gen' +import type { + CreateSnapshotRequest, + CreateVolumeRequest, + DeleteSnapshotRequest, + DeleteVolumeRequest, + GetSnapshotRequest, + GetVolumeRequest, + ListSnapshotsRequest, + ListSnapshotsResponse, + ListVolumeTypesRequest, + ListVolumeTypesResponse, + ListVolumesRequest, + ListVolumesResponse, + Snapshot, + UpdateSnapshotRequest, + UpdateVolumeRequest, + Volume, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Scaleway Block Storage (SBS) API. + * + * This API allows you to use and manage your Block Storage volumes. Scaleway + * Block Storage (SBS) API. + */ +export class API extends ParentAPI { + /** Lists the available zones of the API. */ + public static readonly LOCALITIES: Zone[] = ['fr-par-1', 'pl-waw-3'] + + protected pageOfListVolumeTypes = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volume-types`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListVolumeTypesResponse, + ) + + /** + * List volume types. List all available volume types in a specified zone. The + * volume types listed are ordered by name in ascending order. + * + * @param request - The request {@link ListVolumeTypesRequest} + * @returns A Promise of ListVolumeTypesResponse + */ + listVolumeTypes = (request: Readonly = {}) => + enrichForPagination('volumeTypes', this.pageOfListVolumeTypes, request) + + protected pageOfListVolumes = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volumes`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy ?? 'created_at_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['product_resource_id', request.productResourceId], + ['project_id', request.projectId], + ), + }, + unmarshalListVolumesResponse, + ) + + /** + * List volumes. List all existing volumes in a specified zone. By default, + * the volume listed are ordered by creation date in ascending order. This can + * be modified via the `order_by` field. + * + * @param request - The request {@link ListVolumesRequest} + * @returns A Promise of ListVolumesResponse + */ + listVolumes = (request: Readonly = {}) => + enrichForPagination('volumes', this.pageOfListVolumes, request) + + /** + * Create a new empty volume by specifying the `size`. To create a volume from + * an existing snapshot, specify the `snapshot_id` in the request payload + * instead, size is optional and can be specified if you need to extend the + * original size. In that case the created volume will have the same volume + * class (and underlying IOPS limitations) as the originating snapshot. You + * can specify the desired performance of the volume by setting `requirements` + * accordingly. + * + * @param request - The request {@link CreateVolumeRequest} + * @returns A Promise of Volume + */ + createVolume = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateVolumeRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volumes`, + }, + unmarshalVolume, + ) + + /** + * Get a volume. Retrieve technical information about a specific volume. + * Details such as size, type, and status are returned in the response. + * + * @param request - The request {@link GetVolumeRequest} + * @returns A Promise of Volume + */ + getVolume = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volumes/${validatePathParam('volumeId', request.volumeId)}`, + }, + unmarshalVolume, + ) + + /** + * Waits for {@link Volume} to be in a final state. + * + * @param request - The request {@link GetVolumeRequest} + * @param options - The waiting options + * @returns A Promise of Volume + */ + waitForVolume = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!VOLUME_TRANSIENT_STATUSES.includes(res.status))), + this.getVolume, + request, + options, + ) + + /** + * Delete a detached volume. You must specify the `volume_id` of the volume + * you want to delete. The volume must not be in the `in_use` status. + * + * @param request - The request {@link DeleteVolumeRequest} + */ + deleteVolume = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volumes/${validatePathParam('volumeId', request.volumeId)}`, + }) + + /** + * Update a volume. Update technical details about a volume, such as its name, + * tags, or its new size and `volume_type` (within the same Block Storage + * class). You can only resize a volume to a larger size. It is not possible + * for now to change your Block Storage Class. + * + * @param request - The request {@link UpdateVolumeRequest} + * @returns A Promise of Volume + */ + updateVolume = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateVolumeRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/volumes/${validatePathParam('volumeId', request.volumeId)}`, + }, + unmarshalVolume, + ) + + protected pageOfListSnapshots = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/snapshots`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy ?? 'created_at_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['volume_id', request.volumeId], + ), + }, + unmarshalListSnapshotsResponse, + ) + + /** + * List all snapshots. List all available snapshots in a specified zone. By + * default, the snapshots listed are ordered by creation date in ascending + * order. This can be modified via the `order_by` field. + * + * @param request - The request {@link ListSnapshotsRequest} + * @returns A Promise of ListSnapshotsResponse + */ + listSnapshots = (request: Readonly = {}) => + enrichForPagination('snapshots', this.pageOfListSnapshots, request) + + /** + * Get a snapshot. Retrieve technical information about a specific snapshot. + * Details such as size, volume type, and status are returned in the + * response. + * + * @param request - The request {@link GetSnapshotRequest} + * @returns A Promise of Snapshot + */ + getSnapshot = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) + + /** + * Waits for {@link Snapshot} to be in a final state. + * + * @param request - The request {@link GetSnapshotRequest} + * @param options - The waiting options + * @returns A Promise of Snapshot + */ + waitForSnapshot = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), + this.getSnapshot, + request, + options, + ) + + /** + * Create a snapshot of a volume. To create a snapshot, the volume must be in + * the `in_use` or the `available` status. If your volume is in a transient + * state, you need to wait until the end of the current operation. + * + * @param request - The request {@link CreateSnapshotRequest} + * @returns A Promise of Snapshot + */ + createSnapshot = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateSnapshotRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/snapshots`, + }, + unmarshalSnapshot, + ) + + /** + * Delete a snapshot. You must specify the `snapshot_id` of the snapshot you + * want to delete. The snapshot must not be in use. + * + * @param request - The request {@link DeleteSnapshotRequest} + */ + deleteSnapshot = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }) + + /** + * Update a snapshot. Update name or tags of the snapshot. + * + * @param request - The request {@link UpdateSnapshotRequest} + * @returns A Promise of Snapshot + */ + updateSnapshot = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateSnapshotRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/block/v1alpha1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) +} diff --git a/packages/clients/src/api/block/v1alpha1/content.gen.ts b/packages/clients/src/api/block/v1alpha1/content.gen.ts new file mode 100644 index 000000000..87e78a994 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/content.gen.ts @@ -0,0 +1,24 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { ReferenceStatus, SnapshotStatus, VolumeStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link ReferenceStatus}. */ +export const REFERENCE_TRANSIENT_STATUSES: ReferenceStatus[] = [ + 'attaching', + 'detaching', + 'snapshotting', +] + +/** Lists transient statutes of the enum {@link SnapshotStatus}. */ +export const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[] = [ + 'creating', + 'deleting', +] + +/** Lists transient statutes of the enum {@link VolumeStatus}. */ +export const VOLUME_TRANSIENT_STATUSES: VolumeStatus[] = [ + 'creating', + 'deleting', + 'resizing', + 'snapshotting', +] diff --git a/packages/clients/src/api/block/v1alpha1/index.gen.ts b/packages/clients/src/api/block/v1alpha1/index.gen.ts new file mode 100644 index 000000000..e56db6781 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/index.gen.ts @@ -0,0 +1,37 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { API } from './api.gen' +export * from './content.gen' +export type { + CreateSnapshotRequest, + CreateVolumeRequest, + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + DeleteSnapshotRequest, + DeleteVolumeRequest, + GetSnapshotRequest, + GetVolumeRequest, + ListSnapshotsRequest, + ListSnapshotsRequestOrderBy, + ListSnapshotsResponse, + ListVolumeTypesRequest, + ListVolumeTypesResponse, + ListVolumesRequest, + ListVolumesRequestOrderBy, + ListVolumesResponse, + Reference, + ReferenceStatus, + ReferenceType, + Snapshot, + SnapshotParentVolume, + SnapshotStatus, + SnapshotSummary, + StorageClass, + UpdateSnapshotRequest, + UpdateVolumeRequest, + Volume, + VolumeSpecifications, + VolumeStatus, + VolumeType, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts new file mode 100644 index 000000000..aba6224f8 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts @@ -0,0 +1,274 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, + unmarshalMoney, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + CreateSnapshotRequest, + CreateVolumeRequest, + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Reference, + Snapshot, + SnapshotParentVolume, + SnapshotSummary, + UpdateSnapshotRequest, + UpdateVolumeRequest, + Volume, + VolumeSpecifications, + VolumeType, +} from './types.gen' + +const unmarshalReference = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Reference' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + productResourceId: data.product_resource_id, + productResourceType: data.product_resource_type, + status: data.status, + type: data.type, + } as Reference +} + +const unmarshalSnapshotParentVolume = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + name: data.name, + status: data.status, + type: data.type, + } as SnapshotParentVolume +} + +const unmarshalVolumeSpecifications = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary.`, + ) + } + + return { class: data.class, perfIops: data.perf_iops } as VolumeSpecifications +} + +const unmarshalSnapshotSummary = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SnapshotSummary' failed as data isn't a dictionary.`, + ) + } + + return { + class: data.class, + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + parentVolume: data.parent_volume + ? unmarshalSnapshotParentVolume(data.parent_volume) + : undefined, + projectId: data.project_id, + size: data.size, + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + zone: data.zone, + } as SnapshotSummary +} + +export const unmarshalVolume = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + parentSnapshotId: data.parent_snapshot_id, + projectId: data.project_id, + references: unmarshalArrayOfObject(data.references, unmarshalReference), + size: data.size, + specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined, + status: data.status, + tags: data.tags, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + zone: data.zone, + } as Volume +} + +const unmarshalVolumeType = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'VolumeType' failed as data isn't a dictionary.`, + ) + } + + return { + pricing: data.pricing ? unmarshalMoney(data.pricing) : undefined, + snapshotPricing: data.snapshot_pricing + ? unmarshalMoney(data.snapshot_pricing) + : undefined, + specs: data.specs ? unmarshalVolumeSpecifications(data.specs) : undefined, + type: data.type, + } as VolumeType +} + +export const unmarshalListSnapshotsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshotSummary), + totalCount: data.total_count, + } as ListSnapshotsResponse +} + +export const unmarshalListVolumeTypesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListVolumeTypesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + totalCount: data.total_count, + volumeTypes: unmarshalArrayOfObject(data.volume_types, unmarshalVolumeType), + } as ListVolumeTypesResponse +} + +export const unmarshalListVolumesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListVolumesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + totalCount: data.total_count, + volumes: unmarshalArrayOfObject(data.volumes, unmarshalVolume), + } as ListVolumesResponse +} + +export const unmarshalSnapshot = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`, + ) + } + + return { + class: data.class, + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + parentVolume: data.parent_volume + ? unmarshalSnapshotParentVolume(data.parent_volume) + : undefined, + projectId: data.project_id, + references: unmarshalArrayOfObject(data.references, unmarshalReference), + size: data.size, + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + zone: data.zone, + } as Snapshot +} + +const marshalCreateVolumeRequestFromEmpty = ( + request: CreateVolumeRequestFromEmpty, + defaults: DefaultValues, +): Record => ({ + size: request.size, +}) + +const marshalCreateVolumeRequestFromSnapshot = ( + request: CreateVolumeRequestFromSnapshot, + defaults: DefaultValues, +): Record => ({ + size: request.size, + snapshot_id: request.snapshotId, +}) + +export const marshalCreateSnapshotRequest = ( + request: CreateSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, + volume_id: request.volumeId, +}) + +export const marshalCreateVolumeRequest = ( + request: CreateVolumeRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, + ...resolveOneOf([ + { + param: 'from_empty', + value: request.fromEmpty + ? marshalCreateVolumeRequestFromEmpty(request.fromEmpty, defaults) + : undefined, + }, + { + param: 'from_snapshot', + value: request.fromSnapshot + ? marshalCreateVolumeRequestFromSnapshot(request.fromSnapshot, defaults) + : undefined, + }, + ]), + ...resolveOneOf( + [ + { + param: 'perf_iops', + value: request.perfIops, + }, + ], + true, + ), +}) + +export const marshalUpdateSnapshotRequest = ( + request: UpdateSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateVolumeRequest = ( + request: UpdateVolumeRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + perf_iops: request.perfIops, + size: request.size, + tags: request.tags, +}) diff --git a/packages/clients/src/api/block/v1alpha1/types.gen.ts b/packages/clients/src/api/block/v1alpha1/types.gen.ts new file mode 100644 index 000000000..3124ecbe5 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/types.gen.ts @@ -0,0 +1,407 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Money, Zone } from '../../../bridge' + +export type ListSnapshotsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type ListVolumesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type ReferenceStatus = + | 'unknown_status' + | 'attaching' + | 'attached' + | 'detaching' + | 'detached' + | 'snapshotting' + | 'error' + +export type ReferenceType = 'unknown_type' | 'link' | 'exclusive' | 'read_only' + +export type SnapshotStatus = + | 'unknown_status' + | 'creating' + | 'available' + | 'error' + | 'deleting' + | 'deleted' + | 'in_use' + | 'locked' + +export type StorageClass = + | 'unknown_storage_class' + | 'unspecified' + | 'bssd' + | 'sbs' + +export type VolumeStatus = + | 'unknown_status' + | 'creating' + | 'available' + | 'in_use' + | 'deleting' + | 'deleted' + | 'resizing' + | 'error' + | 'snapshotting' + | 'locked' + +/** Create volume request. from empty. */ +export interface CreateVolumeRequestFromEmpty { + /** + * Volume size in bytes, with a granularity of 1 GB (10^9 bytes). Must be + * compliant with the minimum and maximum allowed size. + */ + size: number +} + +/** Create volume request. from snapshot. */ +export interface CreateVolumeRequestFromSnapshot { + /** + * Volume size in bytes, with a granularity of 1 GB (10^9 bytes). Must be + * compliant with the allowed minimum and maximum allowed size. Size is + * optional and is used only if a resize of the volume is requested, otherwise + * original snapshot size will be used. + */ + size?: number + /** Source snapshot from which create a volume. */ + snapshotId: string +} + +/** List snapshots response. */ +export interface ListSnapshotsResponse { + /** Paginated returned list of snapshots. */ + snapshots: SnapshotSummary[] + /** Total number of snpashots in the project. */ + totalCount: number +} + +/** List volume types response. */ +export interface ListVolumeTypesResponse { + /** Paginated returned list of volume-types. */ + volumeTypes: VolumeType[] + /** Total number of volume-types currently available in stock. */ + totalCount: number +} + +/** List volumes response. */ +export interface ListVolumesResponse { + /** Paginated returned list of volumes. */ + volumes: Volume[] + /** Total number of volumes in the project. */ + totalCount: number +} + +/** Reference. */ +export interface Reference { + /** UUID of the reference. */ + id: string + /** Type of the resoruce the reference is associated (else snapshot or volume). */ + productResourceType: string + /** + * UUID of the volume or the snapshot it refers to (according to the + * product_resource_type). + */ + productResourceId: string + /** Creation date of the reference. */ + createdAt?: Date + /** Type of the reference (link, exclusive, read_only). */ + type: ReferenceType + /** Status of the reference (attaching, attached, detaching). */ + status: ReferenceStatus +} + +/** Snapshot. */ +export interface Snapshot { + /** UUID of the snapshot. */ + id: string + /** Name of the snapshot. */ + name: string + /** + * Informations about the parent volume. If the parent volume has been + * deleted, value is null. + */ + parentVolume?: SnapshotParentVolume + /** Size in bytes of the snapshot. */ + size: number + /** UUID of the project the snapshot belongs to. */ + projectId: string + /** Creation date of the snapshot. */ + createdAt?: Date + /** Last modification date of the properties of a snapshot. */ + updatedAt?: Date + /** List of the references to the snapshot. */ + references: Reference[] + /** Current status of the snapshot (available, in_use, ...). */ + status: SnapshotStatus + /** List of tags assigned to the volume. */ + tags: string[] + /** Snapshot zone. */ + zone: Zone + /** Storage class of the snapshot. */ + class: StorageClass +} + +/** Snapshot. parent volume. */ +export interface SnapshotParentVolume { + /** Volume ID on which the snapshot is based. */ + id: string + /** Name of the parent volume from which the snapshot has been taken. */ + name: string + /** Volume type of the parent volume from which the snapshot has been taken. */ + type: string + /** Current status the parent volume from which the snapshot has been taken. */ + status: VolumeStatus +} + +/** Snapshot summary. */ +export interface SnapshotSummary { + /** UUID of the snapshot. */ + id: string + /** Name of the snapshot. */ + name: string + /** + * Information about the parent volume. If the parent volume has been deleted, + * value is null. + */ + parentVolume?: SnapshotParentVolume + /** Size in bytes of the snapshot. */ + size: number + /** UUID of the project the snapshot belongs to. */ + projectId: string + /** Creation date of the snapshot. */ + createdAt?: Date + /** Last modification date of the properties of a snapshot. */ + updatedAt?: Date + /** Current status of the snapshot (available, in_use, ...). */ + status: SnapshotStatus + /** List of tags assigned to the volume. */ + tags: string[] + /** Snapshot zone. */ + zone: Zone + /** Storage class of the snapshot. */ + class: StorageClass +} + +/** Volume. */ +export interface Volume { + /** UUID of the volume. */ + id: string + /** Name of the volume. */ + name: string + /** Type of the volume. */ + type: string + /** Volume size in bytes. */ + size: number + /** UUID of the project the volume belongs to. */ + projectId: string + /** Creation date of the volume. */ + createdAt?: Date + /** Last modification date of the properties of a volume. */ + updatedAt?: Date + /** List of the references to the volume. */ + references: Reference[] + /** + * When a volume is created from a snapshot, is the UUID of the snapshot from + * which the volume has been created. + */ + parentSnapshotId?: string + /** Current status of the volume (available, in_use, ...). */ + status: VolumeStatus + /** List of tags assigned to the volume. */ + tags: string[] + /** Volume zone. */ + zone: Zone + /** Volume specifications of the volume. */ + specs?: VolumeSpecifications +} + +/** Volume specifications. */ +export interface VolumeSpecifications { + /** + * The maximum IO/s expected, according to the different options available in + * stock (`5000 | 15000`). + */ + perfIops?: number + /** The storage class of the volume. */ + class: StorageClass +} + +/** Volume type. */ +export interface VolumeType { + /** Internal type of the volume. */ + type: string + /** Price of the volume billed in GB/hour. */ + pricing?: Money + /** Price of the snapshot billed in GB/hour. */ + snapshotPricing?: Money + /** Volume specifications of the volume type. */ + specs?: VolumeSpecifications +} + +export type ListVolumeTypesRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** Positive integer to choose the page to return. */ + page?: number + /** + * Positive integer lower or equal to 100 to select the number of items to + * return. + */ + pageSize?: number +} + +export type ListVolumesRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** Sort order of the returned volumes. */ + orderBy?: ListVolumesRequestOrderBy + /** Only list volumes of this project ID. */ + projectId?: string + /** Positive integer to choose the page to return. */ + page?: number + /** + * Positive integer lower or equal to 100 to select the number of items to + * return. + */ + pageSize?: number + /** Filter the return volumes by their names. */ + name?: string + /** + * Filter by a Product Resource Id linked to this volume (such as an Instance + * Server Id). + */ + productResourceId?: string +} + +export type CreateVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** Name of the volume you want to create. */ + name: string + /** + * The maximum IO/s expected, according to the different options available in + * stock (`5000 | 15000`). + * + * One-of ('requirements'): at most one of 'perfIops' could be set. + */ + perfIops?: number + /** UUID of the project the volume belongs to. */ + projectId?: string + /** + * Create a new and empty volume. + * + * One-of ('from'): at most one of 'fromEmpty', 'fromSnapshot' could be set. + */ + fromEmpty?: CreateVolumeRequestFromEmpty + /** + * Create a volume from an existing snapshot. + * + * One-of ('from'): at most one of 'fromEmpty', 'fromSnapshot' could be set. + */ + fromSnapshot?: CreateVolumeRequestFromSnapshot + /** List of tags assigned to the volume. */ + tags?: string[] +} + +export type GetVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the volume you want to get. */ + volumeId: string +} + +export type DeleteVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the volume. */ + volumeId: string +} + +export type UpdateVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the volume. */ + volumeId: string + /** When defined, is the new name of the volume. */ + name?: string + /** + * Optional field for growing a volume (size must be equal or larger than the + * current one). Size in bytes of the volume, with a granularity of 1 GB (10^9 + * bytes). Must be compliant with the minimum and maximum allowed size. + */ + size?: number + /** List of tags assigned to the volume. */ + tags?: string[] + /** + * The maximum IO/s expected, according to the different options available in + * stock (`5000 | 15000`). The selected value must be available on the Storage + * Class where is currently located the volume. + */ + perfIops?: number +} + +export type ListSnapshotsRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** Sort order of the returned snapshots. */ + orderBy?: ListSnapshotsRequestOrderBy + /** Only list snapshots of this project ID. */ + projectId?: string + /** Positive integer to choose the page to return. */ + page?: number + /** + * Positive integer lower or equal to 100 to select the number of items to + * return. + */ + pageSize?: number + /** Filter the return snapshots by the volume it belongs to. */ + volumeId?: string + /** Filter the return snapshots by their names. */ + name?: string +} + +export type GetSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the snapshot. */ + snapshotId: string +} + +export type CreateSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the volume from which creates a snpashot. */ + volumeId: string + /** Name of the snapshot. */ + name: string + /** UUID of the project the volume and the snapshot belong to. */ + projectId?: string + /** List of tags assigned to the snapshot. */ + tags?: string[] +} + +export type DeleteSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the snapshot. */ + snapshotId: string +} + +export type UpdateSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + /** UUID of the snapshot. */ + snapshotId: string + /** When defined, is the name of the snapshot. */ + name?: string + /** List of tags assigned to the snapshot. */ + tags?: string[] +} diff --git a/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts new file mode 100644 index 000000000..da74bfcc6 --- /dev/null +++ b/packages/clients/src/api/block/v1alpha1/validation-rules.gen.ts @@ -0,0 +1,44 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const CreateSnapshotRequest = { + name: { + minLength: 1, + }, +} + +export const CreateVolumeRequest = { + name: { + minLength: 1, + }, +} + +export const ListSnapshotsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const ListVolumeTypesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const ListVolumesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +}