Skip to content

Commit 8686f27

Browse files
committed
feat(client): update openapi
1 parent e1e2534 commit 8686f27

26 files changed

+1465
-2454
lines changed

openapi/_qaas-v1alpha1.yml

Lines changed: 0 additions & 2378 deletions
This file was deleted.

scaleway_qaas_client/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,36 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from .quantum_as_a_service_api_client.models import (
15-
ScalewayQaasV1Alpha1Platform as QaaSPlatform,
14+
from .client import QaaSClient
15+
from .job_payload.models import (
16+
QaaSCircuitData,
17+
QaaSCircuitSerializationFormat,
18+
QaaSJobBackendData,
19+
QaaSJobClientData,
20+
QaaSJobData,
21+
QaaSJobRunData,
1622
)
1723
from .quantum_as_a_service_api_client.models import (
18-
ScalewayQaasV1Alpha1PlatformAvailability as QaaSPlatformAvailability,
24+
ScalewayQaasV1Alpha1Application as QaaSApplication,
1925
)
26+
from .quantum_as_a_service_api_client.models import ScalewayQaasV1Alpha1Job as QaaSJob
2027
from .quantum_as_a_service_api_client.models import (
21-
ScalewayQaasV1Alpha1PlatformTechnology as QaaSPlatformTechnology,
28+
ScalewayQaasV1Alpha1JobResult as QaaSJobResult,
2229
)
23-
from .quantum_as_a_service_api_client.models import ScalewayQaasV1Alpha1Job as QaaSJob
2430
from .quantum_as_a_service_api_client.models import (
2531
ScalewayQaasV1Alpha1JobResult as QaaSJobResut,
2632
)
2733
from .quantum_as_a_service_api_client.models import (
2834
ScalewayQaasV1Alpha1JobStatus as QaaSJobStatus,
2935
)
3036
from .quantum_as_a_service_api_client.models import (
31-
ScalewayQaasV1Alpha1JobResult as QaaSJobResult,
32-
)
33-
from .quantum_as_a_service_api_client.models import (
34-
ScalewayQaasV1Alpha1Session as QaaSSession,
37+
ScalewayQaasV1Alpha1Platform as QaaSPlatform,
3538
)
3639
from .quantum_as_a_service_api_client.models import (
37-
ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus,
40+
ScalewayQaasV1Alpha1PlatformAvailability as QaaSPlatformAvailability,
3841
)
3942
from .quantum_as_a_service_api_client.models import (
40-
ScalewayQaasV1Alpha1Application as QaaSApplication,
43+
ScalewayQaasV1Alpha1PlatformTechnology as QaaSPlatformTechnology,
4144
)
4245
from .quantum_as_a_service_api_client.models import (
4346
ScalewayQaasV1Alpha1Process as QaaSProcess,
@@ -48,12 +51,9 @@
4851
from .quantum_as_a_service_api_client.models import (
4952
ScalewayQaasV1Alpha1ProcessStatus as QaaSProcessStatus,
5053
)
51-
from .job_payload.models import (
52-
QaaSCircuitSerializationFormat,
53-
QaaSCircuitData,
54-
QaaSJobBackendData,
55-
QaaSJobClientData,
56-
QaaSJobData,
57-
QaaSJobRunData,
54+
from .quantum_as_a_service_api_client.models import (
55+
ScalewayQaasV1Alpha1Session as QaaSSession,
56+
)
57+
from .quantum_as_a_service_api_client.models import (
58+
ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus,
5859
)
59-
from .client import QaaSClient

scaleway_qaas_client/client.py

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,59 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import json
15-
import randomname
15+
from typing import Dict, List, Optional, Union
1616

17+
import randomname
1718
from pytimeparse.timeparse import timeparse
1819

19-
from typing import List, Optional, Dict, Union
20-
21-
from scaleway_qaas_client.quantum_as_a_service_api_client.models import (
22-
CreateJobBody,
23-
CreateJobBodyCircuit,
24-
CreateSessionBody,
25-
TerminateSessionBody,
26-
CancelJobBody,
27-
ScalewayQaasV1Alpha1Platform,
28-
ScalewayQaasV1Alpha1Job,
29-
ScalewayQaasV1Alpha1JobResult,
30-
ScalewayQaasV1Alpha1Session,
31-
)
32-
33-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.create_session import (
34-
sync_detailed as _create_session_sync,
20+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.cancel_job import (
21+
sync_detailed as _cancel_job_sync,
3522
)
36-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.get_session import (
37-
sync_detailed as _get_session_sync,
23+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.create_job import (
24+
sync_detailed as _create_job_sync,
3825
)
39-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.list_sessions import (
40-
sync_detailed as _list_session_sync,
26+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.get_job import (
27+
sync_detailed as _get_job_sync,
4128
)
42-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.terminate_session import (
43-
sync_detailed as _terminate_session_sync,
29+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.list_job_results import (
30+
sync_detailed as _list_job_result_sync,
4431
)
45-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.delete_session import (
46-
sync_detailed as _delete_session_sync,
32+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.platforms.get_platform import (
33+
sync_detailed as _get_platform_sync,
4734
)
4835
from scaleway_qaas_client.quantum_as_a_service_api_client.api.platforms.list_platforms import (
4936
sync_detailed as _list_platforms_sync,
5037
)
51-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.platforms.get_platform import (
52-
sync_detailed as _get_platform_sync,
38+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.create_session import (
39+
sync_detailed as _create_session_sync,
5340
)
54-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.create_job import (
55-
sync_detailed as _create_job_sync,
41+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.delete_session import (
42+
sync_detailed as _delete_session_sync,
5643
)
57-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.get_job import (
58-
sync_detailed as _get_job_sync,
44+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.get_session import (
45+
sync_detailed as _get_session_sync,
5946
)
60-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.cancel_job import (
61-
sync_detailed as _cancel_job_sync,
47+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.list_sessions import (
48+
sync_detailed as _list_session_sync,
6249
)
63-
from scaleway_qaas_client.quantum_as_a_service_api_client.api.jobs.list_job_results import (
64-
sync_detailed as _list_job_result_sync,
50+
from scaleway_qaas_client.quantum_as_a_service_api_client.api.sessions.terminate_session import (
51+
sync_detailed as _terminate_session_sync,
6552
)
66-
from scaleway_qaas_client.quantum_as_a_service_api_client.types import Response
67-
6853
from scaleway_qaas_client.quantum_as_a_service_api_client.client import (
6954
AuthenticatedClient,
7055
)
71-
56+
from scaleway_qaas_client.quantum_as_a_service_api_client.models import (
57+
CancelJobBody,
58+
CreateJobBody,
59+
CreateJobBodyCircuit,
60+
CreateSessionBody,
61+
ScalewayQaasV1Alpha1Job,
62+
ScalewayQaasV1Alpha1JobResult,
63+
ScalewayQaasV1Alpha1Platform,
64+
ScalewayQaasV1Alpha1Session,
65+
TerminateSessionBody,
66+
)
67+
from scaleway_qaas_client.quantum_as_a_service_api_client.types import Response
7268

7369
_DEFAULT_URL = "https://api.scaleway.com"
7470

@@ -79,7 +75,7 @@ def _raise_on_error(response: Response):
7975

8076
if response.status_code.is_server_error or response.status_code.is_client_error:
8177
raise Exception(
82-
f"error {response.status_code}: {response.content.decode("utf-8")}"
78+
f"error {response.status_code}: {response.content.decode('utf-8')}"
8379
)
8480

8581

scaleway_qaas_client/job_payload/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from dataclasses import dataclass
1415
from enum import Enum
15-
from typing import List, Dict
16+
from typing import Dict, List
1617

17-
from dataclasses import dataclass
1818
from dataclasses_json import dataclass_json
1919

2020

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
from http import HTTPStatus
2+
from typing import Any, Optional, Union
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.scaleway_qaas_v1_alpha_1_booking import ScalewayQaasV1Alpha1Booking
9+
from ...types import Response
10+
11+
12+
def _get_kwargs(
13+
booking_id: str,
14+
) -> dict[str, Any]:
15+
_kwargs: dict[str, Any] = {
16+
"method": "get",
17+
"url": f"/qaas/v1alpha1/bookings/{booking_id}",
18+
}
19+
20+
return _kwargs
21+
22+
23+
def _parse_response(
24+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
25+
) -> Optional[ScalewayQaasV1Alpha1Booking]:
26+
if response.status_code == 200:
27+
response_200 = ScalewayQaasV1Alpha1Booking.from_dict(response.json())
28+
29+
return response_200
30+
if client.raise_on_unexpected_status:
31+
raise errors.UnexpectedStatus(response.status_code, response.content)
32+
else:
33+
return None
34+
35+
36+
def _build_response(
37+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
38+
) -> Response[ScalewayQaasV1Alpha1Booking]:
39+
return Response(
40+
status_code=HTTPStatus(response.status_code),
41+
content=response.content,
42+
headers=response.headers,
43+
parsed=_parse_response(client=client, response=response),
44+
)
45+
46+
47+
def sync_detailed(
48+
booking_id: str,
49+
*,
50+
client: AuthenticatedClient,
51+
) -> Response[ScalewayQaasV1Alpha1Booking]:
52+
"""Get booking information
53+
54+
Retrieve information about the provided **booking ID**, such as description, status and progress
55+
message.
56+
57+
Args:
58+
booking_id (str): Unique ID of the booking.
59+
60+
Raises:
61+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
62+
httpx.TimeoutException: If the request takes longer than Client.timeout.
63+
64+
Returns:
65+
Response[ScalewayQaasV1Alpha1Booking]
66+
"""
67+
68+
kwargs = _get_kwargs(
69+
booking_id=booking_id,
70+
)
71+
72+
response = client.get_httpx_client().request(
73+
**kwargs,
74+
)
75+
76+
return _build_response(client=client, response=response)
77+
78+
79+
def sync(
80+
booking_id: str,
81+
*,
82+
client: AuthenticatedClient,
83+
) -> Optional[ScalewayQaasV1Alpha1Booking]:
84+
"""Get booking information
85+
86+
Retrieve information about the provided **booking ID**, such as description, status and progress
87+
message.
88+
89+
Args:
90+
booking_id (str): Unique ID of the booking.
91+
92+
Raises:
93+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94+
httpx.TimeoutException: If the request takes longer than Client.timeout.
95+
96+
Returns:
97+
ScalewayQaasV1Alpha1Booking
98+
"""
99+
100+
return sync_detailed(
101+
booking_id=booking_id,
102+
client=client,
103+
).parsed
104+
105+
106+
async def asyncio_detailed(
107+
booking_id: str,
108+
*,
109+
client: AuthenticatedClient,
110+
) -> Response[ScalewayQaasV1Alpha1Booking]:
111+
"""Get booking information
112+
113+
Retrieve information about the provided **booking ID**, such as description, status and progress
114+
message.
115+
116+
Args:
117+
booking_id (str): Unique ID of the booking.
118+
119+
Raises:
120+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
121+
httpx.TimeoutException: If the request takes longer than Client.timeout.
122+
123+
Returns:
124+
Response[ScalewayQaasV1Alpha1Booking]
125+
"""
126+
127+
kwargs = _get_kwargs(
128+
booking_id=booking_id,
129+
)
130+
131+
response = await client.get_async_httpx_client().request(**kwargs)
132+
133+
return _build_response(client=client, response=response)
134+
135+
136+
async def asyncio(
137+
booking_id: str,
138+
*,
139+
client: AuthenticatedClient,
140+
) -> Optional[ScalewayQaasV1Alpha1Booking]:
141+
"""Get booking information
142+
143+
Retrieve information about the provided **booking ID**, such as description, status and progress
144+
message.
145+
146+
Args:
147+
booking_id (str): Unique ID of the booking.
148+
149+
Raises:
150+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
151+
httpx.TimeoutException: If the request takes longer than Client.timeout.
152+
153+
Returns:
154+
ScalewayQaasV1Alpha1Booking
155+
"""
156+
157+
return (
158+
await asyncio_detailed(
159+
booking_id=booking_id,
160+
client=client,
161+
)
162+
).parsed

0 commit comments

Comments
 (0)