gcore 0.1.0a1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gcore might be problematic. Click here for more details.

Files changed (78) hide show
  1. gcore/__init__.py +5 -0
  2. gcore/_client.py +9 -0
  3. gcore/_utils/_proxy.py +4 -1
  4. gcore/_utils/_resources_proxy.py +24 -0
  5. gcore/_version.py +1 -1
  6. gcore/resources/__init__.py +14 -0
  7. gcore/resources/cloud/baremetal/servers.py +234 -0
  8. gcore/resources/cloud/billing_reservations.py +24 -0
  9. gcore/resources/cloud/file_shares/file_shares.py +16 -0
  10. gcore/resources/cloud/gpu_baremetal_clusters/gpu_baremetal_clusters.py +352 -2
  11. gcore/resources/cloud/gpu_baremetal_clusters/images.py +204 -0
  12. gcore/resources/cloud/gpu_baremetal_clusters/servers.py +80 -0
  13. gcore/resources/cloud/inference/deployments/deployments.py +322 -4
  14. gcore/resources/cloud/instances/images.py +316 -0
  15. gcore/resources/cloud/instances/instances.py +472 -0
  16. gcore/resources/cloud/load_balancers/l7_policies/l7_policies.py +282 -0
  17. gcore/resources/cloud/load_balancers/l7_policies/rules.py +326 -0
  18. gcore/resources/cloud/load_balancers/listeners.py +371 -6
  19. gcore/resources/cloud/load_balancers/load_balancers.py +364 -0
  20. gcore/resources/cloud/load_balancers/pools/health_monitors.py +24 -0
  21. gcore/resources/cloud/load_balancers/pools/members.py +28 -0
  22. gcore/resources/cloud/load_balancers/pools/pools.py +388 -8
  23. gcore/resources/cloud/networks/networks.py +72 -16
  24. gcore/resources/cloud/secrets.py +56 -11
  25. gcore/resources/cloud/tasks.py +107 -96
  26. gcore/resources/waap/__init__.py +33 -0
  27. gcore/resources/waap/domains/__init__.py +33 -0
  28. gcore/resources/waap/domains/domains.py +515 -0
  29. gcore/resources/waap/domains/settings.py +271 -0
  30. gcore/resources/waap/waap.py +102 -0
  31. gcore/types/cloud/__init__.py +1 -0
  32. gcore/types/cloud/billing_reservation_list_params.py +5 -0
  33. gcore/types/cloud/container_probe_config_create_param.py +1 -2
  34. gcore/types/cloud/file_share.py +3 -0
  35. gcore/types/cloud/file_share_list_params.py +7 -1
  36. gcore/types/cloud/gpu_baremetal_cluster_create_params.py +20 -0
  37. gcore/types/cloud/inference/deployment_update_params.py +203 -6
  38. gcore/types/cloud/inference/inference.py +3 -1
  39. gcore/types/cloud/load_balancer_listener_detail.py +13 -13
  40. gcore/types/cloud/load_balancer_pool.py +13 -13
  41. gcore/types/cloud/load_balancer_pool_list.py +99 -4
  42. gcore/types/cloud/load_balancers/listener_create_params.py +2 -0
  43. gcore/types/cloud/load_balancers/listener_get_params.py +3 -1
  44. gcore/types/cloud/load_balancers/listener_list_params.py +4 -2
  45. gcore/types/cloud/load_balancers/listener_update_params.py +2 -0
  46. gcore/types/cloud/load_balancers/pool_create_params.py +2 -0
  47. gcore/types/cloud/load_balancers/pool_list_params.py +5 -6
  48. gcore/types/cloud/load_balancers/pool_update_params.py +2 -0
  49. gcore/types/cloud/load_balancers/pools/health_monitor_create_params.py +2 -0
  50. gcore/types/cloud/load_balancers/pools/member_add_params.py +2 -0
  51. gcore/types/cloud/network.py +21 -21
  52. gcore/types/cloud/network_create_params.py +2 -0
  53. gcore/types/cloud/network_details.py +24 -23
  54. gcore/types/cloud/network_list_params.py +15 -10
  55. gcore/types/cloud/network_update_params.py +2 -0
  56. gcore/types/cloud/quota_get_all_response.py +18 -0
  57. gcore/types/cloud/quota_get_by_region_response.py +18 -0
  58. gcore/types/cloud/quotas/request_create_params.py +9 -0
  59. gcore/types/cloud/quotas/request_get_response.py +9 -0
  60. gcore/types/cloud/quotas/request_list_response.py +9 -0
  61. gcore/types/cloud/secret_list_params.py +24 -0
  62. gcore/types/cloud/task.py +0 -3
  63. gcore/types/cloud/task_list_params.py +8 -2
  64. gcore/types/waap/__init__.py +12 -0
  65. gcore/types/waap/domain_list_params.py +30 -0
  66. gcore/types/waap/domain_update_params.py +12 -0
  67. gcore/types/waap/domains/__init__.py +5 -0
  68. gcore/types/waap/domains/setting_update_params.py +41 -0
  69. gcore/types/waap/waap_api_urls.py +15 -0
  70. gcore/types/waap/waap_detailed_domain.py +37 -0
  71. gcore/types/waap/waap_domain_ddos_settings.py +31 -0
  72. gcore/types/waap/waap_domain_settings.py +15 -0
  73. gcore/types/waap/waap_domain_status.py +7 -0
  74. gcore/types/waap/waap_summary_domain.py +26 -0
  75. {gcore-0.1.0a1.dist-info → gcore-0.2.0.dist-info}/METADATA +4 -7
  76. {gcore-0.1.0a1.dist-info → gcore-0.2.0.dist-info}/RECORD +78 -60
  77. {gcore-0.1.0a1.dist-info → gcore-0.2.0.dist-info}/WHEEL +0 -0
  78. {gcore-0.1.0a1.dist-info → gcore-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -335,6 +335,147 @@ class L7PoliciesResource(SyncAPIResource):
335
335
  cast_to=TaskIDList,
336
336
  )
