Skip to content

Commit c4649ea

Browse files
committed
feat(qaas): wip timezone
1 parent cd532de commit c4649ea

34 files changed

+356
-364
lines changed

openapi/scaleway.qaas.v1alpha1.Api.yml

Lines changed: 9 additions & 64 deletions
Large diffs are not rendered by default.

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ randomname>=0.2.1
44
httpx>=0.27.0
55
pytimeparse>=1.1.8
66
attrs>=22.2.0
7-
python-dateutil>=2.8.0
7+
python-dateutil>=2.8.0
8+
pytz>=2024.1
9+
tzlocal>=5.3.1

scaleway_qaas_client/v1alpha1/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
from .quantum_as_a_service_api_client.models import (
2626
ScalewayQaasV1Alpha1Application as QaaSApplication,
2727
)
28+
from .quantum_as_a_service_api_client.models import (
29+
ScalewayQaasV1Alpha1Booking as QaaSBooking,
30+
)
2831
from .quantum_as_a_service_api_client.models import ScalewayQaasV1Alpha1Job as QaaSJob
2932
from .quantum_as_a_service_api_client.models import (
3033
ScalewayQaasV1Alpha1JobResult as QaaSJobResult,
@@ -44,6 +47,9 @@
4447
from .quantum_as_a_service_api_client.models import (
4548
ScalewayQaasV1Alpha1PlatformAvailability as QaaSPlatformAvailability,
4649
)
50+
from .quantum_as_a_service_api_client.models import (
51+
ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements,
52+
)
4753
from .quantum_as_a_service_api_client.models import (
4854
ScalewayQaasV1Alpha1PlatformTechnology as QaaSPlatformTechnology,
4955
)
@@ -65,9 +71,3 @@
6571
from .quantum_as_a_service_api_client.models import (
6672
ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus,
6773
)
68-
from .quantum_as_a_service_api_client.models import (
69-
ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements,
70-
)
71-
from .quantum_as_a_service_api_client.models import (
72-
ScalewayQaasV1Alpha1Booking as QaaSBooking,
73-
)

scaleway_qaas_client/v1alpha1/client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
Response,
128128
)
129129

130+
from scaleway_qaas_client.v1alpha1.utils import get_local_iana_timezone, is_valid_iana
131+
130132
_DEFAULT_URL = "https://api.scaleway.com"
131133

132134

