8989from scaleway_qaas_client .v1alpha1 .quantum_as_a_service_api_client .api .sessions .terminate_session import (
9090 sync_detailed as _terminate_session_sync ,
9191)
92+ from scaleway_qaas_client .v1alpha1 .quantum_as_a_service_api_client .api .bookings .get_booking import (
93+ sync_detailed as _get_booking_sync ,
94+ )
95+ from scaleway_qaas_client .v1alpha1 .quantum_as_a_service_api_client .api .bookings .list_bookings import (
96+ sync_detailed as _list_bookings_sync ,
97+ )
9298from scaleway_qaas_client .v1alpha1 .quantum_as_a_service_api_client .client import (
9399 AuthenticatedClient ,
94100)
100106 CreateModelBody ,
101107 CreateProcessBody ,
102108 CreateSessionBody ,
109+ CreateSessionBodyBookingDemand ,
103110 ListPlatformsPlatformTechnology ,
104111 ListPlatformsPlatformType ,
105112 ScalewayQaasV1Alpha1Application ,
106113 ScalewayQaasV1Alpha1Job ,
107114 ScalewayQaasV1Alpha1JobResult ,
108115 ScalewayQaasV1Alpha1Model ,
116+ ScalewayQaasV1Alpha1Booking ,
109117 ScalewayQaasV1Alpha1Platform ,
110118 ScalewayQaasV1Alpha1Process ,
111119 ScalewayQaasV1Alpha1ProcessResult ,
@@ -239,6 +247,9 @@ def create_session(
239247 name : Optional [str ] = None ,
240248 model_id : Optional [str ] = None ,
241249 parameters : Optional [Union [Dict , List , str ]] = None ,
250+ booking_demand_started_at : Optional [str ] = None ,
251+ booking_demand_finished_at : Optional [str ] = None ,
252+ booking_demand_description : Optional [str ] = None ,
242253 ) -> ScalewayQaasV1Alpha1Session :
243254 """Create a session
244255
@@ -261,6 +272,16 @@ def create_session(
261272 ScalewayQaasV1Alpha1Session
262273 """
263274
275+ if not booking_demand_started_at and booking_demand_finished_at :
276+ raise Exception (
277+ "booking_demand_started_at and booking_demand_finished_at must be set"
278+ )
279+
280+ if booking_demand_started_at and not booking_demand_finished_at :
281+ raise Exception (
282+ "booking_demand_started_at and booking_demand_finished_at must be set"
283+ )
284+
264285 if not platform_id :
265286 raise Exception ("create_session: platform_id cannot be None" )
266287
@@ -277,6 +298,15 @@ def create_session(
277298 if isinstance (max_idle_duration , str ):
278299 max_idle_duration = f"{ timeparse (max_idle_duration )} s"
279300
301+ booking_demand = UNSET
302+
303+ if booking_demand_started_at and booking_demand_finished_at :
304+ booking_demand = CreateSessionBodyBookingDemand (
305+ started_at = booking_demand_started_at ,
306+ finished_at = booking_demand_finished_at ,
307+ description = booking_demand_description ,
308+ )
309+
280310 response = _create_session_sync (
281311 client = self .__client ,
282312 body = CreateSessionBody (
@@ -288,6 +318,7 @@ def create_session(
288318 max_idle_duration = max_idle_duration ,
289319 model_id = model_id ,
290320 parameters = parameters ,
321+ booking_demand = booking_demand ,
291322 ),
292323 )
293324
@@ -890,3 +921,85 @@ def list_models(self) -> List[ScalewayQaasV1Alpha1Model]:
890921 _raise_on_error (response )
891922
892923 return response .parsed .models
924+
925+ def get_booking (self , booking_id : str ) -> ScalewayQaasV1Alpha1Booking :
926+ """Get booking information
927+
928+ Retrieve information about the provided **booking ID**, such as description, status and progress
929+ message.
930+
931+ Args:
932+ booking_id (str): Unique ID of the booking.
933+
934+ Raises:
935+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
936+ httpx.TimeoutException: If the request takes longer than Client.timeout.
937+
938+ Returns:
939+ Response[ScalewayQaasV1Alpha1Booking]
940+ """
941+
942+ if not booking_id :
943+ raise Exception ("get_booking: booking_id cannot be None" )
944+
945+ response = _get_booking_sync (client = self .__client , booking_id = booking_id )
946+
947+ _raise_on_error (response )
948+
949+ return response .parsed
950+
951+ def list_platform_bookings (
952+ self , platform_id : str
953+ ) -> List [ScalewayQaasV1Alpha1Booking ]:
954+ """List all bookings according of the target platform
955+
956+ Retrieve information about all bookings of the provided ** platform ID**.
957+
958+ Args:
959+ platform_id (Union[Unset, str]): List bookings attached to this platform ID.
960+
961+ Raises:
962+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
963+ httpx.TimeoutException: If the request takes longer than Client.timeout.
964+
965+ Returns:
966+ Response[ScalewayQaasV1Alpha1ListBookingsResponse]
967+ """
968+
969+ response = _list_bookings_sync (client = self .__client , platform_id = platform_id )
970+
971+ _raise_on_error (response )
972+
973+ return response .parsed .bookings
974+
975+ def list_bookings (
976+ self , platform_id : Optional [str ] = None
977+ ) -> List [ScalewayQaasV1Alpha1Booking ]:
978+ """List all bookings according the filter of the current project.
979+
980+ Retrieve information about all bookings of the project ID.
981+
982+ Args:
983+ platform_id (Union[Unset, str]): Will list only bookings attached to this platform ID.
984+
985+ Raises:
986+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
987+ httpx.TimeoutException: If the request takes longer than Client.timeout.
988+
989+ Returns:
990+ Response[ScalewayQaasV1Alpha1ListBookingsResponse]
991+ """
992+ if platform_id :
993+ response = _list_bookings_sync (
994+ client = self .__client ,
995+ platform_id = platform_id ,
996+ project_id = self .__project_id ,
997+ )
998+ else :
999+ response = _list_bookings_sync (
1000+ client = self .__client , project_id = self .__project_id
1001+ )
1002+
1003+ _raise_on_error (response )
1004+
1005+ return response .parsed .bookings
0 commit comments