Skip to content

Commit b74f906

Browse files
committed
feat(client): fix jobs
1 parent 60d3e95 commit b74f906

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

scaleway_qaas_client/client.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from scaleway_qaas_client.quantum_as_a_service_api_client.models import (
2020
CreateJobBody,
21+
CancelJobBody,
2122
CreateJobBodyCircuit,
2223
CreateSessionBody,
2324
TerminateSessionBody,
@@ -33,6 +34,9 @@
3334
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.get_session import (
3435
sync as _get_session_sync,
3536
)
37+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.list_sessions import (
38+
sync as _list_session_sync,
39+
)
3640
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.terminate_session import (
3741
sync as _terminate_session_sync,
3842
)
@@ -51,25 +55,34 @@
5155
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.get_job import (
5256
sync as _get_job_sync,
5357
)
58+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.cancel_job import (
59+
sync as _cancel_job_sync,
60+
)
5461
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.list_job_results import (
5562
sync as _list_job_result_sync,
5663
)
5764

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+
)
5969

6070

61-
_DEFAULT_URL = "https://api.scaleway.com/qaas/v1alpha1"
71+
_DEFAULT_URL = "https://api.scaleway.com"
6272

6373

6474
class QaaSClient:
6575
def __init__(self, project_id: str, secret_key: str, url: str = _DEFAULT_URL):
6676
self.__project_id = project_id
6777

68-
self.__client = Client(
69-
headers={"X-Auth-Token": secret_key},
78+
self.__client = AuthenticatedClient(
79+
# headers={"X-Auth-Token": secret_key},
7080
base_url=url,
7181
timeout=10.0,
7282
verify_ssl="https" in url,
83+
token=secret_key,
84+
prefix=None,
85+
auth_header_name="X-Auth-Token",
7386
)
7487

7588
def __repr__(self) -> str:
@@ -118,6 +131,19 @@ def get_session(self, session_id: str) -> ScalewayQaasV1Alpha1Session:
118131

119132
return session
120133

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+
121147
def terminate_session(self, session_id: str) -> ScalewayQaasV1Alpha1Session:
122148
session = _terminate_session_sync(
123149
client=self.__client,
@@ -160,3 +186,8 @@ def list_job_results(self, job_id: str) -> List[ScalewayQaasV1Alpha1JobResult]:
160186
response = _list_job_result_sync(client=self.__client, job_id=job_id)
161187

162188
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

Comments
 (0)