gcore 0.13.0__py3-none-any.whl → 0.14.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 (334) hide show
  1. gcore/__init__.py +3 -1
  2. gcore/_base_client.py +9 -9
  3. gcore/_client.py +25 -10
  4. gcore/_models.py +10 -4
  5. gcore/_qs.py +7 -7
  6. gcore/_types.py +18 -11
  7. gcore/_utils/_transform.py +2 -2
  8. gcore/_utils/_utils.py +4 -4
  9. gcore/_version.py +1 -1
  10. gcore/pagination.py +137 -0
  11. gcore/resources/__init__.py +14 -0
  12. gcore/resources/cdn/__init__.py +201 -0
  13. gcore/resources/cdn/audit_log.py +406 -0
  14. gcore/resources/cdn/cdn.py +957 -0
  15. gcore/resources/cdn/certificates.py +1062 -0
  16. gcore/resources/cdn/ip_ranges.py +224 -0
  17. gcore/resources/cdn/logs/__init__.py +33 -0
  18. gcore/resources/cdn/logs/logs.py +1424 -0
  19. gcore/resources/cdn/logs/settings.py +1081 -0
  20. gcore/resources/cdn/logs_uploader/__init__.py +61 -0
  21. gcore/resources/cdn/logs_uploader/configs.py +868 -0
  22. gcore/resources/cdn/logs_uploader/logs_uploader.py +166 -0
  23. gcore/resources/cdn/logs_uploader/policies.py +1060 -0
  24. gcore/resources/cdn/logs_uploader/targets.py +811 -0
  25. gcore/resources/cdn/metrics.py +419 -0
  26. gcore/resources/cdn/network_capacity.py +139 -0
  27. gcore/resources/cdn/origin_groups.py +1496 -0
  28. gcore/resources/cdn/resources/__init__.py +47 -0
  29. gcore/resources/cdn/resources/resources.py +2060 -0
  30. gcore/resources/cdn/resources/rules.py +1027 -0
  31. gcore/resources/cdn/resources/shield.py +259 -0
  32. gcore/resources/cdn/rule_templates.py +883 -0
  33. gcore/resources/cdn/shields.py +139 -0
  34. gcore/resources/cdn/statistics.py +1408 -0
  35. gcore/resources/cdn/trusted_ca_certificates.py +592 -0
  36. gcore/resources/cloud/audit_logs.py +33 -29
  37. gcore/resources/cloud/baremetal/flavors.py +21 -17
  38. gcore/resources/cloud/baremetal/images.py +19 -15
  39. gcore/resources/cloud/baremetal/servers.py +141 -119
  40. gcore/resources/cloud/billing_reservations.py +41 -33
  41. gcore/resources/cloud/cloud.py +24 -0
  42. gcore/resources/cloud/cost_reports.py +149 -119
  43. gcore/resources/cloud/file_shares/access_rules.py +25 -13
  44. gcore/resources/cloud/file_shares/file_shares.py +107 -71
  45. gcore/resources/cloud/floating_ips.py +101 -59
  46. gcore/resources/cloud/gpu_baremetal_clusters/flavors.py +13 -9
  47. gcore/resources/cloud/gpu_baremetal_clusters/gpu_baremetal_clusters.py +275 -65
  48. gcore/resources/cloud/gpu_baremetal_clusters/images.py +69 -53
  49. gcore/resources/cloud/gpu_baremetal_clusters/interfaces.py +9 -5
  50. gcore/resources/cloud/gpu_baremetal_clusters/servers.py +151 -127
  51. gcore/resources/cloud/inference/api_keys.py +51 -31
  52. gcore/resources/cloud/inference/applications/deployments.py +49 -31
  53. gcore/resources/cloud/inference/applications/templates.py +17 -9
  54. gcore/resources/cloud/inference/deployments/deployments.py +171 -139
  55. gcore/resources/cloud/inference/deployments/logs.py +17 -13
  56. gcore/resources/cloud/inference/flavors.py +21 -13
  57. gcore/resources/cloud/inference/inference.py +9 -5
  58. gcore/resources/cloud/inference/registry_credentials.py +45 -25
  59. gcore/resources/cloud/inference/secrets.py +45 -25
  60. gcore/resources/cloud/instances/flavors.py +17 -13
  61. gcore/resources/cloud/instances/images.py +153 -129
  62. gcore/resources/cloud/instances/instances.py +287 -213
  63. gcore/resources/cloud/instances/interfaces.py +165 -161
  64. gcore/resources/cloud/instances/metrics.py +9 -5
  65. gcore/resources/cloud/ip_ranges.py +25 -15
  66. gcore/resources/cloud/k8s/clusters/clusters.py +151 -87
  67. gcore/resources/cloud/k8s/clusters/nodes.py +19 -11
  68. gcore/resources/cloud/k8s/clusters/pools/nodes.py +19 -11
  69. gcore/resources/cloud/k8s/clusters/pools/pools.py +83 -59
  70. gcore/resources/cloud/k8s/flavors.py +13 -9
  71. gcore/resources/cloud/k8s/k8s.py +9 -5
  72. gcore/resources/cloud/load_balancers/flavors.py +11 -7
  73. gcore/resources/cloud/load_balancers/l7_policies/l7_policies.py +103 -83
  74. gcore/resources/cloud/load_balancers/l7_policies/rules.py +77 -57
  75. gcore/resources/cloud/load_balancers/listeners.py +125 -105
  76. gcore/resources/cloud/load_balancers/load_balancers.py +155 -123
  77. gcore/resources/cloud/load_balancers/metrics.py +9 -5
  78. gcore/resources/cloud/load_balancers/pools/health_monitors.py +25 -17
  79. gcore/resources/cloud/load_balancers/pools/members.py +31 -23
  80. gcore/resources/cloud/load_balancers/pools/pools.py +155 -129
  81. gcore/resources/cloud/load_balancers/statuses.py +17 -9
  82. gcore/resources/cloud/networks/networks.py +79 -55
  83. gcore/resources/cloud/networks/routers.py +75 -47
  84. gcore/resources/cloud/networks/subnets.py +105 -81
  85. gcore/resources/cloud/placement_groups.py +33 -17
  86. gcore/resources/cloud/projects.py +53 -41
  87. gcore/resources/cloud/quotas/quotas.py +25 -13
  88. gcore/resources/cloud/quotas/requests.py +41 -25
  89. gcore/resources/cloud/regions.py +25 -23
  90. gcore/resources/cloud/registries/artifacts.py +17 -9
  91. gcore/resources/cloud/registries/registries.py +55 -29
  92. gcore/resources/cloud/registries/repositories.py +17 -9
  93. gcore/resources/cloud/registries/tags.py +9 -5
  94. gcore/resources/cloud/registries/users.py +65 -35
  95. gcore/resources/cloud/reserved_fixed_ips/reserved_fixed_ips.py +123 -107
  96. gcore/resources/cloud/reserved_fixed_ips/vip.py +45 -25
  97. gcore/resources/cloud/secrets.py +43 -27
  98. gcore/resources/cloud/security_groups/rules.py +55 -43
  99. gcore/resources/cloud/security_groups/security_groups.py +79 -47
  100. gcore/resources/cloud/ssh_keys.py +51 -31
  101. gcore/resources/cloud/tasks.py +57 -45
  102. gcore/resources/cloud/usage_reports.py +27 -23
  103. gcore/resources/cloud/users/role_assignments.py +49 -33
  104. gcore/resources/cloud/volumes.py +237 -201
  105. gcore/resources/dns/dns.py +17 -13
  106. gcore/resources/dns/locations.py +29 -17
  107. gcore/resources/dns/metrics.py +13 -9
  108. gcore/resources/dns/pickers/pickers.py +5 -5
  109. gcore/resources/dns/pickers/presets.py +9 -5
  110. gcore/resources/dns/zones/dnssec.py +19 -11
  111. gcore/resources/dns/zones/rrsets.py +149 -91
  112. gcore/resources/dns/zones/zones.py +245 -187
  113. gcore/resources/fastedge/apps/apps.py +105 -89
  114. gcore/resources/fastedge/apps/logs.py +25 -21
  115. gcore/resources/fastedge/binaries.py +33 -17
  116. gcore/resources/fastedge/fastedge.py +5 -5
  117. gcore/resources/fastedge/kv_stores.py +43 -31
  118. gcore/resources/fastedge/secrets.py +69 -45
  119. gcore/resources/fastedge/statistics.py +25 -17
  120. gcore/resources/fastedge/templates.py +59 -39
  121. gcore/resources/iam/api_tokens.py +43 -27
  122. gcore/resources/iam/iam.py +5 -5
  123. gcore/resources/iam/users.py +97 -65
  124. gcore/resources/security/bgp_announces.py +27 -19
  125. gcore/resources/security/events.py +23 -19
  126. gcore/resources/security/profile_templates.py +9 -5
  127. gcore/resources/security/profiles.py +69 -45
  128. gcore/resources/storage/buckets/buckets.py +37 -25
  129. gcore/resources/storage/buckets/cors.py +19 -11
  130. gcore/resources/storage/buckets/lifecycle.py +19 -11
  131. gcore/resources/storage/buckets/policy.py +25 -13
  132. gcore/resources/storage/credentials.py +19 -15
  133. gcore/resources/storage/locations.py +13 -9
  134. gcore/resources/storage/statistics.py +39 -31
  135. gcore/resources/storage/storage.py +105 -69
  136. gcore/resources/streaming/ai_tasks.py +307 -197
  137. gcore/resources/streaming/broadcasts.py +63 -35
  138. gcore/resources/streaming/directories.py +65 -39
  139. gcore/resources/streaming/players.py +47 -31
  140. gcore/resources/streaming/playlists.py +189 -123
  141. gcore/resources/streaming/quality_sets.py +69 -39
  142. gcore/resources/streaming/restreams.py +47 -27
  143. gcore/resources/streaming/statistics.py +613 -407
  144. gcore/resources/streaming/streams/overlays.py +107 -67
  145. gcore/resources/streaming/streams/streams.py +403 -263
  146. gcore/resources/streaming/videos/subtitles.py +131 -75
  147. gcore/resources/streaming/videos/videos.py +429 -279
  148. gcore/resources/waap/advanced_rules.py +9 -5
  149. gcore/resources/waap/custom_page_sets.py +99 -75
  150. gcore/resources/waap/domains/advanced_rules.py +157 -99
  151. gcore/resources/waap/domains/api_discovery.py +71 -47
  152. gcore/resources/waap/domains/api_path_groups.py +9 -5
  153. gcore/resources/waap/domains/api_paths.py +79 -83
  154. gcore/resources/waap/domains/custom_rules.py +89 -59
  155. gcore/resources/waap/domains/domains.py +59 -41
  156. gcore/resources/waap/domains/firewall_rules.py +83 -55
  157. gcore/resources/waap/domains/insight_silences.py +59 -39
  158. gcore/resources/waap/domains/insights.py +39 -27
  159. gcore/resources/waap/domains/settings.py +21 -13
  160. gcore/resources/waap/domains/statistics.py +99 -75
  161. gcore/resources/waap/insights.py +23 -21
  162. gcore/resources/waap/ip_info/ip_info.py +65 -33
  163. gcore/resources/waap/ip_info/metrics.py +11 -7
  164. gcore/resources/waap/organizations.py +17 -13
  165. gcore/resources/waap/statistics.py +9 -5
  166. gcore/resources/waap/tags.py +17 -17
  167. gcore/resources/waap/waap.py +5 -5
  168. gcore/types/cdn/__init__.py +80 -0
  169. gcore/types/cdn/audit_log_list_params.py +73 -0
  170. gcore/types/cdn/ca_certificate.py +53 -0
  171. gcore/types/cdn/ca_certificate_list.py +10 -0
  172. gcore/types/cdn/cdn_account.py +86 -0
  173. gcore/types/cdn/cdn_account_limits.py +27 -0
  174. gcore/types/cdn/cdn_audit_log_entry.py +66 -0
  175. gcore/types/cdn/cdn_available_features.py +46 -0
  176. gcore/types/cdn/cdn_list_purge_statuses_params.py +67 -0
  177. gcore/types/cdn/cdn_log_entry.py +70 -0
  178. gcore/types/cdn/cdn_metrics.py +22 -0
  179. gcore/types/cdn/cdn_metrics_groups.py +13 -0
  180. gcore/types/cdn/cdn_metrics_values.py +19 -0
  181. gcore/types/cdn/cdn_resource.py +1977 -0
  182. gcore/types/cdn/cdn_resource_list.py +10 -0
  183. gcore/types/cdn/cdn_update_account_params.py +15 -0
  184. gcore/types/cdn/certificate_create_params.py +51 -0
  185. gcore/types/cdn/certificate_get_status_params.py +14 -0
  186. gcore/types/cdn/certificate_list_params.py +29 -0
  187. gcore/types/cdn/certificate_replace_params.py +39 -0
  188. gcore/types/cdn/log_download_params.py +279 -0
  189. gcore/types/cdn/log_list_params.py +273 -0
  190. gcore/types/cdn/logs/__init__.py +7 -0
  191. gcore/types/cdn/logs/log_settings.py +172 -0
  192. gcore/types/cdn/logs/setting_create_params.py +200 -0
  193. gcore/types/cdn/logs/setting_update_params.py +200 -0
  194. gcore/types/cdn/logs_aggregated_stats.py +23 -0
  195. gcore/types/cdn/logs_uploader/__init__.py +23 -0
  196. gcore/types/cdn/logs_uploader/config_create_params.py +32 -0
  197. gcore/types/cdn/logs_uploader/config_list_params.py +16 -0
  198. gcore/types/cdn/logs_uploader/config_replace_params.py +32 -0
  199. gcore/types/cdn/logs_uploader/config_update_params.py +32 -0
  200. gcore/types/cdn/logs_uploader/logs_uploader_config.py +51 -0
  201. gcore/types/cdn/logs_uploader/logs_uploader_config_list.py +10 -0
  202. gcore/types/cdn/logs_uploader/logs_uploader_policy.py +73 -0
  203. gcore/types/cdn/logs_uploader/logs_uploader_policy_list.py +10 -0
  204. gcore/types/cdn/logs_uploader/logs_uploader_target.py +236 -0
  205. gcore/types/cdn/logs_uploader/logs_uploader_target_list.py +10 -0
  206. gcore/types/cdn/logs_uploader/policy_create_params.py +61 -0
  207. gcore/types/cdn/logs_uploader/policy_list_fields_response.py +8 -0
  208. gcore/types/cdn/logs_uploader/policy_list_params.py +16 -0
  209. gcore/types/cdn/logs_uploader/policy_replace_params.py +61 -0
  210. gcore/types/cdn/logs_uploader/policy_update_params.py +61 -0
  211. gcore/types/cdn/logs_uploader/target_create_params.py +249 -0
  212. gcore/types/cdn/logs_uploader/target_list_params.py +16 -0
  213. gcore/types/cdn/logs_uploader/target_replace_params.py +249 -0
  214. gcore/types/cdn/logs_uploader/target_update_params.py +249 -0
  215. gcore/types/cdn/logs_uploader_validation.py +23 -0
  216. gcore/types/cdn/metric_list_params.py +168 -0
  217. gcore/types/cdn/network_capacity.py +22 -0
  218. gcore/types/cdn/origin_group_create_params.py +184 -0
  219. gcore/types/cdn/origin_group_list_params.py +24 -0
  220. gcore/types/cdn/origin_group_replace_params.py +190 -0
  221. gcore/types/cdn/origin_group_update_params.py +190 -0
  222. gcore/types/cdn/origin_groups.py +212 -0
  223. gcore/types/cdn/origin_groups_list.py +10 -0
  224. gcore/types/cdn/public_ip_list.py +15 -0
  225. gcore/types/cdn/public_network_list.py +15 -0
  226. gcore/types/cdn/purge_status.py +55 -0
  227. gcore/types/cdn/resource_aggregated_stats.py +80 -0
  228. gcore/types/cdn/resource_create_params.py +1825 -0
  229. gcore/types/cdn/resource_list_params.py +107 -0
  230. gcore/types/cdn/resource_prefetch_params.py +17 -0
  231. gcore/types/cdn/resource_purge_params.py +71 -0
  232. gcore/types/cdn/resource_replace_params.py +1803 -0
  233. gcore/types/cdn/resource_update_params.py +1794 -0
  234. gcore/types/cdn/resource_usage_stats.py +111 -0
  235. gcore/types/cdn/resources/__init__.py +11 -0
  236. gcore/types/cdn/resources/cdn_resource_rule.py +1695 -0
  237. gcore/types/cdn/resources/origin_shielding.py +15 -0
  238. gcore/types/cdn/resources/rule_create_params.py +1652 -0
  239. gcore/types/cdn/resources/rule_list_response.py +10 -0
  240. gcore/types/cdn/resources/rule_replace_params.py +1654 -0
  241. gcore/types/cdn/resources/rule_update_params.py +1654 -0
  242. gcore/types/cdn/resources/shield_replace_params.py +16 -0
  243. gcore/types/cdn/rule_template.py +1666 -0
  244. gcore/types/cdn/rule_template_create_params.py +1636 -0
  245. gcore/types/cdn/rule_template_list.py +10 -0
  246. gcore/types/cdn/rule_template_replace_params.py +1636 -0
  247. gcore/types/cdn/rule_template_update_params.py +1636 -0
  248. gcore/types/cdn/shield_aggregated_stats.py +23 -0
  249. gcore/types/cdn/shield_list_response.py +25 -0
  250. gcore/types/cdn/ssl_detail.py +62 -0
  251. gcore/types/cdn/ssl_detail_list.py +10 -0
  252. gcore/types/cdn/ssl_request_status.py +135 -0
  253. gcore/types/cdn/statistic_get_logs_usage_aggregated_params.py +42 -0
  254. gcore/types/cdn/statistic_get_logs_usage_series_params.py +35 -0
  255. gcore/types/cdn/statistic_get_resource_usage_aggregated_params.py +151 -0
  256. gcore/types/cdn/statistic_get_resource_usage_series_params.py +131 -0
  257. gcore/types/cdn/statistic_get_shield_usage_aggregated_params.py +42 -0
  258. gcore/types/cdn/statistic_get_shield_usage_series_params.py +25 -0
  259. gcore/types/cdn/trusted_ca_certificate_create_params.py +23 -0
  260. gcore/types/cdn/trusted_ca_certificate_list_params.py +29 -0
  261. gcore/types/cdn/trusted_ca_certificate_replace_params.py +15 -0
  262. gcore/types/cdn/usage_series_stats.py +31 -0
  263. gcore/types/cloud/__init__.py +1 -0
  264. gcore/types/cloud/file_share.py +4 -0
  265. gcore/types/cloud/file_share_create_params.py +20 -0
  266. gcore/types/cloud/file_share_update_params.py +40 -3
  267. gcore/types/cloud/floating_ip_update_params.py +3 -1
  268. gcore/types/cloud/gpu_baremetal_cluster_action_params.py +46 -0
  269. gcore/types/cloud/inference/inference_deployment.py +3 -1
  270. gcore/types/cloud/instance_create_params.py +3 -1
  271. gcore/types/cloud/k8s/cluster_create_params.py +46 -4
  272. gcore/types/cloud/k8s/cluster_update_params.py +60 -6
  273. gcore/types/cloud/k8s/clusters/pool_update_params.py +1 -1
  274. gcore/types/cloud/k8s/k8s_cluster.py +40 -3
  275. gcore/types/cloud/load_balancer_update_params.py +3 -1
  276. gcore/types/cloud/network_update_params.py +3 -1
  277. gcore/types/cloud/networks/subnet_update_params.py +3 -1
  278. gcore/types/cloud/registries/user_create_multiple_params.py +5 -3
  279. gcore/types/cloud/registries/user_create_params.py +5 -3
  280. gcore/types/cloud/registry_create_params.py +5 -3
  281. gcore/types/cloud/security_group_update_params.py +3 -1
  282. gcore/types/cloud/ssh_key_created.py +6 -3
  283. gcore/types/cloud/volume_update_params.py +3 -1
  284. gcore/types/dns/zone_get_statistics_params.py +12 -9
  285. gcore/types/dns/zone_get_statistics_response.py +3 -1
  286. gcore/types/dns/zone_import_params.py +21 -15
  287. gcore/types/dns/zones/dns_output_rrset.py +7 -3
  288. gcore/types/iam/account_overview.py +7 -2
  289. gcore/types/iam/user.py +7 -2
  290. gcore/types/iam/user_detailed.py +7 -2
  291. gcore/types/iam/user_invite_params.py +4 -1
  292. gcore/types/iam/user_update.py +7 -2
  293. gcore/types/iam/user_update_params.py +7 -2
  294. gcore/types/streaming/ai_contentmoderation_hardnudity.py +6 -4
  295. gcore/types/streaming/ai_contentmoderation_nsfw.py +6 -4
  296. gcore/types/streaming/ai_contentmoderation_softnudity.py +6 -4
  297. gcore/types/streaming/ai_contentmoderation_sport.py +6 -4
  298. gcore/types/streaming/ai_task.py +20 -11
  299. gcore/types/streaming/ai_task_create_params.py +20 -11
  300. gcore/types/streaming/ai_task_get_response.py +5 -4
  301. gcore/types/streaming/ai_task_list_params.py +11 -5
  302. gcore/types/streaming/clip.py +33 -22
  303. gcore/types/streaming/create_video_param.py +75 -43
  304. gcore/types/streaming/playlist.py +7 -5
  305. gcore/types/streaming/playlist_create_params.py +7 -5
  306. gcore/types/streaming/playlist_update_params.py +7 -5
  307. gcore/types/streaming/playlist_video.py +75 -43
  308. gcore/types/streaming/statistic_get_unique_viewers_cdn_params.py +7 -4
  309. gcore/types/streaming/stream.py +207 -136
  310. gcore/types/streaming/stream_create_clip_params.py +33 -22
  311. gcore/types/streaming/stream_create_params.py +41 -24
  312. gcore/types/streaming/stream_update_params.py +41 -24
  313. gcore/types/streaming/video.py +138 -76
  314. gcore/types/streaming/video_list_params.py +4 -2
  315. gcore/types/streaming/video_update_params.py +75 -43
  316. gcore/types/waap/domain_update_params.py +2 -2
  317. gcore/types/waap/domains/advanced_rule_create_params.py +26 -18
  318. gcore/types/waap/domains/advanced_rule_list_params.py +10 -7
  319. gcore/types/waap/domains/advanced_rule_update_params.py +22 -17
  320. gcore/types/waap/domains/api_path_create_params.py +0 -3
  321. gcore/types/waap/domains/api_path_update_params.py +1 -3
  322. gcore/types/waap/domains/custom_rule_create_params.py +36 -35
  323. gcore/types/waap/domains/custom_rule_update_params.py +31 -33
  324. gcore/types/waap/domains/firewall_rule_create_params.py +6 -6
  325. gcore/types/waap/domains/firewall_rule_update_params.py +5 -5
  326. gcore/types/waap/domains/waap_advanced_rule.py +17 -9
  327. gcore/types/waap/domains/waap_custom_rule.py +5 -2
  328. gcore/types/waap/domains/waap_firewall_rule.py +1 -1
  329. gcore/types/waap/domains/waap_insight.py +1 -1
  330. gcore/types/waap/insight_list_types_params.py +1 -1
  331. {gcore-0.13.0.dist-info → gcore-0.14.0.dist-info}/METADATA +1 -1
  332. {gcore-0.13.0.dist-info → gcore-0.14.0.dist-info}/RECORD +334 -214
  333. {gcore-0.13.0.dist-info → gcore-0.14.0.dist-info}/WHEEL +0 -0
  334. {gcore-0.13.0.dist-info → gcore-0.14.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1027 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
11
+ from ...._utils import maybe_transform, async_maybe_transform
12
+ from ...._compat import cached_property
13
+ from ...._resource import SyncAPIResource, AsyncAPIResource
14
+ from ...._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from ...._base_client import make_request_options
21
+ from ....types.cdn.resources import rule_create_params, rule_update_params, rule_replace_params
22
+ from ....types.cdn.resources.cdn_resource_rule import CdnResourceRule
23
+ from ....types.cdn.resources.rule_list_response import RuleListResponse
24
+
25
+ __all__ = ["RulesResource", "AsyncRulesResource"]
26
+
27
+
28
+ class RulesResource(SyncAPIResource):
29
+ @cached_property
30
+ def with_raw_response(self) -> RulesResourceWithRawResponse:
31
+ """
32
+ This property can be used as a prefix for any HTTP method call to return
33
+ the raw response object instead of the parsed content.
34
+
35
+ For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers
36
+ """
37
+ return RulesResourceWithRawResponse(self)
38
+
39
+ @cached_property
40
+ def with_streaming_response(self) -> RulesResourceWithStreamingResponse:
41
+ """
42
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
43
+
44
+ For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response
45
+ """
46
+ return RulesResourceWithStreamingResponse(self)
47
+
48
+ def create(
49
+ self,
50
+ resource_id: int,
51
+ *,
52
+ name: str,
53
+ rule: str,
54
+ rule_type: int,
55
+ active: bool | Omit = omit,
56
+ options: rule_create_params.Options | Omit = omit,
57
+ origin_group: Optional[int] | Omit = omit,
58
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
59
+ weight: int | Omit = omit,
60
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
61
+ # The extra values given here take precedence over values defined on the client or passed to this method.
62
+ extra_headers: Headers | None = None,
63
+ extra_query: Query | None = None,
64
+ extra_body: Body | None = None,
65
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
66
+ ) -> CdnResourceRule:
67
+ """
68
+ Create rule
69
+
70
+ Args:
71
+ name: Rule name.
72
+
73
+ rule: Path to the file or folder for which the rule will be applied.
74
+
75
+ The rule is applied if the requested URI matches the rule path.
76
+
77
+ We add a leading forward slash to any rule path. Specify a path without a
78
+ forward slash.
79
+
80
+ rule_type: Rule type.
81
+
82
+ Possible values:
83
+
84
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
85
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
86
+ add / to each rule pattern before your regular expression. This type is
87
+ **legacy**, please use Type 0.
88
+
89
+ active: Enables or disables a rule.
90
+
91
+ Possible values:
92
+
93
+ - **true** - Rule is active, rule settings are applied.
94
+ - **false** - Rule is inactive, rule settings are not applied.
95
+
96
+ options: List of options that can be configured for the rule.
97
+
98
+ In case of `null` value the option is not added to the rule. Option inherits its
99
+ value from the CDN resource settings.
100
+
101
+ origin_group: ID of the origin group to which the rule is applied.
102
+
103
+ If the origin group is not specified, the rule is applied to the origin group
104
+ that the CDN resource is associated with.
105
+
106
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
107
+ connect to the origin.
108
+
109
+ Possible values:
110
+
111
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
112
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
113
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
114
+ on origin source should be available for the CDN both through HTTP and HTTPS
115
+ protocols.
116
+ - **null** - `originProtocol` setting is inherited from the CDN resource
117
+ settings.
118
+
119
+ weight: Rule execution order: from lowest (1) to highest.
120
+
121
+ If requested URI matches multiple rules, the one higher in the order of the
122
+ rules will be applied.
123
+
124
+ extra_headers: Send extra headers
125
+
126
+ extra_query: Add additional query parameters to the request
127
+
128
+ extra_body: Add additional JSON properties to the request
129
+
130
+ timeout: Override the client-level default timeout for this request, in seconds
131
+ """
132
+ return self._post(
133
+ f"/cdn/resources/{resource_id}/rules"
134
+ if self._client._base_url_overridden
135
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules",
136
+ body=maybe_transform(
137
+ {
138
+ "name": name,
139
+ "rule": rule,
140
+ "rule_type": rule_type,
141
+ "active": active,
142
+ "options": options,
143
+ "origin_group": origin_group,
144
+ "override_origin_protocol": override_origin_protocol,
145
+ "weight": weight,
146
+ },
147
+ rule_create_params.RuleCreateParams,
148
+ ),
149
+ options=make_request_options(
150
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
151
+ ),
152
+ cast_to=CdnResourceRule,
153
+ )
154
+
155
+ def update(
156
+ self,
157
+ rule_id: int,
158
+ *,
159
+ resource_id: int,
160
+ active: bool | Omit = omit,
161
+ name: str | Omit = omit,
162
+ options: rule_update_params.Options | Omit = omit,
163
+ origin_group: Optional[int] | Omit = omit,
164
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
165
+ rule: str | Omit = omit,
166
+ rule_type: int | Omit = omit,
167
+ weight: int | Omit = omit,
168
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
169
+ # The extra values given here take precedence over values defined on the client or passed to this method.
170
+ extra_headers: Headers | None = None,
171
+ extra_query: Query | None = None,
172
+ extra_body: Body | None = None,
173
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
174
+ ) -> CdnResourceRule:
175
+ """
176
+ Change rule
177
+
178
+ Args:
179
+ active: Enables or disables a rule.
180
+
181
+ Possible values:
182
+
183
+ - **true** - Rule is active, rule settings are applied.
184
+ - **false** - Rule is inactive, rule settings are not applied.
185
+
186
+ name: Rule name.
187
+
188
+ options: List of options that can be configured for the rule.
189
+
190
+ In case of `null` value the option is not added to the rule. Option inherits its
191
+ value from the CDN resource settings.
192
+
193
+ origin_group: ID of the origin group to which the rule is applied.
194
+
195
+ If the origin group is not specified, the rule is applied to the origin group
196
+ that the CDN resource is associated with.
197
+
198
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
199
+ connect to the origin.
200
+
201
+ Possible values:
202
+
203
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
204
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
205
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
206
+ on origin source should be available for the CDN both through HTTP and HTTPS
207
+ protocols.
208
+ - **null** - `originProtocol` setting is inherited from the CDN resource
209
+ settings.
210
+
211
+ rule: Path to the file or folder for which the rule will be applied.
212
+
213
+ The rule is applied if the requested URI matches the rule path.
214
+
215
+ We add a leading forward slash to any rule path. Specify a path without a
216
+ forward slash.
217
+
218
+ rule_type: Rule type.
219
+
220
+ Possible values:
221
+
222
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
223
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
224
+ add / to each rule pattern before your regular expression. This type is
225
+ **legacy**, please use Type 0.
226
+
227
+ weight: Rule execution order: from lowest (1) to highest.
228
+
229
+ If requested URI matches multiple rules, the one higher in the order of the
230
+ rules will be applied.
231
+
232
+ extra_headers: Send extra headers
233
+
234
+ extra_query: Add additional query parameters to the request
235
+
236
+ extra_body: Add additional JSON properties to the request
237
+
238
+ timeout: Override the client-level default timeout for this request, in seconds
239
+ """
240
+ return self._patch(
241
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
242
+ if self._client._base_url_overridden
243
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
244
+ body=maybe_transform(
245
+ {
246
+ "active": active,
247
+ "name": name,
248
+ "options": options,
249
+ "origin_group": origin_group,
250
+ "override_origin_protocol": override_origin_protocol,
251
+ "rule": rule,
252
+ "rule_type": rule_type,
253
+ "weight": weight,
254
+ },
255
+ rule_update_params.RuleUpdateParams,
256
+ ),
257
+ options=make_request_options(
258
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
259
+ ),
260
+ cast_to=CdnResourceRule,
261
+ )
262
+
263
+ def list(
264
+ self,
265
+ resource_id: int,
266
+ *,
267
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
268
+ # The extra values given here take precedence over values defined on the client or passed to this method.
269
+ extra_headers: Headers | None = None,
270
+ extra_query: Query | None = None,
271
+ extra_body: Body | None = None,
272
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
273
+ ) -> RuleListResponse:
274
+ """
275
+ Get rules list
276
+
277
+ Args:
278
+ extra_headers: Send extra headers
279
+
280
+ extra_query: Add additional query parameters to the request
281
+
282
+ extra_body: Add additional JSON properties to the request
283
+
284
+ timeout: Override the client-level default timeout for this request, in seconds
285
+ """
286
+ return self._get(
287
+ f"/cdn/resources/{resource_id}/rules"
288
+ if self._client._base_url_overridden
289
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules",
290
+ options=make_request_options(
291
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
292
+ ),
293
+ cast_to=RuleListResponse,
294
+ )
295
+
296
+ def delete(
297
+ self,
298
+ rule_id: int,
299
+ *,
300
+ resource_id: int,
301
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
302
+ # The extra values given here take precedence over values defined on the client or passed to this method.
303
+ extra_headers: Headers | None = None,
304
+ extra_query: Query | None = None,
305
+ extra_body: Body | None = None,
306
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
307
+ ) -> None:
308
+ """
309
+ Delete the rule from the system permanently.
310
+
311
+ Notes:
312
+
313
+ - **Deactivation Requirement**: Set the `active` attribute to `false` before
314
+ deletion.
315
+ - **Irreversibility**: This action is irreversible. Once deleted, the rule
316
+ cannot be recovered.
317
+
318
+ Args:
319
+ extra_headers: Send extra headers
320
+
321
+ extra_query: Add additional query parameters to the request
322
+
323
+ extra_body: Add additional JSON properties to the request
324
+
325
+ timeout: Override the client-level default timeout for this request, in seconds
326
+ """
327
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
328
+ return self._delete(
329
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
330
+ if self._client._base_url_overridden
331
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
332
+ options=make_request_options(
333
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
334
+ ),
335
+ cast_to=NoneType,
336
+ )
337
+
338
+ def get(
339
+ self,
340
+ rule_id: int,
341
+ *,
342
+ resource_id: int,
343
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
344
+ # The extra values given here take precedence over values defined on the client or passed to this method.
345
+ extra_headers: Headers | None = None,
346
+ extra_query: Query | None = None,
347
+ extra_body: Body | None = None,
348
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
349
+ ) -> CdnResourceRule:
350
+ """
351
+ Get rule details
352
+
353
+ Args:
354
+ extra_headers: Send extra headers
355
+
356
+ extra_query: Add additional query parameters to the request
357
+
358
+ extra_body: Add additional JSON properties to the request
359
+
360
+ timeout: Override the client-level default timeout for this request, in seconds
361
+ """
362
+ return self._get(
363
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
364
+ if self._client._base_url_overridden
365
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
366
+ options=make_request_options(
367
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
368
+ ),
369
+ cast_to=CdnResourceRule,
370
+ )
371
+
372
+ def replace(
373
+ self,
374
+ rule_id: int,
375
+ *,
376
+ resource_id: int,
377
+ rule: str,
378
+ rule_type: int,
379
+ active: bool | Omit = omit,
380
+ name: str | Omit = omit,
381
+ options: rule_replace_params.Options | Omit = omit,
382
+ origin_group: Optional[int] | Omit = omit,
383
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
384
+ weight: int | Omit = omit,
385
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
386
+ # The extra values given here take precedence over values defined on the client or passed to this method.
387
+ extra_headers: Headers | None = None,
388
+ extra_query: Query | None = None,
389
+ extra_body: Body | None = None,
390
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
391
+ ) -> CdnResourceRule:
392
+ """
393
+ Change rule
394
+
395
+ Args:
396
+ rule: Path to the file or folder for which the rule will be applied.
397
+
398
+ The rule is applied if the requested URI matches the rule path.
399
+
400
+ We add a leading forward slash to any rule path. Specify a path without a
401
+ forward slash.
402
+
403
+ rule_type: Rule type.
404
+
405
+ Possible values:
406
+
407
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
408
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
409
+ add / to each rule pattern before your regular expression. This type is
410
+ **legacy**, please use Type 0.
411
+
412
+ active: Enables or disables a rule.
413
+
414
+ Possible values:
415
+
416
+ - **true** - Rule is active, rule settings are applied.
417
+ - **false** - Rule is inactive, rule settings are not applied.
418
+
419
+ name: Rule name.
420
+
421
+ options: List of options that can be configured for the rule.
422
+
423
+ In case of `null` value the option is not added to the rule. Option inherits its
424
+ value from the CDN resource settings.
425
+
426
+ origin_group: ID of the origin group to which the rule is applied.
427
+
428
+ If the origin group is not specified, the rule is applied to the origin group
429
+ that the CDN resource is associated with.
430
+
431
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
432
+ connect to the origin.
433
+
434
+ Possible values:
435
+
436
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
437
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
438
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
439
+ on origin source should be available for the CDN both through HTTP and HTTPS
440
+ protocols.
441
+ - **null** - `originProtocol` setting is inherited from the CDN resource
442
+ settings.
443
+
444
+ weight: Rule execution order: from lowest (1) to highest.
445
+
446
+ If requested URI matches multiple rules, the one higher in the order of the
447
+ rules will be applied.
448
+
449
+ extra_headers: Send extra headers
450
+
451
+ extra_query: Add additional query parameters to the request
452
+
453
+ extra_body: Add additional JSON properties to the request
454
+
455
+ timeout: Override the client-level default timeout for this request, in seconds
456
+ """
457
+ return self._put(
458
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
459
+ if self._client._base_url_overridden
460
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
461
+ body=maybe_transform(
462
+ {
463
+ "rule": rule,
464
+ "rule_type": rule_type,
465
+ "active": active,
466
+ "name": name,
467
+ "options": options,
468
+ "origin_group": origin_group,
469
+ "override_origin_protocol": override_origin_protocol,
470
+ "weight": weight,
471
+ },
472
+ rule_replace_params.RuleReplaceParams,
473
+ ),
474
+ options=make_request_options(
475
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
476
+ ),
477
+ cast_to=CdnResourceRule,
478
+ )
479
+
480
+
481
+ class AsyncRulesResource(AsyncAPIResource):
482
+ @cached_property
483
+ def with_raw_response(self) -> AsyncRulesResourceWithRawResponse:
484
+ """
485
+ This property can be used as a prefix for any HTTP method call to return
486
+ the raw response object instead of the parsed content.
487
+
488
+ For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers
489
+ """
490
+ return AsyncRulesResourceWithRawResponse(self)
491
+
492
+ @cached_property
493
+ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse:
494
+ """
495
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
496
+
497
+ For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response
498
+ """
499
+ return AsyncRulesResourceWithStreamingResponse(self)
500
+
501
+ async def create(
502
+ self,
503
+ resource_id: int,
504
+ *,
505
+ name: str,
506
+ rule: str,
507
+ rule_type: int,
508
+ active: bool | Omit = omit,
509
+ options: rule_create_params.Options | Omit = omit,
510
+ origin_group: Optional[int] | Omit = omit,
511
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
512
+ weight: int | Omit = omit,
513
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
514
+ # The extra values given here take precedence over values defined on the client or passed to this method.
515
+ extra_headers: Headers | None = None,
516
+ extra_query: Query | None = None,
517
+ extra_body: Body | None = None,
518
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
519
+ ) -> CdnResourceRule:
520
+ """
521
+ Create rule
522
+
523
+ Args:
524
+ name: Rule name.
525
+
526
+ rule: Path to the file or folder for which the rule will be applied.
527
+
528
+ The rule is applied if the requested URI matches the rule path.
529
+
530
+ We add a leading forward slash to any rule path. Specify a path without a
531
+ forward slash.
532
+
533
+ rule_type: Rule type.
534
+
535
+ Possible values:
536
+
537
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
538
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
539
+ add / to each rule pattern before your regular expression. This type is
540
+ **legacy**, please use Type 0.
541
+
542
+ active: Enables or disables a rule.
543
+
544
+ Possible values:
545
+
546
+ - **true** - Rule is active, rule settings are applied.
547
+ - **false** - Rule is inactive, rule settings are not applied.
548
+
549
+ options: List of options that can be configured for the rule.
550
+
551
+ In case of `null` value the option is not added to the rule. Option inherits its
552
+ value from the CDN resource settings.
553
+
554
+ origin_group: ID of the origin group to which the rule is applied.
555
+
556
+ If the origin group is not specified, the rule is applied to the origin group
557
+ that the CDN resource is associated with.
558
+
559
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
560
+ connect to the origin.
561
+
562
+ Possible values:
563
+
564
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
565
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
566
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
567
+ on origin source should be available for the CDN both through HTTP and HTTPS
568
+ protocols.
569
+ - **null** - `originProtocol` setting is inherited from the CDN resource
570
+ settings.
571
+
572
+ weight: Rule execution order: from lowest (1) to highest.
573
+
574
+ If requested URI matches multiple rules, the one higher in the order of the
575
+ rules will be applied.
576
+
577
+ extra_headers: Send extra headers
578
+
579
+ extra_query: Add additional query parameters to the request
580
+
581
+ extra_body: Add additional JSON properties to the request
582
+
583
+ timeout: Override the client-level default timeout for this request, in seconds
584
+ """
585
+ return await self._post(
586
+ f"/cdn/resources/{resource_id}/rules"
587
+ if self._client._base_url_overridden
588
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules",
589
+ body=await async_maybe_transform(
590
+ {
591
+ "name": name,
592
+ "rule": rule,
593
+ "rule_type": rule_type,
594
+ "active": active,
595
+ "options": options,
596
+ "origin_group": origin_group,
597
+ "override_origin_protocol": override_origin_protocol,
598
+ "weight": weight,
599
+ },
600
+ rule_create_params.RuleCreateParams,
601
+ ),
602
+ options=make_request_options(
603
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
604
+ ),
605
+ cast_to=CdnResourceRule,
606
+ )
607
+
608
+ async def update(
609
+ self,
610
+ rule_id: int,
611
+ *,
612
+ resource_id: int,
613
+ active: bool | Omit = omit,
614
+ name: str | Omit = omit,
615
+ options: rule_update_params.Options | Omit = omit,
616
+ origin_group: Optional[int] | Omit = omit,
617
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
618
+ rule: str | Omit = omit,
619
+ rule_type: int | Omit = omit,
620
+ weight: int | Omit = omit,
621
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
622
+ # The extra values given here take precedence over values defined on the client or passed to this method.
623
+ extra_headers: Headers | None = None,
624
+ extra_query: Query | None = None,
625
+ extra_body: Body | None = None,
626
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
627
+ ) -> CdnResourceRule:
628
+ """
629
+ Change rule
630
+
631
+ Args:
632
+ active: Enables or disables a rule.
633
+
634
+ Possible values:
635
+
636
+ - **true** - Rule is active, rule settings are applied.
637
+ - **false** - Rule is inactive, rule settings are not applied.
638
+
639
+ name: Rule name.
640
+
641
+ options: List of options that can be configured for the rule.
642
+
643
+ In case of `null` value the option is not added to the rule. Option inherits its
644
+ value from the CDN resource settings.
645
+
646
+ origin_group: ID of the origin group to which the rule is applied.
647
+
648
+ If the origin group is not specified, the rule is applied to the origin group
649
+ that the CDN resource is associated with.
650
+
651
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
652
+ connect to the origin.
653
+
654
+ Possible values:
655
+
656
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
657
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
658
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
659
+ on origin source should be available for the CDN both through HTTP and HTTPS
660
+ protocols.
661
+ - **null** - `originProtocol` setting is inherited from the CDN resource
662
+ settings.
663
+
664
+ rule: Path to the file or folder for which the rule will be applied.
665
+
666
+ The rule is applied if the requested URI matches the rule path.
667
+
668
+ We add a leading forward slash to any rule path. Specify a path without a
669
+ forward slash.
670
+
671
+ rule_type: Rule type.
672
+
673
+ Possible values:
674
+
675
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
676
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
677
+ add / to each rule pattern before your regular expression. This type is
678
+ **legacy**, please use Type 0.
679
+
680
+ weight: Rule execution order: from lowest (1) to highest.
681
+
682
+ If requested URI matches multiple rules, the one higher in the order of the
683
+ rules will be applied.
684
+
685
+ extra_headers: Send extra headers
686
+
687
+ extra_query: Add additional query parameters to the request
688
+
689
+ extra_body: Add additional JSON properties to the request
690
+
691
+ timeout: Override the client-level default timeout for this request, in seconds
692
+ """
693
+ return await self._patch(
694
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
695
+ if self._client._base_url_overridden
696
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
697
+ body=await async_maybe_transform(
698
+ {
699
+ "active": active,
700
+ "name": name,
701
+ "options": options,
702
+ "origin_group": origin_group,
703
+ "override_origin_protocol": override_origin_protocol,
704
+ "rule": rule,
705
+ "rule_type": rule_type,
706
+ "weight": weight,
707
+ },
708
+ rule_update_params.RuleUpdateParams,
709
+ ),
710
+ options=make_request_options(
711
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
712
+ ),
713
+ cast_to=CdnResourceRule,
714
+ )
715
+
716
+ async def list(
717
+ self,
718
+ resource_id: int,
719
+ *,
720
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
721
+ # The extra values given here take precedence over values defined on the client or passed to this method.
722
+ extra_headers: Headers | None = None,
723
+ extra_query: Query | None = None,
724
+ extra_body: Body | None = None,
725
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
726
+ ) -> RuleListResponse:
727
+ """
728
+ Get rules list
729
+
730
+ Args:
731
+ extra_headers: Send extra headers
732
+
733
+ extra_query: Add additional query parameters to the request
734
+
735
+ extra_body: Add additional JSON properties to the request
736
+
737
+ timeout: Override the client-level default timeout for this request, in seconds
738
+ """
739
+ return await self._get(
740
+ f"/cdn/resources/{resource_id}/rules"
741
+ if self._client._base_url_overridden
742
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules",
743
+ options=make_request_options(
744
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
745
+ ),
746
+ cast_to=RuleListResponse,
747
+ )
748
+
749
+ async def delete(
750
+ self,
751
+ rule_id: int,
752
+ *,
753
+ resource_id: int,
754
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
755
+ # The extra values given here take precedence over values defined on the client or passed to this method.
756
+ extra_headers: Headers | None = None,
757
+ extra_query: Query | None = None,
758
+ extra_body: Body | None = None,
759
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
760
+ ) -> None:
761
+ """
762
+ Delete the rule from the system permanently.
763
+
764
+ Notes:
765
+
766
+ - **Deactivation Requirement**: Set the `active` attribute to `false` before
767
+ deletion.
768
+ - **Irreversibility**: This action is irreversible. Once deleted, the rule
769
+ cannot be recovered.
770
+
771
+ Args:
772
+ extra_headers: Send extra headers
773
+
774
+ extra_query: Add additional query parameters to the request
775
+
776
+ extra_body: Add additional JSON properties to the request
777
+
778
+ timeout: Override the client-level default timeout for this request, in seconds
779
+ """
780
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
781
+ return await self._delete(
782
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
783
+ if self._client._base_url_overridden
784
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
785
+ options=make_request_options(
786
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
787
+ ),
788
+ cast_to=NoneType,
789
+ )
790
+
791
+ async def get(
792
+ self,
793
+ rule_id: int,
794
+ *,
795
+ resource_id: int,
796
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
797
+ # The extra values given here take precedence over values defined on the client or passed to this method.
798
+ extra_headers: Headers | None = None,
799
+ extra_query: Query | None = None,
800
+ extra_body: Body | None = None,
801
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
802
+ ) -> CdnResourceRule:
803
+ """
804
+ Get rule details
805
+
806
+ Args:
807
+ extra_headers: Send extra headers
808
+
809
+ extra_query: Add additional query parameters to the request
810
+
811
+ extra_body: Add additional JSON properties to the request
812
+
813
+ timeout: Override the client-level default timeout for this request, in seconds
814
+ """
815
+ return await self._get(
816
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
817
+ if self._client._base_url_overridden
818
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
819
+ options=make_request_options(
820
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
821
+ ),
822
+ cast_to=CdnResourceRule,
823
+ )
824
+
825
+ async def replace(
826
+ self,
827
+ rule_id: int,
828
+ *,
829
+ resource_id: int,
830
+ rule: str,
831
+ rule_type: int,
832
+ active: bool | Omit = omit,
833
+ name: str | Omit = omit,
834
+ options: rule_replace_params.Options | Omit = omit,
835
+ origin_group: Optional[int] | Omit = omit,
836
+ override_origin_protocol: Optional[Literal["HTTPS", "HTTP", "MATCH"]] | Omit = omit,
837
+ weight: int | Omit = omit,
838
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
839
+ # The extra values given here take precedence over values defined on the client or passed to this method.
840
+ extra_headers: Headers | None = None,
841
+ extra_query: Query | None = None,
842
+ extra_body: Body | None = None,
843
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
844
+ ) -> CdnResourceRule:
845
+ """
846
+ Change rule
847
+
848
+ Args:
849
+ rule: Path to the file or folder for which the rule will be applied.
850
+
851
+ The rule is applied if the requested URI matches the rule path.
852
+
853
+ We add a leading forward slash to any rule path. Specify a path without a
854
+ forward slash.
855
+
856
+ rule_type: Rule type.
857
+
858
+ Possible values:
859
+
860
+ - **Type 0** - Regular expression. Must start with '^/' or '/'.
861
+ - **Type 1** - Regular expression. Note that for this rule type we automatically
862
+ add / to each rule pattern before your regular expression. This type is
863
+ **legacy**, please use Type 0.
864
+
865
+ active: Enables or disables a rule.
866
+
867
+ Possible values:
868
+
869
+ - **true** - Rule is active, rule settings are applied.
870
+ - **false** - Rule is inactive, rule settings are not applied.
871
+
872
+ name: Rule name.
873
+
874
+ options: List of options that can be configured for the rule.
875
+
876
+ In case of `null` value the option is not added to the rule. Option inherits its
877
+ value from the CDN resource settings.
878
+
879
+ origin_group: ID of the origin group to which the rule is applied.
880
+
881
+ If the origin group is not specified, the rule is applied to the origin group
882
+ that the CDN resource is associated with.
883
+
884
+ override_origin_protocol: Sets a protocol other than the one specified in the CDN resource settings to
885
+ connect to the origin.
886
+
887
+ Possible values:
888
+
889
+ - **HTTPS** - CDN servers connect to origin via HTTPS protocol.
890
+ - **HTTP** - CDN servers connect to origin via HTTP protocol.
891
+ - **MATCH** - Connection protocol is chosen automatically; in this case, content
892
+ on origin source should be available for the CDN both through HTTP and HTTPS
893
+ protocols.
894
+ - **null** - `originProtocol` setting is inherited from the CDN resource
895
+ settings.
896
+
897
+ weight: Rule execution order: from lowest (1) to highest.
898
+
899
+ If requested URI matches multiple rules, the one higher in the order of the
900
+ rules will be applied.
901
+
902
+ extra_headers: Send extra headers
903
+
904
+ extra_query: Add additional query parameters to the request
905
+
906
+ extra_body: Add additional JSON properties to the request
907
+
908
+ timeout: Override the client-level default timeout for this request, in seconds
909
+ """
910
+ return await self._put(
911
+ f"/cdn/resources/{resource_id}/rules/{rule_id}"
912
+ if self._client._base_url_overridden
913
+ else f"https://api.gcore.com//cdn/resources/{resource_id}/rules/{rule_id}",
914
+ body=await async_maybe_transform(
915
+ {
916
+ "rule": rule,
917
+ "rule_type": rule_type,
918
+ "active": active,
919
+ "name": name,
920
+ "options": options,
921
+ "origin_group": origin_group,
922
+ "override_origin_protocol": override_origin_protocol,
923
+ "weight": weight,
924
+ },
925
+ rule_replace_params.RuleReplaceParams,
926
+ ),
927
+ options=make_request_options(
928
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
929
+ ),
930
+ cast_to=CdnResourceRule,
931
+ )
932
+
933
+
934
+ class RulesResourceWithRawResponse:
935
+ def __init__(self, rules: RulesResource) -> None:
936
+ self._rules = rules
937
+
938
+ self.create = to_raw_response_wrapper(
939
+ rules.create,
940
+ )
941
+ self.update = to_raw_response_wrapper(
942
+ rules.update,
943
+ )
944
+ self.list = to_raw_response_wrapper(
945
+ rules.list,
946
+ )
947
+ self.delete = to_raw_response_wrapper(
948
+ rules.delete,
949
+ )
950
+ self.get = to_raw_response_wrapper(
951
+ rules.get,
952
+ )
953
+ self.replace = to_raw_response_wrapper(
954
+ rules.replace,
955
+ )
956
+
957
+
958
+ class AsyncRulesResourceWithRawResponse:
959
+ def __init__(self, rules: AsyncRulesResource) -> None:
960
+ self._rules = rules
961
+
962
+ self.create = async_to_raw_response_wrapper(
963
+ rules.create,
964
+ )
965
+ self.update = async_to_raw_response_wrapper(
966
+ rules.update,
967
+ )
968
+ self.list = async_to_raw_response_wrapper(
969
+ rules.list,
970
+ )
971
+ self.delete = async_to_raw_response_wrapper(
972
+ rules.delete,
973
+ )
974
+ self.get = async_to_raw_response_wrapper(
975
+ rules.get,
976
+ )
977
+ self.replace = async_to_raw_response_wrapper(
978
+ rules.replace,
979
+ )
980
+
981
+
982
+ class RulesResourceWithStreamingResponse:
983
+ def __init__(self, rules: RulesResource) -> None:
984
+ self._rules = rules
985
+
986
+ self.create = to_streamed_response_wrapper(
987
+ rules.create,
988
+ )
989
+ self.update = to_streamed_response_wrapper(
990
+ rules.update,
991
+ )
992
+ self.list = to_streamed_response_wrapper(
993
+ rules.list,
994
+ )
995
+ self.delete = to_streamed_response_wrapper(
996
+ rules.delete,
997
+ )
998
+ self.get = to_streamed_response_wrapper(
999
+ rules.get,
1000
+ )
1001
+ self.replace = to_streamed_response_wrapper(
1002
+ rules.replace,
1003
+ )
1004
+
1005
+
1006
+ class AsyncRulesResourceWithStreamingResponse:
1007
+ def __init__(self, rules: AsyncRulesResource) -> None:
1008
+ self._rules = rules
1009
+
1010
+ self.create = async_to_streamed_response_wrapper(
1011
+ rules.create,
1012
+ )
1013
+ self.update = async_to_streamed_response_wrapper(
1014
+ rules.update,
1015
+ )
1016
+ self.list = async_to_streamed_response_wrapper(
1017
+ rules.list,
1018
+ )
1019
+ self.delete = async_to_streamed_response_wrapper(
1020
+ rules.delete,
1021
+ )
1022
+ self.get = async_to_streamed_response_wrapper(
1023
+ rules.get,
1024
+ )
1025
+ self.replace = async_to_streamed_response_wrapper(
1026
+ rules.replace,
1027
+ )