@@ -10,6 +10,7 @@ import {
1010} from '@scaleway/sdk-client'
1111import type { WaitForOptions } from '@scaleway/sdk-client'
1212import {
13+ BOOKING_TRANSIENT_STATUSES as BOOKING_TRANSIENT_STATUSES_QAAS ,
1314 JOB_TRANSIENT_STATUSES as JOB_TRANSIENT_STATUSES_QAAS ,
1415 PROCESS_TRANSIENT_STATUSES as PROCESS_TRANSIENT_STATUSES_QAAS ,
1516 SESSION_TRANSIENT_STATUSES as SESSION_TRANSIENT_STATUSES_QAAS ,
@@ -18,13 +19,16 @@ import {
1819 marshalCreateJobRequest ,
1920 marshalCreateProcessRequest ,
2021 marshalCreateSessionRequest ,
22+ marshalUpdateBookingRequest ,
2123 marshalUpdateJobRequest ,
2224 marshalUpdateProcessRequest ,
2325 marshalUpdateSessionRequest ,
2426 unmarshalApplication ,
27+ unmarshalBooking ,
2528 unmarshalJob ,
2629 unmarshalJobCircuit ,
2730 unmarshalListApplicationsResponse ,
31+ unmarshalListBookingsResponse ,
2832 unmarshalListJobResultsResponse ,
2933 unmarshalListJobsResponse ,
3034 unmarshalListPlatformsResponse ,
@@ -38,6 +42,7 @@ import {
3842} from './marshalling.gen'
3943import type {
4044 Application ,
45+ Booking ,
4146 CancelJobRequest ,
4247 CancelProcessRequest ,
4348 CreateJobRequest ,
@@ -47,6 +52,7 @@ import type {
4752 DeleteProcessRequest ,
4853 DeleteSessionRequest ,
4954 GetApplicationRequest ,
55+ GetBookingRequest ,
5056 GetJobCircuitRequest ,
5157 GetJobRequest ,
5258 GetPlatformRequest ,
@@ -56,6 +62,8 @@ import type {
5662 JobCircuit ,
5763 ListApplicationsRequest ,
5864 ListApplicationsResponse ,
65+ ListBookingsRequest ,
66+ ListBookingsResponse ,
5967 ListJobResultsRequest ,
6068 ListJobResultsResponse ,
6169 ListJobsRequest ,
@@ -74,6 +82,7 @@ import type {
7482 Process ,
7583 Session ,
7684 TerminateSessionRequest ,
85+ UpdateBookingRequest ,
7786 UpdateJobRequest ,
7887 UpdateProcessRequest ,
7988 UpdateSessionRequest ,
@@ -317,7 +326,7 @@ export class API extends ParentAPI {
317326 enrichForPagination ( 'platforms' , this . pageOfListPlatforms , request )
318327
319328 /**
320- * Get session infrormation . Retrieve information about the provided **session ID**, such as name, status, and number of executed jobs.
329+ * Get session information . Retrieve information about the provided **session ID**, such as name, status, and number of executed jobs.
321330 *
322331 * @param request - The request {@link GetSessionRequest}
323332 * @returns A Promise of Session
@@ -426,7 +435,7 @@ export class API extends ParentAPI {
426435 )
427436
428437 /**
429- * Terminate an existing session. Terminate a session by its unique ID and cancel all its attached jobs.
438+ * Terminate an existing session. Terminate a session by its unique ID and cancel all its attached jobs and booking .
430439 *
431440 * @param request - The request {@link TerminateSessionRequest}
432441 * @returns A Promise of Session
@@ -443,7 +452,7 @@ export class API extends ParentAPI {
443452 )
444453
445454 /**
446- * Delete an existing session. Delete a session by its unique ID and delete all its attached jobs .
455+ * Delete an existing session. Delete a session by its unique ID and delete all its attached job and booking .
447456 *
448457 * @param request - The request {@link DeleteSessionRequest}
449458 */
@@ -495,7 +504,7 @@ export class API extends ParentAPI {
495504 )
496505
497506 /**
498- * Get process infrormation . Retrieve information about the provided **process ID**, such as name, status and progress.
507+ * Get process information . Retrieve information about the provided **process ID**, such as name, status and progress.
499508 *
500509 * @param request - The request {@link GetProcessRequest}
501510 * @returns A Promise of Process
@@ -688,4 +697,90 @@ export class API extends ParentAPI {
688697 */
689698 listApplications = ( request : Readonly < ListApplicationsRequest > = { } ) =>
690699 enrichForPagination ( 'applications' , this . pageOfListApplications , request )
700+
701+ /**
702+ * Get booking information. Retrieve information about the provided **booking ID**, such as description, status and progress message.
703+ *
704+ * @param request - The request {@link GetBookingRequest}
705+ * @returns A Promise of Booking
706+ */
707+ getBooking = ( request : Readonly < GetBookingRequest > ) =>
708+ this . client . fetch < Booking > (
709+ {
710+ method : 'GET' ,
711+ path : `/qaas/v1alpha1/bookings/${ validatePathParam ( 'bookingId' , request . bookingId ) } ` ,
712+ } ,
713+ unmarshalBooking ,
714+ )
715+
716+ /**
717+ * Waits for {@link Booking} to be in a final state.
718+ *
719+ * @param request - The request {@link GetBookingRequest}
720+ * @param options - The waiting options
721+ * @returns A Promise of Booking
722+ */
723+ waitForBooking = (
724+ request : Readonly < GetBookingRequest > ,
725+ options ?: Readonly < WaitForOptions < Booking > > ,
726+ ) =>
727+ waitForResource (
728+ options ?. stop ??
729+ ( res =>
730+ Promise . resolve (
731+ ! BOOKING_TRANSIENT_STATUSES_QAAS . includes ( res . status ) ,
732+ ) ) ,
733+ this . getBooking ,
734+ request ,
735+ options ,
736+ )
737+
738+ protected pageOfListBookings = (
739+ request : Readonly < ListBookingsRequest > = { } ,
740+ ) =>
741+ this . client . fetch < ListBookingsResponse > (
742+ {
743+ method : 'GET' ,
744+ path : `/qaas/v1alpha1/bookings` ,
745+ urlParams : urlParams (
746+ [ 'order_by' , request . orderBy ] ,
747+ [ 'page' , request . page ] ,
748+ [
749+ 'page_size' ,
750+ request . pageSize ?? this . client . settings . defaultPageSize ,
751+ ] ,
752+ [ 'platform_id' , request . platformId ] ,
753+ [ 'project_id' , request . projectId ] ,
754+ ) ,
755+ } ,
756+ unmarshalListBookingsResponse ,
757+ )
758+
759+ /**
760+ * List all bookings according the filter. Retrieve information about all bookings of the provided **project ID** or ** platform ID**.
761+ *
762+ * @param request - The request {@link ListBookingsRequest}
763+ * @returns A Promise of ListBookingsResponse
764+ */
765+ listBookings = ( request : Readonly < ListBookingsRequest > = { } ) =>
766+ enrichForPagination ( 'bookings' , this . pageOfListBookings , request )
767+
768+ /**
769+ * Update booking information. Update booking information of the provided **booking ID**.
770+ *
771+ * @param request - The request {@link UpdateBookingRequest}
772+ * @returns A Promise of Booking
773+ */
774+ updateBooking = ( request : Readonly < UpdateBookingRequest > ) =>
775+ this . client . fetch < Booking > (
776+ {
777+ body : JSON . stringify (
778+ marshalUpdateBookingRequest ( request , this . client . settings ) ,
779+ ) ,
780+ headers : jsonContentHeaders ,
781+ method : 'PATCH' ,
782+ path : `/qaas/v1alpha1/bookings/${ validatePathParam ( 'bookingId' , request . bookingId ) } ` ,
783+ } ,
784+ unmarshalBooking ,
785+ )
691786}
0 commit comments