Skip to content

Commit 8b556ae

Browse files
feat(cloud): add polling_timeout_seconds parameter to polling methods
1 parent 0d1d290 commit 8b556ae

File tree

21 files changed

+235
-5
lines changed

21 files changed

+235
-5
lines changed

src/gcore/resources/cloud/baremetal/servers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def rebuild_and_poll(
477477
image_id: str | Omit = omit,
478478
user_data: str | Omit = omit,
479479
polling_interval_seconds: int | Omit = omit,
480+
polling_timeout_seconds: int | Omit = omit,
480481
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
481482
# The extra values given here take precedence over values defined on the client or passed to this method.
482483
extra_headers: Headers | None = None,
@@ -502,6 +503,7 @@ def rebuild_and_poll(
502503
response.tasks[0],
503504
extra_headers=extra_headers,
504505
polling_interval_seconds=polling_interval_seconds,
506+
polling_timeout_seconds=polling_timeout_seconds,
505507
)
506508
servers = self.list(
507509
project_id=project_id,
@@ -904,6 +906,7 @@ async def create_and_poll(
904906
user_data: str | Omit = omit,
905907
username: str | Omit = omit,
906908
polling_interval_seconds: int | Omit = omit,
909+
polling_timeout_seconds: int | Omit = omit,
907910
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
908911
# The extra values given here take precedence over values defined on the client or passed to this method.
909912
extra_headers: Headers | None = None,
@@ -939,6 +942,7 @@ async def create_and_poll(
939942
response.tasks[0],
940943
extra_headers=extra_headers,
941944
polling_interval_seconds=polling_interval_seconds,
945+
polling_timeout_seconds=polling_timeout_seconds,
942946
)
943947
if not task.created_resources or not task.created_resources.instances:
944948
raise ValueError("No server was created")
@@ -964,6 +968,7 @@ async def rebuild_and_poll(
964968
image_id: str | Omit = omit,
965969
user_data: str | Omit = omit,
966970
polling_interval_seconds: int | Omit = omit,
971+
polling_timeout_seconds: int | Omit = omit,
967972
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
968973
# The extra values given here take precedence over values defined on the client or passed to this method.
969974
extra_headers: Headers | None = None,
@@ -989,6 +994,7 @@ async def rebuild_and_poll(
989994
response.tasks[0],
990995
extra_headers=extra_headers,
991996
polling_interval_seconds=polling_interval_seconds,
997+
polling_timeout_seconds=polling_timeout_seconds,
992998
)
993999
servers = await self.list(
9941000
project_id=project_id,

src/gcore/resources/cloud/file_shares/file_shares.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ def update_and_poll(
319319
share_settings: file_share_update_params.ShareSettings | Omit = omit,
320320
tags: Optional[TagUpdateMapParam] | Omit = omit,
321321
polling_interval_seconds: int | Omit = omit,
322+
polling_timeout_seconds: int | Omit = omit,
322323
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
323324
# The extra values given here take precedence over values defined on the client or passed to this method.
324325
extra_headers: Headers | None = None,
@@ -344,6 +345,7 @@ def update_and_poll(
344345
task_id=response.tasks[0],
345346
extra_headers=extra_headers,
346347
polling_interval_seconds=polling_interval_seconds,
348+
polling_timeout_seconds=polling_timeout_seconds,
347349
)
348350
return self.get(
349351
file_share_id,
@@ -840,6 +842,7 @@ async def update_and_poll(
840842
share_settings: file_share_update_params.ShareSettings | Omit = omit,
841843
tags: Optional[TagUpdateMapParam] | Omit = omit,
842844
polling_interval_seconds: int | Omit = omit,
845+
polling_timeout_seconds: int | Omit = omit,
843846
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
844847
# The extra values given here take precedence over values defined on the client or passed to this method.
845848
extra_headers: Headers | None = None,
@@ -865,6 +868,7 @@ async def update_and_poll(
865868
task_id=response.tasks[0],
866869
extra_headers=extra_headers,
867870
polling_interval_seconds=polling_interval_seconds,
871+
polling_timeout_seconds=polling_timeout_seconds,
868872
)
869873
return await self.get(
870874
file_share_id,

src/gcore/resources/cloud/floating_ips.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def create_and_poll(
445445
port_id: Optional[str] | Omit = omit,
446446
tags: Dict[str, str] | Omit = omit,
447447
polling_interval_seconds: int | Omit = omit,
448+
polling_timeout_seconds: int | Omit = omit,
448449
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
449450
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
450451
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -472,6 +473,7 @@ def create_and_poll(
472473
task_id=response.tasks[0],
473474
extra_headers=extra_headers,
474475
polling_interval_seconds=polling_interval_seconds,
476+
polling_timeout_seconds=polling_timeout_seconds,
475477
)
476478
if task.created_resources is None or task.created_resources.floatingips is None:
477479
raise ValueError("Task completed but created_resources or floatingips is missing")
@@ -493,6 +495,7 @@ def delete_and_poll(
493495
project_id: int | None = None,
494496
region_id: int | None = None,
495497
polling_interval_seconds: int | Omit = omit,
498+
polling_timeout_seconds: int | Omit = omit,
496499
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
497500
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
498501
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -518,6 +521,7 @@ def delete_and_poll(
518521
task_id=response.tasks[0],
519522
extra_headers=extra_headers,
520523
polling_interval_seconds=polling_interval_seconds,
524+
polling_timeout_seconds=polling_timeout_seconds,
521525
)
522526

523527

@@ -934,6 +938,7 @@ async def create_and_poll(
934938
port_id: Optional[str] | Omit = omit,
935939
tags: Dict[str, str] | Omit = omit,
936940
polling_interval_seconds: int | Omit = omit,
941+
polling_timeout_seconds: int | Omit = omit,
937942
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
938943
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
939944
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -961,6 +966,7 @@ async def create_and_poll(
961966
task_id=response.tasks[0],
962967
extra_headers=extra_headers,
963968
polling_interval_seconds=polling_interval_seconds,
969+
polling_timeout_seconds=polling_timeout_seconds,
964970
)
965971
if task.created_resources is None or task.created_resources.floatingips is None:
966972
raise ValueError("Task completed but created_resources or floatingips is missing")
@@ -982,6 +988,7 @@ async def delete_and_poll(
982988
project_id: int | None = None,
983989
region_id: int | None = None,
984990
polling_interval_seconds: int | Omit = omit,
991+
polling_timeout_seconds: int | Omit = omit,
985992
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
986993
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
987994
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1007,6 +1014,7 @@ async def delete_and_poll(
10071014
task_id=response.tasks[0],
10081015
extra_headers=extra_headers,
10091016
polling_interval_seconds=polling_interval_seconds,
1017+
polling_timeout_seconds=polling_timeout_seconds,
10101018
)
10111019

10121020

src/gcore/resources/cloud/gpu_baremetal_clusters/gpu_baremetal_clusters.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ def create_and_poll(
635635
servers_settings: gpu_baremetal_cluster_create_params.ServersSettings,
636636
tags: Dict[str, str] | Omit = omit,
637637
polling_interval_seconds: int | Omit = omit,
638+
polling_timeout_seconds: int | Omit = omit,
638639
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
639640
# The extra values given here take precedence over values defined on the client or passed to this method.
640641
extra_headers: Headers | None = None,
@@ -667,6 +668,7 @@ def create_and_poll(
667668
extra_query=extra_query,
668669
extra_body=extra_body,
669670
polling_interval_seconds=polling_interval_seconds,
671+
polling_timeout_seconds=polling_timeout_seconds,
670672
)
671673
if not task.created_resources or not task.created_resources.ai_clusters:
672674
raise ValueError("No cluster was created")
@@ -691,6 +693,7 @@ def rebuild_and_poll(
691693
image_id: Optional[str] | Omit = omit,
692694
user_data: Optional[str] | Omit = omit,
693695
polling_interval_seconds: int | Omit = omit,
696+
polling_timeout_seconds: int | Omit = omit,
694697
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
695698
# The extra values given here take precedence over values defined on the client or passed to this method.
696699
extra_headers: Headers | None = None,
@@ -721,6 +724,7 @@ def rebuild_and_poll(
721724
extra_query=extra_query,
722725
extra_body=extra_body,
723726
polling_interval_seconds=polling_interval_seconds,
727+
polling_timeout_seconds=polling_timeout_seconds,
724728
)
725729
return self.get( # pyright: ignore[reportDeprecated]
726730
cluster_id=cluster_id,
@@ -740,6 +744,7 @@ def resize_and_poll(
740744
region_id: int | None = None,
741745
instances_count: int,
742746
polling_interval_seconds: int | Omit = omit,
747+
polling_timeout_seconds: int | Omit = omit,
743748
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
744749
# The extra values given here take precedence over values defined on the client or passed to this method.
745750
extra_headers: Headers | None = None,
@@ -768,6 +773,7 @@ def resize_and_poll(
768773
extra_query=extra_query,
769774
extra_body=extra_body,
770775
polling_interval_seconds=polling_interval_seconds,
776+
polling_timeout_seconds=polling_timeout_seconds,
771777
)
772778
return self.get( # pyright: ignore[reportDeprecated]
773779
cluster_id=cluster_id,
@@ -1348,6 +1354,7 @@ async def create_and_poll(
13481354
servers_settings: gpu_baremetal_cluster_create_params.ServersSettings,
13491355
tags: Dict[str, str] | Omit = omit,
13501356
polling_interval_seconds: int | Omit = omit,
1357+
polling_timeout_seconds: int | Omit = omit,
13511358
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
13521359
# The extra values given here take precedence over values defined on the client or passed to this method.
13531360
extra_headers: Headers | None = None,
@@ -1380,6 +1387,7 @@ async def create_and_poll(
13801387
extra_query=extra_query,
13811388
extra_body=extra_body,
13821389
polling_interval_seconds=polling_interval_seconds,
1390+
polling_timeout_seconds=polling_timeout_seconds,
13831391
)
13841392
if not task.created_resources or not task.created_resources.ai_clusters:
13851393
raise ValueError("No cluster was created")
@@ -1404,6 +1412,7 @@ async def rebuild_and_poll(
14041412
image_id: Optional[str] | Omit = omit,
14051413
user_data: Optional[str] | Omit = omit,
14061414
polling_interval_seconds: int | Omit = omit,
1415+
polling_timeout_seconds: int | Omit = omit,
14071416
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
14081417
# The extra values given here take precedence over values defined on the client or passed to this method.
14091418
extra_headers: Headers | None = None,
@@ -1434,6 +1443,7 @@ async def rebuild_and_poll(
14341443
extra_query=extra_query,
14351444
extra_body=extra_body,
14361445
polling_interval_seconds=polling_interval_seconds,
1446+
polling_timeout_seconds=polling_timeout_seconds,
14371447
)
14381448
return await self.get( # pyright: ignore[reportDeprecated]
14391449
cluster_id=cluster_id,
@@ -1453,6 +1463,7 @@ async def resize_and_poll(
14531463
region_id: int | None = None,
14541464
instances_count: int,
14551465
polling_interval_seconds: int | Omit = omit,
1466+
polling_timeout_seconds: int | Omit = omit,
14561467
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
14571468
# The extra values given here take precedence over values defined on the client or passed to this method.
14581469
extra_headers: Headers | None = None,
@@ -1481,6 +1492,7 @@ async def resize_and_poll(
14811492
extra_query=extra_query,
14821493
extra_body=extra_body,
14831494
polling_interval_seconds=polling_interval_seconds,
1495+
polling_timeout_seconds=polling_timeout_seconds,
14841496
)
14851497
return await self.get( # pyright: ignore[reportDeprecated]
14861498
cluster_id=cluster_id,

src/gcore/resources/cloud/gpu_baremetal_clusters/images.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def delete_and_poll(
138138
project_id: int | None = None,
139139
region_id: int | None = None,
140140
polling_interval_seconds: int | Omit = omit,
141+
polling_timeout_seconds: int | Omit = omit,
141142
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
142143
# The extra values given here take precedence over values defined on the client or passed to this method.
143144
extra_headers: Headers | None = None,
@@ -165,6 +166,7 @@ def delete_and_poll(
165166
extra_query=extra_query,
166167
extra_body=extra_body,
167168
polling_interval_seconds=polling_interval_seconds,
169+
polling_timeout_seconds=polling_timeout_seconds,
168170
)
169171

170172
def get(
@@ -318,6 +320,7 @@ def upload_and_poll(
318320
ssh_key: Literal["allow", "deny", "required"] | Omit = omit,
319321
tags: Dict[str, str] | Omit = omit,
320322
polling_interval_seconds: int | Omit = omit,
323+
polling_timeout_seconds: int | Omit = omit,
321324
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
322325
# The extra values given here take precedence over values defined on the client or passed to this method.
323326
extra_headers: Headers | None = None,
@@ -354,6 +357,7 @@ def upload_and_poll(
354357
extra_query=extra_query,
355358
extra_body=extra_body,
356359
polling_interval_seconds=polling_interval_seconds,
360+
polling_timeout_seconds=polling_timeout_seconds,
357361
)
358362
if not task.created_resources or not task.created_resources.images:
359363
raise ValueError("No image was created")
@@ -481,6 +485,7 @@ async def delete_and_poll(
481485
project_id: int | None = None,
482486
region_id: int | None = None,
483487
polling_interval_seconds: int | Omit = omit,
488+
polling_timeout_seconds: int | Omit = omit,
484489
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
485490
# The extra values given here take precedence over values defined on the client or passed to this method.
486491
extra_headers: Headers | None = None,
@@ -508,6 +513,7 @@ async def delete_and_poll(
508513
extra_query=extra_query,
509514
extra_body=extra_body,
510515
polling_interval_seconds=polling_interval_seconds,
516+
polling_timeout_seconds=polling_timeout_seconds,
511517
)
512518

513519
async def get(
@@ -661,6 +667,7 @@ async def upload_and_poll(
661667
ssh_key: Literal["allow", "deny", "required"] | Omit = omit,
662668
tags: Dict[str, str] | Omit = omit,
663669
polling_interval_seconds: int | Omit = omit,
670+
polling_timeout_seconds: int | Omit = omit,
664671
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
665672
# The extra values given here take precedence over values defined on the client or passed to this method.
666673
extra_headers: Headers | None = None,
@@ -697,6 +704,7 @@ async def upload_and_poll(
697704
extra_query=extra_query,
698705
extra_body=extra_body,
699706
polling_interval_seconds=polling_interval_seconds,
707+
polling_timeout_seconds=polling_timeout_seconds,
700708
)
701709
if not task.created_resources or not task.created_resources.images:
702710
raise ValueError("No image was created")

src/gcore/resources/cloud/gpu_baremetal_clusters/servers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def delete_and_poll(
229229
cluster_id: str,
230230
delete_floatings: bool | Omit = omit,
231231
polling_interval_seconds: int | Omit = omit,
232+
polling_timeout_seconds: int | Omit = omit,
232233
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
233234
# The extra values given here take precedence over values defined on the client or passed to this method.
234235
extra_headers: Headers | None = None,
@@ -258,6 +259,7 @@ def delete_and_poll(
258259
extra_query=extra_query,
259260
extra_body=extra_body,
260261
polling_interval_seconds=polling_interval_seconds,
262+
polling_timeout_seconds=polling_timeout_seconds,
261263
)
262264

263265
@overload
@@ -876,6 +878,7 @@ async def delete_and_poll(
876878
cluster_id: str,
877879
delete_floatings: bool | Omit = omit,
878880
polling_interval_seconds: int | Omit = omit,
881+
polling_timeout_seconds: int | Omit = omit,
879882
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
880883
# The extra values given here take precedence over values defined on the client or passed to this method.
881884
extra_headers: Headers | None = None,
@@ -905,6 +908,7 @@ async def delete_and_poll(
905908
extra_query=extra_query,
906909
extra_body=extra_body,
907910
polling_interval_seconds=polling_interval_seconds,
911+
polling_timeout_seconds=polling_timeout_seconds,
908912
)
909913

910914
@overload

0 commit comments

Comments
 (0)