From f033b91ca17c65006d24b0d8f7ce1eaf4710573e Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 27 Feb 2025 10:04:29 +0000 Subject: [PATCH 1/4] feat: update generated APIs --- .../src/api/audit_trail/v1alpha1/api.gen.ts | 4 + .../audit_trail/v1alpha1/marshalling.gen.ts | 1 + .../src/api/audit_trail/v1alpha1/types.gen.ts | 6 +- packages/clients/src/api/block/index.gen.ts | 1 + packages/clients/src/api/block/v1/api.gen.ts | 401 +++++++++++++++++ .../clients/src/api/block/v1/content.gen.ts | 26 ++ .../clients/src/api/block/v1/index.gen.ts | 38 ++ .../src/api/block/v1/marshalling.gen.ts | 279 ++++++++++++ .../clients/src/api/block/v1/types.gen.ts | 407 ++++++++++++++++++ .../src/api/block/v1/validation-rules.gen.ts | 56 +++ .../src/api/block/v1alpha1/marshalling.gen.ts | 2 +- .../api/edge_services/v1beta1/types.gen.ts | 104 ++--- 12 files changed, 1271 insertions(+), 54 deletions(-) create mode 100644 packages/clients/src/api/block/v1/api.gen.ts create mode 100644 packages/clients/src/api/block/v1/content.gen.ts create mode 100644 packages/clients/src/api/block/v1/index.gen.ts create mode 100644 packages/clients/src/api/block/v1/marshalling.gen.ts create mode 100644 packages/clients/src/api/block/v1/types.gen.ts create mode 100644 packages/clients/src/api/block/v1/validation-rules.gen.ts diff --git a/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts index f12040249..5abac31a0 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts @@ -72,6 +72,10 @@ export class API extends ParentAPI { { method: 'GET', path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/products`, + urlParams: urlParams([ + 'organization_id', + request.organizationId ?? this.client.settings.defaultOrganizationId, + ]), }, unmarshalListProductsResponse, ) diff --git a/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts index 8a8c1f676..1efa6f4a0 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts @@ -179,6 +179,7 @@ export const unmarshalEvent = (data: unknown): Event => { requestBody: data.request_body, requestId: data.request_id, resource: data.resource ? unmarshalResource(data.resource) : undefined, + resources: unmarshalArrayOfObject(data.resources, unmarshalResource), serviceName: data.service_name, sourceIp: data.source_ip, statusCode: data.status_code, diff --git a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts index 0feebfcc9..fbe2d3a67 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts @@ -127,8 +127,10 @@ export interface Event { serviceName: string /** API method called to trigger the event. */ methodName: string - /** Resource attached to the event. */ + /** @deprecated Resource attached to the event. */ resource?: Resource + /** Resources attached to the event. */ + resources: Resource[] /** Unique identifier of the request at the origin of the event. */ requestId: string /** Request at the origin of the event. */ @@ -199,6 +201,8 @@ export type ListProductsRequest = { * config. */ region?: ScwRegion + /** ID of the Organization containing the Audit Trail events. */ + organizationId?: string } export interface ListProductsResponse { diff --git a/packages/clients/src/api/block/index.gen.ts b/packages/clients/src/api/block/index.gen.ts index 6dec29b44..3c605af8e 100644 --- a/packages/clients/src/api/block/index.gen.ts +++ b/packages/clients/src/api/block/index.gen.ts @@ -3,4 +3,5 @@ * EDIT HERE */ +export * as v1 from './v1/index.gen' export * as v1alpha1 from './v1alpha1/index.gen' diff --git a/packages/clients/src/api/block/v1/api.gen.ts b/packages/clients/src/api/block/v1/api.gen.ts new file mode 100644 index 000000000..39acf0466 --- /dev/null +++ b/packages/clients/src/api/block/v1/api.gen.ts @@ -0,0 +1,401 @@ +// 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 { Zone as ScwZone, WaitForOptions } from '../../../bridge' +import { + SNAPSHOT_TRANSIENT_STATUSES, + VOLUME_TRANSIENT_STATUSES, +} from './content.gen' +import { + marshalCreateSnapshotRequest, + marshalCreateVolumeRequest, + marshalExportSnapshotToObjectStorageRequest, + marshalImportSnapshotFromObjectStorageRequest, + marshalUpdateSnapshotRequest, + marshalUpdateVolumeRequest, + unmarshalListSnapshotsResponse, + unmarshalListVolumeTypesResponse, + unmarshalListVolumesResponse, + unmarshalSnapshot, + unmarshalVolume, +} from './marshalling.gen' +import type { + CreateSnapshotRequest, + CreateVolumeRequest, + DeleteSnapshotRequest, + DeleteVolumeRequest, + ExportSnapshotToObjectStorageRequest, + GetSnapshotRequest, + GetVolumeRequest, + ImportSnapshotFromObjectStorageRequest, + ListSnapshotsRequest, + ListSnapshotsResponse, + ListVolumeTypesRequest, + ListVolumeTypesResponse, + ListVolumesRequest, + ListVolumesResponse, + Snapshot, + UpdateSnapshotRequest, + UpdateVolumeRequest, + Volume, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Block Storage API. + * + * This API allows you to manage your Block Storage volumes. + */ +export class API extends ParentAPI { + /** Lists the available zones of the API. */ + public static readonly LOCALITIES: ScwZone[] = [ + 'fr-par-1', + 'fr-par-2', + 'fr-par-3', + 'nl-ams-1', + 'nl-ams-2', + 'nl-ams-3', + 'pl-waw-1', + 'pl-waw-2', + 'pl-waw-3', + ] + + protected pageOfListVolumeTypes = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/block/v1/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/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['product_resource_id', request.productResourceId], + ['project_id', request.projectId], + ['tags', request.tags], + ), + }, + unmarshalListVolumesResponse, + ) + + /** + * List volumes. List all existing volumes in a specified zone. By default, + * the volumes 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 volume. To create a new volume from scratch, you must specify + * `from_empty` and the `size`. To create a volume from an existing snapshot, + * specify `from_snapshot` and the `snapshot_id` in the request payload + * instead, size is optional and can be specified if you need to extend the + * original size. The volume will take on the same volume class and underlying + * IOPS limitations as the original snapshot. + * + * @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/v1/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/v1/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/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/volumes/${validatePathParam('volumeId', request.volumeId)}`, + }) + + /** + * Update a volume. Update the technical details of 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 + * currently not possible 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/v1/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/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['tags', request.tags], + ['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/v1/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/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots`, + }, + 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/v1/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/v1/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. + * + * @param request - The request {@link DeleteSnapshotRequest} + */ + deleteSnapshot = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/block/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }) + + /** + * Update a snapshot. Update the 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/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) +} diff --git a/packages/clients/src/api/block/v1/content.gen.ts b/packages/clients/src/api/block/v1/content.gen.ts new file mode 100644 index 000000000..2e3e5f343 --- /dev/null +++ b/packages/clients/src/api/block/v1/content.gen.ts @@ -0,0 +1,26 @@ +// 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', + 'creating', +] + +/** Lists transient statutes of the enum {@link SnapshotStatus}. */ +export const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[] = [ + 'creating', + 'deleting', + 'exporting', +] + +/** Lists transient statutes of the enum {@link VolumeStatus}. */ +export const VOLUME_TRANSIENT_STATUSES: VolumeStatus[] = [ + 'creating', + 'deleting', + 'resizing', + 'snapshotting', + 'updating', +] diff --git a/packages/clients/src/api/block/v1/index.gen.ts b/packages/clients/src/api/block/v1/index.gen.ts new file mode 100644 index 000000000..e21aefad4 --- /dev/null +++ b/packages/clients/src/api/block/v1/index.gen.ts @@ -0,0 +1,38 @@ +// 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, + ExportSnapshotToObjectStorageRequest, + GetSnapshotRequest, + GetVolumeRequest, + ImportSnapshotFromObjectStorageRequest, + ListSnapshotsRequest, + ListSnapshotsRequestOrderBy, + ListSnapshotsResponse, + ListVolumeTypesRequest, + ListVolumeTypesResponse, + ListVolumesRequest, + ListVolumesRequestOrderBy, + ListVolumesResponse, + Reference, + ReferenceStatus, + ReferenceType, + Snapshot, + SnapshotParentVolume, + SnapshotStatus, + 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/v1/marshalling.gen.ts b/packages/clients/src/api/block/v1/marshalling.gen.ts new file mode 100644 index 000000000..d9fc607e3 --- /dev/null +++ b/packages/clients/src/api/block/v1/marshalling.gen.ts @@ -0,0 +1,279 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import randomName from '@scaleway/random-name' +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, + unmarshalMoney, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + CreateSnapshotRequest, + CreateVolumeRequest, + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ExportSnapshotToObjectStorageRequest, + ImportSnapshotFromObjectStorageRequest, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Reference, + Snapshot, + SnapshotParentVolume, + UpdateSnapshotRequest, + UpdateVolumeRequest, + Volume, + VolumeSpecifications, + VolumeType, +} from './types.gen' + +export const unmarshalReference = (data: unknown): Reference => { + 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): SnapshotParentVolume => { + 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 +} + +export const unmarshalSnapshot = (data: unknown): Snapshot => { + 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 unmarshalVolumeSpecifications = (data: unknown): VolumeSpecifications => { + 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 +} + +export const unmarshalVolume = (data: unknown): Volume => { + 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, + lastDetachedAt: unmarshalDate(data.last_detached_at), + 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 +} + +export const unmarshalListSnapshotsResponse = ( + data: unknown, +): ListSnapshotsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot), + totalCount: data.total_count, + } as ListSnapshotsResponse +} + +const unmarshalVolumeType = (data: unknown): VolumeType => { + 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 unmarshalListVolumeTypesResponse = ( + data: unknown, +): ListVolumeTypesResponse => { + 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, +): ListVolumesResponse => { + 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 marshalCreateSnapshotRequest = ( + request: CreateSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name || randomName('snp'), + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, + volume_id: request.volumeId, +}) + +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 marshalCreateVolumeRequest = ( + request: CreateVolumeRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name || randomName('vol'), + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, + ...resolveOneOf([ + { + param: 'from_empty', + value: + request.fromEmpty !== undefined + ? marshalCreateVolumeRequestFromEmpty(request.fromEmpty, defaults) + : undefined, + }, + { + param: 'from_snapshot', + value: + request.fromSnapshot !== undefined + ? marshalCreateVolumeRequestFromSnapshot( + request.fromSnapshot, + defaults, + ) + : undefined, + }, + ]), + ...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 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/v1/types.gen.ts b/packages/clients/src/api/block/v1/types.gen.ts new file mode 100644 index 000000000..8f9be03a0 --- /dev/null +++ b/packages/clients/src/api/block/v1/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 as ScwZone } 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' + | 'creating' + | 'error' + +export type ReferenceType = 'unknown_type' | 'link' | 'exclusive' | 'read_only' + +export type SnapshotStatus = + | 'unknown_status' + | 'creating' + | 'available' + | 'error' + | 'deleting' + | 'deleted' + | 'in_use' + | 'locked' + | 'exporting' + +export type StorageClass = + | 'unknown_storage_class' + | 'unspecified' + | 'bssd' + | 'sbs' + +export type VolumeStatus = + | 'unknown_status' + | 'creating' + | 'available' + | 'in_use' + | 'deleting' + | 'deleted' + | 'resizing' + | 'error' + | 'snapshotting' + | 'locked' + | 'updating' + +export interface Reference { + /** UUID of the reference. */ + id: string + /** Type of resource to which the reference is associated. */ + productResourceType: string + /** + * UUID of the product resource it refers to (according to the + * product_resource_type). + */ + productResourceId: string + /** Creation date of the reference. */ + createdAt?: Date + /** Type of reference (link, exclusive, read_only). */ + type: ReferenceType + /** + * Status of the reference. Statuses include `attaching`, `attached`, and + * `detaching`. + */ + status: ReferenceStatus +} + +export interface SnapshotParentVolume { + /** Parent volume UUID (volume from which the snapshot originates). */ + id: string + /** Name of the parent volume. */ + name: string + /** Volume type of the parent volume. */ + type: string + /** Current status the parent volume. */ + status: VolumeStatus +} + +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 +} + +export interface CreateVolumeRequestFromEmpty { + /** Must be compliant with the minimum (1 GB) and maximum (10 TB) allowed size. */ + size: number +} + +export interface CreateVolumeRequestFromSnapshot { + /** + * Must be compliant with the minimum (1 GB) and maximum (10 TB) 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 volume will be created. */ + snapshotId: string +} + +export interface Snapshot { + /** UUID of the snapshot. */ + id: string + /** Name of the snapshot. */ + name: string + /** If the parent volume was 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: ScwZone + /** Storage class of the snapshot. */ + class: StorageClass +} + +export interface VolumeType { + /** Volume type. */ + 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 interface Volume { + /** UUID of the volume. */ + id: string + /** Name of the volume. */ + name: string + /** Volume type. */ + type: string + /** Volume size in bytes. */ + size: number + /** UUID of the project to which the volume belongs. */ + projectId: string + /** Creation date of the volume. */ + createdAt?: Date + /** Last update 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: ScwZone + /** Specifications of the volume. */ + specs?: VolumeSpecifications + /** Last time the volume was detached. */ + lastDetachedAt?: Date +} + +export type CreateSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the volume to snapshot. */ + volumeId: 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[] +} + +export type CreateVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** Name of the volume. */ + 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 + /** + * Specify the size of the new volume if creating a new one from scratch. + * + * One-of ('from'): at most one of 'fromEmpty', 'fromSnapshot' could be set. + */ + fromEmpty?: CreateVolumeRequestFromEmpty + /** + * Specify the snapshot ID of the original 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 DeleteSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the snapshot. */ + snapshotId: string +} + +export type DeleteVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the volume. */ + volumeId: string +} + +export type ExportSnapshotToObjectStorageRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** 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?: ScwZone + /** UUID of the snapshot. */ + snapshotId: string +} + +export type GetVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the volume. */ + volumeId: string +} + +export type ImportSnapshotFromObjectStorageRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** 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?: ScwZone + /** Criteria to use when ordering the list. */ + orderBy?: ListSnapshotsRequestOrderBy + /** Filter by Project ID. */ + projectId?: string + /** Filter by Organization ID. */ + organizationId?: string + /** Page number. */ + page?: number + /** + * Page size, defines how many entries are returned in one page, must be lower + * or equal to 100. + */ + pageSize?: number + /** Filter snapshots by the ID of the original volume. */ + volumeId?: string + /** Filter snapshots by their names. */ + name?: string + /** + * Filter by tags. Only snapshots with one or more matching tags will be + * returned. + */ + tags?: string[] +} + +export interface ListSnapshotsResponse { + /** Paginated returned list of snapshots. */ + snapshots: Snapshot[] + /** Total number of snpashots in the project. */ + totalCount: number +} + +export type ListVolumeTypesRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** Page number. */ + page?: number + /** + * Page size, defines how many entries are returned in one page, must be lower + * or equal to 100. + */ + pageSize?: number +} + +export interface ListVolumeTypesResponse { + /** Returns paginated list of volume-types. */ + volumeTypes: VolumeType[] + /** Total number of volume-types currently available in stock. */ + totalCount: number +} + +export type ListVolumesRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** Criteria to use when ordering the list. */ + orderBy?: ListVolumesRequestOrderBy + /** Filter by Project ID. */ + projectId?: string + /** Filter by Organization ID. */ + organizationId?: string + /** Page number. */ + page?: number + /** + * Page size, defines how many entries are returned in one page, must be lower + * or equal to 100. + */ + 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 + * ID). + */ + productResourceId?: string + /** + * Filter by tags. Only volumes with one or more matching tags will be + * returned. + */ + tags?: string[] +} + +export interface ListVolumesResponse { + /** Paginated returned list of volumes. */ + volumes: Volume[] + /** Total number of volumes in the project. */ + totalCount: number +} + +export type UpdateSnapshotRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** 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[] +} + +export type UpdateVolumeRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the volume. */ + volumeId: string + /** When defined, is the new name of the volume. */ + name?: string + /** + * Size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). Must + * be compliant with the minimum (1GB) and maximum (10TB) allowed size. + */ + size?: number + /** List of tags assigned to the volume. */ + tags?: string[] + /** + * The selected value must be available for the volume's current storage + * class. + */ + perfIops?: number +} diff --git a/packages/clients/src/api/block/v1/validation-rules.gen.ts b/packages/clients/src/api/block/v1/validation-rules.gen.ts new file mode 100644 index 000000000..83ad905ae --- /dev/null +++ b/packages/clients/src/api/block/v1/validation-rules.gen.ts @@ -0,0 +1,56 @@ +// 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 ImportSnapshotFromObjectStorageRequest = { + 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, + }, +} + +export const Reference = { + productResourceType: { + minLength: 1, + }, +} diff --git a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts index 3aff55dec..d60c7d43e 100644 --- a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts @@ -30,7 +30,7 @@ import type { VolumeType, } from './types.gen' -export const unmarshalReference = (data: unknown): Reference => { +const unmarshalReference = (data: unknown): Reference => { if (!isJSONObject(data)) { throw new TypeError( `Unmarshalling the type 'Reference' failed as data isn't a dictionary.`, diff --git a/packages/clients/src/api/edge_services/v1beta1/types.gen.ts b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts index b85b803c6..76605513d 100644 --- a/packages/clients/src/api/edge_services/v1beta1/types.gen.ts +++ b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts @@ -520,7 +520,7 @@ export interface TLSSecretsConfig { tlsSecrets: TLSSecret[] } -export interface AddRouteRulesRequest { +export type AddRouteRulesRequest = { /** ID of the route stage to update. */ routeStageId: string /** @@ -556,7 +556,7 @@ export interface AddRouteRulesResponse { routeRules: RouteRule[] } -export interface CheckDomainRequest { +export type CheckDomainRequest = { projectId?: string fqdn: string cname: string @@ -566,7 +566,7 @@ export interface CheckDomainResponse { isValid: boolean } -export interface CheckLbOriginRequest { +export type CheckLbOriginRequest = { lb?: ScalewayLb } @@ -575,7 +575,7 @@ export interface CheckLbOriginResponse { errorType: LbOriginError } -export interface CheckPEMChainRequest { +export type CheckPEMChainRequest = { projectId?: string fqdn: string /** One-of ('chain'): at most one of 'secret', 'raw' could be set. */ @@ -588,7 +588,7 @@ export interface CheckPEMChainResponse { isValid: boolean } -export interface CreateBackendStageRequest { +export type CreateBackendStageRequest = { /** Pipeline ID the Backend stage belongs to. */ pipelineId: string /** @@ -607,7 +607,7 @@ export interface CreateBackendStageRequest { scalewayLb?: ScalewayLbBackendConfig } -export interface CreateCacheStageRequest { +export type CreateCacheStageRequest = { /** Pipeline ID the Cache stage belongs to. */ pipelineId: string /** Time To Live (TTL) in seconds. Defines how long content is cached. */ @@ -631,7 +631,7 @@ export interface CreateCacheStageRequest { routeStageId?: string } -export interface CreateDNSStageRequest { +export type CreateDNSStageRequest = { /** Pipeline ID the DNS stage belongs to. */ pipelineId: string /** @@ -662,7 +662,7 @@ export interface CreateDNSStageRequest { backendStageId?: string } -export interface CreatePipelineRequest { +export type CreatePipelineRequest = { /** Project ID in which the pipeline will be created. */ projectId?: string /** Name of the pipeline. */ @@ -671,7 +671,7 @@ export interface CreatePipelineRequest { description: string } -export interface CreatePurgeRequestRequest { +export type CreatePurgeRequestRequest = { /** Pipeline ID in which the purge request will be created. */ pipelineId: string /** @@ -688,7 +688,7 @@ export interface CreatePurgeRequestRequest { all?: boolean } -export interface CreateRouteStageRequest { +export type CreateRouteStageRequest = { /** Pipeline ID the route stage belongs to. */ pipelineId: string /** @@ -700,7 +700,7 @@ export interface CreateRouteStageRequest { wafStageId?: string } -export interface CreateTLSStageRequest { +export type CreateTLSStageRequest = { /** Pipeline ID the TLS stage belongs to. */ pipelineId: string /** Secret (from Scaleway Secret Manager) containing your custom certificate. */ @@ -736,7 +736,7 @@ export interface CreateTLSStageRequest { wafStageId?: string } -export interface CreateWafStageRequest { +export type CreateWafStageRequest = { /** Pipeline ID the WAF stage belongs to. */ pipelineId: string /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ @@ -756,51 +756,51 @@ export interface CreateWafStageRequest { backendStageId?: string } -export interface DeleteBackendStageRequest { +export type DeleteBackendStageRequest = { /** ID of the backend stage to delete. */ backendStageId: string } -export interface DeleteCacheStageRequest { +export type DeleteCacheStageRequest = { /** ID of the cache stage to delete. */ cacheStageId: string } -export interface DeleteCurrentPlanRequest { +export type DeleteCurrentPlanRequest = { projectId?: string } -export interface DeleteDNSStageRequest { +export type DeleteDNSStageRequest = { /** ID of the DNS stage to delete. */ dnsStageId: string } -export interface DeletePipelineRequest { +export type DeletePipelineRequest = { /** ID of the pipeline to delete. */ pipelineId: string } -export interface DeleteRouteStageRequest { +export type DeleteRouteStageRequest = { /** ID of the route stage to delete. */ routeStageId: string } -export interface DeleteTLSStageRequest { +export type DeleteTLSStageRequest = { /** ID of the TLS stage to delete. */ tlsStageId: string } -export interface DeleteWafStageRequest { +export type DeleteWafStageRequest = { /** ID of the WAF stage to delete. */ wafStageId: string } -export interface GetBackendStageRequest { +export type GetBackendStageRequest = { /** ID of the requested backend stage. */ backendStageId: string } -export interface GetBillingRequest { +export type GetBillingRequest = { projectId?: string } @@ -871,41 +871,41 @@ export interface GetBillingResponse { totalCost?: Money } -export interface GetCacheStageRequest { +export type GetCacheStageRequest = { /** ID of the requested cache stage. */ cacheStageId: string } -export interface GetCurrentPlanRequest { +export type GetCurrentPlanRequest = { projectId?: string } -export interface GetDNSStageRequest { +export type GetDNSStageRequest = { /** ID of the requested DNS stage. */ dnsStageId: string } -export interface GetPipelineRequest { +export type GetPipelineRequest = { /** ID of the requested pipeline. */ pipelineId: string } -export interface GetPurgeRequestRequest { +export type GetPurgeRequestRequest = { /** ID of the requested purge request. */ purgeRequestId: string } -export interface GetRouteStageRequest { +export type GetRouteStageRequest = { /** ID of the requested route stage. */ routeStageId: string } -export interface GetTLSStageRequest { +export type GetTLSStageRequest = { /** ID of the requested TLS stage. */ tlsStageId: string } -export interface GetWafStageRequest { +export type GetWafStageRequest = { /** ID of the requested WAF stage. */ wafStageId: string } @@ -915,7 +915,7 @@ export interface HeadStageResponse { headStage?: HeadStageResponseHeadStage } -export interface ListBackendStagesRequest { +export type ListBackendStagesRequest = { /** * Pipeline ID to filter for. Only backend stages from this pipeline will be * returned. @@ -951,7 +951,7 @@ export interface ListBackendStagesResponse { totalCount: number } -export interface ListCacheStagesRequest { +export type ListCacheStagesRequest = { /** * Pipeline ID to filter for. Only cache stages from this pipeline will be * returned. @@ -972,7 +972,7 @@ export interface ListCacheStagesResponse { totalCount: number } -export interface ListDNSStagesRequest { +export type ListDNSStagesRequest = { /** * Pipeline ID to filter for. Only DNS stages from this pipeline will be * returned. @@ -998,7 +998,7 @@ export interface ListDNSStagesResponse { totalCount: number } -export interface ListHeadStagesRequest { +export type ListHeadStagesRequest = { /** ID of the pipeline to update. */ pipelineId: string /** Page number to return, from the paginated results. */ @@ -1014,7 +1014,7 @@ export interface ListHeadStagesResponse { totalCount: number } -export interface ListPipelinesRequest { +export type ListPipelinesRequest = { /** Sort order of pipelines in the response. */ orderBy?: ListPipelinesRequestOrderBy /** Page number to return, from the paginated results. */ @@ -1050,7 +1050,7 @@ export interface ListPipelinesResponse { totalCount: number } -export interface ListPipelinesWithStagesRequest { +export type ListPipelinesWithStagesRequest = { orderBy?: ListPipelinesWithStagesRequestOrderBy page?: number pageSize?: number @@ -1069,7 +1069,7 @@ export interface ListPlansResponse { plans: PlanDetails[] } -export interface ListPurgeRequestsRequest { +export type ListPurgeRequestsRequest = { /** Sort order of purge requests in the response. */ orderBy?: ListPurgeRequestsRequestOrderBy /** Page number to return, from the paginated results. */ @@ -1100,7 +1100,7 @@ export interface ListPurgeRequestsResponse { totalCount: number } -export interface ListRouteRulesRequest { +export type ListRouteRulesRequest = { /** * Route stage ID to filter for. Only route rules from this route stage will * be returned. @@ -1118,7 +1118,7 @@ export interface ListRouteRulesResponse { routeRules: RouteRule[] } -export interface ListRouteStagesRequest { +export type ListRouteStagesRequest = { /** * Pipeline ID to filter for. Only route stages from this pipeline will be * returned. @@ -1139,7 +1139,7 @@ export interface ListRouteStagesResponse { totalCount: number } -export interface ListTLSStagesRequest { +export type ListTLSStagesRequest = { /** * Pipeline ID to filter for. Only TLS stages from this pipeline will be * returned. @@ -1170,7 +1170,7 @@ export interface ListTLSStagesResponse { totalCount: number } -export interface ListWafStagesRequest { +export type ListWafStagesRequest = { /** * Pipeline ID to filter for. Only WAF stages from this pipeline will be * returned. @@ -1195,7 +1195,7 @@ export interface Plan { planName: PlanName } -export interface SearchBackendStagesRequest { +export type SearchBackendStagesRequest = { orderBy?: SearchBackendStagesRequestOrderBy page?: number pageSize?: number @@ -1205,12 +1205,12 @@ export interface SearchBackendStagesRequest { lbId?: string } -export interface SelectPlanRequest { +export type SelectPlanRequest = { projectId?: string planName?: PlanName } -export interface SetHeadStageRequest { +export type SetHeadStageRequest = { /** ID of the pipeline to update. */ pipelineId: string /** @@ -1236,7 +1236,7 @@ export interface SetHeadStageRequest { swapHeadStage?: SetHeadStageRequestSwapHeadStage } -export interface SetRouteRulesRequest { +export type SetRouteRulesRequest = { /** ID of the route stage to update. */ routeStageId: string /** @@ -1258,7 +1258,7 @@ export interface SetRouteRulesResponse { routeRules: RouteRule[] } -export interface UpdateBackendStageRequest { +export type UpdateBackendStageRequest = { /** ID of the backend stage to update. */ backendStageId: string /** @@ -1279,7 +1279,7 @@ export interface UpdateBackendStageRequest { pipelineId: string } -export interface UpdateCacheStageRequest { +export type UpdateCacheStageRequest = { /** ID of the cache stage to update. */ cacheStageId: string /** Time To Live (TTL) in seconds. Defines how long content is cached. */ @@ -1303,7 +1303,7 @@ export interface UpdateCacheStageRequest { routeStageId?: string } -export interface UpdateDNSStageRequest { +export type UpdateDNSStageRequest = { /** ID of the DNS stage to update. */ dnsStageId: string /** @@ -1334,7 +1334,7 @@ export interface UpdateDNSStageRequest { backendStageId?: string } -export interface UpdatePipelineRequest { +export type UpdatePipelineRequest = { /** ID of the pipeline to update. */ pipelineId: string /** Name of the pipeline. */ @@ -1343,7 +1343,7 @@ export interface UpdatePipelineRequest { description?: string } -export interface UpdateRouteStageRequest { +export type UpdateRouteStageRequest = { /** ID of the route stage to update. */ routeStageId: string /** @@ -1355,7 +1355,7 @@ export interface UpdateRouteStageRequest { wafStageId?: string } -export interface UpdateTLSStageRequest { +export type UpdateTLSStageRequest = { /** ID of the TLS stage to update. */ tlsStageId: string /** Secret (from Scaleway Secret-Manager) containing your custom certificate. */ @@ -1391,7 +1391,7 @@ export interface UpdateTLSStageRequest { wafStageId?: string } -export interface UpdateWafStageRequest { +export type UpdateWafStageRequest = { /** ID of the WAF stage to update. */ wafStageId: string /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ From 1cfbbe5079e59a73f25f020669599dd3afdd18d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 27 Feb 2025 11:08:22 +0100 Subject: [PATCH 2/4] feat(block): add support for block v1 --- .../src/api/audit_trail/v1alpha1/api.gen.ts | 4 - .../audit_trail/v1alpha1/marshalling.gen.ts | 1 - .../src/api/audit_trail/v1alpha1/types.gen.ts | 10 +- .../api/edge_services/v1beta1/types.gen.ts | 104 +++++++++--------- 4 files changed, 55 insertions(+), 64 deletions(-) diff --git a/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts index 5abac31a0..f12040249 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/api.gen.ts @@ -72,10 +72,6 @@ export class API extends ParentAPI { { method: 'GET', path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/products`, - urlParams: urlParams([ - 'organization_id', - request.organizationId ?? this.client.settings.defaultOrganizationId, - ]), }, unmarshalListProductsResponse, ) diff --git a/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts index 1efa6f4a0..8a8c1f676 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/marshalling.gen.ts @@ -179,7 +179,6 @@ export const unmarshalEvent = (data: unknown): Event => { requestBody: data.request_body, requestId: data.request_id, resource: data.resource ? unmarshalResource(data.resource) : undefined, - resources: unmarshalArrayOfObject(data.resources, unmarshalResource), serviceName: data.service_name, sourceIp: data.source_ip, statusCode: data.status_code, diff --git a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts index fbe2d3a67..bbf7aa7ba 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts @@ -127,10 +127,8 @@ export interface Event { serviceName: string /** API method called to trigger the event. */ methodName: string - /** @deprecated Resource attached to the event. */ + /** Resource attached to the event. */ resource?: Resource - /** Resources attached to the event. */ - resources: Resource[] /** Unique identifier of the request at the origin of the event. */ requestId: string /** Request at the origin of the event. */ @@ -151,7 +149,7 @@ export interface Product { services: ProductService[] } -export type ListEventsRequest = { +export interface ListEventsRequest { /** * Region to target. If none is passed will use default region from the * config. @@ -195,14 +193,12 @@ export interface ListEventsResponse { nextPageToken?: string } -export type ListProductsRequest = { +export interface ListProductsRequest { /** * Region to target. If none is passed will use default region from the * config. */ region?: ScwRegion - /** ID of the Organization containing the Audit Trail events. */ - organizationId?: string } export interface ListProductsResponse { diff --git a/packages/clients/src/api/edge_services/v1beta1/types.gen.ts b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts index 76605513d..b85b803c6 100644 --- a/packages/clients/src/api/edge_services/v1beta1/types.gen.ts +++ b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts @@ -520,7 +520,7 @@ export interface TLSSecretsConfig { tlsSecrets: TLSSecret[] } -export type AddRouteRulesRequest = { +export interface AddRouteRulesRequest { /** ID of the route stage to update. */ routeStageId: string /** @@ -556,7 +556,7 @@ export interface AddRouteRulesResponse { routeRules: RouteRule[] } -export type CheckDomainRequest = { +export interface CheckDomainRequest { projectId?: string fqdn: string cname: string @@ -566,7 +566,7 @@ export interface CheckDomainResponse { isValid: boolean } -export type CheckLbOriginRequest = { +export interface CheckLbOriginRequest { lb?: ScalewayLb } @@ -575,7 +575,7 @@ export interface CheckLbOriginResponse { errorType: LbOriginError } -export type CheckPEMChainRequest = { +export interface CheckPEMChainRequest { projectId?: string fqdn: string /** One-of ('chain'): at most one of 'secret', 'raw' could be set. */ @@ -588,7 +588,7 @@ export interface CheckPEMChainResponse { isValid: boolean } -export type CreateBackendStageRequest = { +export interface CreateBackendStageRequest { /** Pipeline ID the Backend stage belongs to. */ pipelineId: string /** @@ -607,7 +607,7 @@ export type CreateBackendStageRequest = { scalewayLb?: ScalewayLbBackendConfig } -export type CreateCacheStageRequest = { +export interface CreateCacheStageRequest { /** Pipeline ID the Cache stage belongs to. */ pipelineId: string /** Time To Live (TTL) in seconds. Defines how long content is cached. */ @@ -631,7 +631,7 @@ export type CreateCacheStageRequest = { routeStageId?: string } -export type CreateDNSStageRequest = { +export interface CreateDNSStageRequest { /** Pipeline ID the DNS stage belongs to. */ pipelineId: string /** @@ -662,7 +662,7 @@ export type CreateDNSStageRequest = { backendStageId?: string } -export type CreatePipelineRequest = { +export interface CreatePipelineRequest { /** Project ID in which the pipeline will be created. */ projectId?: string /** Name of the pipeline. */ @@ -671,7 +671,7 @@ export type CreatePipelineRequest = { description: string } -export type CreatePurgeRequestRequest = { +export interface CreatePurgeRequestRequest { /** Pipeline ID in which the purge request will be created. */ pipelineId: string /** @@ -688,7 +688,7 @@ export type CreatePurgeRequestRequest = { all?: boolean } -export type CreateRouteStageRequest = { +export interface CreateRouteStageRequest { /** Pipeline ID the route stage belongs to. */ pipelineId: string /** @@ -700,7 +700,7 @@ export type CreateRouteStageRequest = { wafStageId?: string } -export type CreateTLSStageRequest = { +export interface CreateTLSStageRequest { /** Pipeline ID the TLS stage belongs to. */ pipelineId: string /** Secret (from Scaleway Secret Manager) containing your custom certificate. */ @@ -736,7 +736,7 @@ export type CreateTLSStageRequest = { wafStageId?: string } -export type CreateWafStageRequest = { +export interface CreateWafStageRequest { /** Pipeline ID the WAF stage belongs to. */ pipelineId: string /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ @@ -756,51 +756,51 @@ export type CreateWafStageRequest = { backendStageId?: string } -export type DeleteBackendStageRequest = { +export interface DeleteBackendStageRequest { /** ID of the backend stage to delete. */ backendStageId: string } -export type DeleteCacheStageRequest = { +export interface DeleteCacheStageRequest { /** ID of the cache stage to delete. */ cacheStageId: string } -export type DeleteCurrentPlanRequest = { +export interface DeleteCurrentPlanRequest { projectId?: string } -export type DeleteDNSStageRequest = { +export interface DeleteDNSStageRequest { /** ID of the DNS stage to delete. */ dnsStageId: string } -export type DeletePipelineRequest = { +export interface DeletePipelineRequest { /** ID of the pipeline to delete. */ pipelineId: string } -export type DeleteRouteStageRequest = { +export interface DeleteRouteStageRequest { /** ID of the route stage to delete. */ routeStageId: string } -export type DeleteTLSStageRequest = { +export interface DeleteTLSStageRequest { /** ID of the TLS stage to delete. */ tlsStageId: string } -export type DeleteWafStageRequest = { +export interface DeleteWafStageRequest { /** ID of the WAF stage to delete. */ wafStageId: string } -export type GetBackendStageRequest = { +export interface GetBackendStageRequest { /** ID of the requested backend stage. */ backendStageId: string } -export type GetBillingRequest = { +export interface GetBillingRequest { projectId?: string } @@ -871,41 +871,41 @@ export interface GetBillingResponse { totalCost?: Money } -export type GetCacheStageRequest = { +export interface GetCacheStageRequest { /** ID of the requested cache stage. */ cacheStageId: string } -export type GetCurrentPlanRequest = { +export interface GetCurrentPlanRequest { projectId?: string } -export type GetDNSStageRequest = { +export interface GetDNSStageRequest { /** ID of the requested DNS stage. */ dnsStageId: string } -export type GetPipelineRequest = { +export interface GetPipelineRequest { /** ID of the requested pipeline. */ pipelineId: string } -export type GetPurgeRequestRequest = { +export interface GetPurgeRequestRequest { /** ID of the requested purge request. */ purgeRequestId: string } -export type GetRouteStageRequest = { +export interface GetRouteStageRequest { /** ID of the requested route stage. */ routeStageId: string } -export type GetTLSStageRequest = { +export interface GetTLSStageRequest { /** ID of the requested TLS stage. */ tlsStageId: string } -export type GetWafStageRequest = { +export interface GetWafStageRequest { /** ID of the requested WAF stage. */ wafStageId: string } @@ -915,7 +915,7 @@ export interface HeadStageResponse { headStage?: HeadStageResponseHeadStage } -export type ListBackendStagesRequest = { +export interface ListBackendStagesRequest { /** * Pipeline ID to filter for. Only backend stages from this pipeline will be * returned. @@ -951,7 +951,7 @@ export interface ListBackendStagesResponse { totalCount: number } -export type ListCacheStagesRequest = { +export interface ListCacheStagesRequest { /** * Pipeline ID to filter for. Only cache stages from this pipeline will be * returned. @@ -972,7 +972,7 @@ export interface ListCacheStagesResponse { totalCount: number } -export type ListDNSStagesRequest = { +export interface ListDNSStagesRequest { /** * Pipeline ID to filter for. Only DNS stages from this pipeline will be * returned. @@ -998,7 +998,7 @@ export interface ListDNSStagesResponse { totalCount: number } -export type ListHeadStagesRequest = { +export interface ListHeadStagesRequest { /** ID of the pipeline to update. */ pipelineId: string /** Page number to return, from the paginated results. */ @@ -1014,7 +1014,7 @@ export interface ListHeadStagesResponse { totalCount: number } -export type ListPipelinesRequest = { +export interface ListPipelinesRequest { /** Sort order of pipelines in the response. */ orderBy?: ListPipelinesRequestOrderBy /** Page number to return, from the paginated results. */ @@ -1050,7 +1050,7 @@ export interface ListPipelinesResponse { totalCount: number } -export type ListPipelinesWithStagesRequest = { +export interface ListPipelinesWithStagesRequest { orderBy?: ListPipelinesWithStagesRequestOrderBy page?: number pageSize?: number @@ -1069,7 +1069,7 @@ export interface ListPlansResponse { plans: PlanDetails[] } -export type ListPurgeRequestsRequest = { +export interface ListPurgeRequestsRequest { /** Sort order of purge requests in the response. */ orderBy?: ListPurgeRequestsRequestOrderBy /** Page number to return, from the paginated results. */ @@ -1100,7 +1100,7 @@ export interface ListPurgeRequestsResponse { totalCount: number } -export type ListRouteRulesRequest = { +export interface ListRouteRulesRequest { /** * Route stage ID to filter for. Only route rules from this route stage will * be returned. @@ -1118,7 +1118,7 @@ export interface ListRouteRulesResponse { routeRules: RouteRule[] } -export type ListRouteStagesRequest = { +export interface ListRouteStagesRequest { /** * Pipeline ID to filter for. Only route stages from this pipeline will be * returned. @@ -1139,7 +1139,7 @@ export interface ListRouteStagesResponse { totalCount: number } -export type ListTLSStagesRequest = { +export interface ListTLSStagesRequest { /** * Pipeline ID to filter for. Only TLS stages from this pipeline will be * returned. @@ -1170,7 +1170,7 @@ export interface ListTLSStagesResponse { totalCount: number } -export type ListWafStagesRequest = { +export interface ListWafStagesRequest { /** * Pipeline ID to filter for. Only WAF stages from this pipeline will be * returned. @@ -1195,7 +1195,7 @@ export interface Plan { planName: PlanName } -export type SearchBackendStagesRequest = { +export interface SearchBackendStagesRequest { orderBy?: SearchBackendStagesRequestOrderBy page?: number pageSize?: number @@ -1205,12 +1205,12 @@ export type SearchBackendStagesRequest = { lbId?: string } -export type SelectPlanRequest = { +export interface SelectPlanRequest { projectId?: string planName?: PlanName } -export type SetHeadStageRequest = { +export interface SetHeadStageRequest { /** ID of the pipeline to update. */ pipelineId: string /** @@ -1236,7 +1236,7 @@ export type SetHeadStageRequest = { swapHeadStage?: SetHeadStageRequestSwapHeadStage } -export type SetRouteRulesRequest = { +export interface SetRouteRulesRequest { /** ID of the route stage to update. */ routeStageId: string /** @@ -1258,7 +1258,7 @@ export interface SetRouteRulesResponse { routeRules: RouteRule[] } -export type UpdateBackendStageRequest = { +export interface UpdateBackendStageRequest { /** ID of the backend stage to update. */ backendStageId: string /** @@ -1279,7 +1279,7 @@ export type UpdateBackendStageRequest = { pipelineId: string } -export type UpdateCacheStageRequest = { +export interface UpdateCacheStageRequest { /** ID of the cache stage to update. */ cacheStageId: string /** Time To Live (TTL) in seconds. Defines how long content is cached. */ @@ -1303,7 +1303,7 @@ export type UpdateCacheStageRequest = { routeStageId?: string } -export type UpdateDNSStageRequest = { +export interface UpdateDNSStageRequest { /** ID of the DNS stage to update. */ dnsStageId: string /** @@ -1334,7 +1334,7 @@ export type UpdateDNSStageRequest = { backendStageId?: string } -export type UpdatePipelineRequest = { +export interface UpdatePipelineRequest { /** ID of the pipeline to update. */ pipelineId: string /** Name of the pipeline. */ @@ -1343,7 +1343,7 @@ export type UpdatePipelineRequest = { description?: string } -export type UpdateRouteStageRequest = { +export interface UpdateRouteStageRequest { /** ID of the route stage to update. */ routeStageId: string /** @@ -1355,7 +1355,7 @@ export type UpdateRouteStageRequest = { wafStageId?: string } -export type UpdateTLSStageRequest = { +export interface UpdateTLSStageRequest { /** ID of the TLS stage to update. */ tlsStageId: string /** Secret (from Scaleway Secret-Manager) containing your custom certificate. */ @@ -1391,7 +1391,7 @@ export type UpdateTLSStageRequest = { wafStageId?: string } -export type UpdateWafStageRequest = { +export interface UpdateWafStageRequest { /** ID of the WAF stage to update. */ wafStageId: string /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ From 81bc96722db7fe5e4ae6eaa4fbb7d5ddcee24681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 27 Feb 2025 11:21:19 +0100 Subject: [PATCH 3/4] Fix --- packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts index bbf7aa7ba..0feebfcc9 100644 --- a/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/audit_trail/v1alpha1/types.gen.ts @@ -149,7 +149,7 @@ export interface Product { services: ProductService[] } -export interface ListEventsRequest { +export type ListEventsRequest = { /** * Region to target. If none is passed will use default region from the * config. @@ -193,7 +193,7 @@ export interface ListEventsResponse { nextPageToken?: string } -export interface ListProductsRequest { +export type ListProductsRequest = { /** * Region to target. If none is passed will use default region from the * config. From 583273266cd1240006b0adfcbf056b7ec403494c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 27 Feb 2025 11:22:52 +0100 Subject: [PATCH 4/4] Fix --- packages/clients/src/api/block/v1alpha1/marshalling.gen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts index d60c7d43e..3aff55dec 100644 --- a/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/block/v1alpha1/marshalling.gen.ts @@ -30,7 +30,7 @@ import type { VolumeType, } from './types.gen' -const unmarshalReference = (data: unknown): Reference => { +export const unmarshalReference = (data: unknown): Reference => { if (!isJSONObject(data)) { throw new TypeError( `Unmarshalling the type 'Reference' failed as data isn't a dictionary.`,