337
337
 
338
+ def create_and_poll(
339
+ self,
340
+ *,
341
+ project_id: int | None = None,
342
+ region_id: int | None = None,
343
+ action: Literal["REDIRECT_PREFIX", "REDIRECT_TO_POOL", "REDIRECT_TO_URL", "REJECT"],
344
+ listener_id: str,
345
+ name: str | NotGiven = NOT_GIVEN,
346
+ position: int | NotGiven = NOT_GIVEN,
347
+ redirect_http_code: int | NotGiven = NOT_GIVEN,
348
+ redirect_pool_id: str | NotGiven = NOT_GIVEN,
349
+ redirect_prefix: str | NotGiven = NOT_GIVEN,
350
+ redirect_url: str | NotGiven = NOT_GIVEN,
351
+ tags: List[str] | NotGiven = NOT_GIVEN,
352
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
353
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
354
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
355
+ # The extra values given here take precedence over values defined on the client or passed to this method.
356
+ extra_headers: Headers | None = None,
357
+ extra_query: Query | None = None,
358
+ extra_body: Body | None = None,
359
+ ) -> LoadBalancerL7Policy:
360
+ response = self.create(
361
+ project_id=project_id,
362
+ region_id=region_id,
363
+ action=action,
364
+ listener_id=listener_id,
365
+ name=name,
366
+ position=position,
367
+ redirect_http_code=redirect_http_code,
368
+ redirect_pool_id=redirect_pool_id,
369
+ redirect_prefix=redirect_prefix,
370
+ redirect_url=redirect_url,
371
+ tags=tags,
372
+ extra_headers=extra_headers,
373
+ extra_query=extra_query,
374
+ extra_body=extra_body,
375
+ timeout=timeout,
376
+ )
377
+ if not response.tasks or len(response.tasks) != 1:
378
+ raise ValueError(f"Expected exactly one task to be created")
379
+ task = self._client.cloud.tasks.poll(
380
+ task_id=response.tasks[0],
381
+ extra_headers=extra_headers,
382
+ polling_interval_seconds=polling_interval_seconds,
383
+ )
384
+ if not task.created_resources or not task.created_resources.l7polices or len(task.created_resources.l7polices) != 1:
385
+ raise ValueError(f"Expected exactly one resource to be created in a task")
386
+ return self.get(
387
+ l7policy_id=task.created_resources.l7polices[0],
388
+ project_id=project_id,
389
+ region_id=region_id,
390
+ extra_headers=extra_headers,
391
+ timeout=timeout,
392
+ )
393
+
394
+ def delete_and_poll(
395
+ self,
396
+ l7policy_id: str,
397
+ *,
398
+ project_id: int | None = None,
399
+ region_id: int | None = None,
400
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
401
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
402
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
403
+ # The extra values given here take precedence over values defined on the client or passed to this method.
404
+ extra_headers: Headers | None = None,
405
+ extra_query: Query | None = None,
406
+ extra_body: Body | None = None,
407
+ ) -> None:
408
+ response = self.delete(
409
+ l7policy_id=l7policy_id,
410
+ project_id=project_id,
411
+ region_id=region_id,
412
+ extra_headers=extra_headers,
413
+ extra_query=extra_query,
414
+ extra_body=extra_body,
415
+ timeout=timeout,
416
+ )
417
+ if not response.tasks or len(response.tasks) != 1:
418
+ raise ValueError(f"Expected exactly one task to be created")
419
+ self._client.cloud.tasks.poll(
420
+ task_id=response.tasks[0],
421
+ extra_headers=extra_headers,
422
+ polling_interval_seconds=polling_interval_seconds,
423
+ )
424
+
425
+ def replace_and_poll(
426
+ self,
427
+ l7policy_id: str,
428
+ *,
429
+ project_id: int | None = None,
430
+ region_id: int | None = None,
431
+ action: Literal["REDIRECT_PREFIX", "REDIRECT_TO_POOL", "REDIRECT_TO_URL", "REJECT"],
432
+ name: str | NotGiven = NOT_GIVEN,
433
+ position: int | NotGiven = NOT_GIVEN,
434
+ redirect_http_code: int | NotGiven = NOT_GIVEN,
435
+ redirect_pool_id: str | NotGiven = NOT_GIVEN,
436
+ redirect_prefix: str | NotGiven = NOT_GIVEN,
437
+ redirect_url: str | NotGiven = NOT_GIVEN,
438
+ tags: List[str] | NotGiven = NOT_GIVEN,
439
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
440
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
441
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
442
+ # The extra values given here take precedence over values defined on the client or passed to this method.
443
+ extra_headers: Headers | None = None,
444
+ extra_query: Query | None = None,
445
+ extra_body: Body | None = None,
446
+ ) -> LoadBalancerL7Policy:
447
+ response = self.replace(
448
+ l7policy_id=l7policy_id,
449
+ project_id=project_id,
450
+ region_id=region_id,
451
+ action=action,
452
+ name=name,
453
+ position=position,
454
+ redirect_http_code=redirect_http_code,
455
+ redirect_pool_id=redirect_pool_id,
456
+ redirect_prefix=redirect_prefix,
457
+ redirect_url=redirect_url,
458
+ tags=tags,
459
+ extra_headers=extra_headers,
460
+ extra_query=extra_query,
461
+ extra_body=extra_body,
462
+ timeout=timeout,
463
+ )
464
+ if not response.tasks or len(response.tasks) != 1:
465
+ raise ValueError(f"Expected exactly one task to be created")
466
+ self._client.cloud.tasks.poll(
467
+ task_id=response.tasks[0],
468
+ extra_headers=extra_headers,
469
+ polling_interval_seconds=polling_interval_seconds,
470
+ )
471
+ return self.get(
472
+ l7policy_id=l7policy_id,
473
+ project_id=project_id,
474
+ region_id=region_id,
475
+ extra_headers=extra_headers,
476
+ timeout=timeout,
477
+ )
478
+
338
479
 
