diff --git a/packages_generated/qaas/src/v1alpha1/api.gen.ts b/packages_generated/qaas/src/v1alpha1/api.gen.ts index 6369d52e3..2195be7e3 100644 --- a/packages_generated/qaas/src/v1alpha1/api.gen.ts +++ b/packages_generated/qaas/src/v1alpha1/api.gen.ts @@ -10,6 +10,7 @@ import { } from '@scaleway/sdk-client' import type { WaitForOptions } from '@scaleway/sdk-client' import { + BOOKING_TRANSIENT_STATUSES as BOOKING_TRANSIENT_STATUSES_QAAS, JOB_TRANSIENT_STATUSES as JOB_TRANSIENT_STATUSES_QAAS, PROCESS_TRANSIENT_STATUSES as PROCESS_TRANSIENT_STATUSES_QAAS, SESSION_TRANSIENT_STATUSES as SESSION_TRANSIENT_STATUSES_QAAS, @@ -18,13 +19,16 @@ import { marshalCreateJobRequest, marshalCreateProcessRequest, marshalCreateSessionRequest, + marshalUpdateBookingRequest, marshalUpdateJobRequest, marshalUpdateProcessRequest, marshalUpdateSessionRequest, unmarshalApplication, + unmarshalBooking, unmarshalJob, unmarshalJobCircuit, unmarshalListApplicationsResponse, + unmarshalListBookingsResponse, unmarshalListJobResultsResponse, unmarshalListJobsResponse, unmarshalListPlatformsResponse, @@ -38,6 +42,7 @@ import { } from './marshalling.gen' import type { Application, + Booking, CancelJobRequest, CancelProcessRequest, CreateJobRequest, @@ -47,6 +52,7 @@ import type { DeleteProcessRequest, DeleteSessionRequest, GetApplicationRequest, + GetBookingRequest, GetJobCircuitRequest, GetJobRequest, GetPlatformRequest, @@ -56,6 +62,8 @@ import type { JobCircuit, ListApplicationsRequest, ListApplicationsResponse, + ListBookingsRequest, + ListBookingsResponse, ListJobResultsRequest, ListJobResultsResponse, ListJobsRequest, @@ -74,6 +82,7 @@ import type { Process, Session, TerminateSessionRequest, + UpdateBookingRequest, UpdateJobRequest, UpdateProcessRequest, UpdateSessionRequest, @@ -317,7 +326,7 @@ export class API extends ParentAPI { enrichForPagination('platforms', this.pageOfListPlatforms, request) /** - * Get session infrormation. Retrieve information about the provided **session ID**, such as name, status, and number of executed jobs. + * Get session information. Retrieve information about the provided **session ID**, such as name, status, and number of executed jobs. * * @param request - The request {@link GetSessionRequest} * @returns A Promise of Session @@ -426,7 +435,7 @@ export class API extends ParentAPI { ) /** - * Terminate an existing session. Terminate a session by its unique ID and cancel all its attached jobs. + * Terminate an existing session. Terminate a session by its unique ID and cancel all its attached jobs and booking. * * @param request - The request {@link TerminateSessionRequest} * @returns A Promise of Session @@ -443,7 +452,7 @@ export class API extends ParentAPI { ) /** - * Delete an existing session. Delete a session by its unique ID and delete all its attached jobs. + * Delete an existing session. Delete a session by its unique ID and delete all its attached job and booking. * * @param request - The request {@link DeleteSessionRequest} */ @@ -495,7 +504,7 @@ export class API extends ParentAPI { ) /** - * Get process infrormation. Retrieve information about the provided **process ID**, such as name, status and progress. + * Get process information. Retrieve information about the provided **process ID**, such as name, status and progress. * * @param request - The request {@link GetProcessRequest} * @returns A Promise of Process @@ -688,4 +697,90 @@ export class API extends ParentAPI { */ listApplications = (request: Readonly = {}) => enrichForPagination('applications', this.pageOfListApplications, request) + + /** + * Get booking information. Retrieve information about the provided **booking ID**, such as description, status and progress message. + * + * @param request - The request {@link GetBookingRequest} + * @returns A Promise of Booking + */ + getBooking = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/bookings/${validatePathParam('bookingId', request.bookingId)}`, + }, + unmarshalBooking, + ) + + /** + * Waits for {@link Booking} to be in a final state. + * + * @param request - The request {@link GetBookingRequest} + * @param options - The waiting options + * @returns A Promise of Booking + */ + waitForBooking = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !BOOKING_TRANSIENT_STATUSES_QAAS.includes(res.status), + )), + this.getBooking, + request, + options, + ) + + protected pageOfListBookings = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/bookings`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['platform_id', request.platformId], + ['project_id', request.projectId], + ), + }, + unmarshalListBookingsResponse, + ) + + /** + * List all bookings according the filter. Retrieve information about all bookings of the provided **project ID** or ** platform ID**. + * + * @param request - The request {@link ListBookingsRequest} + * @returns A Promise of ListBookingsResponse + */ + listBookings = (request: Readonly = {}) => + enrichForPagination('bookings', this.pageOfListBookings, request) + + /** + * Update booking information. Update booking information of the provided **booking ID**. + * + * @param request - The request {@link UpdateBookingRequest} + * @returns A Promise of Booking + */ + updateBooking = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateBookingRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/qaas/v1alpha1/bookings/${validatePathParam('bookingId', request.bookingId)}`, + }, + unmarshalBooking, + ) } diff --git a/packages_generated/qaas/src/v1alpha1/content.gen.ts b/packages_generated/qaas/src/v1alpha1/content.gen.ts index de90902ac..903da1b20 100644 --- a/packages_generated/qaas/src/v1alpha1/content.gen.ts +++ b/packages_generated/qaas/src/v1alpha1/content.gen.ts @@ -1,6 +1,18 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -import type { JobStatus, ProcessStatus, SessionStatus } from './types.gen' +import type { + BookingStatus, + JobStatus, + ProcessStatus, + SessionStatus, +} from './types.gen' + +/** Lists transient statutes of the enum {@link BookingStatus}. */ +export const BOOKING_TRANSIENT_STATUSES: BookingStatus[] = [ + 'waiting', + 'validating', + 'cancelling', +] /** Lists transient statutes of the enum {@link JobStatus}. */ export const JOB_TRANSIENT_STATUSES: JobStatus[] = [ diff --git a/packages_generated/qaas/src/v1alpha1/index.gen.ts b/packages_generated/qaas/src/v1alpha1/index.gen.ts index 98cdda2ad..8b7e34adc 100644 --- a/packages_generated/qaas/src/v1alpha1/index.gen.ts +++ b/packages_generated/qaas/src/v1alpha1/index.gen.ts @@ -6,15 +6,19 @@ export * from './marshalling.gen' export type { Application, ApplicationType, + Booking, + BookingStatus, CancelJobRequest, CancelProcessRequest, CreateJobRequest, CreateProcessRequest, CreateSessionRequest, + CreateSessionRequestBookingDemand, DeleteJobRequest, DeleteProcessRequest, DeleteSessionRequest, GetApplicationRequest, + GetBookingRequest, GetJobCircuitRequest, GetJobRequest, GetPlatformRequest, @@ -27,6 +31,9 @@ export type { ListApplicationsRequest, ListApplicationsRequestOrderBy, ListApplicationsResponse, + ListBookingsRequest, + ListBookingsRequestOrderBy, + ListBookingsResponse, ListJobResultsRequest, ListJobResultsRequestOrderBy, ListJobResultsResponse, @@ -50,6 +57,7 @@ export type { ListSessionsResponse, Platform, PlatformAvailability, + PlatformBookingRequirement, PlatformHardware, PlatformTechnology, PlatformType, @@ -61,6 +69,7 @@ export type { SessionOriginType, SessionStatus, TerminateSessionRequest, + UpdateBookingRequest, UpdateJobRequest, UpdateProcessRequest, UpdateSessionRequest, diff --git a/packages_generated/qaas/src/v1alpha1/marshalling.gen.ts b/packages_generated/qaas/src/v1alpha1/marshalling.gen.ts index c0aa1f6ad..8099b02b8 100644 --- a/packages_generated/qaas/src/v1alpha1/marshalling.gen.ts +++ b/packages_generated/qaas/src/v1alpha1/marshalling.gen.ts @@ -10,13 +10,16 @@ import { import type { DefaultValues } from '@scaleway/sdk-client' import type { Application, + Booking, CreateJobRequest, CreateProcessRequest, CreateSessionRequest, + CreateSessionRequestBookingDemand, Job, JobCircuit, JobResult, ListApplicationsResponse, + ListBookingsResponse, ListJobResultsResponse, ListJobsResponse, ListPlatformsResponse, @@ -25,10 +28,12 @@ import type { ListSessionACLsResponse, ListSessionsResponse, Platform, + PlatformBookingRequirement, PlatformHardware, Process, ProcessResult, Session, + UpdateBookingRequest, UpdateJobRequest, UpdateProcessRequest, UpdateSessionRequest, @@ -63,6 +68,25 @@ export const unmarshalApplication = (data: unknown): Application => { } as Application } +export const unmarshalBooking = (data: unknown): Booking => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Booking' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + description: data.description, + finishedAt: unmarshalDate(data.finished_at), + id: data.id, + progressMessage: data.progress_message, + startedAt: unmarshalDate(data.started_at), + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as Booking +} + export const unmarshalJob = (data: unknown): Job => { if (!isJSONObject(data)) { throw new TypeError( @@ -85,6 +109,23 @@ export const unmarshalJob = (data: unknown): Job => { } as Job } +const unmarshalPlatformBookingRequirement = ( + data: unknown, +): PlatformBookingRequirement => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PlatformBookingRequirement' failed as data isn't a dictionary.`, + ) + } + + return { + maxCancellationDuration: data.max_cancellation_duration, + maxDuration: data.max_duration, + maxPlanificationDuration: data.max_planification_duration, + minDuration: data.min_duration, + } as PlatformBookingRequirement +} + const unmarshalPlatformHardware = (data: unknown): PlatformHardware => { if (!isJSONObject(data)) { throw new TypeError( @@ -112,10 +153,16 @@ export const unmarshalPlatform = (data: unknown): Platform => { return { availability: data.availability, backendName: data.backend_name, + bookingRequirement: data.booking_requirement + ? unmarshalPlatformBookingRequirement(data.booking_requirement) + : undefined, + description: data.description, + documentationUrl: data.documentation_url, hardware: data.hardware ? unmarshalPlatformHardware(data.hardware) : undefined, id: data.id, + isBookable: data.is_bookable, maxCircuitCount: data.max_circuit_count, maxQubitCount: data.max_qubit_count, maxShotCount: data.max_shot_count, @@ -171,6 +218,7 @@ export const unmarshalSession = (data: unknown): Session => { } return { + bookingId: data.booking_id, createdAt: unmarshalDate(data.created_at), deduplicationId: data.deduplication_id, finishedJobCount: data.finished_job_count, @@ -210,6 +258,21 @@ export const unmarshalListApplicationsResponse = ( } as ListApplicationsResponse } +export const unmarshalListBookingsResponse = ( + data: unknown, +): ListBookingsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListBookingsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + bookings: unmarshalArrayOfObject(data.bookings, unmarshalBooking), + totalCount: data.total_count, + } as ListBookingsResponse +} + const unmarshalJobResult = (data: unknown): JobResult => { if (!isJSONObject(data)) { throw new TypeError( @@ -378,10 +441,26 @@ export const marshalCreateProcessRequest = ( tags: request.tags, }) +const marshalCreateSessionRequestBookingDemand = ( + request: CreateSessionRequestBookingDemand, + defaults: DefaultValues, +): Record => ({ + description: request.description, + finished_at: request.finishedAt, + started_at: request.startedAt, +}) + export const marshalCreateSessionRequest = ( request: CreateSessionRequest, defaults: DefaultValues, ): Record => ({ + booking_demand: + request.bookingDemand !== undefined + ? marshalCreateSessionRequestBookingDemand( + request.bookingDemand, + defaults, + ) + : undefined, deduplication_id: request.deduplicationId, max_duration: request.maxDuration, max_idle_duration: request.maxIdleDuration, @@ -391,6 +470,13 @@ export const marshalCreateSessionRequest = ( tags: request.tags, }) +export const marshalUpdateBookingRequest = ( + request: UpdateBookingRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, +}) + export const marshalUpdateJobRequest = ( request: UpdateJobRequest, defaults: DefaultValues, diff --git a/packages_generated/qaas/src/v1alpha1/types.gen.ts b/packages_generated/qaas/src/v1alpha1/types.gen.ts index 4d0ad8db7..fb97fe36e 100644 --- a/packages_generated/qaas/src/v1alpha1/types.gen.ts +++ b/packages_generated/qaas/src/v1alpha1/types.gen.ts @@ -4,6 +4,15 @@ import type { Money } from '@scaleway/sdk-client' export type ApplicationType = 'unknown_type' | 'vqe' +export type BookingStatus = + | 'unknown_status' + | 'waiting' + | 'validating' + | 'validated' + | 'cancelling' + | 'cancelled' + | 'error' + export type JobStatus = | 'unknown_status' | 'waiting' @@ -19,6 +28,12 @@ export type ListApplicationsRequestOrderBy = | 'type_asc' | 'type_desc' +export type ListBookingsRequestOrderBy = + | 'created_at_desc' + | 'created_at_asc' + | 'started_at_desc' + | 'started_at_asc' + export type ListJobResultsRequestOrderBy = 'created_at_desc' | 'created_at_asc' export type ListJobsRequestOrderBy = @@ -84,6 +99,7 @@ export type PlatformTechnology = | 'general_purpose' | 'trapped_ion' | 'superconducting' + | 'neutral_atom' export type PlatformType = 'unknown_type' | 'simulator' | 'qpu' @@ -115,6 +131,25 @@ export type SessionStatus = | 'starting' | 'stopping' +export interface PlatformBookingRequirement { + /** + * Minimal duration of any booking based on this platform. + */ + minDuration?: string + /** + * Maximal duration of any bookings based on this platform. + */ + maxDuration?: string + /** + * Allowed time to cancel a booking attached to this platform before the beginning of the session. + */ + maxCancellationDuration?: string + /** + * Allowed planification time from now where the platform can be booked in the future. + */ + maxPlanificationDuration?: string +} + export interface PlatformHardware { /** * Product name of the hardware. @@ -157,6 +192,12 @@ export interface JobCircuit { qiskitCircuit?: string } +export interface CreateSessionRequestBookingDemand { + startedAt?: Date + finishedAt?: Date + description?: string +} + export interface Application { /** * Unique ID of the application. @@ -180,6 +221,41 @@ export interface Application { inputTemplate: string } +export interface Booking { + /** + * Unique ID of the booking. + */ + id: string + /** + * Time at which the booking was created. + */ + createdAt?: Date + /** + * Time at which the booking starts. + */ + startedAt?: Date + /** + * Time at which the booking was updated. + */ + updatedAt?: Date + /** + * Time at which the booking finishes. + */ + finishedAt?: Date + /** + * Status of the booking. + */ + status: BookingStatus + /** + * Description of the booking slot. + */ + description: string + /** + * Any progress message of the booking. + */ + progressMessage: string +} + export interface JobResult { /** * ID of the parent job. @@ -311,6 +387,22 @@ export interface Platform { * Specifications of the underlying hardware. */ hardware?: PlatformHardware + /** + * Booking constraints to fit if the platform is bookable. + */ + bookingRequirement?: PlatformBookingRequirement + /** + * English description of the platform. + */ + description: string + /** + * Documentation link to external documentation to learn more on this platform. + */ + documentationUrl: string + /** + * Specify if the platform is bookable. + */ + isBookable: boolean } export interface ProcessResult { @@ -350,7 +442,7 @@ export interface Process { */ attachedSessionIds: string[] /** - * Tme at which the process was created. + * Time at which the process was created. */ createdAt?: Date /** @@ -464,6 +556,10 @@ export interface Session { * Any progress of the session. */ progressMessage?: string + /** + * An optional booking unique ID of an attached booking. + */ + bookingId?: string } export type CancelJobRequest = { @@ -559,6 +655,10 @@ export type CreateSessionRequest = { * Deduplication ID of the session. */ deduplicationId?: string + /** + * A booking demand to schedule the session, only applicable if the platform is bookable. + */ + bookingDemand?: CreateSessionRequestBookingDemand } export type DeleteJobRequest = { @@ -589,6 +689,13 @@ export type GetApplicationRequest = { applicationId: string } +export type GetBookingRequest = { + /** + * Unique ID of the booking. + */ + bookingId: string +} + export type GetJobCircuitRequest = { /** * Unique ID of the job. @@ -658,6 +765,40 @@ export interface ListApplicationsResponse { applications: Application[] } +export type ListBookingsRequest = { + /** + * List bookings belonging to this project ID. + */ + projectId?: string + /** + * List bookings attached to this platform ID. + */ + platformId?: string + /** + * Page number. + */ + page?: number + /** + * Maximum number of results to return per page. + */ + pageSize?: number + /** + * Sort order of the returned results. + */ + orderBy?: ListBookingsRequestOrderBy +} + +export interface ListBookingsResponse { + /** + * Total number of bookings. + */ + totalCount: number + /** + * List of bookings. + */ + bookings: Booking[] +} + export type ListJobResultsRequest = { /** * ID of the job. @@ -901,6 +1042,17 @@ export type TerminateSessionRequest = { sessionId: string } +export type UpdateBookingRequest = { + /** + * Unique ID of the booking. + */ + bookingId: string + /** + * Description of the booking slot. + */ + description?: string +} + export type UpdateJobRequest = { /** * Unique ID of the job.