|
18 | 18 |
|
19 | 19 | from scaleway_qaas_client.quantum_as_a_service_api_client.models import (
|
20 | 20 | CreateJobBody,
|
| 21 | + CancelJobBody, |
21 | 22 | CreateJobBodyCircuit,
|
22 | 23 | CreateSessionBody,
|
23 | 24 | TerminateSessionBody,
|
|
33 | 34 | from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.get_session import (
|
34 | 35 | sync as _get_session_sync,
|
35 | 36 | )
|
| 37 | +from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.list_sessions import ( |
| 38 | + sync as _list_session_sync, |
| 39 | +) |
36 | 40 | from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.terminate_session import (
|
37 | 41 | sync as _terminate_session_sync,
|
38 | 42 | )
|
|
51 | 55 | from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.get_job import (
|
52 | 56 | sync as _get_job_sync,
|
53 | 57 | )
|
| 58 | +from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.cancel_job import ( |
| 59 | + sync as _cancel_job_sync, |
| 60 | +) |
54 | 61 | from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.list_job_results import (
|
55 | 62 | sync as _list_job_result_sync,
|
56 | 63 | )
|
57 | 64 |
|
58 |
| -from scaleway_qaas_client.quantum_as_a_service_api_client.client import Client |
| 65 | +from scaleway_qaas_client.quantum_as_a_service_api_client.client import ( |
| 66 | + Client, |
| 67 | + AuthenticatedClient, |
| 68 | +) |
59 | 69 |
|
60 | 70 |
|
61 |
| -_DEFAULT_URL = "https://api.scaleway.com/qaas/v1alpha1" |
| 71 | +_DEFAULT_URL = "https://api.scaleway.com" |
62 | 72 |
|
63 | 73 |
|
64 | 74 | class QaaSClient:
|
65 | 75 | def __init__(self, project_id: str, secret_key: str, url: str = _DEFAULT_URL):
|
66 | 76 | self.__project_id = project_id
|
67 | 77 |
|
68 |
| - self.__client = Client( |
69 |
| - headers={"X-Auth-Token": secret_key}, |
| 78 | + self.__client = AuthenticatedClient( |
| 79 | + # headers={"X-Auth-Token": secret_key}, |
70 | 80 | base_url=url,
|
71 | 81 | timeout=10.0,
|
72 | 82 | verify_ssl="https" in url,
|
| 83 | + token=secret_key, |
| 84 | + prefix=None, |
| 85 | + auth_header_name="X-Auth-Token", |
73 | 86 | )
|
74 | 87 |
|
75 | 88 | def __repr__(self) -> str:
|
@@ -118,6 +131,19 @@ def get_session(self, session_id: str) -> ScalewayQaasV1Alpha1Session:
|
118 | 131 |
|
119 | 132 | return session
|
120 | 133 |
|
| 134 | + def list_session( |
| 135 | + self, platform_id: Optional[str] = None |
| 136 | + ) -> List[ScalewayQaasV1Alpha1Session]: |
| 137 | + response = _list_session_sync( |
| 138 | + client=self.__client, |
| 139 | + project_id=self.__project_id, |
| 140 | + platform_id=platform_id |
| 141 | + ) |
| 142 | + |
| 143 | + assert response |
| 144 | + |
| 145 | + return response.sessions |
| 146 | + |
121 | 147 | def terminate_session(self, session_id: str) -> ScalewayQaasV1Alpha1Session:
|
122 | 148 | session = _terminate_session_sync(
|
123 | 149 | client=self.__client,
|
@@ -160,3 +186,8 @@ def list_job_results(self, job_id: str) -> List[ScalewayQaasV1Alpha1JobResult]:
|
160 | 186 | response = _list_job_result_sync(client=self.__client, job_id=job_id)
|
161 | 187 |
|
162 | 188 | return response.job_results
|
| 189 | + |
| 190 | + def cancel_job(self, job_id: str) -> ScalewayQaasV1Alpha1Job: |
| 191 | + job = _cancel_job_sync(client=self.__client, body=CancelJobBody(job_id=job_id)) |
| 192 | + |
| 193 | + return job |
0 commit comments