339
480
  class AsyncL7PoliciesResource(AsyncAPIResource):
340
481
  @cached_property
@@ -637,6 +778,147 @@ class AsyncL7PoliciesResource(AsyncAPIResource):
637
778
  cast_to=TaskIDList,
638
779
  )
639
780
 
781
+ async def create_and_poll(
782
+ self,
783
+ *,
784
+ project_id: int | None = None,
785
+ region_id: int | None = None,
786
+ action: Literal["REDIRECT_PREFIX", "REDIRECT_TO_POOL", "REDIRECT_TO_URL", "REJECT"],
787
+ listener_id: str,
788
+ name: str | NotGiven = NOT_GIVEN,
789
+ position: int | NotGiven = NOT_GIVEN,
790
+ redirect_http_code: int | NotGiven = NOT_GIVEN,
791
+ redirect_pool_id: str | NotGiven = NOT_GIVEN,
792
+ redirect_prefix: str | NotGiven = NOT_GIVEN,
793
+ redirect_url: str | NotGiven = NOT_GIVEN,
794
+ tags: List[str] | NotGiven = NOT_GIVEN,
795
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
796
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
797
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
798
+ # The extra values given here take precedence over values defined on the client or passed to this method.
799
+ extra_headers: Headers | None = None,
800
+ extra_query: Query | None = None,
801
+ extra_body: Body | None = None,
802
+ ) -> LoadBalancerL7Policy:
803
+ response = await self.create(
804
+ project_id=project_id,
805
+ region_id=region_id,
806
+ action=action,
807
+ listener_id=listener_id,
808
+ name=name,
809
+ position=position,
810
+ redirect_http_code=redirect_http_code,
811
+ redirect_pool_id=redirect_pool_id,
812
+ redirect_prefix=redirect_prefix,
813
+ redirect_url=redirect_url,
814
+ tags=tags,
815
+ extra_headers=extra_headers,
816
+ extra_query=extra_query,
817
+ extra_body=extra_body,
818
+ timeout=timeout,
819
+ )
820
+ if not response.tasks or len(response.tasks) != 1:
821
+ raise ValueError(f"Expected exactly one task to be created")
822
+ task = await self._client.cloud.tasks.poll(
823
+ task_id=response.tasks[0],
824
+ extra_headers=extra_headers,
825
+ polling_interval_seconds=polling_interval_seconds,
826
+ )
827
+ if not task.created_resources or not task.created_resources.l7polices or len(task.created_resources.l7polices) != 1:
828
+ raise ValueError(f"Expected exactly one resource to be created in a task")
829
+ return await self.get(
830
+ l7policy_id=task.created_resources.l7polices[0],
831
+ project_id=project_id,
832
+ region_id=region_id,
833
+ extra_headers=extra_headers,
834
+ timeout=timeout,
835
+ )
836
+
837
+ async def delete_and_poll(
838
+ self,
839
+ l7policy_id: str,
840
+ *,
841
+ project_id: int | None = None,
842
+ region_id: int | None = None,
843
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
844
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
845
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
846
+ # The extra values given here take precedence over values defined on the client or passed to this method.
847
+ extra_headers: Headers | None = None,
848
+ extra_query: Query | None = None,
849
+ extra_body: Body | None = None,
850
+ ) -> None:
851
+ response = await self.delete(
852
+ l7policy_id=l7policy_id,
853
+ project_id=project_id,
854
+ region_id=region_id,
855
+ extra_headers=extra_headers,
856
+ extra_query=extra_query,
857
+ extra_body=extra_body,
858
+ timeout=timeout,
859
+ )
860
+ if not response.tasks or len(response.tasks) != 1:
861
+ raise ValueError(f"Expected exactly one task to be created")
862
+ await self._client.cloud.tasks.poll(
863
+ task_id=response.tasks[0],
864
+ extra_headers=extra_headers,
865
+ polling_interval_seconds=polling_interval_seconds,
866
+ )
867
+
868
+ async def replace_and_poll(
869
+ self,
870
+ l7policy_id: str,
871
+ *,
872
+ project_id: int | None = None,
873
+ region_id: int | None = None,
874
+ action: Literal["REDIRECT_PREFIX", "REDIRECT_TO_POOL", "REDIRECT_TO_URL", "REJECT"],
875
+ name: str | NotGiven = NOT_GIVEN,
876
+ position: int | NotGiven = NOT_GIVEN,
877
+ redirect_http_code: int | NotGiven = NOT_GIVEN,
878
+ redirect_pool_id: str | NotGiven = NOT_GIVEN,
879
+ redirect_prefix: str | NotGiven = NOT_GIVEN,
880
+ redirect_url: str | NotGiven = NOT_GIVEN,
881
+ tags: List[str] | NotGiven = NOT_GIVEN,
882
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
883
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
884
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
885
+ # The extra values given here take precedence over values defined on the client or passed to this method.
886
+ extra_headers: Headers | None = None,
887
+ extra_query: Query | None = None,
888
+ extra_body: Body | None = None,
889
+ ) -> LoadBalancerL7Policy:
890
+ response = await self.replace(
891
+ l7policy_id=l7policy_id,
892
+ project_id=project_id,
893
+ region_id=region_id,
894
+ action=action,
895
+ name=name,
896
+ position=position,
897
+ redirect_http_code=redirect_http_code,
898
+ redirect_pool_id=redirect_pool_id,
899
+ redirect_prefix=redirect_prefix,
900
+ redirect_url=redirect_url,
901
+ tags=tags,
902
+ extra_headers=extra_headers,
903
+ extra_query=extra_query,
904
+ extra_body=extra_body,
905
+ timeout=timeout,
906
+ )
907
+ if not response.tasks or len(response.tasks) != 1:
908
+ raise ValueError(f"Expected exactly one task to be created")
909
+ await self._client.cloud.tasks.poll(
910
+ task_id=response.tasks[0],
911
+ extra_headers=extra_headers,
912
+ polling_interval_seconds=polling_interval_seconds,
913
+ )
914
+ return await self.get(
915
+ l7policy_id=l7policy_id,
916
+ project_id=project_id,
917
+ region_id=region_id,
918
+ extra_headers=extra_headers,
919
+ timeout=timeout,
920
+ )
921
+
640
922
 
