4545 sync_detailed as _get_session_sync ,
4646)
4747from scaleway_qaas_client .quantum_as_a_service_api_client .api .sessions .list_sessions import (
48- sync_detailed as _list_session_sync ,
48+ sync_detailed as _list_sessions_sync ,
4949)
5050from scaleway_qaas_client .quantum_as_a_service_api_client .api .sessions .terminate_session import (
5151 sync_detailed as _terminate_session_sync ,
@@ -81,10 +81,15 @@ def _raise_on_error(response: Response):
8181
8282class QaaSClient :
8383 def __init__ (self , project_id : str , secret_key : str , url : str = _DEFAULT_URL ):
84+ if not project_id :
85+ raise Exception ("QaasClient: project_id cannot be None" )
86+
87+ if not secret_key :
88+ raise Exception ("QaasClient: secret_key cannot be None" )
89+
8490 self .__project_id = project_id
8591
8692 self .__client = AuthenticatedClient (
87- # headers={"X-Auth-Token": secret_key},
8893 base_url = url ,
8994 timeout = 10.0 ,
9095 verify_ssl = "https" in url ,
@@ -113,6 +118,9 @@ def __repr__(self) -> str:
113118 """
114119
115120 def get_platform (self , platform_id : str ) -> ScalewayQaasV1Alpha1Platform :
121+ if not platform_id :
122+ raise Exception ("get_platform: platform_id cannot be None" )
123+
116124 response = _get_platform_sync (client = self .__client , platform_id = platform_id )
117125
118126 _raise_on_error (response )
@@ -166,6 +174,9 @@ def create_session(
166174 deduplication_id : Optional [str ] = None ,
167175 name : Optional [str ] = None ,
168176 ) -> ScalewayQaasV1Alpha1Session :
177+ if not platform_id :
178+ raise Exception ("create_session: platform_id cannot be None" )
179+
169180 name = name if name else f"qs-{ randomname .get_name ()} "
170181
171182 if isinstance (max_duration , str ):
@@ -207,16 +218,44 @@ def create_session(
207218 """
208219
209220 def get_session (self , session_id : str ) -> ScalewayQaasV1Alpha1Session :
221+ if not session_id :
222+ raise Exception ("get_session: session_id cannot be None" )
223+
210224 response = _get_session_sync (client = self .__client , session_id = session_id )
211225
212226 _raise_on_error (response )
213227
214228 return response .parsed
215229
216- def list_session (
230+ """List all sessions
231+
232+ Retrieve information about all sessions.
233+
234+ Args:
235+ platform_id (Union[Unset, str]): List sessions that have been created for this platform.
236+ tags (Union[Unset, list[str]]): List sessions with these tags.
237+ page (Union[Unset, int]): Page number.
238+ page_size (Union[Unset, int]): Maximum number of sessions to return per page.
239+ order_by (Union[Unset, ListSessionsOrderBy]): Sort order of the returned sessions.
240+ Default: ListSessionsOrderBy.NAME_ASC.
241+ project_id (str): List sessions belonging to this project ID. (UUID format) Example:
242+ 6170692e-7363-616c-6577-61792e636f6d.
243+
244+ Raises:
245+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
246+ httpx.TimeoutException: If the request takes longer than Client.timeout.
247+
248+ Returns:
249+ List[ScalewayQaasV1Alpha1ListSessionsResponse]
250+ """
251+
252+ def list_sessions (
217253 self , platform_id : Optional [str ] = None
218254 ) -> List [ScalewayQaasV1Alpha1Session ]:
219- response = _list_session_sync (
255+ if not platform_id :
256+ raise Exception ("list_session: platform_id cannot be None" )
257+
258+ response = _list_sessions_sync (
220259 client = self .__client , project_id = self .__project_id , platform_id = platform_id
221260 )
222261
@@ -241,6 +280,9 @@ def list_session(
241280 """
242281
243282 def terminate_session (self , session_id : str ) -> ScalewayQaasV1Alpha1Session :
283+ if not session_id :
284+ raise Exception ("terminate_session: session_id cannot be None" )
285+
244286 response = _terminate_session_sync (
245287 client = self .__client ,
246288 session_id = session_id ,
@@ -264,6 +306,9 @@ def terminate_session(self, session_id: str) -> ScalewayQaasV1Alpha1Session:
264306 """
265307
266308 def delete_session (self , session_id : str ):
309+ if not session_id :
310+ raise Exception ("delete_session: session_id cannot be None" )
311+
267312 _delete_session_sync (client = self .__client , session_id = session_id )
268313
269314 """Create a job
@@ -287,6 +332,12 @@ def create_job(
287332 payload : Union [Dict , List , str ],
288333 name : Optional [str ] = None ,
289334 ) -> ScalewayQaasV1Alpha1Job :
335+ if not session_id :
336+ raise Exception ("create_job: session_id cannot be None" )
337+
338+ if not payload :
339+ raise Exception ("create_job: payload cannot be None" )
340+
290341 payload = payload if isinstance (payload , str ) else json .dumps (payload )
291342 name = name if name else f"qj-{ randomname .get_name ()} "
292343
@@ -319,6 +370,9 @@ def create_job(
319370 """
320371
321372 def get_job (self , job_id : str ) -> ScalewayQaasV1Alpha1Job :
373+ if not job_id :
374+ raise Exception ("get_job: job_id cannot be None" )
375+
322376 response = _get_job_sync (client = self .__client , job_id = job_id )
323377
324378 _raise_on_error (response )
@@ -341,6 +395,9 @@ def get_job(self, job_id: str) -> ScalewayQaasV1Alpha1Job:
341395 """
342396
343397 def list_job_results (self , job_id : str ) -> List [ScalewayQaasV1Alpha1JobResult ]:
398+ if not job_id :
399+ raise Exception ("list_job_results: job_id cannot be None" )
400+
344401 response = _list_job_result_sync (client = self .__client , job_id = job_id )
345402
346403 _raise_on_error (response )
@@ -364,6 +421,9 @@ def list_job_results(self, job_id: str) -> List[ScalewayQaasV1Alpha1JobResult]:
364421 """
365422
366423 def cancel_job (self , job_id : str ) -> ScalewayQaasV1Alpha1Job :
424+ if not job_id :
425+ raise Exception ("cancel_job: job_id cannot be None" )
426+
367427 response = _cancel_job_sync (
368428 client = self .__client ,
369429 job_id = job_id ,
0 commit comments