@@ -251,6 +253,7 @@ def create_session(
251253
booking_demand_started_at: Optional[datetime] = None,
252254
booking_demand_finished_at: Optional[datetime] = None,
253255
booking_demand_description: Optional[str] = None,
256+
booking_demand_time_zone: Optional[str] = None,
254257
) -> ScalewayQaasV1Alpha1Session:
255258
"""Create a session
256259
@@ -267,6 +270,7 @@ def create_session(
267270
booking_demand_started_at (Union[None, Unset, datetime.datetime]): Wished started time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z.
268271
booking_demand_finished_at (Union[None, Unset, datetime.datetime]): Wished finished time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z.
269272
booking_demand_description (Union[None, Unset, str]): User description of the booking
273+
booking_demand_time_zone (Union[None, Unset, str]): Time zone of the demanded booking (eg: Europe/Paris, America/New_York...)
270274
271275
Raises:
272276
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -309,13 +313,21 @@ def create_session(
309313
booking_demand_finished_at_timestamp = (
310314
booking_demand_finished_at.timestamp()
311315
)
312-
# seconds = int(booking_demand_started_at_timestamp)
313-
# nanos = int(booking_demand_started_at_timestamp % 1 * 1e9)
316+
317+
if booking_demand_time_zone is not None and not is_valid_iana(
318+
booking_demand_time_zone
319+
):
320+
raise Exception(
321+
f"create_session: invalid time zone {booking_demand_time_zone} as IANA format"
322+
)
323+
else:
324+
time_zone = get_local_iana_timezone()
314325

315326
booking_demand = CreateSessionBodyBookingDemand(
316327
started_at=booking_demand_started_at_timestamp,
317328
finished_at=booking_demand_finished_at_timestamp,
318329
description=booking_demand_description,
330+
time_zone=time_zone,
319331
)
320332

321333
response = _create_session_sync(

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/get_application.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def sync_detailed(
5757
platforms.
5858
5959
Args:
60-
application_id (str): Unique ID of the application.
60+
application_id (str):
6161
6262
Raises:
6363
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -89,7 +89,7 @@ def sync(
8989
platforms.
9090
9191
Args:
92-
application_id (str): Unique ID of the application.
92+
application_id (str):
9393
9494
Raises:
9595
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -116,7 +116,7 @@ async def asyncio_detailed(
116116
platforms.
117117
118118
Args:
119-
application_id (str): Unique ID of the application.
119+
application_id (str):
120120
121121
Raises:
122122
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -146,7 +146,7 @@ async def asyncio(
146146
platforms.
147147
148148
Args:
149-
application_id (str): Unique ID of the application.
149+
application_id (str):
150150
151151
Raises:
152152
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/list_applications.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def sync_detailed(
9696
Retrieve information about all applications.
9797
9898
Args:
99-
name (Union[Unset, str]): List applications with this name.
100-
application_type (Union[Unset, ListApplicationsApplicationType]): List applications with
101-
this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE.
102-
page (Union[Unset, int]): Page number.
103-
page_size (Union[Unset, int]): Maximum number of applications a to return per page.
104-
order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications.
105-
Default: ListApplicationsOrderBy.NAME_ASC.
99+
name (Union[Unset, str]):
100+
application_type (Union[Unset, ListApplicationsApplicationType]): Default:
101+
ListApplicationsApplicationType.UNKNOWN_TYPE.
102+
page (Union[Unset, int]):
103+
page_size (Union[Unset, int]):
104+
order_by (Union[Unset, ListApplicationsOrderBy]): Default:
105+
ListApplicationsOrderBy.NAME_ASC.
106106
107107
Raises:
108108
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -143,13 +143,13 @@ def sync(
143143
Retrieve information about all applications.
144144
145145
Args:
146-
name (Union[Unset, str]): List applications with this name.
147-
application_type (Union[Unset, ListApplicationsApplicationType]): List applications with
148-
this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE.
149-
page (Union[Unset, int]): Page number.
150-
page_size (Union[Unset, int]): Maximum number of applications a to return per page.
151-
order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications.
152-
Default: ListApplicationsOrderBy.NAME_ASC.
146+
name (Union[Unset, str]):
147+
application_type (Union[Unset, ListApplicationsApplicationType]): Default:
148+
ListApplicationsApplicationType.UNKNOWN_TYPE.
149+
page (Union[Unset, int]):
150+
page_size (Union[Unset, int]):
151+
order_by (Union[Unset, ListApplicationsOrderBy]): Default:
152+
ListApplicationsOrderBy.NAME_ASC.
153153
154154
Raises:
155155
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -185,13 +185,13 @@ async def asyncio_detailed(
185185
Retrieve information about all applications.
186186
187187
Args:
188-
name (Union[Unset, str]): List applications with this name.
189-
application_type (Union[Unset, ListApplicationsApplicationType]): List applications with
190-
this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE.
191-
page (Union[Unset, int]): Page number.
192-
page_size (Union[Unset, int]): Maximum number of applications a to return per page.
193-
order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications.
194-
Default: ListApplicationsOrderBy.NAME_ASC.
188+
name (Union[Unset, str]):
189+
application_type (Union[Unset, ListApplicationsApplicationType]): Default:
190+
ListApplicationsApplicationType.UNKNOWN_TYPE.
191+
page (Union[Unset, int]):
192+
page_size (Union[Unset, int]):
193+
order_by (Union[Unset, ListApplicationsOrderBy]): Default:
194+
ListApplicationsOrderBy.NAME_ASC.
195195
196196
Raises:
197197
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -230,13 +230,13 @@ async def asyncio(
230230
Retrieve information about all applications.
231231
232232
Args:
233-
name (Union[Unset, str]): List applications with this name.
234-
application_type (Union[Unset, ListApplicationsApplicationType]): List applications with
235-
this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE.
236-
page (Union[Unset, int]): Page number.
237-
page_size (Union[Unset, int]): Maximum number of applications a to return per page.
238-
order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications.
239-
Default: ListApplicationsOrderBy.NAME_ASC.
233+
name (Union[Unset, str]):
234+
application_type (Union[Unset, ListApplicationsApplicationType]): Default:
235+
ListApplicationsApplicationType.UNKNOWN_TYPE.
236+
page (Union[Unset, int]):
237+
page_size (Union[Unset, int]):
238+
order_by (Union[Unset, ListApplicationsOrderBy]): Default:
239+
ListApplicationsOrderBy.NAME_ASC.
240240
241241
Raises:
242242
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/get_booking.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def sync_detailed(
5555
message.
5656
5757
Args:
58-
booking_id (str): Unique ID of the booking.
58+
booking_id (str):
5959
6060
Raises:
6161
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -87,7 +87,7 @@ def sync(
8787
message.
8888
8989
Args:
90-
booking_id (str): Unique ID of the booking.
90+
booking_id (str):
9191
9292
Raises:
9393
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -114,7 +114,7 @@ async def asyncio_detailed(
114114
message.
115115
116116
Args:
117-
booking_id (str): Unique ID of the booking.
117+
booking_id (str):
118118
119119
Raises:
120120
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -144,7 +144,7 @@ async def asyncio(
144144
message.
145145
146146
Args:
147-
booking_id (str): Unique ID of the booking.
147+
booking_id (str):
148148
149149
Raises:
150150
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/list_bookings.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ def sync_detailed(
8787
Retrieve information about all bookings of the provided **project ID** or ** platform ID**.
8888
8989
Args:
90-
project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format)
91-
Example: 6170692e-7363-616c-6577-61792e636f6d.
92-
platform_id (Union[Unset, str]): List bookings attached to this platform ID.
93-
page (Union[Unset, int]): Page number.
94-
page_size (Union[Unset, int]): Maximum number of results to return per page.
95-
order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default:
90+
project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d.
91+
platform_id (Union[Unset, str]):
92+
page (Union[Unset, int]):
93+
page_size (Union[Unset, int]):
94+
order_by (Union[Unset, ListBookingsOrderBy]): Default:
9695
ListBookingsOrderBy.CREATED_AT_DESC.
9796
9897
Raises:
@@ -132,12 +131,11 @@ def sync(
132131
Retrieve information about all bookings of the provided **project ID** or ** platform ID**.
133132
134133
Args:
135-
project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format)
136-
Example: 6170692e-7363-616c-6577-61792e636f6d.
137-
platform_id (Union[Unset, str]): List bookings attached to this platform ID.
138-
page (Union[Unset, int]): Page number.
139-
page_size (Union[Unset, int]): Maximum number of results to return per page.
140-
order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default:
134+
project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d.
135+
platform_id (Union[Unset, str]):
136+
page (Union[Unset, int]):
137+
page_size (Union[Unset, int]):
138+
order_by (Union[Unset, ListBookingsOrderBy]): Default:
141139
ListBookingsOrderBy.CREATED_AT_DESC.
142140
143141
Raises:
@@ -172,12 +170,11 @@ async def asyncio_detailed(
172170
Retrieve information about all bookings of the provided **project ID** or ** platform ID**.
173171
174172
Args:
175-
project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format)
176-
Example: 6170692e-7363-616c-6577-61792e636f6d.
177-
platform_id (Union[Unset, str]): List bookings attached to this platform ID.
178-
page (Union[Unset, int]): Page number.
179-
page_size (Union[Unset, int]): Maximum number of results to return per page.
180-
order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default:
173+
project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d.
174+
platform_id (Union[Unset, str]):
175+
page (Union[Unset, int]):
176+
page_size (Union[Unset, int]):
177+
order_by (Union[Unset, ListBookingsOrderBy]): Default:
181178
ListBookingsOrderBy.CREATED_AT_DESC.
182179
183180
Raises:
@@ -215,12 +212,11 @@ async def asyncio(
215212
Retrieve information about all bookings of the provided **project ID** or ** platform ID**.
216213
217214
Args:
218-
project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format)
219-
Example: 6170692e-7363-616c-6577-61792e636f6d.
220-
platform_id (Union[Unset, str]): List bookings attached to this platform ID.
221-
page (Union[Unset, int]): Page number.
222-
page_size (Union[Unset, int]): Maximum number of results to return per page.
223-
order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default:
215+
project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d.
216+
platform_id (Union[Unset, str]):
217+
page (Union[Unset, int]):
218+
page_size (Union[Unset, int]):
219+
order_by (Union[Unset, ListBookingsOrderBy]): Default:
224220
ListBookingsOrderBy.CREATED_AT_DESC.
225221
226222
Raises:

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/update_booking.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def sync_detailed(
6565
Update booking information of the provided **booking ID**.
6666
6767
Args:
68-
booking_id (str): Unique ID of the booking.
68+
booking_id (str):
6969
body (UpdateBookingBody):
7070
7171
Raises:
@@ -99,7 +99,7 @@ def sync(
9999
Update booking information of the provided **booking ID**.
100100
101101
Args:
102-
booking_id (str): Unique ID of the booking.
102+
booking_id (str):
103103
body (UpdateBookingBody):
104104
105105
Raises:
@@ -128,7 +128,7 @@ async def asyncio_detailed(
128128
Update booking information of the provided **booking ID**.
129129
130130
Args:
131-
booking_id (str): Unique ID of the booking.
131+
booking_id (str):
132132
body (UpdateBookingBody):
133133
134134
Raises:
@@ -160,7 +160,7 @@ async def asyncio(
160160
Update booking information of the provided **booking ID**.
161161
162162
Args:
163-
booking_id (str): Unique ID of the booking.
163+
booking_id (str):
164164
body (UpdateBookingBody):
165165
166166
Raises:

scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/cancel_job.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def sync_detailed(
6565
Cancel the job corresponding to the provided **job ID**.
6666
6767
Args:
68-
job_id (str): Unique ID of the job.
68+
job_id (str):
6969
body (CancelJobBody):
7070
7171
Raises:
@@ -99,7 +99,7 @@ def sync(
9999
Cancel the job corresponding to the provided **job ID**.
100100
101101
Args:
102-
job_id (str): Unique ID of the job.
102+
job_id (str):
103103
body (CancelJobBody):
104104
105105
Raises:
@@ -128,7 +128,7 @@ async def asyncio_detailed(
128128
Cancel the job corresponding to the provided **job ID**.
129129
130130
Args:
131-
job_id (str): Unique ID of the job.
131+
job_id (str):
132132
body (CancelJobBody):
133133
134134
Raises:
@@ -160,7 +160,7 @@ async def asyncio(
160160
Cancel the job corresponding to the provided **job ID**.
161161
162162
Args:
163-
job_id (str): Unique ID of the job.
163+
job_id (str):
164164
body (CancelJobBody):
165165
166166
Raises:

0 commit comments

Comments
 (0)