641
923
  class L7PoliciesResourceWithRawResponse:
642
924
  def __init__(self, l7_policies: L7PoliciesResource) -> None:
@@ -331,6 +331,169 @@ class RulesResource(SyncAPIResource):
331
331
  cast_to=TaskIDList,
332
332
  )
333
333
 
334
+ def create_and_poll(
335
+ self,
336
+ l7policy_id: str,
337
+ *,
338
+ project_id: int | None = None,
339
+ region_id: int | None = None,
340
+ compare_type: Literal["CONTAINS", "ENDS_WITH", "EQUAL_TO", "REGEX", "STARTS_WITH"],
341
+ type: Literal[
342
+ "COOKIE",
343
+ "FILE_TYPE",
344
+ "HEADER",
345
+ "HOST_NAME",
346
+ "PATH",
347
+ "SSL_CONN_HAS_CERT",
348
+ "SSL_DN_FIELD",
349
+ "SSL_VERIFY_RESULT",
350
+ ],
351
+ value: str,
352
+ invert: bool | NotGiven = NOT_GIVEN,
353
+ key: str | NotGiven = NOT_GIVEN,
354
+ tags: List[str] | NotGiven = NOT_GIVEN,
355
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
356
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
357
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
358
+ # The extra values given here take precedence over values defined on the client or passed to this method.
359
+ extra_headers: Headers | None = None,
360
+ extra_query: Query | None = None,
361
+ extra_body: Body | None = None,
362
+ ) -> LoadBalancerL7Rule:
363
+ response = self.create(
364
+ l7policy_id=l7policy_id,
365
+ project_id=project_id,
366
+ region_id=region_id,
367
+ compare_type=compare_type,
368
+ type=type,
369
+ value=value,
370
+ invert=invert,
371
+ key=key,
372
+ tags=tags,
373
+ extra_headers=extra_headers,
374
+ extra_query=extra_query,
375
+ extra_body=extra_body,
376
+ timeout=timeout,
377
+ )
378
+ if not response.tasks or len(response.tasks) != 1:
379
+ raise ValueError(f"Expected exactly one task to be created")
380
+ task = self._client.cloud.tasks.poll(
381
+ task_id=response.tasks[0],
382
+ extra_headers=extra_headers,
383
+ polling_interval_seconds=polling_interval_seconds,
384
+ )
385
+ if not task.created_resources or not task.created_resources.l7rules or len(task.created_resources.l7rules) != 1:
386
+ raise ValueError(f"Expected exactly one resource to be created in a task")
387
+ return self.get(
388
+ l7rule_id=task.created_resources.l7rules[0],
389
+ project_id=project_id,
390
+ region_id=region_id,
391
+ l7policy_id=l7policy_id,
392
+ extra_headers=extra_headers,
393
+ timeout=timeout,
394
+ )
395
+
396
+ def delete_and_poll(
397
+ self,
398
+ l7rule_id: str,
399
+ *,
400
+ project_id: int | None = None,
401
+ region_id: int | None = None,
402
+ l7policy_id: str,
403
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
404
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
405
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
406
+ # The extra values given here take precedence over values defined on the client or passed to this method.
407
+ extra_headers: Headers | None = None,
408
+ extra_query: Query | None = None,
409
+ extra_body: Body | None = None,
410
+ ) -> None:
411
+ """
412
+ Delete L7 rule and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
413
+ """
414
+ response = self.delete(
415
+ l7rule_id=l7rule_id,
416
+ project_id=project_id,
417
+ region_id=region_id,
418
+ l7policy_id=l7policy_id,
419
+ extra_headers=extra_headers,
420
+ extra_query=extra_query,
421
+ extra_body=extra_body,
422
+ timeout=timeout,
423
+ )
424
+ if not response.tasks:
425
+ raise ValueError("Expected at least one task to be created")
426
+ self._client.cloud.tasks.poll(
427
+ task_id=response.tasks[0],
428
+ extra_headers=extra_headers,
429
+ polling_interval_seconds=polling_interval_seconds,
430
+ )
431
+
432
+ def replace_and_poll(
433
+ self,
434
+ l7rule_id: str,
435
+ *,
436
+ project_id: int | None = None,
437
+ region_id: int | None = None,
438
+ l7policy_id: str,
439
+ compare_type: Literal["CONTAINS", "ENDS_WITH", "EQUAL_TO", "REGEX", "STARTS_WITH"],
440
+ type: Literal[
441
+ "COOKIE",
442
+ "FILE_TYPE",
443
+ "HEADER",
444
+ "HOST_NAME",
445
+ "PATH",
446
+ "SSL_CONN_HAS_CERT",
447
+ "SSL_DN_FIELD",
448
+ "SSL_VERIFY_RESULT",
449
+ ],
450
+ value: str,
451
+ invert: bool | NotGiven = NOT_GIVEN,
452
+ key: str | NotGiven = NOT_GIVEN,
453
+ tags: List[str] | NotGiven = NOT_GIVEN,
454
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
455
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
456
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
457
+ # The extra values given here take precedence over values defined on the client or passed to this method.
458
+ extra_headers: Headers | None = None,
459
+ extra_query: Query | None = None,
460
+ extra_body: Body | None = None,
461
+ ) -> LoadBalancerL7Rule:
462
+ """
463
+ Replace L7 rule and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
464
+ """
465
+ response = self.replace(
466
+ l7rule_id=l7rule_id,
467
+ project_id=project_id,
468
+ region_id=region_id,
469
+ l7policy_id=l7policy_id,
470
+ compare_type=compare_type,
471
+ type=type,
472
+ value=value,
473
+ invert=invert,
474
+ key=key,
475
+ tags=tags,
476
+ extra_headers=extra_headers,
477
+ extra_query=extra_query,
478
+ extra_body=extra_body,
479
+ timeout=timeout,
480
+ )
481
+ if not response.tasks:
482
+ raise ValueError("Expected at least one task to be created")
483
+ self._client.cloud.tasks.poll(
484
+ task_id=response.tasks[0],
485
+ extra_headers=extra_headers,
486
+ polling_interval_seconds=polling_interval_seconds,
487
+ )
488
+ return self.get(
489
+ l7rule_id=l7rule_id,
490
+ project_id=project_id,
491
+ region_id=region_id,
492
+ l7policy_id=l7policy_id,
493
+ extra_headers=extra_headers,
494
+ timeout=timeout,
495
+ )
496
+
334
497
 
