gcore 0.16.0__py3-none-any.whl → 0.23.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 (220) hide show
  1. gcore/_client.py +16 -0
  2. gcore/_models.py +37 -15
  3. gcore/_streaming.py +12 -12
  4. gcore/_utils/_sync.py +3 -31
  5. gcore/_utils/_utils.py +1 -1
  6. gcore/_version.py +1 -1
  7. gcore/resources/cdn/audit_log.py +4 -4
  8. gcore/resources/cdn/cdn.py +120 -21
  9. gcore/resources/cdn/ip_ranges.py +97 -5
  10. gcore/resources/cdn/{logs/logs.py → logs.py} +9 -9
  11. gcore/resources/cdn/resources/resources.py +20 -20
  12. gcore/resources/cdn/statistics.py +56 -58
  13. gcore/resources/cloud/__init__.py +40 -12
  14. gcore/resources/cloud/audit_logs.py +20 -0
  15. gcore/resources/cloud/baremetal/servers.py +48 -14
  16. gcore/resources/cloud/billing_reservations.py +2 -2
  17. gcore/resources/cloud/cloud.py +100 -18
  18. gcore/resources/cloud/databases/__init__.py +33 -0
  19. gcore/resources/cloud/databases/databases.py +102 -0
  20. gcore/resources/cloud/databases/postgres/__init__.py +61 -0
  21. gcore/resources/cloud/databases/postgres/clusters/__init__.py +33 -0
  22. gcore/resources/cloud/databases/postgres/clusters/clusters.py +716 -0
  23. gcore/resources/cloud/databases/postgres/clusters/user_credentials.py +281 -0
  24. gcore/resources/cloud/databases/postgres/configurations.py +169 -0
  25. gcore/resources/cloud/databases/postgres/custom_configurations.py +197 -0
  26. gcore/resources/cloud/databases/postgres/postgres.py +166 -0
  27. gcore/resources/cloud/file_shares/file_shares.py +154 -49
  28. gcore/resources/cloud/floating_ips.py +42 -10
  29. gcore/resources/cloud/gpu_baremetal_clusters/gpu_baremetal_clusters.py +70 -10
  30. gcore/resources/cloud/gpu_baremetal_clusters/images.py +40 -6
  31. gcore/resources/cloud/gpu_baremetal_clusters/servers.py +16 -0
  32. gcore/resources/cloud/gpu_virtual_clusters/__init__.py +89 -0
  33. gcore/resources/cloud/gpu_virtual_clusters/flavors.py +211 -0
  34. gcore/resources/cloud/gpu_virtual_clusters/gpu_virtual_clusters.py +1551 -0
  35. gcore/resources/cloud/gpu_virtual_clusters/images.py +582 -0
  36. gcore/resources/cloud/gpu_virtual_clusters/interfaces.py +187 -0
  37. gcore/resources/cloud/gpu_virtual_clusters/servers.py +506 -0
  38. gcore/resources/cloud/gpu_virtual_clusters/volumes.py +187 -0
  39. gcore/resources/cloud/inference/deployments/deployments.py +52 -4
  40. gcore/resources/cloud/instances/images.py +72 -18
  41. gcore/resources/cloud/instances/instances.py +110 -18
  42. gcore/resources/cloud/instances/interfaces.py +12 -0
  43. gcore/resources/cloud/k8s/__init__.py +12 -12
  44. gcore/resources/cloud/k8s/clusters/clusters.py +25 -25
  45. gcore/resources/cloud/k8s/clusters/pools/pools.py +14 -14
  46. gcore/resources/cloud/k8s/k8s.py +24 -24
  47. gcore/resources/cloud/load_balancers/l7_policies/l7_policies.py +1420 -218
  48. gcore/resources/cloud/load_balancers/l7_policies/rules.py +134 -22
  49. gcore/resources/cloud/load_balancers/listeners.py +77 -6
  50. gcore/resources/cloud/load_balancers/load_balancers.py +92 -14
  51. gcore/resources/cloud/load_balancers/pools/pools.py +52 -4
  52. gcore/resources/cloud/networks/networks.py +30 -10
  53. gcore/resources/cloud/networks/subnets.py +26 -10
  54. gcore/resources/cloud/placement_groups.py +8 -0
  55. gcore/resources/cloud/projects.py +99 -119
  56. gcore/resources/cloud/quotas/requests.py +0 -8
  57. gcore/resources/cloud/reserved_fixed_ips/reserved_fixed_ips.py +18 -0
  58. gcore/resources/cloud/secrets.py +16 -0
  59. gcore/resources/cloud/security_groups/security_groups.py +38 -12
  60. gcore/resources/cloud/ssh_keys.py +10 -0
  61. gcore/resources/cloud/tasks.py +22 -7
  62. gcore/resources/cloud/volumes.py +65 -23
  63. gcore/resources/dns/zones/rrsets.py +10 -10
  64. gcore/resources/dns/zones/zones.py +2 -2
  65. gcore/resources/security/bgp_announces.py +0 -4
  66. gcore/resources/security/profiles.py +31 -7
  67. gcore/resources/storage/credentials.py +0 -28
  68. gcore/resources/storage/storage.py +2 -2
  69. gcore/types/cdn/__init__.py +5 -0
  70. gcore/types/cdn/alibaba_regions.py +22 -0
  71. gcore/types/cdn/audit_log_list_params.py +2 -2
  72. gcore/types/cdn/aws_regions.py +22 -0
  73. gcore/types/cdn/cdn_list_purge_statuses_response.py +10 -0
  74. gcore/types/cdn/cdn_resource.py +17 -12
  75. gcore/types/cdn/ip_range_list_ips_params.py +19 -0
  76. gcore/types/cdn/ip_range_list_params.py +19 -0
  77. gcore/types/cdn/resource_create_params.py +17 -12
  78. gcore/types/cdn/resource_purge_params.py +4 -4
  79. gcore/types/cdn/resource_replace_params.py +17 -12
  80. gcore/types/cdn/resource_update_params.py +17 -12
  81. gcore/types/cdn/resource_usage_stats.py +16 -15
  82. gcore/types/cdn/resources/cdn_resource_rule.py +15 -10
  83. gcore/types/cdn/resources/rule_create_params.py +15 -10
  84. gcore/types/cdn/resources/rule_replace_params.py +15 -10
  85. gcore/types/cdn/resources/rule_update_params.py +15 -10
  86. gcore/types/cdn/rule_template.py +15 -10
  87. gcore/types/cdn/rule_template_create_params.py +15 -10
  88. gcore/types/cdn/rule_template_replace_params.py +15 -10
  89. gcore/types/cdn/rule_template_update_params.py +15 -10
  90. gcore/types/cdn/statistic_get_logs_usage_aggregated_params.py +4 -1
  91. gcore/types/cdn/statistic_get_logs_usage_series_params.py +5 -12
  92. gcore/types/cdn/statistic_get_resource_usage_aggregated_params.py +10 -21
  93. gcore/types/cdn/statistic_get_resource_usage_series_params.py +6 -1
  94. gcore/types/cdn/statistic_get_shield_usage_aggregated_params.py +5 -2
  95. gcore/types/cdn/statistic_get_shield_usage_series_params.py +3 -0
  96. gcore/types/cloud/__init__.py +9 -3
  97. gcore/types/cloud/audit_log_entry.py +9 -3
  98. gcore/types/cloud/audit_log_list_params.py +12 -0
  99. gcore/types/cloud/baremetal/server_create_params.py +7 -7
  100. gcore/types/cloud/baremetal_flavor.py +0 -6
  101. gcore/types/cloud/billing_reservation_list_params.py +1 -1
  102. gcore/types/cloud/blackhole_port.py +4 -1
  103. gcore/types/cloud/databases/postgres/__init__.py +12 -0
  104. gcore/types/cloud/databases/postgres/cluster_create_params.py +108 -0
  105. gcore/types/cloud/databases/postgres/cluster_list_params.py +19 -0
  106. gcore/types/cloud/databases/postgres/cluster_update_params.py +102 -0
  107. gcore/types/cloud/databases/postgres/clusters/__init__.py +5 -0
  108. gcore/types/cloud/databases/postgres/clusters/postgres_user_credentials.py +13 -0
  109. gcore/types/cloud/databases/postgres/custom_configuration_validate_params.py +19 -0
  110. gcore/types/cloud/databases/postgres/pg_conf_validation.py +15 -0
  111. gcore/types/cloud/databases/postgres/postgres_cluster.py +118 -0
  112. gcore/types/cloud/databases/postgres/postgres_cluster_short.py +22 -0
  113. gcore/types/cloud/databases/postgres/postgres_configuration.py +31 -0
  114. gcore/types/cloud/file_share_create_params.py +8 -8
  115. gcore/types/cloud/file_share_update_params.py +7 -2
  116. gcore/types/cloud/floating_ip.py +5 -1
  117. gcore/types/cloud/floating_ip_create_params.py +4 -4
  118. gcore/types/cloud/floating_ip_detailed.py +5 -1
  119. gcore/types/cloud/floating_ip_list_params.py +8 -0
  120. gcore/types/cloud/floating_ip_update_params.py +7 -2
  121. gcore/types/cloud/gpu_baremetal_cluster.py +18 -3
  122. gcore/types/cloud/gpu_baremetal_cluster_action_params.py +7 -2
  123. gcore/types/cloud/gpu_baremetal_cluster_create_params.py +16 -4
  124. gcore/types/cloud/gpu_baremetal_clusters/gpu_baremetal_cluster_server.py +5 -2
  125. gcore/types/cloud/gpu_baremetal_clusters/image_upload_params.py +4 -4
  126. gcore/types/cloud/gpu_image.py +9 -0
  127. gcore/types/cloud/gpu_virtual_cluster.py +189 -0
  128. gcore/types/cloud/gpu_virtual_cluster_action_params.py +127 -0
  129. gcore/types/cloud/gpu_virtual_cluster_create_params.py +213 -0
  130. gcore/types/cloud/gpu_virtual_cluster_delete_params.py +41 -0
  131. gcore/types/cloud/gpu_virtual_cluster_list_params.py +21 -0
  132. gcore/types/cloud/gpu_virtual_cluster_update_params.py +18 -0
  133. gcore/types/cloud/gpu_virtual_clusters/__init__.py +16 -0
  134. gcore/types/cloud/gpu_virtual_clusters/flavor_list_params.py +21 -0
  135. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_cluster_server.py +77 -0
  136. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_cluster_server_list.py +16 -0
  137. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_cluster_volume.py +64 -0
  138. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_cluster_volume_list.py +16 -0
  139. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_flavor.py +155 -0
  140. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_flavor_list.py +16 -0
  141. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_interface.py +190 -0
  142. gcore/types/cloud/gpu_virtual_clusters/gpu_virtual_interface_list.py +16 -0
  143. gcore/types/cloud/gpu_virtual_clusters/image_upload_params.py +56 -0
  144. gcore/types/cloud/gpu_virtual_clusters/server_delete_params.py +44 -0
  145. gcore/types/cloud/gpu_virtual_clusters/server_list_params.py +75 -0
  146. gcore/types/cloud/image.py +9 -0
  147. gcore/types/cloud/inference/deployment_create_params.py +1 -1
  148. gcore/types/cloud/inference/deployment_update_params.py +1 -1
  149. gcore/types/cloud/inference/inference_deployment.py +1 -1
  150. gcore/types/cloud/instance_create_params.py +27 -27
  151. gcore/types/cloud/instance_update_params.py +7 -2
  152. gcore/types/cloud/instances/image_create_from_volume_params.py +4 -4
  153. gcore/types/cloud/instances/image_update_params.py +4 -4
  154. gcore/types/cloud/instances/image_upload_params.py +4 -4
  155. gcore/types/cloud/k8s/__init__.py +4 -4
  156. gcore/types/cloud/k8s/cluster_update_params.py +5 -5
  157. gcore/types/cloud/k8s/clusters/__init__.py +2 -2
  158. gcore/types/cloud/k8s/clusters/k8s_cluster_pool.py +2 -2
  159. gcore/types/cloud/k8s/clusters/k8s_cluster_pool_list.py +4 -4
  160. gcore/types/cloud/k8s/k8s_cluster.py +4 -4
  161. gcore/types/cloud/k8s/k8s_cluster_certificate.py +2 -2
  162. gcore/types/cloud/k8s/k8s_cluster_kubeconfig.py +14 -2
  163. gcore/types/cloud/k8s/k8s_cluster_list.py +4 -4
  164. gcore/types/cloud/k8s_cluster_version.py +2 -2
  165. gcore/types/cloud/k8s_cluster_version_list.py +4 -4
  166. gcore/types/cloud/load_balancer_create_params.py +14 -8
  167. gcore/types/cloud/load_balancer_flavor_detail.py +2 -2
  168. gcore/types/cloud/load_balancer_l7_policy.py +29 -16
  169. gcore/types/cloud/load_balancer_l7_policy_list.py +3 -3
  170. gcore/types/cloud/load_balancer_l7_rule.py +14 -23
  171. gcore/types/cloud/load_balancer_l7_rule_list.py +3 -3
  172. gcore/types/cloud/load_balancer_listener_detail.py +2 -2
  173. gcore/types/cloud/load_balancer_update_params.py +7 -2
  174. gcore/types/cloud/load_balancers/__init__.py +1 -0
  175. gcore/types/cloud/load_balancers/l7_policies/rule_create_params.py +5 -10
  176. gcore/types/cloud/load_balancers/l7_policies/rule_replace_params.py +7 -11
  177. gcore/types/cloud/load_balancers/l7_policy_create_params.py +102 -18
  178. gcore/types/cloud/load_balancers/l7_policy_replace_params.py +94 -16
  179. gcore/types/cloud/load_balancers/listener_create_params.py +4 -1
  180. gcore/types/cloud/load_balancers/listener_delete_params.py +18 -0
  181. gcore/types/cloud/load_balancers/listener_update_params.py +4 -1
  182. gcore/types/cloud/load_balancers/pool_create_params.py +1 -1
  183. gcore/types/cloud/network_create_params.py +4 -4
  184. gcore/types/cloud/network_update_params.py +7 -2
  185. gcore/types/cloud/networks/subnet_create_params.py +4 -4
  186. gcore/types/cloud/networks/subnet_update_params.py +7 -2
  187. gcore/types/cloud/project_create_params.py +0 -6
  188. gcore/types/cloud/{project_replace_params.py → project_update_params.py} +2 -2
  189. gcore/types/cloud/quotas/request_create_params.py +0 -3
  190. gcore/types/cloud/region.py +3 -3
  191. gcore/types/cloud/security_group.py +8 -1
  192. gcore/types/cloud/security_group_create_params.py +7 -5
  193. gcore/types/cloud/security_group_list_params.py +6 -4
  194. gcore/types/cloud/security_group_update_params.py +7 -2
  195. gcore/types/cloud/ssh_key_list_params.py +7 -0
  196. gcore/types/cloud/tag.py +2 -2
  197. gcore/types/cloud/task_id_list.py +3 -3
  198. gcore/types/cloud/volume_create_params.py +12 -12
  199. gcore/types/cloud/volume_update_params.py +7 -2
  200. gcore/types/dns/zone_list_params.py +1 -1
  201. gcore/types/iam/api_token_create.py +70 -1
  202. gcore/types/security/bgp_announce_list_params.py +0 -2
  203. gcore/types/security/client_profile.py +1 -0
  204. gcore/types/security/profile_create_params.py +4 -2
  205. gcore/types/security/profile_recreate_params.py +4 -2
  206. gcore/types/security/profile_replace_params.py +4 -2
  207. gcore/types/storage/credential_recreate_params.py +0 -17
  208. gcore/types/storage/storage.py +1 -1
  209. gcore/types/storage/storage_create_params.py +1 -1
  210. gcore/types/streaming/stream.py +3 -2
  211. gcore/types/streaming/video.py +1 -1
  212. gcore/types/waap/domains/custom_rule_create_params.py +1 -1
  213. gcore/types/waap/domains/custom_rule_update_params.py +1 -1
  214. gcore/types/waap/domains/waap_custom_rule.py +1 -1
  215. {gcore-0.16.0.dist-info → gcore-0.23.0.dist-info}/METADATA +14 -14
  216. {gcore-0.16.0.dist-info → gcore-0.23.0.dist-info}/RECORD +219 -168
  217. gcore/resources/cdn/logs/__init__.py +0 -19
  218. /gcore/types/{cdn/logs → cloud/databases}/__init__.py +0 -0
  219. {gcore-0.16.0.dist-info → gcore-0.23.0.dist-info}/WHEEL +0 -0
  220. {gcore-0.16.0.dist-info → gcore-0.23.0.dist-info}/licenses/LICENSE +0 -0
gcore/_client.py CHANGED
@@ -59,6 +59,7 @@ class Gcore(SyncAPIClient):
59
59
  cloud_project_id: int | None
60
60
  cloud_region_id: int | None
61
61
  cloud_polling_interval_seconds: int | None
62
+ cloud_polling_timeout_seconds: int | None
62
63
 
63
64
  def __init__(
64
65
  self,
@@ -67,6 +68,7 @@ class Gcore(SyncAPIClient):
67
68
  cloud_project_id: int | None = None,
68
69
  cloud_region_id: int | None = None,
69
70
  cloud_polling_interval_seconds: int | None = 3,
71
+ cloud_polling_timeout_seconds: int | None = 7200,
70
72
  base_url: str | httpx.URL | None = None,
71
73
  timeout: float | Timeout | None | NotGiven = not_given,
72
74
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -113,6 +115,10 @@ class Gcore(SyncAPIClient):
113
115
  cloud_polling_interval_seconds = 3
114
116
  self.cloud_polling_interval_seconds = cloud_polling_interval_seconds
115
117
 
118
+ if cloud_polling_timeout_seconds is None:
119
+ cloud_polling_timeout_seconds = 7200
120
+ self.cloud_polling_timeout_seconds = cloud_polling_timeout_seconds
121
+
116
122
  if base_url is None:
117
123
  base_url = os.environ.get("GCORE_BASE_URL")
118
124
  if base_url is None:
@@ -168,6 +174,7 @@ class Gcore(SyncAPIClient):
168
174
  cloud_project_id: int | None = None,
169
175
  cloud_region_id: int | None = None,
170
176
  cloud_polling_interval_seconds: int | None = None,
177
+ cloud_polling_timeout_seconds: int | None = None,
171
178
  base_url: str | httpx.URL | None = None,
172
179
  timeout: float | Timeout | None | NotGiven = not_given,
173
180
  http_client: httpx.Client | None = None,
@@ -205,6 +212,7 @@ class Gcore(SyncAPIClient):
205
212
  cloud_project_id=cloud_project_id or self.cloud_project_id,
206
213
  cloud_region_id=cloud_region_id or self.cloud_region_id,
207
214
  cloud_polling_interval_seconds=cloud_polling_interval_seconds or self.cloud_polling_interval_seconds,
215
+ cloud_polling_timeout_seconds=cloud_polling_timeout_seconds or self.cloud_polling_timeout_seconds,
208
216
  base_url=base_url or self.base_url,
209
217
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
210
218
  http_client=http_client,
@@ -288,6 +296,7 @@ class AsyncGcore(AsyncAPIClient):
288
296
  cloud_project_id: int | None
289
297
  cloud_region_id: int | None
290
298
  cloud_polling_interval_seconds: int | None
299
+ cloud_polling_timeout_seconds: int | None
291
300
 
292
301
  def __init__(
293
302
  self,
@@ -296,6 +305,7 @@ class AsyncGcore(AsyncAPIClient):
296
305
  cloud_project_id: int | None = None,
297
306
  cloud_region_id: int | None = None,
298
307
  cloud_polling_interval_seconds: int | None = 3,
308
+ cloud_polling_timeout_seconds: int | None = 7200,
299
309
  base_url: str | httpx.URL | None = None,
300
310
  timeout: float | Timeout | None | NotGiven = not_given,
301
311
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -342,6 +352,10 @@ class AsyncGcore(AsyncAPIClient):
342
352
  cloud_polling_interval_seconds = 3
343
353
  self.cloud_polling_interval_seconds = cloud_polling_interval_seconds
344
354
 
355
+ if cloud_polling_timeout_seconds is None:
356
+ cloud_polling_timeout_seconds = 7200
357
+ self.cloud_polling_timeout_seconds = cloud_polling_timeout_seconds
358
+
345
359
  if base_url is None:
346
360
  base_url = os.environ.get("GCORE_BASE_URL")
347
361
  if base_url is None:
@@ -397,6 +411,7 @@ class AsyncGcore(AsyncAPIClient):
397
411
  cloud_project_id: int | None = None,
398
412
  cloud_region_id: int | None = None,
399
413
  cloud_polling_interval_seconds: int | None = None,
414
+ cloud_polling_timeout_seconds: int | None = None,
400
415
  base_url: str | httpx.URL | None = None,
401
416
  timeout: float | Timeout | None | NotGiven = not_given,
402
417
  http_client: httpx.AsyncClient | None = None,
@@ -434,6 +449,7 @@ class AsyncGcore(AsyncAPIClient):
434
449
  cloud_project_id=cloud_project_id or self.cloud_project_id,
435
450
  cloud_region_id=cloud_region_id or self.cloud_region_id,
436
451
  cloud_polling_interval_seconds=cloud_polling_interval_seconds or self.cloud_polling_interval_seconds,
452
+ cloud_polling_timeout_seconds=cloud_polling_timeout_seconds or self.cloud_polling_timeout_seconds,
437
453
  base_url=base_url or self.base_url,
438
454
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
439
455
  http_client=http_client,
gcore/_models.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import os
4
4
  import inspect
5
+ import weakref
5
6
  from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
6
7
  from datetime import date, datetime
7
8
  from typing_extensions import (
@@ -256,15 +257,16 @@ class BaseModel(pydantic.BaseModel):
256
257
  mode: Literal["json", "python"] | str = "python",
257
258
  include: IncEx | None = None,
258
259
  exclude: IncEx | None = None,
260
+ context: Any | None = None,
259
261
  by_alias: bool | None = None,
260
262
  exclude_unset: bool = False,
261
263
  exclude_defaults: bool = False,
262
264
  exclude_none: bool = False,
265
+ exclude_computed_fields: bool = False,
263
266
  round_trip: bool = False,
264
267
  warnings: bool | Literal["none", "warn", "error"] = True,
265
- context: dict[str, Any] | None = None,
266
- serialize_as_any: bool = False,
267
268
  fallback: Callable[[Any], Any] | None = None,
269
+ serialize_as_any: bool = False,
268
270
  ) -> dict[str, Any]:
269
271
  """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
270
272
 
@@ -272,16 +274,24 @@ class BaseModel(pydantic.BaseModel):
272
274
 
273
275
  Args:
274
276
  mode: The mode in which `to_python` should run.
275
- If mode is 'json', the dictionary will only contain JSON serializable types.
276
- If mode is 'python', the dictionary may contain any Python objects.
277
- include: A list of fields to include in the output.
278
- exclude: A list of fields to exclude from the output.
277
+ If mode is 'json', the output will only contain JSON serializable types.
278
+ If mode is 'python', the output may contain non-JSON-serializable Python objects.
279
+ include: A set of fields to include in the output.
280
+ exclude: A set of fields to exclude from the output.
281
+ context: Additional context to pass to the serializer.
279
282
  by_alias: Whether to use the field's alias in the dictionary key if defined.
280
- exclude_unset: Whether to exclude fields that are unset or None from the output.
281
- exclude_defaults: Whether to exclude fields that are set to their default value from the output.
282
- exclude_none: Whether to exclude fields that have a value of `None` from the output.
283
- round_trip: Whether to enable serialization and deserialization round-trip support.
284
- warnings: Whether to log warnings when invalid fields are encountered.
283
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
284
+ exclude_defaults: Whether to exclude fields that are set to their default value.
285
+ exclude_none: Whether to exclude fields that have a value of `None`.
286
+ exclude_computed_fields: Whether to exclude computed fields.
287
+ While this can be useful for round-tripping, it is usually recommended to use the dedicated
288
+ `round_trip` parameter instead.
289
+ round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
290
+ warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
291
+ "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].
292
+ fallback: A function to call when an unknown value is encountered. If not provided,
293
+ a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
294
+ serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
285
295
 
286
296
  Returns:
287
297
  A dictionary representation of the model.
@@ -298,6 +308,8 @@ class BaseModel(pydantic.BaseModel):
298
308
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
299
309
  if fallback is not None:
300
310
  raise ValueError("fallback is only supported in Pydantic v2")
311
+ if exclude_computed_fields != False:
312
+ raise ValueError("exclude_computed_fields is only supported in Pydantic v2")
301
313
  dumped = super().dict( # pyright: ignore[reportDeprecated]
302
314
  include=include,
303
315
  exclude=exclude,
@@ -314,15 +326,17 @@ class BaseModel(pydantic.BaseModel):
314
326
  self,
315
327
  *,
316
328
  indent: int | None = None,
329
+ ensure_ascii: bool = False,
317
330
  include: IncEx | None = None,
318
331
  exclude: IncEx | None = None,
332
+ context: Any | None = None,
319
333
  by_alias: bool | None = None,
320
334
  exclude_unset: bool = False,
321
335
  exclude_defaults: bool = False,
322
336
  exclude_none: bool = False,
337
+ exclude_computed_fields: bool = False,
323
338
  round_trip: bool = False,
324
339
  warnings: bool | Literal["none", "warn", "error"] = True,
325
- context: dict[str, Any] | None = None,
326
340
  fallback: Callable[[Any], Any] | None = None,
327
341
  serialize_as_any: bool = False,
328
342
  ) -> str:
@@ -354,6 +368,10 @@ class BaseModel(pydantic.BaseModel):
354
368
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
355
369
  if fallback is not None:
356
370
  raise ValueError("fallback is only supported in Pydantic v2")
371
+ if ensure_ascii != False:
372
+ raise ValueError("ensure_ascii is only supported in Pydantic v2")
373
+ if exclude_computed_fields != False:
374
+ raise ValueError("exclude_computed_fields is only supported in Pydantic v2")
357
375
  return super().json( # type: ignore[reportDeprecated]
358
376
  indent=indent,
359
377
  include=include,
@@ -573,6 +591,9 @@ class CachedDiscriminatorType(Protocol):
573
591
  __discriminator__: DiscriminatorDetails
574
592
 
575
593
 
594
+ DISCRIMINATOR_CACHE: weakref.WeakKeyDictionary[type, DiscriminatorDetails] = weakref.WeakKeyDictionary()
595
+
596
+
576
597
  class DiscriminatorDetails:
577
598
  field_name: str
578
599
  """The name of the discriminator field in the variant class, e.g.
@@ -615,8 +636,9 @@ class DiscriminatorDetails:
615
636
 
616
637
 
617
638
  def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None:
618
- if isinstance(union, CachedDiscriminatorType):
619
- return union.__discriminator__
639
+ cached = DISCRIMINATOR_CACHE.get(union)
640
+ if cached is not None:
641
+ return cached
620
642
 
621
643
  discriminator_field_name: str | None = None
622
644
 
@@ -669,7 +691,7 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
669
691
  discriminator_field=discriminator_field_name,
670
692
  discriminator_alias=discriminator_alias,
671
693
  )
672
- cast(CachedDiscriminatorType, union).__discriminator__ = details
694
+ DISCRIMINATOR_CACHE.setdefault(union, details)
673
695
  return details
674
696
 
675
697
 
gcore/_streaming.py CHANGED
@@ -54,12 +54,12 @@ class Stream(Generic[_T]):
54
54
  process_data = self._client._process_response_data
55
55
  iterator = self._iter_events()
56
56
 
57
- for sse in iterator:
58
- yield process_data(data=sse.json(), cast_to=cast_to, response=response)
59
-
60
- # Ensure the entire stream is consumed
61
- for _sse in iterator:
62
- ...
57
+ try:
58
+ for sse in iterator:
59
+ yield process_data(data=sse.json(), cast_to=cast_to, response=response)
60
+ finally:
61
+ # Ensure the response is closed even if the consumer doesn't read all data
62
+ response.close()
63
63
 
64
64
  def __enter__(self) -> Self:
65
65
  return self
@@ -118,12 +118,12 @@ class AsyncStream(Generic[_T]):
118
118
  process_data = self._client._process_response_data
119
119
  iterator = self._iter_events()
120
120
 
121
- async for sse in iterator:
122
- yield process_data(data=sse.json(), cast_to=cast_to, response=response)
123
-
124
- # Ensure the entire stream is consumed
125
- async for _sse in iterator:
126
- ...
121
+ try:
122
+ async for sse in iterator:
123
+ yield process_data(data=sse.json(), cast_to=cast_to, response=response)
124
+ finally:
125
+ # Ensure the response is closed even if the consumer doesn't read all data
126
+ await response.aclose()
127
127
 
128
128
  async def __aenter__(self) -> Self:
129
129
  return self
gcore/_utils/_sync.py CHANGED
@@ -1,10 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
- import sys
4
3
  import asyncio
5
4
  import functools
6
- import contextvars
7
- from typing import Any, TypeVar, Callable, Awaitable
5
+ from typing import TypeVar, Callable, Awaitable
8
6
  from typing_extensions import ParamSpec
9
7
 
10
8
  import anyio
@@ -15,34 +13,11 @@ T_Retval = TypeVar("T_Retval")
15
13
  T_ParamSpec = ParamSpec("T_ParamSpec")
16
14
 
17
15
 
18
- if sys.version_info >= (3, 9):
19
- _asyncio_to_thread = asyncio.to_thread
20
- else:
21
- # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
22
- # for Python 3.8 support
23
- async def _asyncio_to_thread(
24
- func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
25
- ) -> Any:
26
- """Asynchronously run function *func* in a separate thread.
27
-
28
- Any *args and **kwargs supplied for this function are directly passed
29
- to *func*. Also, the current :class:`contextvars.Context` is propagated,
30
- allowing context variables from the main thread to be accessed in the
31
- separate thread.
32
-
33
- Returns a coroutine that can be awaited to get the eventual result of *func*.
34
- """
35
- loop = asyncio.events.get_running_loop()
36
- ctx = contextvars.copy_context()
37
- func_call = functools.partial(ctx.run, func, *args, **kwargs)
38
- return await loop.run_in_executor(None, func_call)
39
-
40
-
41
16
  async def to_thread(
42
17
  func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
43
18
  ) -> T_Retval:
44
19
  if sniffio.current_async_library() == "asyncio":
45
- return await _asyncio_to_thread(func, *args, **kwargs)
20
+ return await asyncio.to_thread(func, *args, **kwargs)
46
21
 
47
22
  return await anyio.to_thread.run_sync(
48
23
  functools.partial(func, *args, **kwargs),
@@ -53,10 +28,7 @@ async def to_thread(
53
28
  def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
54
29
  """
55
30
  Take a blocking function and create an async one that receives the same
56
- positional and keyword arguments. For python version 3.9 and above, it uses
57
- asyncio.to_thread to run the function in a separate thread. For python version
58
- 3.8, it uses locally defined copy of the asyncio.to_thread function which was
59
- introduced in python 3.9.
31
+ positional and keyword arguments.
60
32
 
61
33
  Usage:
62
34
 
gcore/_utils/_utils.py CHANGED
@@ -133,7 +133,7 @@ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
133
133
  # Type safe methods for narrowing types with TypeVars.
134
134
  # The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
135
135
  # however this cause Pyright to rightfully report errors. As we know we don't
136
- # care about the contained types we can safely use `object` in it's place.
136
+ # care about the contained types we can safely use `object` in its place.
137
137
  #
138
138
  # There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
139
139
  # `is_*` is for when you're dealing with an unknown input
gcore/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "gcore"
4
- __version__ = "0.16.0" # x-release-please-version
4
+ __version__ = "0.23.0" # x-release-please-version
@@ -99,9 +99,9 @@ class AuditLogResource(SyncAPIResource):
99
99
 
100
100
  offset: Offset relative to the beginning of activity logs.
101
101
 
102
- path: Path that a requested URL should contain.
102
+ path: Exact URL path.
103
103
 
104
- remote_ip_address: IP address or part of it from which requests are sent.
104
+ remote_ip_address: Exact IP address from which requests are sent.
105
105
 
106
106
  status_code: Status code returned in the response.
107
107
 
@@ -263,9 +263,9 @@ class AsyncAuditLogResource(AsyncAPIResource):
263
263
 
264
264
  offset: Offset relative to the beginning of activity logs.
265
265
 
266
- path: Path that a requested URL should contain.
266
+ path: Exact URL path.
267
267
 
268
- remote_ip_address: IP address or part of it from which requests are sent.
268
+ remote_ip_address: Exact IP address from which requests are sent.
269
269
 
270
270
  status_code: Status code returned in the response.
271
271
 
@@ -4,6 +4,14 @@ from __future__ import annotations
4
4
 
5
5
  import httpx
6
6
 
7
+ from .logs import (
8
+ LogsResource,
9
+ AsyncLogsResource,
10
+ LogsResourceWithRawResponse,
11
+ AsyncLogsResourceWithRawResponse,
12
+ LogsResourceWithStreamingResponse,
13
+ AsyncLogsResourceWithStreamingResponse,
14
+ )
7
15
  from .metrics import (
8
16
  MetricsResource,
9
17
  AsyncMetricsResource,
@@ -39,14 +47,6 @@ from .ip_ranges import (
39
47
  IPRangesResourceWithStreamingResponse,
40
48
  AsyncIPRangesResourceWithStreamingResponse,
41
49
  )
42
- from .logs.logs import (
43
- LogsResource,
44
- AsyncLogsResource,
45
- LogsResourceWithRawResponse,
46
- AsyncLogsResourceWithRawResponse,
47
- LogsResourceWithStreamingResponse,
48
- AsyncLogsResourceWithStreamingResponse,
49
- )
50
50
  from .statistics import (
51
51
  StatisticsResource,
52
52
  AsyncStatisticsResource,
@@ -63,7 +63,6 @@ from ..._response import (
63
63
  async_to_streamed_response_wrapper,
64
64
  )
65
65
  from ...types.cdn import cdn_update_account_params, cdn_list_purge_statuses_params
66
- from ...pagination import SyncOffsetPageCdn, AsyncOffsetPageCdn
67
66
  from .certificates import (
68
67
  CertificatesResource,
69
68
  AsyncCertificatesResource,
@@ -80,7 +79,7 @@ from .origin_groups import (
80
79
  OriginGroupsResourceWithStreamingResponse,
81
80
  AsyncOriginGroupsResourceWithStreamingResponse,
82
81
  )
83
- from ..._base_client import AsyncPaginator, make_request_options
82
+ from ..._base_client import make_request_options
84
83
  from .rule_templates import (
85
84
  RuleTemplatesResource,
86
85
  AsyncRuleTemplatesResource,
@@ -105,6 +104,7 @@ from .resources.resources import (
105
104
  ResourcesResourceWithStreamingResponse,
106
105
  AsyncResourcesResourceWithStreamingResponse,
107
106
  )
107
+ from ...types.cdn.aws_regions import AwsRegions
108
108
  from ...types.cdn.cdn_account import CdnAccount
109
109
  from .trusted_ca_certificates import (
110
110
  TrustedCaCertificatesResource,
@@ -114,7 +114,7 @@ from .trusted_ca_certificates import (
114
114
  TrustedCaCertificatesResourceWithStreamingResponse,
115
115
  AsyncTrustedCaCertificatesResourceWithStreamingResponse,
116
116
  )
117
- from ...types.cdn.purge_status import PurgeStatus
117
+ from ...types.cdn.alibaba_regions import AlibabaRegions
118
118
  from .logs_uploader.logs_uploader import (
119
119
  LogsUploaderResource,
120
120
  AsyncLogsUploaderResource,
@@ -125,6 +125,7 @@ from .logs_uploader.logs_uploader import (
125
125
  )
126
126
  from ...types.cdn.cdn_account_limits import CdnAccountLimits
127
127
  from ...types.cdn.cdn_available_features import CdnAvailableFeatures
128
+ from ...types.cdn.cdn_list_purge_statuses_response import CdnListPurgeStatusesResponse
128
129
 
129
130
  __all__ = ["CdnResource", "AsyncCdnResource"]
130
131
 
@@ -258,6 +259,44 @@ class CdnResource(SyncAPIResource):
258
259
  cast_to=CdnAvailableFeatures,
259
260
  )
260
261
 
262
+ def list_alibaba_regions(
263
+ self,
264
+ *,
265
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
266
+ # The extra values given here take precedence over values defined on the client or passed to this method.
267
+ extra_headers: Headers | None = None,
268
+ extra_query: Query | None = None,
269
+ extra_body: Body | None = None,
270
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
271
+ ) -> AlibabaRegions:
272
+ """Get the list of Alibaba Cloud regions."""
273
+ return self._get(
274
+ "/cdn/alibaba_regions",
275
+ options=make_request_options(
276
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
277
+ ),
278
+ cast_to=AlibabaRegions,
279
+ )
280
+
281
+ def list_aws_regions(
282
+ self,
283
+ *,
284
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
285
+ # The extra values given here take precedence over values defined on the client or passed to this method.
286
+ extra_headers: Headers | None = None,
287
+ extra_query: Query | None = None,
288
+ extra_body: Body | None = None,
289
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
290
+ ) -> AwsRegions:
291
+ """Get the list of Amazon AWS regions."""
292
+ return self._get(
293
+ "/cdn/aws_regions",
294
+ options=make_request_options(
295
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
296
+ ),
297
+ cast_to=AwsRegions,
298
+ )
299
+
261
300
  def list_purge_statuses(
262
301
  self,
263
302
  *,
@@ -274,7 +313,7 @@ class CdnResource(SyncAPIResource):
274
313
  extra_query: Query | None = None,
275
314
  extra_body: Body | None = None,
276
315
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
277
- ) -> SyncOffsetPageCdn[PurgeStatus]:
316
+ ) -> CdnListPurgeStatusesResponse:
278
317
  """
279
318
  Get purges history.
280
319
 
@@ -330,9 +369,8 @@ class CdnResource(SyncAPIResource):
330
369
 
331
370
  timeout: Override the client-level default timeout for this request, in seconds
332
371
  """
333
- return self._get_api_list(
372
+ return self._get(
334
373
  "/cdn/purge_statuses",
335
- page=SyncOffsetPageCdn[PurgeStatus],
336
374
  options=make_request_options(
337
375
  extra_headers=extra_headers,
338
376
  extra_query=extra_query,
@@ -351,7 +389,7 @@ class CdnResource(SyncAPIResource):
351
389
  cdn_list_purge_statuses_params.CdnListPurgeStatusesParams,
352
390
  ),
353
391
  ),
354
- model=PurgeStatus,
392
+ cast_to=CdnListPurgeStatusesResponse,
355
393
  )
356
394
 
357
395
  def update_account(
@@ -522,7 +560,45 @@ class AsyncCdnResource(AsyncAPIResource):
522
560
  cast_to=CdnAvailableFeatures,
523
561
  )
524
562
 
525
- def list_purge_statuses(
563
+ async def list_alibaba_regions(
564
+ self,
565
+ *,
566
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
567
+ # The extra values given here take precedence over values defined on the client or passed to this method.
568
+ extra_headers: Headers | None = None,
569
+ extra_query: Query | None = None,
570
+ extra_body: Body | None = None,
571
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
572
+ ) -> AlibabaRegions:
573
+ """Get the list of Alibaba Cloud regions."""
574
+ return await self._get(
575
+ "/cdn/alibaba_regions",
576
+ options=make_request_options(
577
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
578
+ ),
579
+ cast_to=AlibabaRegions,
580
+ )
581
+
582
+ async def list_aws_regions(
583
+ self,
584
+ *,
585
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
586
+ # The extra values given here take precedence over values defined on the client or passed to this method.
587
+ extra_headers: Headers | None = None,
588
+ extra_query: Query | None = None,
589
+ extra_body: Body | None = None,
590
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
591
+ ) -> AwsRegions:
592
+ """Get the list of Amazon AWS regions."""
593
+ return await self._get(
594
+ "/cdn/aws_regions",
595
+ options=make_request_options(
596
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
597
+ ),
598
+ cast_to=AwsRegions,
599
+ )
600
+
601
+ async def list_purge_statuses(
526
602
  self,
527
603
  *,
528
604
  cname: str | Omit = omit,
@@ -538,7 +614,7 @@ class AsyncCdnResource(AsyncAPIResource):
538
614
  extra_query: Query | None = None,
539
615
  extra_body: Body | None = None,
540
616
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
541
- ) -> AsyncPaginator[PurgeStatus, AsyncOffsetPageCdn[PurgeStatus]]:
617
+ ) -> CdnListPurgeStatusesResponse:
542
618
  """
543
619
  Get purges history.
544
620
 
@@ -594,15 +670,14 @@ class AsyncCdnResource(AsyncAPIResource):
594
670
 
595
671
  timeout: Override the client-level default timeout for this request, in seconds
596
672
  """
597
- return self._get_api_list(
673
+ return await self._get(
598
674
  "/cdn/purge_statuses",
599
- page=AsyncOffsetPageCdn[PurgeStatus],
600
675
  options=make_request_options(
601
676
  extra_headers=extra_headers,
602
677
  extra_query=extra_query,
603
678
  extra_body=extra_body,
604
679
  timeout=timeout,
605
- query=maybe_transform(
680
+ query=await async_maybe_transform(
606
681
  {
607
682
  "cname": cname,
608
683
  "from_created": from_created,
@@ -615,7 +690,7 @@ class AsyncCdnResource(AsyncAPIResource):
615
690
  cdn_list_purge_statuses_params.CdnListPurgeStatusesParams,
616
691
  ),
617
692
  ),
618
- model=PurgeStatus,
693
+ cast_to=CdnListPurgeStatusesResponse,
619
694
  )
620
695
 
621
696
  async def update_account(
@@ -670,6 +745,12 @@ class CdnResourceWithRawResponse:
670
745
  self.get_available_features = to_raw_response_wrapper(
671
746
  cdn.get_available_features,
672
747
  )
748
+ self.list_alibaba_regions = to_raw_response_wrapper(
749
+ cdn.list_alibaba_regions,
750
+ )
751
+ self.list_aws_regions = to_raw_response_wrapper(
752
+ cdn.list_aws_regions,
753
+ )
673
754
  self.list_purge_statuses = to_raw_response_wrapper(
674
755
  cdn.list_purge_statuses,
675
756
  )
@@ -743,6 +824,12 @@ class AsyncCdnResourceWithRawResponse:
743
824
  self.get_available_features = async_to_raw_response_wrapper(
744
825
  cdn.get_available_features,
745
826
  )
827
+ self.list_alibaba_regions = async_to_raw_response_wrapper(
828
+ cdn.list_alibaba_regions,
829
+ )
830
+ self.list_aws_regions = async_to_raw_response_wrapper(
831
+ cdn.list_aws_regions,
832
+ )
746
833
  self.list_purge_statuses = async_to_raw_response_wrapper(
747
834
  cdn.list_purge_statuses,
748
835
  )
@@ -816,6 +903,12 @@ class CdnResourceWithStreamingResponse:
816
903
  self.get_available_features = to_streamed_response_wrapper(
817
904
  cdn.get_available_features,
818
905
  )
906
+ self.list_alibaba_regions = to_streamed_response_wrapper(
907
+ cdn.list_alibaba_regions,
908
+ )
909
+ self.list_aws_regions = to_streamed_response_wrapper(
910
+ cdn.list_aws_regions,
911
+ )
819
912
  self.list_purge_statuses = to_streamed_response_wrapper(
820
913
  cdn.list_purge_statuses,
821
914
  )
@@ -889,6 +982,12 @@ class AsyncCdnResourceWithStreamingResponse:
889
982
  self.get_available_features = async_to_streamed_response_wrapper(
890
983
  cdn.get_available_features,
891
984
  )
985
+ self.list_alibaba_regions = async_to_streamed_response_wrapper(
986
+ cdn.list_alibaba_regions,
987
+ )
988
+ self.list_aws_regions = async_to_streamed_response_wrapper(
989
+ cdn.list_aws_regions,
990
+ )
892
991
  self.list_purge_statuses = async_to_streamed_response_wrapper(
893
992
  cdn.list_purge_statuses,
894
993
  )