335
498
  class AsyncRulesResource(AsyncAPIResource):
336
499
  @cached_property
@@ -637,6 +800,169 @@ class AsyncRulesResource(AsyncAPIResource):
637
800
  cast_to=TaskIDList,
638
801
  )
639
802
 
803
+ async def create_and_poll(
804
+ self,
805
+ l7policy_id: str,
806
+ *,
807
+ project_id: int | None = None,
808
+ region_id: int | None = None,
809
+ compare_type: Literal["CONTAINS", "ENDS_WITH", "EQUAL_TO", "REGEX", "STARTS_WITH"],
810
+ type: Literal[
811
+ "COOKIE",
812
+ "FILE_TYPE",
813
+ "HEADER",
814
+ "HOST_NAME",
815
+ "PATH",
816
+ "SSL_CONN_HAS_CERT",
817
+ "SSL_DN_FIELD",
818
+ "SSL_VERIFY_RESULT",
819
+ ],
820
+ value: str,
821
+ invert: bool | NotGiven = NOT_GIVEN,
822
+ key: str | NotGiven = NOT_GIVEN,
823
+ tags: List[str] | NotGiven = NOT_GIVEN,
824
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
825
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
826
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
827
+ # The extra values given here take precedence over values defined on the client or passed to this method.
828
+ extra_headers: Headers | None = None,
829
+ extra_query: Query | None = None,
830
+ extra_body: Body | None = None,
831
+ ) -> LoadBalancerL7Rule:
832
+ response = await self.create(
833
+ l7policy_id=l7policy_id,
834
+ project_id=project_id,
835
+ region_id=region_id,
836
+ compare_type=compare_type,
837
+ type=type,
838
+ value=value,
839
+ invert=invert,
840
+ key=key,
841
+ tags=tags,
842
+ extra_headers=extra_headers,
843
+ extra_query=extra_query,
844
+ extra_body=extra_body,
845
+ timeout=timeout,
846
+ )
847
+ if not response.tasks or len(response.tasks) != 1:
848
+ raise ValueError(f"Expected exactly one task to be created")
849
+ task = await self._client.cloud.tasks.poll(
850
+ task_id=response.tasks[0],
851
+ extra_headers=extra_headers,
852
+ polling_interval_seconds=polling_interval_seconds,
853
+ )
854
+ if not task.created_resources or not task.created_resources.l7rules or len(task.created_resources.l7rules) != 1:
855
+ raise ValueError(f"Expected exactly one resource to be created in a task")
856
+ return await self.get(
857
+ l7rule_id=task.created_resources.l7rules[0],
858
+ project_id=project_id,
859
+ region_id=region_id,
860
+ l7policy_id=l7policy_id,
861
+ extra_headers=extra_headers,
862
+ timeout=timeout,
863
+ )
864
+
865
+ async def delete_and_poll(
866
+ self,
867
+ l7rule_id: str,
868
+ *,
869
+ project_id: int | None = None,
870
+ region_id: int | None = None,
871
+ l7policy_id: str,
872
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
873
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
874
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
875
+ # The extra values given here take precedence over values defined on the client or passed to this method.
876
+ extra_headers: Headers | None = None,
877
+ extra_query: Query | None = None,
878
+ extra_body: Body | None = None,
879
+ ) -> None:
880
+ """
881
+ Delete L7 rule and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
882
+ """
883
+ response = await self.delete(
884
+ l7rule_id=l7rule_id,
885
+ project_id=project_id,
886
+ region_id=region_id,
887
+ l7policy_id=l7policy_id,
888
+ extra_headers=extra_headers,
889
+ extra_query=extra_query,
890
+ extra_body=extra_body,
891
+ timeout=timeout,
892
+ )
893
+ if not response.tasks:
894
+ raise ValueError("Expected at least one task to be created")
895
+ await self._client.cloud.tasks.poll(
896
+ task_id=response.tasks[0],
897
+ extra_headers=extra_headers,
898
+ polling_interval_seconds=polling_interval_seconds,
899
+ )
900
+
901
+ async def replace_and_poll(
902
+ self,
903
+ l7rule_id: str,
904
+ *,
905
+ project_id: int | None = None,
906
+ region_id: int | None = None,
907
+ l7policy_id: str,
908
+ compare_type: Literal["CONTAINS", "ENDS_WITH", "EQUAL_TO", "REGEX", "STARTS_WITH"],
909
+ type: Literal[
910
+ "COOKIE",
911
+ "FILE_TYPE",
912
+ "HEADER",
913
+ "HOST_NAME",
914
+ "PATH",
915
+ "SSL_CONN_HAS_CERT",
916
+ "SSL_DN_FIELD",
917
+ "SSL_VERIFY_RESULT",
918
+ ],
919
+ value: str,
920
+ invert: bool | NotGiven = NOT_GIVEN,
921
+ key: str | NotGiven = NOT_GIVEN,
922
+ tags: List[str] | NotGiven = NOT_GIVEN,
923
+ polling_interval_seconds: int | NotGiven = NOT_GIVEN,
924
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
925
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
926
+ # The extra values given here take precedence over values defined on the client or passed to this method.
927
+ extra_headers: Headers | None = None,
928
+ extra_query: Query | None = None,
929
+ extra_body: Body | None = None,
930
+ ) -> LoadBalancerL7Rule:
931
+ """
932
+ Replace L7 rule and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
933
+ """
934
+ response = await self.replace(
935
+ l7rule_id=l7rule_id,
936
+ project_id=project_id,
937
+ region_id=region_id,
938
+ l7policy_id=l7policy_id,
939
+ compare_type=compare_type,
940
+ type=type,
941
+ value=value,
942
+ invert=invert,
943
+ key=key,
944
+ tags=tags,
945
+ extra_headers=extra_headers,
946
+ extra_query=extra_query,
947
+ extra_body=extra_body,
948
+ timeout=timeout,
949
+ )
950
+ if not response.tasks:
951
+ raise ValueError("Expected at least one task to be created")
952
+ await self._client.cloud.tasks.poll(
953
+ task_id=response.tasks[0],
954
+ extra_headers=extra_headers,
955
+ polling_interval_seconds=polling_interval_seconds,
956
+ )
957
+ return await self.get(
958
+ l7rule_id=l7rule_id,
959
+ project_id=project_id,
960
+ region_id=region_id,
961
+ l7policy_id=l7policy_id,
962
+ extra_headers=extra_headers,
963
+ timeout=timeout,
964
+ )
965
+
640
966
 
641
967
  class RulesResourceWithRawResponse:
642
968
  def __init__(self, rules: RulesResource) -> None: