From ac8dcb31118520f7673ba8386e2c0e150e1a33aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 12:22:58 +0000 Subject: [PATCH 01/11] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index e9e01167..d86c632a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-06555b1b7559c234823e37c3970ba3ea9f11ed14270b872b22761f6be8692e74.yml -openapi_spec_hash: 619bca59fafad89221a4b35f797f14f1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-1cde63e41e6a58c6a1f86f9175df845d5e9894294483e6f7e23f50507951a872.yml +openapi_spec_hash: d65dff21548c2c34f0a6077ee2eb0af1 config_hash: bc578a7de14c42e33b7d4bd4502218f2 From 925535479aea739b6abbd1fa76ea892d342fc355 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 14:27:11 +0000 Subject: [PATCH 02/11] feat(api): aggregated API specs update --- .stats.yml | 4 ++-- src/gcore/resources/cloud/baremetal/servers.py | 4 ++-- .../resources/cloud/file_shares/file_shares.py | 14 +++++++------- src/gcore/resources/cloud/floating_ips.py | 6 +++--- .../cloud/gpu_baremetal/clusters/clusters.py | 6 +++--- .../cloud/gpu_baremetal/clusters/images.py | 6 +++--- .../cloud/gpu_virtual/clusters/clusters.py | 6 +++--- .../cloud/gpu_virtual/clusters/images.py | 6 +++--- src/gcore/resources/cloud/instances/images.py | 10 +++++----- src/gcore/resources/cloud/instances/instances.py | 4 ++-- .../cloud/load_balancers/load_balancers.py | 6 +++--- src/gcore/resources/cloud/networks/networks.py | 6 +++--- src/gcore/resources/cloud/networks/subnets.py | 6 +++--- .../cloud/security_groups/security_groups.py | 6 +++--- src/gcore/resources/cloud/volume_snapshots.py | 6 +++--- .../cloud/baremetal/server_create_params.py | 2 +- .../types/cloud/file_share_create_params.py | 6 +++--- .../types/cloud/floating_ip_create_params.py | 4 ++-- .../cloud/gpu_baremetal/cluster_create_params.py | 4 ++-- .../clusters/image_upload_params.py | 4 ++-- .../cloud/gpu_virtual/cluster_create_params.py | 2 +- .../gpu_virtual/clusters/image_upload_params.py | 4 ++-- src/gcore/types/cloud/instance_create_params.py | 12 ++++++------ .../instances/image_create_from_volume_params.py | 4 ++-- .../types/cloud/instances/image_upload_params.py | 4 ++-- .../types/cloud/load_balancer_create_params.py | 4 ++-- src/gcore/types/cloud/network_create_params.py | 3 +-- .../types/cloud/networks/subnet_create_params.py | 4 ++-- .../types/cloud/security_group_create_params.py | 4 ++-- src/gcore/types/cloud/tag.py | 12 ++++++++++-- src/gcore/types/cloud/tag_update_map_param.py | 3 +-- .../types/cloud/volume_snapshot_create_params.py | 3 +-- .../cloud/gpu_baremetal/test_clusters.py | 16 ++++++++-------- .../cloud/gpu_virtual/test_clusters.py | 16 ++++++++-------- .../api_resources/cloud/instances/test_images.py | 4 ++-- .../api_resources/cloud/networks/test_subnets.py | 4 ++-- tests/api_resources/cloud/test_file_shares.py | 4 ++-- tests/api_resources/cloud/test_floating_ips.py | 4 ++-- tests/api_resources/cloud/test_instances.py | 4 ++-- tests/api_resources/cloud/test_load_balancers.py | 4 ++-- tests/api_resources/cloud/test_networks.py | 4 ++-- .../api_resources/cloud/test_security_groups.py | 4 ++-- .../api_resources/cloud/test_volume_snapshots.py | 4 ++-- tests/api_resources/cloud/test_volumes.py | 16 ++++++++-------- 44 files changed, 132 insertions(+), 127 deletions(-) diff --git a/.stats.yml b/.stats.yml index d86c632a..54d04e2d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-1cde63e41e6a58c6a1f86f9175df845d5e9894294483e6f7e23f50507951a872.yml -openapi_spec_hash: d65dff21548c2c34f0a6077ee2eb0af1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-30f92b095e6f90731f4e7652affc69f27c57849dccf30119b79c26314aa2ae00.yml +openapi_spec_hash: 2348a329bec98d05bf5e4c109d300382 config_hash: bc578a7de14c42e33b7d4bd4502218f2 diff --git a/src/gcore/resources/cloud/baremetal/servers.py b/src/gcore/resources/cloud/baremetal/servers.py index ae77f521..1b5c725d 100644 --- a/src/gcore/resources/cloud/baremetal/servers.py +++ b/src/gcore/resources/cloud/baremetal/servers.py @@ -62,7 +62,7 @@ def create( name_template: str | Omit = omit, password: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -554,7 +554,7 @@ async def create( name_template: str | Omit = omit, password: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/gcore/resources/cloud/file_shares/file_shares.py b/src/gcore/resources/cloud/file_shares/file_shares.py index 7b5cdea2..19e36c97 100644 --- a/src/gcore/resources/cloud/file_shares/file_shares.py +++ b/src/gcore/resources/cloud/file_shares/file_shares.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Literal, overload import httpx @@ -75,7 +75,7 @@ def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["standard"] | Omit = omit, volume_type: Literal["default_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,7 +134,7 @@ def create( protocol: Literal["NFS"], size: int, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["vast"] | Omit = omit, volume_type: Literal["vast_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -192,7 +192,7 @@ def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["standard"] | Literal["vast"] | Omit = omit, volume_type: Literal["default_share_type"] | Literal["vast_share_type"] | Omit = omit, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, @@ -600,7 +600,7 @@ async def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["standard"] | Omit = omit, volume_type: Literal["default_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -659,7 +659,7 @@ async def create( protocol: Literal["NFS"], size: int, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["vast"] | Omit = omit, volume_type: Literal["vast_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -717,7 +717,7 @@ async def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type_name: Literal["standard"] | Literal["vast"] | Omit = omit, volume_type: Literal["default_share_type"] | Literal["vast_share_type"] | Omit = omit, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, diff --git a/src/gcore/resources/cloud/floating_ips.py b/src/gcore/resources/cloud/floating_ips.py index f3b95468..fd677c44 100644 --- a/src/gcore/resources/cloud/floating_ips.py +++ b/src/gcore/resources/cloud/floating_ips.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing_extensions -from typing import Dict, Optional +from typing import Optional import httpx @@ -67,7 +67,7 @@ def create( region_id: int | None = None, fixed_ip_address: Optional[str] | Omit = omit, port_id: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -690,7 +690,7 @@ async def create( region_id: int | None = None, fixed_ip_address: Optional[str] | Omit = omit, port_id: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py b/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py index adfb58cb..7385e2c8 100644 --- a/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py +++ b/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Optional +from typing import List, Optional from typing_extensions import Literal import httpx @@ -113,7 +113,7 @@ def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -830,7 +830,7 @@ async def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py b/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py index dee06b23..e73c4468 100644 --- a/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py +++ b/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal import httpx @@ -228,7 +228,7 @@ def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -576,7 +576,7 @@ async def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py b/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py index 486048b5..8fe0de91 100644 --- a/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py +++ b/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal, overload import httpx @@ -122,7 +122,7 @@ def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -767,7 +767,7 @@ async def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_virtual/clusters/images.py b/src/gcore/resources/cloud/gpu_virtual/clusters/images.py index 9c7d1472..d83f68fa 100644 --- a/src/gcore/resources/cloud/gpu_virtual/clusters/images.py +++ b/src/gcore/resources/cloud/gpu_virtual/clusters/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal import httpx @@ -190,7 +190,7 @@ def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -432,7 +432,7 @@ async def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/instances/images.py b/src/gcore/resources/cloud/instances/images.py index 8737a631..9b5fb71e 100644 --- a/src/gcore/resources/cloud/instances/images.py +++ b/src/gcore/resources/cloud/instances/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal import httpx @@ -288,7 +288,7 @@ def create_from_volume( os_type: Literal["linux", "windows"] | Omit = omit, source: Literal["volume"] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -486,7 +486,7 @@ def upload( os_type: Literal["linux", "windows"] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -889,7 +889,7 @@ async def create_from_volume( os_type: Literal["linux", "windows"] | Omit = omit, source: Literal["volume"] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1087,7 +1087,7 @@ async def upload( os_type: Literal["linux", "windows"] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/instances/instances.py b/src/gcore/resources/cloud/instances/instances.py index 2c83bbae..499f1006 100644 --- a/src/gcore/resources/cloud/instances/instances.py +++ b/src/gcore/resources/cloud/instances/instances.py @@ -125,7 +125,7 @@ def create( security_groups: Iterable[instance_create_params.SecurityGroup] | Omit = omit, servergroup_id: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1544,7 +1544,7 @@ async def create( security_groups: Iterable[instance_create_params.SecurityGroup] | Omit = omit, servergroup_id: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/gcore/resources/cloud/load_balancers/load_balancers.py b/src/gcore/resources/cloud/load_balancers/load_balancers.py index 54c7ef99..cc52a7b9 100644 --- a/src/gcore/resources/cloud/load_balancers/load_balancers.py +++ b/src/gcore/resources/cloud/load_balancers/load_balancers.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing_extensions -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Literal import httpx @@ -143,7 +143,7 @@ def create( name: str | Omit = omit, name_template: str | Omit = omit, preferred_connectivity: LoadBalancerMemberConnectivity | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, vip_ip_family: InterfaceIPFamily | Omit = omit, vip_network_id: str | Omit = omit, vip_port_id: str | Omit = omit, @@ -895,7 +895,7 @@ async def create( name: str | Omit = omit, name_template: str | Omit = omit, preferred_connectivity: LoadBalancerMemberConnectivity | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, vip_ip_family: InterfaceIPFamily | Omit = omit, vip_network_id: str | Omit = omit, vip_port_id: str | Omit = omit, diff --git a/src/gcore/resources/cloud/networks/networks.py b/src/gcore/resources/cloud/networks/networks.py index 847a36da..08940886 100644 --- a/src/gcore/resources/cloud/networks/networks.py +++ b/src/gcore/resources/cloud/networks/networks.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal import httpx @@ -78,7 +78,7 @@ def create( region_id: int | None = None, name: str, create_router: bool | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type: Literal["vlan", "vxlan"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -505,7 +505,7 @@ async def create( region_id: int | None = None, name: str, create_router: bool | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, type: Literal["vlan", "vxlan"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. diff --git a/src/gcore/resources/cloud/networks/subnets.py b/src/gcore/resources/cloud/networks/subnets.py index 1ca16f53..e53fe98a 100644 --- a/src/gcore/resources/cloud/networks/subnets.py +++ b/src/gcore/resources/cloud/networks/subnets.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Literal import httpx @@ -64,7 +64,7 @@ def create( host_routes: Optional[Iterable[subnet_create_params.HostRoute]] | Omit = omit, ip_version: IPVersion | Omit = omit, router_id_to_connect: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -524,7 +524,7 @@ async def create( host_routes: Optional[Iterable[subnet_create_params.HostRoute]] | Omit = omit, ip_version: IPVersion | Omit = omit, router_id_to_connect: Optional[str] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/security_groups/security_groups.py b/src/gcore/resources/cloud/security_groups/security_groups.py index 52b209e1..0e3ecfeb 100644 --- a/src/gcore/resources/cloud/security_groups/security_groups.py +++ b/src/gcore/resources/cloud/security_groups/security_groups.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional import httpx @@ -71,7 +71,7 @@ def create( name: str, description: str | Omit = omit, rules: Iterable[security_group_create_params.Rule] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -629,7 +629,7 @@ async def create( name: str, description: str | Omit = omit, rules: Iterable[security_group_create_params.Rule] | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/volume_snapshots.py b/src/gcore/resources/cloud/volume_snapshots.py index a8b6850a..52dc4971 100644 --- a/src/gcore/resources/cloud/volume_snapshots.py +++ b/src/gcore/resources/cloud/volume_snapshots.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional import httpx @@ -53,7 +53,7 @@ def create( name: str, volume_id: str, description: str | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -305,7 +305,7 @@ async def create( name: str, volume_id: str, description: str | Omit = omit, - tags: Dict[str, str] | Omit = omit, + tags: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/types/cloud/baremetal/server_create_params.py b/src/gcore/types/cloud/baremetal/server_create_params.py index 6a0d6aa9..08280551 100644 --- a/src/gcore/types/cloud/baremetal/server_create_params.py +++ b/src/gcore/types/cloud/baremetal/server_create_params.py @@ -87,7 +87,7 @@ class ServerCreateParams(TypedDict, total=False): [/v1/`ssh_keys` endpoint](/docs/api-reference/cloud/ssh-keys/add-or-generate-ssh-key). """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/file_share_create_params.py b/src/gcore/types/cloud/file_share_create_params.py index dc69d0d0..5dca72de 100644 --- a/src/gcore/types/cloud/file_share_create_params.py +++ b/src/gcore/types/cloud/file_share_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Iterable +from typing import Union, Iterable from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ @@ -37,7 +37,7 @@ class CreateStandardFileShareSerializer(TypedDict, total=False): access: Iterable[CreateStandardFileShareSerializerAccess] """Access Rules""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -94,7 +94,7 @@ class CreateVastFileShareSerializer(TypedDict, total=False): share_settings: CreateVastFileShareSerializerShareSettings """Configuration settings for the share""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/floating_ip_create_params.py b/src/gcore/types/cloud/floating_ip_create_params.py index 48cddda9..ee28a9e9 100644 --- a/src/gcore/types/cloud/floating_ip_create_params.py +++ b/src/gcore/types/cloud/floating_ip_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import TypedDict __all__ = ["FloatingIPCreateParams"] @@ -27,7 +27,7 @@ class FloatingIPCreateParams(TypedDict, total=False): If provided, the floating IP will be immediately attached to the specified port. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py b/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py index ed821b5d..d2b5284b 100644 --- a/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py +++ b/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Iterable +from typing import Union, Iterable from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ @@ -42,7 +42,7 @@ class ClusterCreateParams(TypedDict, total=False): servers_settings: Required[ServersSettings] """Configuration settings for the servers in the cluster""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py b/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py index 4cae77be..269dfd76 100644 --- a/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py +++ b/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -45,7 +45,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Permission to use a ssh key in instances""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py b/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py index 762e4879..a6b6e0b1 100644 --- a/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py +++ b/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py @@ -42,7 +42,7 @@ class ClusterCreateParams(TypedDict, total=False): servers_settings: Required[ServersSettings] """Configuration settings for the servers in the cluster""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py b/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py index 4cae77be..269dfd76 100644 --- a/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py +++ b/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -45,7 +45,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Permission to use a ssh key in instances""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instance_create_params.py b/src/gcore/types/cloud/instance_create_params.py index ee1ba080..bed6de52 100644 --- a/src/gcore/types/cloud/instance_create_params.py +++ b/src/gcore/types/cloud/instance_create_params.py @@ -114,7 +114,7 @@ class InstanceCreateParams(TypedDict, total=False): [/v1/`ssh_keys` endpoint](/docs/api-reference/cloud/ssh-keys/add-or-generate-ssh-key). """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -398,7 +398,7 @@ class VolumeCreateInstanceCreateNewVolumeSerializer(TypedDict, total=False): If not specified, a name will be generated automatically. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -459,7 +459,7 @@ class VolumeCreateInstanceCreateVolumeFromImageSerializer(TypedDict, total=False - For basic VMs: the size is set automatically based on the flavor. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -513,7 +513,7 @@ class VolumeCreateInstanceCreateVolumeFromSnapshotSerializer(TypedDict, total=Fa If not specified, a name will be generated automatically. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -559,7 +559,7 @@ class VolumeCreateInstanceCreateVolumeFromApptemplateSerializer(TypedDict, total size: int """Volume size in GiB.""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -604,7 +604,7 @@ class VolumeCreateInstanceExistingVolumeSerializer(TypedDict, total=False): delete_on_termination: bool """Set to `true` to automatically delete the volume when the instance is deleted.""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instances/image_create_from_volume_params.py b/src/gcore/types/cloud/instances/image_create_from_volume_params.py index d98e34ae..52928edb 100644 --- a/src/gcore/types/cloud/instances/image_create_from_volume_params.py +++ b/src/gcore/types/cloud/instances/image_create_from_volume_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageCreateFromVolumeParams"] @@ -40,7 +40,7 @@ class ImageCreateFromVolumeParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Whether the image supports SSH key or not""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instances/image_upload_params.py b/src/gcore/types/cloud/instances/image_upload_params.py index 4085ea54..a10d83fe 100644 --- a/src/gcore/types/cloud/instances/image_upload_params.py +++ b/src/gcore/types/cloud/instances/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -49,7 +49,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Whether the image supports SSH key or not""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/load_balancer_create_params.py b/src/gcore/types/cloud/load_balancer_create_params.py index 8d56613c..db1d053d 100644 --- a/src/gcore/types/cloud/load_balancer_create_params.py +++ b/src/gcore/types/cloud/load_balancer_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Iterable, Optional +from typing import Union, Iterable, Optional from typing_extensions import Literal, Required, TypeAlias, TypedDict from ..._types import SequenceNotStr @@ -71,7 +71,7 @@ class LoadBalancerCreateParams(TypedDict, total=False): specification. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/network_create_params.py b/src/gcore/types/cloud/network_create_params.py index b4cb5e77..935f9bc0 100644 --- a/src/gcore/types/cloud/network_create_params.py +++ b/src/gcore/types/cloud/network_create_params.py @@ -2,7 +2,6 @@ from __future__ import annotations -from typing import Dict from typing_extensions import Literal, Required, TypedDict __all__ = ["NetworkCreateParams"] @@ -21,7 +20,7 @@ class NetworkCreateParams(TypedDict, total=False): create_router: bool """Defaults to True""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/networks/subnet_create_params.py b/src/gcore/types/cloud/networks/subnet_create_params.py index 5a6b365f..41274927 100644 --- a/src/gcore/types/cloud/networks/subnet_create_params.py +++ b/src/gcore/types/cloud/networks/subnet_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Required, TypedDict from ...._types import SequenceNotStr @@ -60,7 +60,7 @@ class SubnetCreateParams(TypedDict, total=False): find a router created during network creation. """ - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/security_group_create_params.py b/src/gcore/types/cloud/security_group_create_params.py index e660dee3..d4904c5d 100644 --- a/src/gcore/types/cloud/security_group_create_params.py +++ b/src/gcore/types/cloud/security_group_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["SecurityGroupCreateParams", "Rule"] @@ -24,7 +24,7 @@ class SecurityGroupCreateParams(TypedDict, total=False): rules: Iterable[Rule] """Security group rules""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/tag.py b/src/gcore/types/cloud/tag.py index 56ac9aa0..9ee9fdba 100644 --- a/src/gcore/types/cloud/tag.py +++ b/src/gcore/types/cloud/tag.py @@ -14,10 +14,18 @@ class Tag(BaseModel): """ key: str - """Tag key. The maximum size for a key is 255 characters.""" + """Tag key. + + Maximum 255 characters. Cannot contain spaces, tabs, newlines, empty string or + '=' character. + """ read_only: bool """If true, the tag is read-only and cannot be modified by the user""" value: str - """Tag value. The maximum size for a value is 255 characters.""" + """Tag value. + + Maximum 255 characters. Cannot contain spaces, tabs, newlines, empty string or + '=' character. + """ diff --git a/src/gcore/types/cloud/tag_update_map_param.py b/src/gcore/types/cloud/tag_update_map_param.py index 6726649c..9a70575e 100644 --- a/src/gcore/types/cloud/tag_update_map_param.py +++ b/src/gcore/types/cloud/tag_update_map_param.py @@ -2,9 +2,8 @@ from __future__ import annotations -from typing import Dict, Optional from typing_extensions import TypeAlias __all__ = ["TagUpdateMapParam"] -TagUpdateMapParam: TypeAlias = Dict[str, Optional[str]] +TagUpdateMapParam: TypeAlias = object diff --git a/src/gcore/types/cloud/volume_snapshot_create_params.py b/src/gcore/types/cloud/volume_snapshot_create_params.py index b832806b..8d77c011 100644 --- a/src/gcore/types/cloud/volume_snapshot_create_params.py +++ b/src/gcore/types/cloud/volume_snapshot_create_params.py @@ -2,7 +2,6 @@ from __future__ import annotations -from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["VolumeSnapshotCreateParams"] @@ -22,7 +21,7 @@ class VolumeSnapshotCreateParams(TypedDict, total=False): description: str """Snapshot description""" - tags: Dict[str, str] + tags: object """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/tests/api_resources/cloud/gpu_baremetal/test_clusters.py b/tests/api_resources/cloud/gpu_baremetal/test_clusters.py index cd68c18a..3a47eba9 100644 --- a/tests/api_resources/cloud/gpu_baremetal/test_clusters.py +++ b/tests/api_resources/cloud/gpu_baremetal/test_clusters.py @@ -217,7 +217,7 @@ def test_method_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -228,7 +228,7 @@ def test_raw_response_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert response.is_closed is True @@ -243,7 +243,7 @@ def test_streaming_response_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -261,7 +261,7 @@ def test_path_params_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) @parametrize @@ -715,7 +715,7 @@ async def test_method_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -726,7 +726,7 @@ async def test_raw_response_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert response.is_closed is True @@ -741,7 +741,7 @@ async def test_streaming_response_action(self, async_client: AsyncGcore) -> None project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -759,7 +759,7 @@ async def test_path_params_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) @parametrize diff --git a/tests/api_resources/cloud/gpu_virtual/test_clusters.py b/tests/api_resources/cloud/gpu_virtual/test_clusters.py index 91d2ae2d..0487f803 100644 --- a/tests/api_resources/cloud/gpu_virtual/test_clusters.py +++ b/tests/api_resources/cloud/gpu_virtual/test_clusters.py @@ -507,7 +507,7 @@ def test_method_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -518,7 +518,7 @@ def test_raw_response_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert response.is_closed is True @@ -533,7 +533,7 @@ def test_streaming_response_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -551,7 +551,7 @@ def test_path_params_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) @parametrize @@ -1146,7 +1146,7 @@ async def test_method_action_overload_5(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -1157,7 +1157,7 @@ async def test_raw_response_action_overload_5(self, async_client: AsyncGcore) -> project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) assert response.is_closed is True @@ -1172,7 +1172,7 @@ async def test_streaming_response_action_overload_5(self, async_client: AsyncGco project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1190,7 +1190,7 @@ async def test_path_params_action_overload_5(self, async_client: AsyncGcore) -> project_id=1, region_id=7, action="update_tags", - tags={"foo": "my-tag-value"}, + tags={}, ) @parametrize diff --git a/tests/api_resources/cloud/instances/test_images.py b/tests/api_resources/cloud/instances/test_images.py index c30fde90..b97decb0 100644 --- a/tests/api_resources/cloud/instances/test_images.py +++ b/tests/api_resources/cloud/instances/test_images.py @@ -38,7 +38,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: name="my-image", os_type="linux", ssh_key="allow", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Image, image, path=["response"]) @@ -373,7 +373,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> name="my-image", os_type="linux", ssh_key="allow", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Image, image, path=["response"]) diff --git a/tests/api_resources/cloud/networks/test_subnets.py b/tests/api_resources/cloud/networks/test_subnets.py index 8ba4ff6f..dc315c0a 100644 --- a/tests/api_resources/cloud/networks/test_subnets.py +++ b/tests/api_resources/cloud/networks/test_subnets.py @@ -110,7 +110,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: } ], name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Subnet, subnet, path=["response"]) @@ -389,7 +389,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> } ], name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Subnet, subnet, path=["response"]) diff --git a/tests/api_resources/cloud/test_file_shares.py b/tests/api_resources/cloud/test_file_shares.py index 055e05d6..74d9a584 100644 --- a/tests/api_resources/cloud/test_file_shares.py +++ b/tests/api_resources/cloud/test_file_shares.py @@ -174,7 +174,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: "path_length": "LCD", "root_squash": True, }, - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, file_share, path=["response"]) @@ -562,7 +562,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> "path_length": "LCD", "root_squash": True, }, - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, file_share, path=["response"]) diff --git a/tests/api_resources/cloud/test_floating_ips.py b/tests/api_resources/cloud/test_floating_ips.py index 97ff5795..fda155b2 100644 --- a/tests/api_resources/cloud/test_floating_ips.py +++ b/tests/api_resources/cloud/test_floating_ips.py @@ -86,7 +86,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: region_id=1, fixed_ip_address="192.168.10.15", port_id="ee2402d0-f0cd-4503-9b75-69be1d11c5f1", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) @@ -453,7 +453,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> region_id=1, fixed_ip_address="192.168.10.15", port_id="ee2402d0-f0cd-4503-9b75-69be1d11c5f1", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) diff --git a/tests/api_resources/cloud/test_instances.py b/tests/api_resources/cloud/test_instances.py index 7b908015..d5c24486 100644 --- a/tests/api_resources/cloud/test_instances.py +++ b/tests/api_resources/cloud/test_instances.py @@ -137,7 +137,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=0, region_id=0, name="instance_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Instance, instance, path=["response"]) @@ -1007,7 +1007,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=0, region_id=0, name="instance_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Instance, instance, path=["response"]) diff --git a/tests/api_resources/cloud/test_load_balancers.py b/tests/api_resources/cloud/test_load_balancers.py index 5b30c022..75c7a421 100644 --- a/tests/api_resources/cloud/test_load_balancers.py +++ b/tests/api_resources/cloud/test_load_balancers.py @@ -185,7 +185,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: }, name="some_name", preferred_connectivity="L2", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(LoadBalancer, load_balancer, path=["response"]) @@ -659,7 +659,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> }, name="some_name", preferred_connectivity="L2", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(LoadBalancer, load_balancer, path=["response"]) diff --git a/tests/api_resources/cloud/test_networks.py b/tests/api_resources/cloud/test_networks.py index dbd1f4d0..273791bd 100644 --- a/tests/api_resources/cloud/test_networks.py +++ b/tests/api_resources/cloud/test_networks.py @@ -86,7 +86,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Network, network, path=["response"]) @@ -338,7 +338,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Network, network, path=["response"]) diff --git a/tests/api_resources/cloud/test_security_groups.py b/tests/api_resources/cloud/test_security_groups.py index 2bd9402b..6050ff4c 100644 --- a/tests/api_resources/cloud/test_security_groups.py +++ b/tests/api_resources/cloud/test_security_groups.py @@ -110,7 +110,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: "remote_ip_prefix": "10.0.0.0/8", } ], - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, security_group, path=["response"]) @@ -481,7 +481,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> "remote_ip_prefix": "10.0.0.0/8", } ], - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(TaskIDList, security_group, path=["response"]) diff --git a/tests/api_resources/cloud/test_volume_snapshots.py b/tests/api_resources/cloud/test_volume_snapshots.py index 4b2d7bfd..f4da5ed7 100644 --- a/tests/api_resources/cloud/test_volume_snapshots.py +++ b/tests/api_resources/cloud/test_volume_snapshots.py @@ -88,7 +88,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="my-backup-snapshot", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Snapshot, volume_snapshot, path=["response"]) @@ -295,7 +295,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="my-backup-snapshot", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Snapshot, volume_snapshot, path=["response"]) diff --git a/tests/api_resources/cloud/test_volumes.py b/tests/api_resources/cloud/test_volumes.py index 95d43b9f..67bd0e60 100644 --- a/tests/api_resources/cloud/test_volumes.py +++ b/tests/api_resources/cloud/test_volumes.py @@ -45,7 +45,7 @@ def test_method_create_with_all_params_overload_1(self, client: Gcore) -> None: attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -107,7 +107,7 @@ def test_method_create_with_all_params_overload_2(self, client: Gcore) -> None: instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], size=10, - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -166,7 +166,7 @@ def test_method_create_with_all_params_overload_3(self, client: Gcore) -> None: attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -219,7 +219,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Volume, volume, path=["response"]) @@ -701,7 +701,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -763,7 +763,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], size=10, - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -822,7 +822,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={"foo": "my-tag-value"}, + tags={}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -875,7 +875,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="some_name", - tags={"foo": "my-tag-value"}, + tags={}, ) assert_matches_type(Volume, volume, path=["response"]) From 079e24cd6522792e9d841a2e0f408e21e617e05e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 10:24:34 +0000 Subject: [PATCH 03/11] feat(api): aggregated API specs update --- .stats.yml | 4 +- .../resources/cloud/baremetal/servers.py | 4 +- .../cloud/file_shares/file_shares.py | 14 +- src/gcore/resources/cloud/floating_ips.py | 6 +- .../cloud/gpu_baremetal/clusters/clusters.py | 6 +- .../cloud/gpu_baremetal/clusters/images.py | 6 +- .../cloud/gpu_virtual/clusters/clusters.py | 6 +- .../cloud/gpu_virtual/clusters/images.py | 6 +- src/gcore/resources/cloud/instances/images.py | 10 +- .../resources/cloud/instances/instances.py | 4 +- .../cloud/load_balancers/load_balancers.py | 6 +- .../resources/cloud/networks/networks.py | 6 +- src/gcore/resources/cloud/networks/subnets.py | 6 +- .../cloud/security_groups/security_groups.py | 6 +- src/gcore/resources/cloud/volume_snapshots.py | 6 +- .../resources/storage/buckets/buckets.py | 100 ++++- src/gcore/resources/storage/buckets/cors.py | 70 ++- .../resources/storage/buckets/lifecycle.py | 70 ++- src/gcore/resources/storage/buckets/policy.py | 104 ++++- src/gcore/resources/storage/credentials.py | 38 +- src/gcore/resources/storage/locations.py | 34 +- src/gcore/resources/storage/storage.py | 185 ++++++-- .../cloud/baremetal/server_create_params.py | 2 +- .../types/cloud/file_share_create_params.py | 6 +- .../types/cloud/floating_ip_create_params.py | 4 +- .../gpu_baremetal/cluster_create_params.py | 4 +- .../clusters/image_upload_params.py | 4 +- .../gpu_virtual/cluster_create_params.py | 2 +- .../clusters/image_upload_params.py | 4 +- .../types/cloud/instance_create_params.py | 12 +- .../image_create_from_volume_params.py | 4 +- .../cloud/instances/image_upload_params.py | 4 +- .../cloud/load_balancer_create_params.py | 4 +- .../types/cloud/network_create_params.py | 3 +- .../cloud/networks/subnet_create_params.py | 4 +- .../cloud/security_group_create_params.py | 4 +- src/gcore/types/cloud/tag.py | 12 +- src/gcore/types/cloud/tag_update_map_param.py | 3 +- .../cloud/volume_snapshot_create_params.py | 3 +- src/gcore/types/storage/location.py | 2 +- src/gcore/types/storage/storage.py | 2 +- .../types/storage/storage_create_params.py | 6 +- .../types/storage/storage_list_params.py | 2 +- .../cloud/gpu_baremetal/test_clusters.py | 16 +- .../cloud/gpu_virtual/test_clusters.py | 16 +- .../cloud/instances/test_images.py | 4 +- .../cloud/networks/test_subnets.py | 4 +- tests/api_resources/cloud/test_file_shares.py | 4 +- .../api_resources/cloud/test_floating_ips.py | 4 +- tests/api_resources/cloud/test_instances.py | 4 +- .../cloud/test_load_balancers.py | 4 +- tests/api_resources/cloud/test_networks.py | 4 +- .../cloud/test_security_groups.py | 4 +- .../cloud/test_volume_snapshots.py | 4 +- tests/api_resources/cloud/test_volumes.py | 16 +- .../storage/buckets/test_cors.py | 214 +++++---- .../storage/buckets/test_lifecycle.py | 214 +++++---- .../storage/buckets/test_policy.py | 284 ++++++------ tests/api_resources/storage/test_buckets.py | 274 +++++++----- .../api_resources/storage/test_credentials.py | 100 +++-- tests/api_resources/storage/test_locations.py | 58 ++- tests/api_resources/test_storage.py | 416 ++++++++++-------- 62 files changed, 1466 insertions(+), 966 deletions(-) diff --git a/.stats.yml b/.stats.yml index 54d04e2d..a290a331 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-30f92b095e6f90731f4e7652affc69f27c57849dccf30119b79c26314aa2ae00.yml -openapi_spec_hash: 2348a329bec98d05bf5e4c109d300382 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-247700eb0839f11fe995398e8b8160e264107a22a6d8a783628f070ef9888cee.yml +openapi_spec_hash: 05ee580780bc68d0c339faad61915b9b config_hash: bc578a7de14c42e33b7d4bd4502218f2 diff --git a/src/gcore/resources/cloud/baremetal/servers.py b/src/gcore/resources/cloud/baremetal/servers.py index 1b5c725d..ae77f521 100644 --- a/src/gcore/resources/cloud/baremetal/servers.py +++ b/src/gcore/resources/cloud/baremetal/servers.py @@ -62,7 +62,7 @@ def create( name_template: str | Omit = omit, password: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -554,7 +554,7 @@ async def create( name_template: str | Omit = omit, password: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/gcore/resources/cloud/file_shares/file_shares.py b/src/gcore/resources/cloud/file_shares/file_shares.py index 19e36c97..7b5cdea2 100644 --- a/src/gcore/resources/cloud/file_shares/file_shares.py +++ b/src/gcore/resources/cloud/file_shares/file_shares.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Literal, overload import httpx @@ -75,7 +75,7 @@ def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["standard"] | Omit = omit, volume_type: Literal["default_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,7 +134,7 @@ def create( protocol: Literal["NFS"], size: int, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["vast"] | Omit = omit, volume_type: Literal["vast_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -192,7 +192,7 @@ def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["standard"] | Literal["vast"] | Omit = omit, volume_type: Literal["default_share_type"] | Literal["vast_share_type"] | Omit = omit, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, @@ -600,7 +600,7 @@ async def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["standard"] | Omit = omit, volume_type: Literal["default_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -659,7 +659,7 @@ async def create( protocol: Literal["NFS"], size: int, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["vast"] | Omit = omit, volume_type: Literal["vast_share_type"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -717,7 +717,7 @@ async def create( protocol: Literal["NFS"], size: int, access: Iterable[file_share_create_params.CreateStandardFileShareSerializerAccess] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type_name: Literal["standard"] | Literal["vast"] | Omit = omit, volume_type: Literal["default_share_type"] | Literal["vast_share_type"] | Omit = omit, share_settings: file_share_create_params.CreateVastFileShareSerializerShareSettings | Omit = omit, diff --git a/src/gcore/resources/cloud/floating_ips.py b/src/gcore/resources/cloud/floating_ips.py index fd677c44..f3b95468 100644 --- a/src/gcore/resources/cloud/floating_ips.py +++ b/src/gcore/resources/cloud/floating_ips.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing_extensions -from typing import Optional +from typing import Dict, Optional import httpx @@ -67,7 +67,7 @@ def create( region_id: int | None = None, fixed_ip_address: Optional[str] | Omit = omit, port_id: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -690,7 +690,7 @@ async def create( region_id: int | None = None, fixed_ip_address: Optional[str] | Omit = omit, port_id: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py b/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py index 7385e2c8..adfb58cb 100644 --- a/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py +++ b/src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Optional +from typing import Dict, List, Optional from typing_extensions import Literal import httpx @@ -113,7 +113,7 @@ def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -830,7 +830,7 @@ async def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py b/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py index e73c4468..dee06b23 100644 --- a/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py +++ b/src/gcore/resources/cloud/gpu_baremetal/clusters/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal import httpx @@ -228,7 +228,7 @@ def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -576,7 +576,7 @@ async def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py b/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py index 8fe0de91..486048b5 100644 --- a/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py +++ b/src/gcore/resources/cloud/gpu_virtual/clusters/clusters.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal, overload import httpx @@ -122,7 +122,7 @@ def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -767,7 +767,7 @@ async def create( name: str, servers_count: int, servers_settings: cluster_create_params.ServersSettings, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/gpu_virtual/clusters/images.py b/src/gcore/resources/cloud/gpu_virtual/clusters/images.py index d83f68fa..9c7d1472 100644 --- a/src/gcore/resources/cloud/gpu_virtual/clusters/images.py +++ b/src/gcore/resources/cloud/gpu_virtual/clusters/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal import httpx @@ -190,7 +190,7 @@ def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -432,7 +432,7 @@ async def upload( os_type: Optional[Literal["linux", "windows"]] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/instances/images.py b/src/gcore/resources/cloud/instances/images.py index 9b5fb71e..8737a631 100644 --- a/src/gcore/resources/cloud/instances/images.py +++ b/src/gcore/resources/cloud/instances/images.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal import httpx @@ -288,7 +288,7 @@ def create_from_volume( os_type: Literal["linux", "windows"] | Omit = omit, source: Literal["volume"] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -486,7 +486,7 @@ def upload( os_type: Literal["linux", "windows"] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -889,7 +889,7 @@ async def create_from_volume( os_type: Literal["linux", "windows"] | Omit = omit, source: Literal["volume"] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1087,7 +1087,7 @@ async def upload( os_type: Literal["linux", "windows"] | Omit = omit, os_version: Optional[str] | Omit = omit, ssh_key: Literal["allow", "deny", "required"] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/instances/instances.py b/src/gcore/resources/cloud/instances/instances.py index 499f1006..2c83bbae 100644 --- a/src/gcore/resources/cloud/instances/instances.py +++ b/src/gcore/resources/cloud/instances/instances.py @@ -125,7 +125,7 @@ def create( security_groups: Iterable[instance_create_params.SecurityGroup] | Omit = omit, servergroup_id: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1544,7 +1544,7 @@ async def create( security_groups: Iterable[instance_create_params.SecurityGroup] | Omit = omit, servergroup_id: str | Omit = omit, ssh_key_name: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, user_data: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/gcore/resources/cloud/load_balancers/load_balancers.py b/src/gcore/resources/cloud/load_balancers/load_balancers.py index cc52a7b9..54c7ef99 100644 --- a/src/gcore/resources/cloud/load_balancers/load_balancers.py +++ b/src/gcore/resources/cloud/load_balancers/load_balancers.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing_extensions -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Literal import httpx @@ -143,7 +143,7 @@ def create( name: str | Omit = omit, name_template: str | Omit = omit, preferred_connectivity: LoadBalancerMemberConnectivity | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, vip_ip_family: InterfaceIPFamily | Omit = omit, vip_network_id: str | Omit = omit, vip_port_id: str | Omit = omit, @@ -895,7 +895,7 @@ async def create( name: str | Omit = omit, name_template: str | Omit = omit, preferred_connectivity: LoadBalancerMemberConnectivity | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, vip_ip_family: InterfaceIPFamily | Omit = omit, vip_network_id: str | Omit = omit, vip_port_id: str | Omit = omit, diff --git a/src/gcore/resources/cloud/networks/networks.py b/src/gcore/resources/cloud/networks/networks.py index 08940886..847a36da 100644 --- a/src/gcore/resources/cloud/networks/networks.py +++ b/src/gcore/resources/cloud/networks/networks.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal import httpx @@ -78,7 +78,7 @@ def create( region_id: int | None = None, name: str, create_router: bool | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type: Literal["vlan", "vxlan"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -505,7 +505,7 @@ async def create( region_id: int | None = None, name: str, create_router: bool | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, type: Literal["vlan", "vxlan"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. diff --git a/src/gcore/resources/cloud/networks/subnets.py b/src/gcore/resources/cloud/networks/subnets.py index e53fe98a..1ca16f53 100644 --- a/src/gcore/resources/cloud/networks/subnets.py +++ b/src/gcore/resources/cloud/networks/subnets.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Literal import httpx @@ -64,7 +64,7 @@ def create( host_routes: Optional[Iterable[subnet_create_params.HostRoute]] | Omit = omit, ip_version: IPVersion | Omit = omit, router_id_to_connect: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -524,7 +524,7 @@ async def create( host_routes: Optional[Iterable[subnet_create_params.HostRoute]] | Omit = omit, ip_version: IPVersion | Omit = omit, router_id_to_connect: Optional[str] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/security_groups/security_groups.py b/src/gcore/resources/cloud/security_groups/security_groups.py index 0e3ecfeb..52b209e1 100644 --- a/src/gcore/resources/cloud/security_groups/security_groups.py +++ b/src/gcore/resources/cloud/security_groups/security_groups.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional import httpx @@ -71,7 +71,7 @@ def create( name: str, description: str | Omit = omit, rules: Iterable[security_group_create_params.Rule] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -629,7 +629,7 @@ async def create( name: str, description: str | Omit = omit, rules: Iterable[security_group_create_params.Rule] | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/cloud/volume_snapshots.py b/src/gcore/resources/cloud/volume_snapshots.py index 52dc4971..a8b6850a 100644 --- a/src/gcore/resources/cloud/volume_snapshots.py +++ b/src/gcore/resources/cloud/volume_snapshots.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional import httpx @@ -53,7 +53,7 @@ def create( name: str, volume_id: str, description: str | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -305,7 +305,7 @@ async def create( name: str, volume_id: str, description: str | Omit = omit, - tags: object | Omit = omit, + tags: Dict[str, str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/gcore/resources/storage/buckets/buckets.py b/src/gcore/resources/storage/buckets/buckets.py index e6c589fa..5f89b36d 100644 --- a/src/gcore/resources/storage/buckets/buckets.py +++ b/src/gcore/resources/storage/buckets/buckets.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from .cors import ( @@ -78,6 +80,7 @@ def with_streaming_response(self) -> BucketsResourceWithStreamingResponse: """ return BucketsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def create( self, bucket_name: str, @@ -95,6 +98,9 @@ def create( Only applicable to S3-compatible storages. + Deprecated: Use POST /provisioning/v3/storages/{`storage_id`}/buckets with + {"name": "bucket-name"} instead. + Args: extra_headers: Send extra headers @@ -115,6 +121,7 @@ def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def list( self, storage_id: int, @@ -134,6 +141,10 @@ def list( Response format: count: total number of buckets (independent of pagination) results: current page of buckets according to limit/offset + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} for individual + bucket details instead. + Args: limit: Max number of records in response @@ -166,6 +177,7 @@ def list( model=Bucket, ) + @typing_extensions.deprecated("deprecated") def delete( self, bucket_name: str, @@ -183,6 +195,9 @@ def delete( All objects in the bucket will be automatically deleted before the bucket is removed. + Deprecated: Use DELETE + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead. + Args: extra_headers: Send extra headers @@ -236,6 +251,7 @@ def with_streaming_response(self) -> AsyncBucketsResourceWithStreamingResponse: """ return AsyncBucketsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def create( self, bucket_name: str, @@ -253,6 +269,9 @@ async def create( Only applicable to S3-compatible storages. + Deprecated: Use POST /provisioning/v3/storages/{`storage_id`}/buckets with + {"name": "bucket-name"} instead. + Args: extra_headers: Send extra headers @@ -273,6 +292,7 @@ async def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def list( self, storage_id: int, @@ -292,6 +312,10 @@ def list( Response format: count: total number of buckets (independent of pagination) results: current page of buckets according to limit/offset + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} for individual + bucket details instead. + Args: limit: Max number of records in response @@ -324,6 +348,7 @@ def list( model=Bucket, ) + @typing_extensions.deprecated("deprecated") async def delete( self, bucket_name: str, @@ -341,6 +366,9 @@ async def delete( All objects in the bucket will be automatically deleted before the bucket is removed. + Deprecated: Use DELETE + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead. + Args: extra_headers: Send extra headers @@ -366,14 +394,20 @@ class BucketsResourceWithRawResponse: def __init__(self, buckets: BucketsResource) -> None: self._buckets = buckets - self.create = to_raw_response_wrapper( - buckets.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + buckets.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - buckets.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + buckets.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - buckets.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + buckets.delete, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -393,14 +427,20 @@ class AsyncBucketsResourceWithRawResponse: def __init__(self, buckets: AsyncBucketsResource) -> None: self._buckets = buckets - self.create = async_to_raw_response_wrapper( - buckets.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + buckets.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - buckets.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + buckets.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - buckets.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + buckets.delete, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -420,14 +460,20 @@ class BucketsResourceWithStreamingResponse: def __init__(self, buckets: BucketsResource) -> None: self._buckets = buckets - self.create = to_streamed_response_wrapper( - buckets.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + buckets.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - buckets.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + buckets.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - buckets.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + buckets.delete, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -447,14 +493,20 @@ class AsyncBucketsResourceWithStreamingResponse: def __init__(self, buckets: AsyncBucketsResource) -> None: self._buckets = buckets - self.create = async_to_streamed_response_wrapper( - buckets.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + buckets.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_streamed_response_wrapper( - buckets.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + buckets.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - buckets.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + buckets.delete, # pyright: ignore[reportDeprecated], + ) ) @cached_property diff --git a/src/gcore/resources/storage/buckets/cors.py b/src/gcore/resources/storage/buckets/cors.py index 77a3e045..d1983698 100644 --- a/src/gcore/resources/storage/buckets/cors.py +++ b/src/gcore/resources/storage/buckets/cors.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given @@ -41,6 +43,7 @@ def with_streaming_response(self) -> CorsResourceWithStreamingResponse: """ return CorsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def create( self, bucket_name: str, @@ -59,6 +62,10 @@ def create( web applications from specified domains to access bucket resources directly from browsers. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"cors": + {"allowed_origins": [...]}} instead. + Args: allowed_origins: List of allowed origins for CORS requests @@ -82,6 +89,7 @@ def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def get( self, bucket_name: str, @@ -99,6 +107,10 @@ def get( S3 bucket, showing which domains are allowed to access the bucket from web browsers. + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead, which + returns CORS along with policy and lifecycle configuration. + Args: extra_headers: Send extra headers @@ -139,6 +151,7 @@ def with_streaming_response(self) -> AsyncCorsResourceWithStreamingResponse: """ return AsyncCorsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def create( self, bucket_name: str, @@ -157,6 +170,10 @@ async def create( web applications from specified domains to access bucket resources directly from browsers. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"cors": + {"allowed_origins": [...]}} instead. + Args: allowed_origins: List of allowed origins for CORS requests @@ -180,6 +197,7 @@ async def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") async def get( self, bucket_name: str, @@ -197,6 +215,10 @@ async def get( S3 bucket, showing which domains are allowed to access the bucket from web browsers. + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead, which + returns CORS along with policy and lifecycle configuration. + Args: extra_headers: Send extra headers @@ -221,11 +243,15 @@ class CorsResourceWithRawResponse: def __init__(self, cors: CorsResource) -> None: self._cors = cors - self.create = to_raw_response_wrapper( - cors.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + cors.create, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - cors.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + cors.get, # pyright: ignore[reportDeprecated], + ) ) @@ -233,11 +259,15 @@ class AsyncCorsResourceWithRawResponse: def __init__(self, cors: AsyncCorsResource) -> None: self._cors = cors - self.create = async_to_raw_response_wrapper( - cors.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + cors.create, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - cors.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + cors.get, # pyright: ignore[reportDeprecated], + ) ) @@ -245,11 +275,15 @@ class CorsResourceWithStreamingResponse: def __init__(self, cors: CorsResource) -> None: self._cors = cors - self.create = to_streamed_response_wrapper( - cors.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + cors.create, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - cors.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + cors.get, # pyright: ignore[reportDeprecated], + ) ) @@ -257,9 +291,13 @@ class AsyncCorsResourceWithStreamingResponse: def __init__(self, cors: AsyncCorsResource) -> None: self._cors = cors - self.create = async_to_streamed_response_wrapper( - cors.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + cors.create, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - cors.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + cors.get, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/gcore/resources/storage/buckets/lifecycle.py b/src/gcore/resources/storage/buckets/lifecycle.py index b80dffaf..af2c7aec 100644 --- a/src/gcore/resources/storage/buckets/lifecycle.py +++ b/src/gcore/resources/storage/buckets/lifecycle.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given @@ -40,6 +42,7 @@ def with_streaming_response(self) -> LifecycleResourceWithStreamingResponse: """ return LifecycleResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def create( self, bucket_name: str, @@ -61,6 +64,10 @@ def create( rule to the entire bucket - all existing and future objects will be subject to the expiration policy. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with + {"lifecycle": {"expiration_days": N}} instead. + Args: expiration_days: Number of days after which objects will be automatically deleted from the bucket. Must be a positive integer. Common values: 30 for monthly cleanup, 365 @@ -86,6 +93,7 @@ def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def delete( self, bucket_name: str, @@ -102,6 +110,10 @@ def delete( Removes all lifecycle rules from an S3 bucket, disabling automatic object expiration. Objects will no longer be automatically deleted based on age. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with + {"lifecycle": {"expiration_days": null}} instead. + Args: extra_headers: Send extra headers @@ -143,6 +155,7 @@ def with_streaming_response(self) -> AsyncLifecycleResourceWithStreamingResponse """ return AsyncLifecycleResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def create( self, bucket_name: str, @@ -164,6 +177,10 @@ async def create( rule to the entire bucket - all existing and future objects will be subject to the expiration policy. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with + {"lifecycle": {"expiration_days": N}} instead. + Args: expiration_days: Number of days after which objects will be automatically deleted from the bucket. Must be a positive integer. Common values: 30 for monthly cleanup, 365 @@ -191,6 +208,7 @@ async def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") async def delete( self, bucket_name: str, @@ -207,6 +225,10 @@ async def delete( Removes all lifecycle rules from an S3 bucket, disabling automatic object expiration. Objects will no longer be automatically deleted based on age. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with + {"lifecycle": {"expiration_days": null}} instead. + Args: extra_headers: Send extra headers @@ -232,11 +254,15 @@ class LifecycleResourceWithRawResponse: def __init__(self, lifecycle: LifecycleResource) -> None: self._lifecycle = lifecycle - self.create = to_raw_response_wrapper( - lifecycle.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + lifecycle.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - lifecycle.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + lifecycle.delete, # pyright: ignore[reportDeprecated], + ) ) @@ -244,11 +270,15 @@ class AsyncLifecycleResourceWithRawResponse: def __init__(self, lifecycle: AsyncLifecycleResource) -> None: self._lifecycle = lifecycle - self.create = async_to_raw_response_wrapper( - lifecycle.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + lifecycle.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - lifecycle.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + lifecycle.delete, # pyright: ignore[reportDeprecated], + ) ) @@ -256,11 +286,15 @@ class LifecycleResourceWithStreamingResponse: def __init__(self, lifecycle: LifecycleResource) -> None: self._lifecycle = lifecycle - self.create = to_streamed_response_wrapper( - lifecycle.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + lifecycle.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - lifecycle.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + lifecycle.delete, # pyright: ignore[reportDeprecated], + ) ) @@ -268,9 +302,13 @@ class AsyncLifecycleResourceWithStreamingResponse: def __init__(self, lifecycle: AsyncLifecycleResource) -> None: self._lifecycle = lifecycle - self.create = async_to_streamed_response_wrapper( - lifecycle.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + lifecycle.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - lifecycle.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + lifecycle.delete, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/gcore/resources/storage/buckets/policy.py b/src/gcore/resources/storage/buckets/policy.py index cca549f9..d44b173c 100644 --- a/src/gcore/resources/storage/buckets/policy.py +++ b/src/gcore/resources/storage/buckets/policy.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from ...._types import Body, Query, Headers, NoneType, NotGiven, not_given @@ -39,6 +41,7 @@ def with_streaming_response(self) -> PolicyResourceWithStreamingResponse: """ return PolicyResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def create( self, bucket_name: str, @@ -58,6 +61,10 @@ def create( integration. Only grants read access - users cannot upload, modify, or delete objects without proper authentication. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"policy": + {"public": true}} instead. + Args: extra_headers: Send extra headers @@ -78,6 +85,7 @@ def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def delete( self, bucket_name: str, @@ -96,6 +104,10 @@ def delete( anonymous users will no longer be able to access bucket contents via HTTP requests. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"policy": + {"public": false}} instead. + Args: extra_headers: Send extra headers @@ -116,6 +128,7 @@ def delete( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def get( self, bucket_name: str, @@ -132,6 +145,10 @@ def get( Returns whether the S3 bucket is currently configured for public read access. Shows if anonymous users can download objects from the bucket via HTTP requests. + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead, which + returns policy status along with CORS and lifecycle configuration. + Args: extra_headers: Send extra headers @@ -172,6 +189,7 @@ def with_streaming_response(self) -> AsyncPolicyResourceWithStreamingResponse: """ return AsyncPolicyResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def create( self, bucket_name: str, @@ -191,6 +209,10 @@ async def create( integration. Only grants read access - users cannot upload, modify, or delete objects without proper authentication. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"policy": + {"public": true}} instead. + Args: extra_headers: Send extra headers @@ -211,6 +233,7 @@ async def create( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") async def delete( self, bucket_name: str, @@ -229,6 +252,10 @@ async def delete( anonymous users will no longer be able to access bucket contents via HTTP requests. + Deprecated: Use PATCH + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} with {"policy": + {"public": false}} instead. + Args: extra_headers: Send extra headers @@ -249,6 +276,7 @@ async def delete( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") async def get( self, bucket_name: str, @@ -265,6 +293,10 @@ async def get( Returns whether the S3 bucket is currently configured for public read access. Shows if anonymous users can download objects from the bucket via HTTP requests. + Deprecated: Use GET + /provisioning/v3/storages/{`storage_id`}/buckets/{`bucket_name`} instead, which + returns policy status along with CORS and lifecycle configuration. + Args: extra_headers: Send extra headers @@ -289,14 +321,20 @@ class PolicyResourceWithRawResponse: def __init__(self, policy: PolicyResource) -> None: self._policy = policy - self.create = to_raw_response_wrapper( - policy.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + policy.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - policy.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + policy.delete, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - policy.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + policy.get, # pyright: ignore[reportDeprecated], + ) ) @@ -304,14 +342,20 @@ class AsyncPolicyResourceWithRawResponse: def __init__(self, policy: AsyncPolicyResource) -> None: self._policy = policy - self.create = async_to_raw_response_wrapper( - policy.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + policy.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - policy.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + policy.delete, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - policy.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + policy.get, # pyright: ignore[reportDeprecated], + ) ) @@ -319,14 +363,20 @@ class PolicyResourceWithStreamingResponse: def __init__(self, policy: PolicyResource) -> None: self._policy = policy - self.create = to_streamed_response_wrapper( - policy.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + policy.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - policy.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + policy.delete, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - policy.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + policy.get, # pyright: ignore[reportDeprecated], + ) ) @@ -334,12 +384,18 @@ class AsyncPolicyResourceWithStreamingResponse: def __init__(self, policy: AsyncPolicyResource) -> None: self._policy = policy - self.create = async_to_streamed_response_wrapper( - policy.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + policy.create, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - policy.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + policy.delete, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - policy.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + policy.get, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/gcore/resources/storage/credentials.py b/src/gcore/resources/storage/credentials.py index 616afdb8..2b317f6f 100644 --- a/src/gcore/resources/storage/credentials.py +++ b/src/gcore/resources/storage/credentials.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given @@ -41,6 +43,7 @@ def with_streaming_response(self) -> CredentialsResourceWithStreamingResponse: """ return CredentialsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def recreate( self, storage_id: int, @@ -61,6 +64,11 @@ def recreate( Generates new access credentials for the storage (S3 keys for S3 storage, SFTP password for SFTP storage). + Deprecated: Use POST + /provisioning/v3/storages/`s3_compatible`/{`storage_id`}/credentials/reset for + S3 storage or PATCH /provisioning/v3/storages/sftp/{`storage_id`}/credentials + for SFTP storage instead. + Args: extra_headers: Send extra headers @@ -109,6 +117,7 @@ def with_streaming_response(self) -> AsyncCredentialsResourceWithStreamingRespon """ return AsyncCredentialsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def recreate( self, storage_id: int, @@ -129,6 +138,11 @@ async def recreate( Generates new access credentials for the storage (S3 keys for S3 storage, SFTP password for SFTP storage). + Deprecated: Use POST + /provisioning/v3/storages/`s3_compatible`/{`storage_id`}/credentials/reset for + S3 storage or PATCH /provisioning/v3/storages/sftp/{`storage_id`}/credentials + for SFTP storage instead. + Args: extra_headers: Send extra headers @@ -161,8 +175,10 @@ class CredentialsResourceWithRawResponse: def __init__(self, credentials: CredentialsResource) -> None: self._credentials = credentials - self.recreate = to_raw_response_wrapper( - credentials.recreate, + self.recreate = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + credentials.recreate, # pyright: ignore[reportDeprecated], + ) ) @@ -170,8 +186,10 @@ class AsyncCredentialsResourceWithRawResponse: def __init__(self, credentials: AsyncCredentialsResource) -> None: self._credentials = credentials - self.recreate = async_to_raw_response_wrapper( - credentials.recreate, + self.recreate = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + credentials.recreate, # pyright: ignore[reportDeprecated], + ) ) @@ -179,8 +197,10 @@ class CredentialsResourceWithStreamingResponse: def __init__(self, credentials: CredentialsResource) -> None: self._credentials = credentials - self.recreate = to_streamed_response_wrapper( - credentials.recreate, + self.recreate = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + credentials.recreate, # pyright: ignore[reportDeprecated], + ) ) @@ -188,6 +208,8 @@ class AsyncCredentialsResourceWithStreamingResponse: def __init__(self, credentials: AsyncCredentialsResource) -> None: self._credentials = credentials - self.recreate = async_to_streamed_response_wrapper( - credentials.recreate, + self.recreate = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + credentials.recreate, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/gcore/resources/storage/locations.py b/src/gcore/resources/storage/locations.py index bce1aa37..10cee722 100644 --- a/src/gcore/resources/storage/locations.py +++ b/src/gcore/resources/storage/locations.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing_extensions + import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given @@ -42,6 +44,7 @@ def with_streaming_response(self) -> LocationsResourceWithStreamingResponse: """ return LocationsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def list( self, *, @@ -57,7 +60,8 @@ def list( """Returns available storage locations where you can create storages. Each location - represents a geographic region with specific data center facilities. + represents a geographic region with specific data center facilities. Deprecated, + use GET /provisioning/v3/locations instead. Args: extra_headers: Send extra headers @@ -108,6 +112,7 @@ def with_streaming_response(self) -> AsyncLocationsResourceWithStreamingResponse """ return AsyncLocationsResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def list( self, *, @@ -123,7 +128,8 @@ def list( """Returns available storage locations where you can create storages. Each location - represents a geographic region with specific data center facilities. + represents a geographic region with specific data center facilities. Deprecated, + use GET /provisioning/v3/locations instead. Args: extra_headers: Send extra headers @@ -158,8 +164,10 @@ class LocationsResourceWithRawResponse: def __init__(self, locations: LocationsResource) -> None: self._locations = locations - self.list = to_raw_response_wrapper( - locations.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + locations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -167,8 +175,10 @@ class AsyncLocationsResourceWithRawResponse: def __init__(self, locations: AsyncLocationsResource) -> None: self._locations = locations - self.list = async_to_raw_response_wrapper( - locations.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + locations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -176,8 +186,10 @@ class LocationsResourceWithStreamingResponse: def __init__(self, locations: LocationsResource) -> None: self._locations = locations - self.list = to_streamed_response_wrapper( - locations.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + locations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -185,6 +197,8 @@ class AsyncLocationsResourceWithStreamingResponse: def __init__(self, locations: AsyncLocationsResource) -> None: self._locations = locations - self.list = async_to_streamed_response_wrapper( - locations.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + locations.list, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/gcore/resources/storage/storage.py b/src/gcore/resources/storage/storage.py index afc3922f..41b6edb5 100644 --- a/src/gcore/resources/storage/storage.py +++ b/src/gcore/resources/storage/storage.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing_extensions import Literal import httpx @@ -92,12 +93,13 @@ def with_streaming_response(self) -> StorageResourceWithStreamingResponse: """ return StorageResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def create( self, *, location: str, name: str, - type: Literal["sftp", "s3"], + type: Literal["sftp", "s3_compatible"], generate_sftp_password: bool | Omit = omit, sftp_password: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -111,6 +113,9 @@ def create( Creates a new storage instance (S3 or SFTP) in the specified location and returns the storage details including credentials. + Deprecated: Use POST /provisioning/v3/storages/`s3_compatible` for S3 storage or + POST /provisioning/v3/storages/sftp for SFTP storage instead. + Args: location: Geographic location where the storage will be provisioned. Each location represents a specific data center region. @@ -118,8 +123,8 @@ def create( name: Unique storage name identifier. Must contain only letters, numbers, dashes, and underscores. Cannot be empty and must be less than 256 characters. - type: Storage protocol type. Choose 's3' for S3-compatible object storage with API - access, or `sftp` for SFTP file transfer protocol. + type: Storage protocol type. Choose 's3_compatible' for S3-compatible object storage + with API access, or `sftp` for SFTP file transfer protocol. generate_sftp_password: Automatically generate a secure password for SFTP storage access. Only applicable when type is `sftp`. When `true`, a random password will be generated @@ -155,6 +160,7 @@ def create( cast_to=Storage, ) + @typing_extensions.deprecated("deprecated") def update( self, storage_id: int, @@ -173,6 +179,9 @@ def update( Used for SFTP storages. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} for SFTP + storage updates instead. + Args: expires: Duration when the storage should expire in format like "1 years 6 months 2 weeks 3 days 5 hours 10 minutes 15 seconds". Set empty to remove expiration. @@ -214,7 +223,7 @@ def list( order_direction: Literal["asc", "desc"] | Omit = omit, show_deleted: bool | Omit = omit, status: Literal["active", "suspended", "deleted", "pending"] | Omit = omit, - type: Literal["s3", "sftp"] | Omit = omit, + type: Literal["s3_compatible", "sftp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -286,6 +295,7 @@ def list( model=Storage, ) + @typing_extensions.deprecated("deprecated") def delete( self, storage_id: int, @@ -301,6 +311,9 @@ def delete( This action cannot be undone. + Deprecated: Use DELETE /provisioning/v3/storages/`s3_compatible`/{`storage_id`} + or DELETE /provisioning/v3/storages/sftp/{`storage_id`} instead. + Args: extra_headers: Send extra headers @@ -351,6 +364,7 @@ def get( cast_to=Storage, ) + @typing_extensions.deprecated("deprecated") def link_ssh_key( self, key_id: int, @@ -368,6 +382,11 @@ def link_ssh_key( authentication. Only works with SFTP storage types - not applicable to S3-compatible storage. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} with + `ssh_key_ids` array or PATCH + /provisioning/v3/storages/sftp/{`storage_id`}/credentials with `ssh_key_ids` + array instead. + Args: extra_headers: Send extra headers @@ -424,6 +443,7 @@ def restore( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") def unlink_ssh_key( self, key_id: int, @@ -441,6 +461,11 @@ def unlink_ssh_key( authentication for that key. The key itself remains available for other storages. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} with + `ssh_key_ids` array or PATCH + /provisioning/v3/storages/sftp/{`storage_id`}/credentials with `ssh_key_ids` + array instead. + Args: extra_headers: Send extra headers @@ -496,12 +521,13 @@ def with_streaming_response(self) -> AsyncStorageResourceWithStreamingResponse: """ return AsyncStorageResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def create( self, *, location: str, name: str, - type: Literal["sftp", "s3"], + type: Literal["sftp", "s3_compatible"], generate_sftp_password: bool | Omit = omit, sftp_password: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -515,6 +541,9 @@ async def create( Creates a new storage instance (S3 or SFTP) in the specified location and returns the storage details including credentials. + Deprecated: Use POST /provisioning/v3/storages/`s3_compatible` for S3 storage or + POST /provisioning/v3/storages/sftp for SFTP storage instead. + Args: location: Geographic location where the storage will be provisioned. Each location represents a specific data center region. @@ -522,8 +551,8 @@ async def create( name: Unique storage name identifier. Must contain only letters, numbers, dashes, and underscores. Cannot be empty and must be less than 256 characters. - type: Storage protocol type. Choose 's3' for S3-compatible object storage with API - access, or `sftp` for SFTP file transfer protocol. + type: Storage protocol type. Choose 's3_compatible' for S3-compatible object storage + with API access, or `sftp` for SFTP file transfer protocol. generate_sftp_password: Automatically generate a secure password for SFTP storage access. Only applicable when type is `sftp`. When `true`, a random password will be generated @@ -559,6 +588,7 @@ async def create( cast_to=Storage, ) + @typing_extensions.deprecated("deprecated") async def update( self, storage_id: int, @@ -577,6 +607,9 @@ async def update( Used for SFTP storages. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} for SFTP + storage updates instead. + Args: expires: Duration when the storage should expire in format like "1 years 6 months 2 weeks 3 days 5 hours 10 minutes 15 seconds". Set empty to remove expiration. @@ -618,7 +651,7 @@ def list( order_direction: Literal["asc", "desc"] | Omit = omit, show_deleted: bool | Omit = omit, status: Literal["active", "suspended", "deleted", "pending"] | Omit = omit, - type: Literal["s3", "sftp"] | Omit = omit, + type: Literal["s3_compatible", "sftp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -690,6 +723,7 @@ def list( model=Storage, ) + @typing_extensions.deprecated("deprecated") async def delete( self, storage_id: int, @@ -705,6 +739,9 @@ async def delete( This action cannot be undone. + Deprecated: Use DELETE /provisioning/v3/storages/`s3_compatible`/{`storage_id`} + or DELETE /provisioning/v3/storages/sftp/{`storage_id`} instead. + Args: extra_headers: Send extra headers @@ -755,6 +792,7 @@ async def get( cast_to=Storage, ) + @typing_extensions.deprecated("deprecated") async def link_ssh_key( self, key_id: int, @@ -772,6 +810,11 @@ async def link_ssh_key( authentication. Only works with SFTP storage types - not applicable to S3-compatible storage. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} with + `ssh_key_ids` array or PATCH + /provisioning/v3/storages/sftp/{`storage_id`}/credentials with `ssh_key_ids` + array instead. + Args: extra_headers: Send extra headers @@ -830,6 +873,7 @@ async def restore( cast_to=NoneType, ) + @typing_extensions.deprecated("deprecated") async def unlink_ssh_key( self, key_id: int, @@ -847,6 +891,11 @@ async def unlink_ssh_key( authentication for that key. The key itself remains available for other storages. + Deprecated: Use PATCH /provisioning/v3/storages/sftp/{`storage_id`} with + `ssh_key_ids` array or PATCH + /provisioning/v3/storages/sftp/{`storage_id`}/credentials with `ssh_key_ids` + array instead. + Args: extra_headers: Send extra headers @@ -870,29 +919,39 @@ class StorageResourceWithRawResponse: def __init__(self, storage: StorageResource) -> None: self._storage = storage - self.create = to_raw_response_wrapper( - storage.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + storage.create, # pyright: ignore[reportDeprecated], + ) ) - self.update = to_raw_response_wrapper( - storage.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + storage.update, # pyright: ignore[reportDeprecated], + ) ) self.list = to_raw_response_wrapper( storage.list, ) - self.delete = to_raw_response_wrapper( - storage.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + storage.delete, # pyright: ignore[reportDeprecated], + ) ) self.get = to_raw_response_wrapper( storage.get, ) - self.link_ssh_key = to_raw_response_wrapper( - storage.link_ssh_key, + self.link_ssh_key = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + storage.link_ssh_key, # pyright: ignore[reportDeprecated], + ) ) self.restore = to_raw_response_wrapper( storage.restore, ) - self.unlink_ssh_key = to_raw_response_wrapper( - storage.unlink_ssh_key, + self.unlink_ssh_key = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + storage.unlink_ssh_key, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -916,29 +975,39 @@ class AsyncStorageResourceWithRawResponse: def __init__(self, storage: AsyncStorageResource) -> None: self._storage = storage - self.create = async_to_raw_response_wrapper( - storage.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + storage.create, # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_raw_response_wrapper( - storage.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + storage.update, # pyright: ignore[reportDeprecated], + ) ) self.list = async_to_raw_response_wrapper( storage.list, ) - self.delete = async_to_raw_response_wrapper( - storage.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + storage.delete, # pyright: ignore[reportDeprecated], + ) ) self.get = async_to_raw_response_wrapper( storage.get, ) - self.link_ssh_key = async_to_raw_response_wrapper( - storage.link_ssh_key, + self.link_ssh_key = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + storage.link_ssh_key, # pyright: ignore[reportDeprecated], + ) ) self.restore = async_to_raw_response_wrapper( storage.restore, ) - self.unlink_ssh_key = async_to_raw_response_wrapper( - storage.unlink_ssh_key, + self.unlink_ssh_key = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + storage.unlink_ssh_key, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -962,29 +1031,39 @@ class StorageResourceWithStreamingResponse: def __init__(self, storage: StorageResource) -> None: self._storage = storage - self.create = to_streamed_response_wrapper( - storage.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + storage.create, # pyright: ignore[reportDeprecated], + ) ) - self.update = to_streamed_response_wrapper( - storage.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + storage.update, # pyright: ignore[reportDeprecated], + ) ) self.list = to_streamed_response_wrapper( storage.list, ) - self.delete = to_streamed_response_wrapper( - storage.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + storage.delete, # pyright: ignore[reportDeprecated], + ) ) self.get = to_streamed_response_wrapper( storage.get, ) - self.link_ssh_key = to_streamed_response_wrapper( - storage.link_ssh_key, + self.link_ssh_key = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + storage.link_ssh_key, # pyright: ignore[reportDeprecated], + ) ) self.restore = to_streamed_response_wrapper( storage.restore, ) - self.unlink_ssh_key = to_streamed_response_wrapper( - storage.unlink_ssh_key, + self.unlink_ssh_key = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + storage.unlink_ssh_key, # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -1008,29 +1087,39 @@ class AsyncStorageResourceWithStreamingResponse: def __init__(self, storage: AsyncStorageResource) -> None: self._storage = storage - self.create = async_to_streamed_response_wrapper( - storage.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + storage.create, # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_streamed_response_wrapper( - storage.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + storage.update, # pyright: ignore[reportDeprecated], + ) ) self.list = async_to_streamed_response_wrapper( storage.list, ) - self.delete = async_to_streamed_response_wrapper( - storage.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + storage.delete, # pyright: ignore[reportDeprecated], + ) ) self.get = async_to_streamed_response_wrapper( storage.get, ) - self.link_ssh_key = async_to_streamed_response_wrapper( - storage.link_ssh_key, + self.link_ssh_key = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + storage.link_ssh_key, # pyright: ignore[reportDeprecated], + ) ) self.restore = async_to_streamed_response_wrapper( storage.restore, ) - self.unlink_ssh_key = async_to_streamed_response_wrapper( - storage.unlink_ssh_key, + self.unlink_ssh_key = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + storage.unlink_ssh_key, # pyright: ignore[reportDeprecated], + ) ) @cached_property diff --git a/src/gcore/types/cloud/baremetal/server_create_params.py b/src/gcore/types/cloud/baremetal/server_create_params.py index 08280551..6a0d6aa9 100644 --- a/src/gcore/types/cloud/baremetal/server_create_params.py +++ b/src/gcore/types/cloud/baremetal/server_create_params.py @@ -87,7 +87,7 @@ class ServerCreateParams(TypedDict, total=False): [/v1/`ssh_keys` endpoint](/docs/api-reference/cloud/ssh-keys/add-or-generate-ssh-key). """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/file_share_create_params.py b/src/gcore/types/cloud/file_share_create_params.py index 5dca72de..dc69d0d0 100644 --- a/src/gcore/types/cloud/file_share_create_params.py +++ b/src/gcore/types/cloud/file_share_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Dict, Union, Iterable from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ @@ -37,7 +37,7 @@ class CreateStandardFileShareSerializer(TypedDict, total=False): access: Iterable[CreateStandardFileShareSerializerAccess] """Access Rules""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -94,7 +94,7 @@ class CreateVastFileShareSerializer(TypedDict, total=False): share_settings: CreateVastFileShareSerializerShareSettings """Configuration settings for the share""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/floating_ip_create_params.py b/src/gcore/types/cloud/floating_ip_create_params.py index ee28a9e9..48cddda9 100644 --- a/src/gcore/types/cloud/floating_ip_create_params.py +++ b/src/gcore/types/cloud/floating_ip_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import TypedDict __all__ = ["FloatingIPCreateParams"] @@ -27,7 +27,7 @@ class FloatingIPCreateParams(TypedDict, total=False): If provided, the floating IP will be immediately attached to the specified port. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py b/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py index d2b5284b..ed821b5d 100644 --- a/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py +++ b/src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Dict, Union, Iterable from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ @@ -42,7 +42,7 @@ class ClusterCreateParams(TypedDict, total=False): servers_settings: Required[ServersSettings] """Configuration settings for the servers in the cluster""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py b/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py index 269dfd76..4cae77be 100644 --- a/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py +++ b/src/gcore/types/cloud/gpu_baremetal/clusters/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -45,7 +45,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Permission to use a ssh key in instances""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py b/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py index a6b6e0b1..762e4879 100644 --- a/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py +++ b/src/gcore/types/cloud/gpu_virtual/cluster_create_params.py @@ -42,7 +42,7 @@ class ClusterCreateParams(TypedDict, total=False): servers_settings: Required[ServersSettings] """Configuration settings for the servers in the cluster""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py b/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py index 269dfd76..4cae77be 100644 --- a/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py +++ b/src/gcore/types/cloud/gpu_virtual/clusters/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -45,7 +45,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Permission to use a ssh key in instances""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instance_create_params.py b/src/gcore/types/cloud/instance_create_params.py index bed6de52..ee1ba080 100644 --- a/src/gcore/types/cloud/instance_create_params.py +++ b/src/gcore/types/cloud/instance_create_params.py @@ -114,7 +114,7 @@ class InstanceCreateParams(TypedDict, total=False): [/v1/`ssh_keys` endpoint](/docs/api-reference/cloud/ssh-keys/add-or-generate-ssh-key). """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -398,7 +398,7 @@ class VolumeCreateInstanceCreateNewVolumeSerializer(TypedDict, total=False): If not specified, a name will be generated automatically. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -459,7 +459,7 @@ class VolumeCreateInstanceCreateVolumeFromImageSerializer(TypedDict, total=False - For basic VMs: the size is set automatically based on the flavor. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -513,7 +513,7 @@ class VolumeCreateInstanceCreateVolumeFromSnapshotSerializer(TypedDict, total=Fa If not specified, a name will be generated automatically. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -559,7 +559,7 @@ class VolumeCreateInstanceCreateVolumeFromApptemplateSerializer(TypedDict, total size: int """Volume size in GiB.""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling @@ -604,7 +604,7 @@ class VolumeCreateInstanceExistingVolumeSerializer(TypedDict, total=False): delete_on_termination: bool """Set to `true` to automatically delete the volume when the instance is deleted.""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instances/image_create_from_volume_params.py b/src/gcore/types/cloud/instances/image_create_from_volume_params.py index 52928edb..d98e34ae 100644 --- a/src/gcore/types/cloud/instances/image_create_from_volume_params.py +++ b/src/gcore/types/cloud/instances/image_create_from_volume_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageCreateFromVolumeParams"] @@ -40,7 +40,7 @@ class ImageCreateFromVolumeParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Whether the image supports SSH key or not""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/instances/image_upload_params.py b/src/gcore/types/cloud/instances/image_upload_params.py index a10d83fe..4085ea54 100644 --- a/src/gcore/types/cloud/instances/image_upload_params.py +++ b/src/gcore/types/cloud/instances/image_upload_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Dict, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["ImageUploadParams"] @@ -49,7 +49,7 @@ class ImageUploadParams(TypedDict, total=False): ssh_key: Literal["allow", "deny", "required"] """Whether the image supports SSH key or not""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/load_balancer_create_params.py b/src/gcore/types/cloud/load_balancer_create_params.py index db1d053d..8d56613c 100644 --- a/src/gcore/types/cloud/load_balancer_create_params.py +++ b/src/gcore/types/cloud/load_balancer_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Iterable, Optional +from typing import Dict, Union, Iterable, Optional from typing_extensions import Literal, Required, TypeAlias, TypedDict from ..._types import SequenceNotStr @@ -71,7 +71,7 @@ class LoadBalancerCreateParams(TypedDict, total=False): specification. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/network_create_params.py b/src/gcore/types/cloud/network_create_params.py index 935f9bc0..b4cb5e77 100644 --- a/src/gcore/types/cloud/network_create_params.py +++ b/src/gcore/types/cloud/network_create_params.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Dict from typing_extensions import Literal, Required, TypedDict __all__ = ["NetworkCreateParams"] @@ -20,7 +21,7 @@ class NetworkCreateParams(TypedDict, total=False): create_router: bool """Defaults to True""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/networks/subnet_create_params.py b/src/gcore/types/cloud/networks/subnet_create_params.py index 41274927..5a6b365f 100644 --- a/src/gcore/types/cloud/networks/subnet_create_params.py +++ b/src/gcore/types/cloud/networks/subnet_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Required, TypedDict from ...._types import SequenceNotStr @@ -60,7 +60,7 @@ class SubnetCreateParams(TypedDict, total=False): find a router created during network creation. """ - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/security_group_create_params.py b/src/gcore/types/cloud/security_group_create_params.py index d4904c5d..e660dee3 100644 --- a/src/gcore/types/cloud/security_group_create_params.py +++ b/src/gcore/types/cloud/security_group_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Literal, Required, TypedDict __all__ = ["SecurityGroupCreateParams", "Rule"] @@ -24,7 +24,7 @@ class SecurityGroupCreateParams(TypedDict, total=False): rules: Iterable[Rule] """Security group rules""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/cloud/tag.py b/src/gcore/types/cloud/tag.py index 9ee9fdba..56ac9aa0 100644 --- a/src/gcore/types/cloud/tag.py +++ b/src/gcore/types/cloud/tag.py @@ -14,18 +14,10 @@ class Tag(BaseModel): """ key: str - """Tag key. - - Maximum 255 characters. Cannot contain spaces, tabs, newlines, empty string or - '=' character. - """ + """Tag key. The maximum size for a key is 255 characters.""" read_only: bool """If true, the tag is read-only and cannot be modified by the user""" value: str - """Tag value. - - Maximum 255 characters. Cannot contain spaces, tabs, newlines, empty string or - '=' character. - """ + """Tag value. The maximum size for a value is 255 characters.""" diff --git a/src/gcore/types/cloud/tag_update_map_param.py b/src/gcore/types/cloud/tag_update_map_param.py index 9a70575e..6726649c 100644 --- a/src/gcore/types/cloud/tag_update_map_param.py +++ b/src/gcore/types/cloud/tag_update_map_param.py @@ -2,8 +2,9 @@ from __future__ import annotations +from typing import Dict, Optional from typing_extensions import TypeAlias __all__ = ["TagUpdateMapParam"] -TagUpdateMapParam: TypeAlias = object +TagUpdateMapParam: TypeAlias = Dict[str, Optional[str]] diff --git a/src/gcore/types/cloud/volume_snapshot_create_params.py b/src/gcore/types/cloud/volume_snapshot_create_params.py index 8d77c011..b832806b 100644 --- a/src/gcore/types/cloud/volume_snapshot_create_params.py +++ b/src/gcore/types/cloud/volume_snapshot_create_params.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["VolumeSnapshotCreateParams"] @@ -21,7 +22,7 @@ class VolumeSnapshotCreateParams(TypedDict, total=False): description: str """Snapshot description""" - tags: object + tags: Dict[str, str] """Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling diff --git a/src/gcore/types/storage/location.py b/src/gcore/types/storage/location.py index 5fff1680..3cd9cf45 100644 --- a/src/gcore/types/storage/location.py +++ b/src/gcore/types/storage/location.py @@ -22,5 +22,5 @@ class Location(BaseModel): title: str """Human-readable title for the location""" - type: Literal["s3", "sftp"] + type: Literal["s3_compatible", "sftp"] """Storage protocol type supported in this location""" diff --git a/src/gcore/types/storage/storage.py b/src/gcore/types/storage/storage.py index 126b5a7d..f158afa8 100644 --- a/src/gcore/types/storage/storage.py +++ b/src/gcore/types/storage/storage.py @@ -65,7 +65,7 @@ class Storage(BaseModel): reseller_id: int """Reseller technical client ID associated with the client""" - type: Literal["sftp", "s3"] + type: Literal["sftp", "s3_compatible"] """ Storage protocol type - either S3-compatible object storage or SFTP file transfer diff --git a/src/gcore/types/storage/storage_create_params.py b/src/gcore/types/storage/storage_create_params.py index e5582029..348df44c 100644 --- a/src/gcore/types/storage/storage_create_params.py +++ b/src/gcore/types/storage/storage_create_params.py @@ -21,11 +21,11 @@ class StorageCreateParams(TypedDict, total=False): must be less than 256 characters. """ - type: Required[Literal["sftp", "s3"]] + type: Required[Literal["sftp", "s3_compatible"]] """Storage protocol type. - Choose 's3' for S3-compatible object storage with API access, or `sftp` for SFTP - file transfer protocol. + Choose 's3_compatible' for S3-compatible object storage with API access, or + `sftp` for SFTP file transfer protocol. """ generate_sftp_password: bool diff --git a/src/gcore/types/storage/storage_list_params.py b/src/gcore/types/storage/storage_list_params.py index 830c81c9..5028a2e4 100644 --- a/src/gcore/types/storage/storage_list_params.py +++ b/src/gcore/types/storage/storage_list_params.py @@ -35,5 +35,5 @@ class StorageListParams(TypedDict, total=False): status: Literal["active", "suspended", "deleted", "pending"] """Filter by storage status""" - type: Literal["s3", "sftp"] + type: Literal["s3_compatible", "sftp"] """Filter by storage type""" diff --git a/tests/api_resources/cloud/gpu_baremetal/test_clusters.py b/tests/api_resources/cloud/gpu_baremetal/test_clusters.py index 3a47eba9..cd68c18a 100644 --- a/tests/api_resources/cloud/gpu_baremetal/test_clusters.py +++ b/tests/api_resources/cloud/gpu_baremetal/test_clusters.py @@ -217,7 +217,7 @@ def test_method_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -228,7 +228,7 @@ def test_raw_response_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert response.is_closed is True @@ -243,7 +243,7 @@ def test_streaming_response_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -261,7 +261,7 @@ def test_path_params_action(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) @parametrize @@ -715,7 +715,7 @@ async def test_method_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -726,7 +726,7 @@ async def test_raw_response_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert response.is_closed is True @@ -741,7 +741,7 @@ async def test_streaming_response_action(self, async_client: AsyncGcore) -> None project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -759,7 +759,7 @@ async def test_path_params_action(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) @parametrize diff --git a/tests/api_resources/cloud/gpu_virtual/test_clusters.py b/tests/api_resources/cloud/gpu_virtual/test_clusters.py index 0487f803..91d2ae2d 100644 --- a/tests/api_resources/cloud/gpu_virtual/test_clusters.py +++ b/tests/api_resources/cloud/gpu_virtual/test_clusters.py @@ -507,7 +507,7 @@ def test_method_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -518,7 +518,7 @@ def test_raw_response_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert response.is_closed is True @@ -533,7 +533,7 @@ def test_streaming_response_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -551,7 +551,7 @@ def test_path_params_action_overload_5(self, client: Gcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) @parametrize @@ -1146,7 +1146,7 @@ async def test_method_action_overload_5(self, async_client: AsyncGcore) -> None: project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, cluster, path=["response"]) @@ -1157,7 +1157,7 @@ async def test_raw_response_action_overload_5(self, async_client: AsyncGcore) -> project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) assert response.is_closed is True @@ -1172,7 +1172,7 @@ async def test_streaming_response_action_overload_5(self, async_client: AsyncGco project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1190,7 +1190,7 @@ async def test_path_params_action_overload_5(self, async_client: AsyncGcore) -> project_id=1, region_id=7, action="update_tags", - tags={}, + tags={"foo": "my-tag-value"}, ) @parametrize diff --git a/tests/api_resources/cloud/instances/test_images.py b/tests/api_resources/cloud/instances/test_images.py index b97decb0..c30fde90 100644 --- a/tests/api_resources/cloud/instances/test_images.py +++ b/tests/api_resources/cloud/instances/test_images.py @@ -38,7 +38,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: name="my-image", os_type="linux", ssh_key="allow", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Image, image, path=["response"]) @@ -373,7 +373,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> name="my-image", os_type="linux", ssh_key="allow", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Image, image, path=["response"]) diff --git a/tests/api_resources/cloud/networks/test_subnets.py b/tests/api_resources/cloud/networks/test_subnets.py index dc315c0a..8ba4ff6f 100644 --- a/tests/api_resources/cloud/networks/test_subnets.py +++ b/tests/api_resources/cloud/networks/test_subnets.py @@ -110,7 +110,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: } ], name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Subnet, subnet, path=["response"]) @@ -389,7 +389,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> } ], name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Subnet, subnet, path=["response"]) diff --git a/tests/api_resources/cloud/test_file_shares.py b/tests/api_resources/cloud/test_file_shares.py index 74d9a584..055e05d6 100644 --- a/tests/api_resources/cloud/test_file_shares.py +++ b/tests/api_resources/cloud/test_file_shares.py @@ -174,7 +174,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: "path_length": "LCD", "root_squash": True, }, - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, file_share, path=["response"]) @@ -562,7 +562,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> "path_length": "LCD", "root_squash": True, }, - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, file_share, path=["response"]) diff --git a/tests/api_resources/cloud/test_floating_ips.py b/tests/api_resources/cloud/test_floating_ips.py index fda155b2..97ff5795 100644 --- a/tests/api_resources/cloud/test_floating_ips.py +++ b/tests/api_resources/cloud/test_floating_ips.py @@ -86,7 +86,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: region_id=1, fixed_ip_address="192.168.10.15", port_id="ee2402d0-f0cd-4503-9b75-69be1d11c5f1", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) @@ -453,7 +453,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> region_id=1, fixed_ip_address="192.168.10.15", port_id="ee2402d0-f0cd-4503-9b75-69be1d11c5f1", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) diff --git a/tests/api_resources/cloud/test_instances.py b/tests/api_resources/cloud/test_instances.py index d5c24486..7b908015 100644 --- a/tests/api_resources/cloud/test_instances.py +++ b/tests/api_resources/cloud/test_instances.py @@ -137,7 +137,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=0, region_id=0, name="instance_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Instance, instance, path=["response"]) @@ -1007,7 +1007,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=0, region_id=0, name="instance_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Instance, instance, path=["response"]) diff --git a/tests/api_resources/cloud/test_load_balancers.py b/tests/api_resources/cloud/test_load_balancers.py index 75c7a421..5b30c022 100644 --- a/tests/api_resources/cloud/test_load_balancers.py +++ b/tests/api_resources/cloud/test_load_balancers.py @@ -185,7 +185,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: }, name="some_name", preferred_connectivity="L2", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(LoadBalancer, load_balancer, path=["response"]) @@ -659,7 +659,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> }, name="some_name", preferred_connectivity="L2", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(LoadBalancer, load_balancer, path=["response"]) diff --git a/tests/api_resources/cloud/test_networks.py b/tests/api_resources/cloud/test_networks.py index 273791bd..dbd1f4d0 100644 --- a/tests/api_resources/cloud/test_networks.py +++ b/tests/api_resources/cloud/test_networks.py @@ -86,7 +86,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Network, network, path=["response"]) @@ -338,7 +338,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Network, network, path=["response"]) diff --git a/tests/api_resources/cloud/test_security_groups.py b/tests/api_resources/cloud/test_security_groups.py index 6050ff4c..2bd9402b 100644 --- a/tests/api_resources/cloud/test_security_groups.py +++ b/tests/api_resources/cloud/test_security_groups.py @@ -110,7 +110,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: "remote_ip_prefix": "10.0.0.0/8", } ], - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, security_group, path=["response"]) @@ -481,7 +481,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> "remote_ip_prefix": "10.0.0.0/8", } ], - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(TaskIDList, security_group, path=["response"]) diff --git a/tests/api_resources/cloud/test_volume_snapshots.py b/tests/api_resources/cloud/test_volume_snapshots.py index f4da5ed7..4b2d7bfd 100644 --- a/tests/api_resources/cloud/test_volume_snapshots.py +++ b/tests/api_resources/cloud/test_volume_snapshots.py @@ -88,7 +88,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="my-backup-snapshot", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Snapshot, volume_snapshot, path=["response"]) @@ -295,7 +295,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="my-backup-snapshot", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Snapshot, volume_snapshot, path=["response"]) diff --git a/tests/api_resources/cloud/test_volumes.py b/tests/api_resources/cloud/test_volumes.py index 67bd0e60..95d43b9f 100644 --- a/tests/api_resources/cloud/test_volumes.py +++ b/tests/api_resources/cloud/test_volumes.py @@ -45,7 +45,7 @@ def test_method_create_with_all_params_overload_1(self, client: Gcore) -> None: attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -107,7 +107,7 @@ def test_method_create_with_all_params_overload_2(self, client: Gcore) -> None: instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], size=10, - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -166,7 +166,7 @@ def test_method_create_with_all_params_overload_3(self, client: Gcore) -> None: attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -219,7 +219,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: project_id=1, region_id=1, name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Volume, volume, path=["response"]) @@ -701,7 +701,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -763,7 +763,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], size=10, - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -822,7 +822,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn attachment_tag="device-tag", instance_id_to_attach_to="88f3e0bd-ca86-4cf7-be8b-dd2988e23c2d", lifecycle_policy_ids=[1, 2], - tags={}, + tags={"foo": "my-tag-value"}, type_name="standard", ) assert_matches_type(TaskIDList, volume, path=["response"]) @@ -875,7 +875,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> project_id=1, region_id=1, name="some_name", - tags={}, + tags={"foo": "my-tag-value"}, ) assert_matches_type(Volume, volume, path=["response"]) diff --git a/tests/api_resources/storage/buckets/test_cors.py b/tests/api_resources/storage/buckets/test_cors.py index d9bc87a6..acf58e4d 100644 --- a/tests/api_resources/storage/buckets/test_cors.py +++ b/tests/api_resources/storage/buckets/test_cors.py @@ -11,6 +11,8 @@ from tests.utils import assert_matches_type from gcore.types.storage.buckets import BucketCors +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,27 +21,32 @@ class TestCors: @parametrize def test_method_create(self, client: Gcore) -> None: - cor = client.storage.buckets.cors.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + cor = client.storage.buckets.cors.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert cor is None @parametrize def test_method_create_with_all_params(self, client: Gcore) -> None: - cor = client.storage.buckets.cors.create( - bucket_name="bucket_name", - storage_id=0, - allowed_origins=["https://example.com", "https://app.example.com", "*"], - ) + with pytest.warns(DeprecationWarning): + cor = client.storage.buckets.cors.create( + bucket_name="bucket_name", + storage_id=0, + allowed_origins=["https://example.com", "https://app.example.com", "*"], + ) + assert cor is None @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.storage.buckets.cors.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.cors.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -48,40 +55,45 @@ def test_raw_response_create(self, client: Gcore) -> None: @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.storage.buckets.cors.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.cors.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cor = response.parse() - assert cor is None + cor = response.parse() + assert cor is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.cors.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.cors.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize def test_method_get(self, client: Gcore) -> None: - cor = client.storage.buckets.cors.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + cor = client.storage.buckets.cors.get( + bucket_name="bucket_name", + storage_id=0, + ) + assert_matches_type(BucketCors, cor, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: - response = client.storage.buckets.cors.with_raw_response.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.cors.with_raw_response.get( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -90,25 +102,27 @@ def test_raw_response_get(self, client: Gcore) -> None: @parametrize def test_streaming_response_get(self, client: Gcore) -> None: - with client.storage.buckets.cors.with_streaming_response.get( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.cors.with_streaming_response.get( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cor = response.parse() - assert_matches_type(BucketCors, cor, path=["response"]) + cor = response.parse() + assert_matches_type(BucketCors, cor, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.cors.with_raw_response.get( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.cors.with_raw_response.get( + bucket_name="", + storage_id=0, + ) class TestAsyncCors: @@ -118,27 +132,32 @@ class TestAsyncCors: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - cor = await async_client.storage.buckets.cors.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + cor = await async_client.storage.buckets.cors.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert cor is None @parametrize async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: - cor = await async_client.storage.buckets.cors.create( - bucket_name="bucket_name", - storage_id=0, - allowed_origins=["https://example.com", "https://app.example.com", "*"], - ) + with pytest.warns(DeprecationWarning): + cor = await async_client.storage.buckets.cors.create( + bucket_name="bucket_name", + storage_id=0, + allowed_origins=["https://example.com", "https://app.example.com", "*"], + ) + assert cor is None @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.cors.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.cors.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -147,40 +166,45 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.cors.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.cors.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cor = await response.parse() - assert cor is None + cor = await response.parse() + assert cor is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.cors.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.cors.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: - cor = await async_client.storage.buckets.cors.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + cor = await async_client.storage.buckets.cors.get( + bucket_name="bucket_name", + storage_id=0, + ) + assert_matches_type(BucketCors, cor, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.cors.with_raw_response.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.cors.with_raw_response.get( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -189,22 +213,24 @@ async def test_raw_response_get(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.cors.with_streaming_response.get( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.cors.with_streaming_response.get( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cor = await response.parse() - assert_matches_type(BucketCors, cor, path=["response"]) + cor = await response.parse() + assert_matches_type(BucketCors, cor, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.cors.with_raw_response.get( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.cors.with_raw_response.get( + bucket_name="", + storage_id=0, + ) diff --git a/tests/api_resources/storage/buckets/test_lifecycle.py b/tests/api_resources/storage/buckets/test_lifecycle.py index 52e01c12..41747114 100644 --- a/tests/api_resources/storage/buckets/test_lifecycle.py +++ b/tests/api_resources/storage/buckets/test_lifecycle.py @@ -9,6 +9,8 @@ from gcore import Gcore, AsyncGcore +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -17,27 +19,32 @@ class TestLifecycle: @parametrize def test_method_create(self, client: Gcore) -> None: - lifecycle = client.storage.buckets.lifecycle.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + lifecycle = client.storage.buckets.lifecycle.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert lifecycle is None @parametrize def test_method_create_with_all_params(self, client: Gcore) -> None: - lifecycle = client.storage.buckets.lifecycle.create( - bucket_name="bucket_name", - storage_id=0, - expiration_days=30, - ) + with pytest.warns(DeprecationWarning): + lifecycle = client.storage.buckets.lifecycle.create( + bucket_name="bucket_name", + storage_id=0, + expiration_days=30, + ) + assert lifecycle is None @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.storage.buckets.lifecycle.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.lifecycle.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -46,40 +53,45 @@ def test_raw_response_create(self, client: Gcore) -> None: @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.storage.buckets.lifecycle.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.lifecycle.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lifecycle = response.parse() - assert lifecycle is None + lifecycle = response.parse() + assert lifecycle is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.lifecycle.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.lifecycle.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize def test_method_delete(self, client: Gcore) -> None: - lifecycle = client.storage.buckets.lifecycle.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + lifecycle = client.storage.buckets.lifecycle.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert lifecycle is None @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.storage.buckets.lifecycle.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.lifecycle.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -88,25 +100,27 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.storage.buckets.lifecycle.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.lifecycle.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lifecycle = response.parse() - assert lifecycle is None + lifecycle = response.parse() + assert lifecycle is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.lifecycle.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.lifecycle.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) class TestAsyncLifecycle: @@ -116,27 +130,32 @@ class TestAsyncLifecycle: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - lifecycle = await async_client.storage.buckets.lifecycle.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + lifecycle = await async_client.storage.buckets.lifecycle.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert lifecycle is None @parametrize async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: - lifecycle = await async_client.storage.buckets.lifecycle.create( - bucket_name="bucket_name", - storage_id=0, - expiration_days=30, - ) + with pytest.warns(DeprecationWarning): + lifecycle = await async_client.storage.buckets.lifecycle.create( + bucket_name="bucket_name", + storage_id=0, + expiration_days=30, + ) + assert lifecycle is None @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.lifecycle.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.lifecycle.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -145,40 +164,45 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.lifecycle.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.lifecycle.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lifecycle = await response.parse() - assert lifecycle is None + lifecycle = await response.parse() + assert lifecycle is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.lifecycle.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.lifecycle.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - lifecycle = await async_client.storage.buckets.lifecycle.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + lifecycle = await async_client.storage.buckets.lifecycle.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert lifecycle is None @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.lifecycle.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.lifecycle.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -187,22 +211,24 @@ async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.lifecycle.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.lifecycle.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lifecycle = await response.parse() - assert lifecycle is None + lifecycle = await response.parse() + assert lifecycle is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.lifecycle.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.lifecycle.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) diff --git a/tests/api_resources/storage/buckets/test_policy.py b/tests/api_resources/storage/buckets/test_policy.py index fd0a5c06..c95a5f68 100644 --- a/tests/api_resources/storage/buckets/test_policy.py +++ b/tests/api_resources/storage/buckets/test_policy.py @@ -11,6 +11,8 @@ from tests.utils import assert_matches_type from gcore.types.storage.buckets import PolicyGetResponse +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,18 +21,21 @@ class TestPolicy: @parametrize def test_method_create(self, client: Gcore) -> None: - policy = client.storage.buckets.policy.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = client.storage.buckets.policy.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert policy is None @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.storage.buckets.policy.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.policy.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -39,40 +44,45 @@ def test_raw_response_create(self, client: Gcore) -> None: @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.storage.buckets.policy.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.policy.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert policy is None + policy = response.parse() + assert policy is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.policy.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.policy.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize def test_method_delete(self, client: Gcore) -> None: - policy = client.storage.buckets.policy.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = client.storage.buckets.policy.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert policy is None @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.storage.buckets.policy.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.policy.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -81,40 +91,45 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.storage.buckets.policy.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.policy.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert policy is None + policy = response.parse() + assert policy is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.policy.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.policy.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) @parametrize def test_method_get(self, client: Gcore) -> None: - policy = client.storage.buckets.policy.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = client.storage.buckets.policy.get( + bucket_name="bucket_name", + storage_id=0, + ) + assert_matches_type(PolicyGetResponse, policy, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: - response = client.storage.buckets.policy.with_raw_response.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.policy.with_raw_response.get( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -123,25 +138,27 @@ def test_raw_response_get(self, client: Gcore) -> None: @parametrize def test_streaming_response_get(self, client: Gcore) -> None: - with client.storage.buckets.policy.with_streaming_response.get( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.policy.with_streaming_response.get( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(PolicyGetResponse, policy, path=["response"]) + policy = response.parse() + assert_matches_type(PolicyGetResponse, policy, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.policy.with_raw_response.get( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.policy.with_raw_response.get( + bucket_name="", + storage_id=0, + ) class TestAsyncPolicy: @@ -151,18 +168,21 @@ class TestAsyncPolicy: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - policy = await async_client.storage.buckets.policy.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = await async_client.storage.buckets.policy.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert policy is None @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.policy.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.policy.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -171,40 +191,45 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.policy.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.policy.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert policy is None + policy = await response.parse() + assert policy is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.policy.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.policy.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - policy = await async_client.storage.buckets.policy.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = await async_client.storage.buckets.policy.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert policy is None @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.policy.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.policy.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -213,40 +238,45 @@ async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.policy.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.policy.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert policy is None + policy = await response.parse() + assert policy is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.policy.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.policy.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: - policy = await async_client.storage.buckets.policy.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + policy = await async_client.storage.buckets.policy.get( + bucket_name="bucket_name", + storage_id=0, + ) + assert_matches_type(PolicyGetResponse, policy, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.policy.with_raw_response.get( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.policy.with_raw_response.get( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -255,22 +285,24 @@ async def test_raw_response_get(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.policy.with_streaming_response.get( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.policy.with_streaming_response.get( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(PolicyGetResponse, policy, path=["response"]) + policy = await response.parse() + assert_matches_type(PolicyGetResponse, policy, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.policy.with_raw_response.get( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.policy.with_raw_response.get( + bucket_name="", + storage_id=0, + ) diff --git a/tests/api_resources/storage/test_buckets.py b/tests/api_resources/storage/test_buckets.py index eabe5253..2a68140d 100644 --- a/tests/api_resources/storage/test_buckets.py +++ b/tests/api_resources/storage/test_buckets.py @@ -12,6 +12,8 @@ from gcore.pagination import SyncOffsetPage, AsyncOffsetPage from gcore.types.storage import Bucket +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -20,18 +22,21 @@ class TestBuckets: @parametrize def test_method_create(self, client: Gcore) -> None: - bucket = client.storage.buckets.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = client.storage.buckets.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert bucket is None @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.storage.buckets.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -40,47 +45,54 @@ def test_raw_response_create(self, client: Gcore) -> None: @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.storage.buckets.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = response.parse() - assert bucket is None + bucket = response.parse() + assert bucket is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize def test_method_list(self, client: Gcore) -> None: - bucket = client.storage.buckets.list( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = client.storage.buckets.list( + storage_id=0, + ) + assert_matches_type(SyncOffsetPage[Bucket], bucket, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: - bucket = client.storage.buckets.list( - storage_id=0, - limit=1, - offset=0, - ) + with pytest.warns(DeprecationWarning): + bucket = client.storage.buckets.list( + storage_id=0, + limit=1, + offset=0, + ) + assert_matches_type(SyncOffsetPage[Bucket], bucket, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: - response = client.storage.buckets.with_raw_response.list( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.with_raw_response.list( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -89,31 +101,35 @@ def test_raw_response_list(self, client: Gcore) -> None: @parametrize def test_streaming_response_list(self, client: Gcore) -> None: - with client.storage.buckets.with_streaming_response.list( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.with_streaming_response.list( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = response.parse() - assert_matches_type(SyncOffsetPage[Bucket], bucket, path=["response"]) + bucket = response.parse() + assert_matches_type(SyncOffsetPage[Bucket], bucket, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_delete(self, client: Gcore) -> None: - bucket = client.storage.buckets.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = client.storage.buckets.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert bucket is None @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.storage.buckets.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.buckets.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -122,25 +138,27 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.storage.buckets.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.buckets.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = response.parse() - assert bucket is None + bucket = response.parse() + assert bucket is None assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - client.storage.buckets.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + client.storage.buckets.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) class TestAsyncBuckets: @@ -150,18 +168,21 @@ class TestAsyncBuckets: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - bucket = await async_client.storage.buckets.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = await async_client.storage.buckets.create( + bucket_name="bucket_name", + storage_id=0, + ) + assert bucket is None @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.with_raw_response.create( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.with_raw_response.create( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -170,47 +191,54 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.with_streaming_response.create( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.with_streaming_response.create( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = await response.parse() - assert bucket is None + bucket = await response.parse() + assert bucket is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.with_raw_response.create( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.with_raw_response.create( + bucket_name="", + storage_id=0, + ) @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: - bucket = await async_client.storage.buckets.list( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = await async_client.storage.buckets.list( + storage_id=0, + ) + assert_matches_type(AsyncOffsetPage[Bucket], bucket, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: - bucket = await async_client.storage.buckets.list( - storage_id=0, - limit=1, - offset=0, - ) + with pytest.warns(DeprecationWarning): + bucket = await async_client.storage.buckets.list( + storage_id=0, + limit=1, + offset=0, + ) + assert_matches_type(AsyncOffsetPage[Bucket], bucket, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.with_raw_response.list( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.with_raw_response.list( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -219,31 +247,35 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.with_streaming_response.list( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.with_streaming_response.list( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = await response.parse() - assert_matches_type(AsyncOffsetPage[Bucket], bucket, path=["response"]) + bucket = await response.parse() + assert_matches_type(AsyncOffsetPage[Bucket], bucket, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - bucket = await async_client.storage.buckets.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + bucket = await async_client.storage.buckets.delete( + bucket_name="bucket_name", + storage_id=0, + ) + assert bucket is None @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.buckets.with_raw_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.buckets.with_raw_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -252,22 +284,24 @@ async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.storage.buckets.with_streaming_response.delete( - bucket_name="bucket_name", - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.buckets.with_streaming_response.delete( + bucket_name="bucket_name", + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bucket = await response.parse() - assert bucket is None + bucket = await response.parse() + assert bucket is None assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): - await async_client.storage.buckets.with_raw_response.delete( - bucket_name="", - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bucket_name` but received ''"): + await async_client.storage.buckets.with_raw_response.delete( + bucket_name="", + storage_id=0, + ) diff --git a/tests/api_resources/storage/test_credentials.py b/tests/api_resources/storage/test_credentials.py index 8f02e9d0..e6737ee5 100644 --- a/tests/api_resources/storage/test_credentials.py +++ b/tests/api_resources/storage/test_credentials.py @@ -11,6 +11,8 @@ from tests.utils import assert_matches_type from gcore.types.storage import Storage +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,28 +21,33 @@ class TestCredentials: @parametrize def test_method_recreate(self, client: Gcore) -> None: - credential = client.storage.credentials.recreate( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + credential = client.storage.credentials.recreate( + storage_id=0, + ) + assert_matches_type(Storage, credential, path=["response"]) @parametrize def test_method_recreate_with_all_params(self, client: Gcore) -> None: - credential = client.storage.credentials.recreate( - storage_id=0, - delete_sftp_password=True, - generate_s3_keys=True, - generate_sftp_password=True, - reset_sftp_keys=True, - sftp_password="sftp_password", - ) + with pytest.warns(DeprecationWarning): + credential = client.storage.credentials.recreate( + storage_id=0, + delete_sftp_password=True, + generate_s3_keys=True, + generate_sftp_password=True, + reset_sftp_keys=True, + sftp_password="sftp_password", + ) + assert_matches_type(Storage, credential, path=["response"]) @parametrize def test_raw_response_recreate(self, client: Gcore) -> None: - response = client.storage.credentials.with_raw_response.recreate( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.credentials.with_raw_response.recreate( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -49,14 +56,15 @@ def test_raw_response_recreate(self, client: Gcore) -> None: @parametrize def test_streaming_response_recreate(self, client: Gcore) -> None: - with client.storage.credentials.with_streaming_response.recreate( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.credentials.with_streaming_response.recreate( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - credential = response.parse() - assert_matches_type(Storage, credential, path=["response"]) + credential = response.parse() + assert_matches_type(Storage, credential, path=["response"]) assert cast(Any, response.is_closed) is True @@ -68,28 +76,33 @@ class TestAsyncCredentials: @parametrize async def test_method_recreate(self, async_client: AsyncGcore) -> None: - credential = await async_client.storage.credentials.recreate( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + credential = await async_client.storage.credentials.recreate( + storage_id=0, + ) + assert_matches_type(Storage, credential, path=["response"]) @parametrize async def test_method_recreate_with_all_params(self, async_client: AsyncGcore) -> None: - credential = await async_client.storage.credentials.recreate( - storage_id=0, - delete_sftp_password=True, - generate_s3_keys=True, - generate_sftp_password=True, - reset_sftp_keys=True, - sftp_password="sftp_password", - ) + with pytest.warns(DeprecationWarning): + credential = await async_client.storage.credentials.recreate( + storage_id=0, + delete_sftp_password=True, + generate_s3_keys=True, + generate_sftp_password=True, + reset_sftp_keys=True, + sftp_password="sftp_password", + ) + assert_matches_type(Storage, credential, path=["response"]) @parametrize async def test_raw_response_recreate(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.credentials.with_raw_response.recreate( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.credentials.with_raw_response.recreate( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -98,13 +111,14 @@ async def test_raw_response_recreate(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_recreate(self, async_client: AsyncGcore) -> None: - async with async_client.storage.credentials.with_streaming_response.recreate( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - credential = await response.parse() - assert_matches_type(Storage, credential, path=["response"]) + with pytest.warns(DeprecationWarning): + async with async_client.storage.credentials.with_streaming_response.recreate( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + credential = await response.parse() + assert_matches_type(Storage, credential, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/storage/test_locations.py b/tests/api_resources/storage/test_locations.py index f076ff9b..8c1e2407 100644 --- a/tests/api_resources/storage/test_locations.py +++ b/tests/api_resources/storage/test_locations.py @@ -12,6 +12,8 @@ from gcore.pagination import SyncOffsetPage, AsyncOffsetPage from gcore.types.storage import Location +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -20,20 +22,25 @@ class TestLocations: @parametrize def test_method_list(self, client: Gcore) -> None: - location = client.storage.locations.list() + with pytest.warns(DeprecationWarning): + location = client.storage.locations.list() + assert_matches_type(SyncOffsetPage[Location], location, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: - location = client.storage.locations.list( - limit=1, - offset=0, - ) + with pytest.warns(DeprecationWarning): + location = client.storage.locations.list( + limit=1, + offset=0, + ) + assert_matches_type(SyncOffsetPage[Location], location, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: - response = client.storage.locations.with_raw_response.list() + with pytest.warns(DeprecationWarning): + response = client.storage.locations.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -42,12 +49,13 @@ def test_raw_response_list(self, client: Gcore) -> None: @parametrize def test_streaming_response_list(self, client: Gcore) -> None: - with client.storage.locations.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.locations.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - location = response.parse() - assert_matches_type(SyncOffsetPage[Location], location, path=["response"]) + location = response.parse() + assert_matches_type(SyncOffsetPage[Location], location, path=["response"]) assert cast(Any, response.is_closed) is True @@ -59,20 +67,25 @@ class TestAsyncLocations: @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: - location = await async_client.storage.locations.list() + with pytest.warns(DeprecationWarning): + location = await async_client.storage.locations.list() + assert_matches_type(AsyncOffsetPage[Location], location, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: - location = await async_client.storage.locations.list( - limit=1, - offset=0, - ) + with pytest.warns(DeprecationWarning): + location = await async_client.storage.locations.list( + limit=1, + offset=0, + ) + assert_matches_type(AsyncOffsetPage[Location], location, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.locations.with_raw_response.list() + with pytest.warns(DeprecationWarning): + response = await async_client.storage.locations.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -81,11 +94,12 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: - async with async_client.storage.locations.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.locations.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - location = await response.parse() - assert_matches_type(AsyncOffsetPage[Location], location, path=["response"]) + location = await response.parse() + assert_matches_type(AsyncOffsetPage[Location], location, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_storage.py b/tests/api_resources/test_storage.py index 00988587..8261bb66 100644 --- a/tests/api_resources/test_storage.py +++ b/tests/api_resources/test_storage.py @@ -14,6 +14,8 @@ Storage, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -22,31 +24,36 @@ class TestStorage: @parametrize def test_method_create(self, client: Gcore) -> None: - storage = client.storage.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Gcore) -> None: - storage = client.storage.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - generate_sftp_password=True, - sftp_password="sftp_password", - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + generate_sftp_password=True, + sftp_password="sftp_password", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.storage.with_raw_response.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) + with pytest.warns(DeprecationWarning): + response = client.storage.with_raw_response.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -55,40 +62,46 @@ def test_raw_response_create(self, client: Gcore) -> None: @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.storage.with_streaming_response.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - storage = response.parse() - assert_matches_type(Storage, storage, path=["response"]) + with pytest.warns(DeprecationWarning): + with client.storage.with_streaming_response.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + storage = response.parse() + assert_matches_type(Storage, storage, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_update(self, client: Gcore) -> None: - storage = client.storage.update( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.update( + storage_id=0, + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Gcore) -> None: - storage = client.storage.update( - storage_id=0, - expires="1 years 6 months", - server_alias="my-storage.company.com", - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.update( + storage_id=0, + expires="1 years 6 months", + server_alias="my-storage.company.com", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize def test_raw_response_update(self, client: Gcore) -> None: - response = client.storage.with_raw_response.update( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.with_raw_response.update( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -97,14 +110,15 @@ def test_raw_response_update(self, client: Gcore) -> None: @parametrize def test_streaming_response_update(self, client: Gcore) -> None: - with client.storage.with_streaming_response.update( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.with_streaming_response.update( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = response.parse() - assert_matches_type(Storage, storage, path=["response"]) + storage = response.parse() + assert_matches_type(Storage, storage, path=["response"]) assert cast(Any, response.is_closed) is True @@ -125,7 +139,7 @@ def test_method_list_with_all_params(self, client: Gcore) -> None: order_direction="asc", show_deleted=True, status="active", - type="s3", + type="s3_compatible", ) assert_matches_type(SyncOffsetPage[Storage], storage, path=["response"]) @@ -151,16 +165,19 @@ def test_streaming_response_list(self, client: Gcore) -> None: @parametrize def test_method_delete(self, client: Gcore) -> None: - storage = client.storage.delete( - 0, - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.delete( + 0, + ) + assert storage is None @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.storage.with_raw_response.delete( - 0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.with_raw_response.delete( + 0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -169,14 +186,15 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.storage.with_streaming_response.delete( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.with_streaming_response.delete( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = response.parse() - assert storage is None + storage = response.parse() + assert storage is None assert cast(Any, response.is_closed) is True @@ -213,18 +231,21 @@ def test_streaming_response_get(self, client: Gcore) -> None: @parametrize def test_method_link_ssh_key(self, client: Gcore) -> None: - storage = client.storage.link_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.link_ssh_key( + key_id=0, + storage_id=0, + ) + assert storage is None @parametrize def test_raw_response_link_ssh_key(self, client: Gcore) -> None: - response = client.storage.with_raw_response.link_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.with_raw_response.link_ssh_key( + key_id=0, + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -233,15 +254,16 @@ def test_raw_response_link_ssh_key(self, client: Gcore) -> None: @parametrize def test_streaming_response_link_ssh_key(self, client: Gcore) -> None: - with client.storage.with_streaming_response.link_ssh_key( - key_id=0, - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.with_streaming_response.link_ssh_key( + key_id=0, + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = response.parse() - assert storage is None + storage = response.parse() + assert storage is None assert cast(Any, response.is_closed) is True @@ -286,18 +308,21 @@ def test_streaming_response_restore(self, client: Gcore) -> None: @parametrize def test_method_unlink_ssh_key(self, client: Gcore) -> None: - storage = client.storage.unlink_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = client.storage.unlink_ssh_key( + key_id=0, + storage_id=0, + ) + assert storage is None @parametrize def test_raw_response_unlink_ssh_key(self, client: Gcore) -> None: - response = client.storage.with_raw_response.unlink_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = client.storage.with_raw_response.unlink_ssh_key( + key_id=0, + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -306,15 +331,16 @@ def test_raw_response_unlink_ssh_key(self, client: Gcore) -> None: @parametrize def test_streaming_response_unlink_ssh_key(self, client: Gcore) -> None: - with client.storage.with_streaming_response.unlink_ssh_key( - key_id=0, - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.storage.with_streaming_response.unlink_ssh_key( + key_id=0, + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = response.parse() - assert storage is None + storage = response.parse() + assert storage is None assert cast(Any, response.is_closed) is True @@ -326,31 +352,36 @@ class TestAsyncStorage: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - generate_sftp_password=True, - sftp_password="sftp_password", - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + generate_sftp_password=True, + sftp_password="sftp_password", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.with_raw_response.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.with_raw_response.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -359,40 +390,46 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.storage.with_streaming_response.create( - location="s-region-1", - name="my-storage-prod", - type="s3", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - storage = await response.parse() - assert_matches_type(Storage, storage, path=["response"]) + with pytest.warns(DeprecationWarning): + async with async_client.storage.with_streaming_response.create( + location="s-region-1", + name="my-storage-prod", + type="s3_compatible", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + storage = await response.parse() + assert_matches_type(Storage, storage, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_update(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.update( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.update( + storage_id=0, + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.update( - storage_id=0, - expires="1 years 6 months", - server_alias="my-storage.company.com", - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.update( + storage_id=0, + expires="1 years 6 months", + server_alias="my-storage.company.com", + ) + assert_matches_type(Storage, storage, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.with_raw_response.update( - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.with_raw_response.update( + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -401,14 +438,15 @@ async def test_raw_response_update(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_update(self, async_client: AsyncGcore) -> None: - async with async_client.storage.with_streaming_response.update( - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.with_streaming_response.update( + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = await response.parse() - assert_matches_type(Storage, storage, path=["response"]) + storage = await response.parse() + assert_matches_type(Storage, storage, path=["response"]) assert cast(Any, response.is_closed) is True @@ -429,7 +467,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> No order_direction="asc", show_deleted=True, status="active", - type="s3", + type="s3_compatible", ) assert_matches_type(AsyncOffsetPage[Storage], storage, path=["response"]) @@ -455,16 +493,19 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.delete( - 0, - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.delete( + 0, + ) + assert storage is None @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.with_raw_response.delete( - 0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.with_raw_response.delete( + 0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -473,14 +514,15 @@ async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.storage.with_streaming_response.delete( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.with_streaming_response.delete( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = await response.parse() - assert storage is None + storage = await response.parse() + assert storage is None assert cast(Any, response.is_closed) is True @@ -517,18 +559,21 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_link_ssh_key(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.link_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.link_ssh_key( + key_id=0, + storage_id=0, + ) + assert storage is None @parametrize async def test_raw_response_link_ssh_key(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.with_raw_response.link_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.with_raw_response.link_ssh_key( + key_id=0, + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -537,15 +582,16 @@ async def test_raw_response_link_ssh_key(self, async_client: AsyncGcore) -> None @parametrize async def test_streaming_response_link_ssh_key(self, async_client: AsyncGcore) -> None: - async with async_client.storage.with_streaming_response.link_ssh_key( - key_id=0, - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.storage.with_streaming_response.link_ssh_key( + key_id=0, + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - storage = await response.parse() - assert storage is None + storage = await response.parse() + assert storage is None assert cast(Any, response.is_closed) is True @@ -590,18 +636,21 @@ async def test_streaming_response_restore(self, async_client: AsyncGcore) -> Non @parametrize async def test_method_unlink_ssh_key(self, async_client: AsyncGcore) -> None: - storage = await async_client.storage.unlink_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + storage = await async_client.storage.unlink_ssh_key( + key_id=0, + storage_id=0, + ) + assert storage is None @parametrize async def test_raw_response_unlink_ssh_key(self, async_client: AsyncGcore) -> None: - response = await async_client.storage.with_raw_response.unlink_ssh_key( - key_id=0, - storage_id=0, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.storage.with_raw_response.unlink_ssh_key( + key_id=0, + storage_id=0, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -610,14 +659,15 @@ async def test_raw_response_unlink_ssh_key(self, async_client: AsyncGcore) -> No @parametrize async def test_streaming_response_unlink_ssh_key(self, async_client: AsyncGcore) -> None: - async with async_client.storage.with_streaming_response.unlink_ssh_key( - key_id=0, - storage_id=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - storage = await response.parse() - assert storage is None + with pytest.warns(DeprecationWarning): + async with async_client.storage.with_streaming_response.unlink_ssh_key( + key_id=0, + storage_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + storage = await response.parse() + assert storage is None assert cast(Any, response.is_closed) is True From 34d65c17e2438ba6ab5d60907936eb5d12181a31 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:21:23 +0000 Subject: [PATCH 04/11] feat(api): aggregated API specs update --- .stats.yml | 4 ++-- tests/api_resources/iam/test_api_tokens.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index a290a331..f8b5ee01 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-247700eb0839f11fe995398e8b8160e264107a22a6d8a783628f070ef9888cee.yml -openapi_spec_hash: 05ee580780bc68d0c339faad61915b9b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml +openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 config_hash: bc578a7de14c42e33b7d4bd4502218f2 diff --git a/tests/api_resources/iam/test_api_tokens.py b/tests/api_resources/iam/test_api_tokens.py index a524f1db..314e9993 100644 --- a/tests/api_resources/iam/test_api_tokens.py +++ b/tests/api_resources/iam/test_api_tokens.py @@ -22,7 +22,7 @@ def test_method_create(self, client: Gcore) -> None: api_token = client.iam.api_tokens.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) assert_matches_type(APITokenCreated, api_token, path=["response"]) @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: "name": "Administrators", } }, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", description="It's my token", ) @@ -48,7 +48,7 @@ def test_raw_response_create(self, client: Gcore) -> None: response = client.iam.api_tokens.with_raw_response.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) @@ -62,7 +62,7 @@ def test_streaming_response_create(self, client: Gcore) -> None: with client.iam.api_tokens.with_streaming_response.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) as response: assert not response.is_closed @@ -194,7 +194,7 @@ async def test_method_create(self, async_client: AsyncGcore) -> None: api_token = await async_client.iam.api_tokens.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) assert_matches_type(APITokenCreated, api_token, path=["response"]) @@ -209,7 +209,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> "name": "Administrators", } }, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", description="It's my token", ) @@ -220,7 +220,7 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: response = await async_client.iam.api_tokens.with_raw_response.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) @@ -234,7 +234,7 @@ async def test_streaming_response_create(self, async_client: AsyncGcore) -> None async with async_client.iam.api_tokens.with_streaming_response.create( client_id=0, client_user={}, - exp_date="2021-01-01 12:00:00+00:00", + exp_date="2021-01-01T12:00:00.000000Z", name="My token", ) as response: assert not response.is_closed From df7fbed9dca33894eaf3111bf7d87b0a1aa16977 Mon Sep 17 00:00:00 2001 From: Pedro Oliveira <8281907+pedrodeoliveira@users.noreply.github.com> Date: Wed, 18 Feb 2026 13:58:21 +0000 Subject: [PATCH 05/11] fix(storage): update storage type and ignore deprecation in examples --- examples/storage/basic.py | 8 ++++---- examples/storage/basic_async.py | 8 ++++---- examples/storage/credentials.py | 16 ++++++++-------- examples/storage/credentials_async.py | 16 ++++++++-------- examples/storage/s3_buckets.py | 18 +++++++++--------- examples/storage/s3_buckets_async.py | 18 +++++++++--------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/examples/storage/basic.py b/examples/storage/basic.py index 0f21b3c2..cd134630 100644 --- a/examples/storage/basic.py +++ b/examples/storage/basic.py @@ -22,9 +22,9 @@ def main() -> None: def create_storage(*, client: Gcore) -> int: print("\n=== CREATE STORAGE ===") name = f"example-s3-storage-{int(time.time())}" - storage = client.storage.create( + storage = client.storage.create( # pyright: ignore[reportDeprecated] name=name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -57,7 +57,7 @@ def get_storage(*, client: Gcore, storage_id: int) -> None: def update_storage(*, client: Gcore, storage_id: int) -> None: print("\n=== UPDATE STORAGE ===") - storage = client.storage.update( + storage = client.storage.update( # pyright: ignore[reportDeprecated] storage_id=storage_id, expires="30 days", ) @@ -67,7 +67,7 @@ def update_storage(*, client: Gcore, storage_id: int) -> None: def delete_storage(*, client: Gcore, storage_id: int) -> None: print("\n=== DELETE STORAGE ===") - client.storage.delete(storage_id=storage_id) + client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") diff --git a/examples/storage/basic_async.py b/examples/storage/basic_async.py index fcbdf0ec..8d898fec 100644 --- a/examples/storage/basic_async.py +++ b/examples/storage/basic_async.py @@ -23,9 +23,9 @@ async def main() -> None: async def create_storage(*, client: AsyncGcore) -> int: print("\n=== CREATE STORAGE ===") name = f"example-s3-storage-{int(time.time())}" - storage = await client.storage.create( + storage = await client.storage.create( # pyright: ignore[reportDeprecated] name=name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -60,7 +60,7 @@ async def get_storage(*, client: AsyncGcore, storage_id: int) -> None: async def update_storage(*, client: AsyncGcore, storage_id: int) -> None: print("\n=== UPDATE STORAGE ===") - storage = await client.storage.update( + storage = await client.storage.update( # pyright: ignore[reportDeprecated] storage_id=storage_id, expires="30 days", ) @@ -70,7 +70,7 @@ async def update_storage(*, client: AsyncGcore, storage_id: int) -> None: async def delete_storage(*, client: AsyncGcore, storage_id: int) -> None: print("\n=== DELETE STORAGE ===") - await client.storage.delete(storage_id=storage_id) + await client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") diff --git a/examples/storage/credentials.py b/examples/storage/credentials.py index 9c40ede4..f46914f9 100644 --- a/examples/storage/credentials.py +++ b/examples/storage/credentials.py @@ -30,9 +30,9 @@ def main() -> None: def create_s3_storage(*, client: Gcore) -> int: print("\n=== CREATE S3 STORAGE ===") s3_name = f"s3-creds-example-{int(time.time())}" - storage = client.storage.create( + storage = client.storage.create( # pyright: ignore[reportDeprecated] name=s3_name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -47,7 +47,7 @@ def create_s3_storage(*, client: Gcore) -> int: def create_sftp_storage(*, client: Gcore) -> int: print("\n=== CREATE SFTP STORAGE ===") sftp_name = f"sftp-ex-{int(time.time()) % 1000000}" - storage = client.storage.create( + storage = client.storage.create( # pyright: ignore[reportDeprecated] name=sftp_name, type="sftp", location="ams", @@ -90,7 +90,7 @@ def get_storage(*, client: Gcore, storage_id: int) -> None: def generate_s3_keys(*, client: Gcore, s3_storage_id: int) -> None: print("\n=== GENERATE S3 KEYS ===") - storage = client.storage.credentials.recreate( + storage = client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=s3_storage_id, generate_s3_keys=True, ) @@ -103,7 +103,7 @@ def generate_s3_keys(*, client: Gcore, s3_storage_id: int) -> None: def generate_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: print("\n=== GENERATE SFTP PASSWORD ===") - storage = client.storage.credentials.recreate( + storage = client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, generate_sftp_password=True, ) @@ -115,7 +115,7 @@ def generate_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: def set_custom_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: print("\n=== SET CUSTOM SFTP PASSWORD ===") custom_password = "MyNewSecurePassword456!" - client.storage.credentials.recreate( + client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, sftp_password=custom_password, ) @@ -125,7 +125,7 @@ def set_custom_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: def delete_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: print("\n=== DELETE SFTP PASSWORD ===") - client.storage.credentials.recreate( + client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, delete_sftp_password=True, ) @@ -136,7 +136,7 @@ def delete_sftp_password(*, client: Gcore, sftp_storage_id: int) -> None: def delete_storage(*, client: Gcore, storage_id: int) -> None: """Delete a single storage""" print("\n=== DELETE STORAGE ===") - client.storage.delete(storage_id=storage_id) + client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") diff --git a/examples/storage/credentials_async.py b/examples/storage/credentials_async.py index 80ab67c5..4a9b3134 100644 --- a/examples/storage/credentials_async.py +++ b/examples/storage/credentials_async.py @@ -31,9 +31,9 @@ async def main() -> None: async def create_s3_storage(*, client: AsyncGcore) -> int: print("\n=== CREATE S3 STORAGE ===") s3_name = f"s3-creds-example-{int(time.time())}" - storage = await client.storage.create( + storage = await client.storage.create( # pyright: ignore[reportDeprecated] name=s3_name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -48,7 +48,7 @@ async def create_s3_storage(*, client: AsyncGcore) -> int: async def create_sftp_storage(*, client: AsyncGcore) -> int: print("\n=== CREATE SFTP STORAGE ===") sftp_name = f"sftp-ex-{int(time.time()) % 1000000}" - storage = await client.storage.create( + storage = await client.storage.create( # pyright: ignore[reportDeprecated] name=sftp_name, type="sftp", location="ams", @@ -91,7 +91,7 @@ async def get_storage(*, client: AsyncGcore, storage_id: int) -> None: async def generate_s3_keys(*, client: AsyncGcore, s3_storage_id: int) -> None: print("\n=== GENERATE S3 KEYS ===") - storage = await client.storage.credentials.recreate( + storage = await client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=s3_storage_id, generate_s3_keys=True, ) @@ -104,7 +104,7 @@ async def generate_s3_keys(*, client: AsyncGcore, s3_storage_id: int) -> None: async def generate_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) -> None: print("\n=== GENERATE SFTP PASSWORD ===") - storage = await client.storage.credentials.recreate( + storage = await client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, generate_sftp_password=True, ) @@ -116,7 +116,7 @@ async def generate_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) -> async def set_custom_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) -> None: print("\n=== SET CUSTOM SFTP PASSWORD ===") custom_password = "MyNewSecurePassword456!" - await client.storage.credentials.recreate( + await client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, sftp_password=custom_password, ) @@ -126,7 +126,7 @@ async def set_custom_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) async def delete_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) -> None: print("\n=== DELETE SFTP PASSWORD ===") - await client.storage.credentials.recreate( + await client.storage.credentials.recreate( # pyright: ignore[reportDeprecated] storage_id=sftp_storage_id, delete_sftp_password=True, ) @@ -137,7 +137,7 @@ async def delete_sftp_password(*, client: AsyncGcore, sftp_storage_id: int) -> N async def delete_storage(*, client: AsyncGcore, storage_id: int) -> None: """Delete a single storage""" print("\n=== DELETE STORAGE ===") - await client.storage.delete(storage_id=storage_id) + await client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") diff --git a/examples/storage/s3_buckets.py b/examples/storage/s3_buckets.py index fa7a3029..2c516e3e 100644 --- a/examples/storage/s3_buckets.py +++ b/examples/storage/s3_buckets.py @@ -31,9 +31,9 @@ def main() -> None: def create_s3_storage(*, client: Gcore) -> int: print("\n=== CREATE S3 STORAGE ===") storage_name = f"s3-bucket-example-{int(time.time())}" - storage = client.storage.create( + storage = client.storage.create( # pyright: ignore[reportDeprecated] name=storage_name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -66,7 +66,7 @@ def create_bucket(*, client: Gcore, storage_id: int) -> str: print("\n=== CREATE BUCKET ===") timestamp = int(time.time()) bucket_name = f"example-bucket-{timestamp}" - client.storage.buckets.create( + client.storage.buckets.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -77,7 +77,7 @@ def create_bucket(*, client: Gcore, storage_id: int) -> str: def list_buckets(*, client: Gcore, storage_id: int) -> None: print("\n=== LIST BUCKETS ===") - buckets = client.storage.buckets.list(storage_id=storage_id) + buckets = client.storage.buckets.list(storage_id=storage_id) # pyright: ignore[reportDeprecated] for count, bucket in enumerate(buckets, 1): lifecycle_info = f", Lifecycle: {bucket.lifecycle} days" if bucket.lifecycle and bucket.lifecycle > 0 else "" print(f" {count}. Bucket: Name={bucket.name}{lifecycle_info}") @@ -86,7 +86,7 @@ def list_buckets(*, client: Gcore, storage_id: int) -> None: def set_bucket_lifecycle(*, client: Gcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET LIFECYCLE ===") - client.storage.buckets.lifecycle.create( + client.storage.buckets.lifecycle.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, expiration_days=30, @@ -97,7 +97,7 @@ def set_bucket_lifecycle(*, client: Gcore, storage_id: int, bucket_name: str) -> def set_bucket_cors(*, client: Gcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET CORS ===") - client.storage.buckets.cors.create( + client.storage.buckets.cors.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, allowed_origins=["*"], @@ -108,7 +108,7 @@ def set_bucket_cors(*, client: Gcore, storage_id: int, bucket_name: str) -> None def set_bucket_policy(*, client: Gcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET POLICY ===") - client.storage.buckets.policy.create( + client.storage.buckets.policy.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -118,7 +118,7 @@ def set_bucket_policy(*, client: Gcore, storage_id: int, bucket_name: str) -> No def delete_bucket(*, client: Gcore, storage_id: int, bucket_name: str) -> None: print("\n=== DELETE BUCKET ===") - client.storage.buckets.delete( + client.storage.buckets.delete( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -128,7 +128,7 @@ def delete_bucket(*, client: Gcore, storage_id: int, bucket_name: str) -> None: def delete_storage(*, client: Gcore, storage_id: int) -> None: print("\n=== DELETE STORAGE ===") - client.storage.delete(storage_id=storage_id) + client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") diff --git a/examples/storage/s3_buckets_async.py b/examples/storage/s3_buckets_async.py index fc372e13..25934d68 100644 --- a/examples/storage/s3_buckets_async.py +++ b/examples/storage/s3_buckets_async.py @@ -30,9 +30,9 @@ async def main() -> None: async def create_s3_storage(*, client: AsyncGcore) -> int: print("\n=== CREATE S3 STORAGE ===") storage_name = f"s3-bucket-example-{int(time.time())}" - storage = await client.storage.create( + storage = await client.storage.create( # pyright: ignore[reportDeprecated] name=storage_name, - type="s3", + type="s3_compatible", location="s-ed1", ) print(f"Created Storage: ID={storage.id}, Name={storage.name}, Type={storage.type}, Location={storage.location}") @@ -65,7 +65,7 @@ async def create_bucket(*, client: AsyncGcore, storage_id: int) -> str: print("\n=== CREATE BUCKET ===") timestamp = int(time.time()) bucket_name = f"example-bucket-{timestamp}" - await client.storage.buckets.create( + await client.storage.buckets.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -77,7 +77,7 @@ async def create_bucket(*, client: AsyncGcore, storage_id: int) -> str: async def list_buckets(*, client: AsyncGcore, storage_id: int) -> None: print("\n=== LIST BUCKETS ===") count = 1 - async for bucket in client.storage.buckets.list(storage_id=storage_id): + async for bucket in client.storage.buckets.list(storage_id=storage_id): # pyright: ignore[reportDeprecated] lifecycle_info = f", Lifecycle: {bucket.lifecycle} days" if bucket.lifecycle and bucket.lifecycle > 0 else "" print(f" {count}. Bucket: Name={bucket.name}{lifecycle_info}") count += 1 @@ -86,7 +86,7 @@ async def list_buckets(*, client: AsyncGcore, storage_id: int) -> None: async def set_bucket_lifecycle(*, client: AsyncGcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET LIFECYCLE ===") - await client.storage.buckets.lifecycle.create( + await client.storage.buckets.lifecycle.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, expiration_days=30, @@ -97,7 +97,7 @@ async def set_bucket_lifecycle(*, client: AsyncGcore, storage_id: int, bucket_na async def set_bucket_cors(*, client: AsyncGcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET CORS ===") - await client.storage.buckets.cors.create( + await client.storage.buckets.cors.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, allowed_origins=["*"], @@ -108,7 +108,7 @@ async def set_bucket_cors(*, client: AsyncGcore, storage_id: int, bucket_name: s async def set_bucket_policy(*, client: AsyncGcore, storage_id: int, bucket_name: str) -> None: print("\n=== SET BUCKET POLICY ===") - await client.storage.buckets.policy.create( + await client.storage.buckets.policy.create( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -118,7 +118,7 @@ async def set_bucket_policy(*, client: AsyncGcore, storage_id: int, bucket_name: async def delete_bucket(*, client: AsyncGcore, storage_id: int, bucket_name: str) -> None: print("\n=== DELETE BUCKET ===") - await client.storage.buckets.delete( + await client.storage.buckets.delete( # pyright: ignore[reportDeprecated] bucket_name=bucket_name, storage_id=storage_id, ) @@ -128,7 +128,7 @@ async def delete_bucket(*, client: AsyncGcore, storage_id: int, bucket_name: str async def delete_storage(*, client: AsyncGcore, storage_id: int) -> None: print("\n=== DELETE STORAGE ===") - await client.storage.delete(storage_id=storage_id) + await client.storage.delete(storage_id=storage_id) # pyright: ignore[reportDeprecated] print(f"Storage {storage_id} deleted successfully") print("======================") From d86c21322c7ea98ba5ada8ddb6e93843ac2c7719 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:54:00 +0000 Subject: [PATCH 06/11] refactor(cdn)!: move ip_ranges.list_ips to ips.list --- .stats.yml | 2 +- src/gcore/resources/cdn/__init__.py | 14 ++ src/gcore/resources/cdn/api.md | 15 +- src/gcore/resources/cdn/cdn.py | 32 +++ src/gcore/resources/cdn/ip_ranges.py | 115 +--------- src/gcore/resources/cdn/ips.py | 201 ++++++++++++++++++ src/gcore/types/cdn/__init__.py | 2 +- ...e_list_ips_params.py => ip_list_params.py} | 4 +- tests/api_resources/cdn/test_ip_ranges.py | 68 +----- tests/api_resources/cdn/test_ips.py | 90 ++++++++ 10 files changed, 356 insertions(+), 187 deletions(-) create mode 100644 src/gcore/resources/cdn/ips.py rename src/gcore/types/cdn/{ip_range_list_ips_params.py => ip_list_params.py} (84%) create mode 100644 tests/api_resources/cdn/test_ips.py diff --git a/.stats.yml b/.stats.yml index f8b5ee01..d13fc721 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 -config_hash: bc578a7de14c42e33b7d4bd4502218f2 +config_hash: e29bc1c2ddc012af347f59f3ff70a81c diff --git a/src/gcore/resources/cdn/__init__.py b/src/gcore/resources/cdn/__init__.py index 869fc050..4347554b 100644 --- a/src/gcore/resources/cdn/__init__.py +++ b/src/gcore/resources/cdn/__init__.py @@ -8,6 +8,14 @@ CDNResourceWithStreamingResponse, AsyncCDNResourceWithStreamingResponse, ) +from .ips import ( + IPsResource, + AsyncIPsResource, + IPsResourceWithRawResponse, + AsyncIPsResourceWithRawResponse, + IPsResourceWithStreamingResponse, + AsyncIPsResourceWithStreamingResponse, +) from .logs import ( LogsResource, AsyncLogsResource, @@ -192,6 +200,12 @@ "AsyncIPRangesResourceWithRawResponse", "IPRangesResourceWithStreamingResponse", "AsyncIPRangesResourceWithStreamingResponse", + "IPsResource", + "AsyncIPsResource", + "IPsResourceWithRawResponse", + "AsyncIPsResourceWithRawResponse", + "IPsResourceWithStreamingResponse", + "AsyncIPsResourceWithStreamingResponse", "CDNResource", "AsyncCDNResource", "CDNResourceWithRawResponse", diff --git a/src/gcore/resources/cdn/api.md b/src/gcore/resources/cdn/api.md index 70919175..56e75645 100644 --- a/src/gcore/resources/cdn/api.md +++ b/src/gcore/resources/cdn/api.md @@ -299,10 +299,21 @@ Methods: Types: ```python -from gcore.types.cdn import PublicIPList, PublicNetworkList +from gcore.types.cdn import PublicNetworkList ``` Methods: - client.cdn.ip_ranges.list(\*\*params) -> PublicNetworkList -- client.cdn.ip_ranges.list_ips(\*\*params) -> PublicIPList + +## IPs + +Types: + +```python +from gcore.types.cdn import PublicIPList +``` + +Methods: + +- client.cdn.ips.list(\*\*params) -> PublicIPList diff --git a/src/gcore/resources/cdn/cdn.py b/src/gcore/resources/cdn/cdn.py index 771c3776..892b17b5 100644 --- a/src/gcore/resources/cdn/cdn.py +++ b/src/gcore/resources/cdn/cdn.py @@ -4,6 +4,14 @@ import httpx +from .ips import ( + IPsResource, + AsyncIPsResource, + IPsResourceWithRawResponse, + AsyncIPsResourceWithRawResponse, + IPsResourceWithStreamingResponse, + AsyncIPsResourceWithStreamingResponse, +) from .logs import ( LogsResource, AsyncLogsResource, @@ -183,6 +191,10 @@ def metrics(self) -> MetricsResource: def ip_ranges(self) -> IPRangesResource: return IPRangesResource(self._client) + @cached_property + def ips(self) -> IPsResource: + return IPsResource(self._client) + @cached_property def with_raw_response(self) -> CDNResourceWithRawResponse: """ @@ -484,6 +496,10 @@ def metrics(self) -> AsyncMetricsResource: def ip_ranges(self) -> AsyncIPRangesResource: return AsyncIPRangesResource(self._client) + @cached_property + def ips(self) -> AsyncIPsResource: + return AsyncIPsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncCDNResourceWithRawResponse: """ @@ -810,6 +826,10 @@ def metrics(self) -> MetricsResourceWithRawResponse: def ip_ranges(self) -> IPRangesResourceWithRawResponse: return IPRangesResourceWithRawResponse(self._cdn.ip_ranges) + @cached_property + def ips(self) -> IPsResourceWithRawResponse: + return IPsResourceWithRawResponse(self._cdn.ips) + class AsyncCDNResourceWithRawResponse: def __init__(self, cdn: AsyncCDNResource) -> None: @@ -889,6 +909,10 @@ def metrics(self) -> AsyncMetricsResourceWithRawResponse: def ip_ranges(self) -> AsyncIPRangesResourceWithRawResponse: return AsyncIPRangesResourceWithRawResponse(self._cdn.ip_ranges) + @cached_property + def ips(self) -> AsyncIPsResourceWithRawResponse: + return AsyncIPsResourceWithRawResponse(self._cdn.ips) + class CDNResourceWithStreamingResponse: def __init__(self, cdn: CDNResource) -> None: @@ -968,6 +992,10 @@ def metrics(self) -> MetricsResourceWithStreamingResponse: def ip_ranges(self) -> IPRangesResourceWithStreamingResponse: return IPRangesResourceWithStreamingResponse(self._cdn.ip_ranges) + @cached_property + def ips(self) -> IPsResourceWithStreamingResponse: + return IPsResourceWithStreamingResponse(self._cdn.ips) + class AsyncCDNResourceWithStreamingResponse: def __init__(self, cdn: AsyncCDNResource) -> None: @@ -1046,3 +1074,7 @@ def metrics(self) -> AsyncMetricsResourceWithStreamingResponse: @cached_property def ip_ranges(self) -> AsyncIPRangesResourceWithStreamingResponse: return AsyncIPRangesResourceWithStreamingResponse(self._cdn.ip_ranges) + + @cached_property + def ips(self) -> AsyncIPsResourceWithStreamingResponse: + return AsyncIPsResourceWithStreamingResponse(self._cdn.ips) diff --git a/src/gcore/resources/cdn/ip_ranges.py b/src/gcore/resources/cdn/ip_ranges.py index ee39f4a9..7f001ef6 100644 --- a/src/gcore/resources/cdn/ip_ranges.py +++ b/src/gcore/resources/cdn/ip_ranges.py @@ -16,9 +16,8 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...types.cdn import ip_range_list_params, ip_range_list_ips_params +from ...types.cdn import ip_range_list_params from ..._base_client import make_request_options -from ...types.cdn.public_ip_list import PublicIPList from ...types.cdn.public_network_list import PublicNetworkList __all__ = ["IPRangesResource", "AsyncIPRangesResource"] @@ -93,56 +92,6 @@ def list( cast_to=PublicNetworkList, ) - def list_ips( - self, - *, - format: Literal["json", "plain"] | Omit = omit, - accept: Literal["application/json", "text/plain"] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PublicIPList: - """ - Get all IP addresses of CDN servers that can be used to pull content from your - origin. - - This list is updated periodically. If you want to use IP from this list to - configure IP ACL in your origin, you need to independently monitor its - relevance. We recommend using a script to automatically update IP ACL. - - This request does not require authorization. - - Args: - format: Optional format override. When set, this takes precedence over the `Accept` - header. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - extra_headers = { - **strip_not_given({"Accept": str(accept) if is_given(accept) else not_given}), - **(extra_headers or {}), - } - return self._get( - "/cdn/public-ip-list", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"format": format}, ip_range_list_ips_params.IPRangeListIPsParams), - ), - cast_to=PublicIPList, - ) - class AsyncIPRangesResource(AsyncAPIResource): @cached_property @@ -213,56 +162,6 @@ async def list( cast_to=PublicNetworkList, ) - async def list_ips( - self, - *, - format: Literal["json", "plain"] | Omit = omit, - accept: Literal["application/json", "text/plain"] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PublicIPList: - """ - Get all IP addresses of CDN servers that can be used to pull content from your - origin. - - This list is updated periodically. If you want to use IP from this list to - configure IP ACL in your origin, you need to independently monitor its - relevance. We recommend using a script to automatically update IP ACL. - - This request does not require authorization. - - Args: - format: Optional format override. When set, this takes precedence over the `Accept` - header. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - extra_headers = { - **strip_not_given({"Accept": str(accept) if is_given(accept) else not_given}), - **(extra_headers or {}), - } - return await self._get( - "/cdn/public-ip-list", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"format": format}, ip_range_list_ips_params.IPRangeListIPsParams), - ), - cast_to=PublicIPList, - ) - class IPRangesResourceWithRawResponse: def __init__(self, ip_ranges: IPRangesResource) -> None: @@ -271,9 +170,6 @@ def __init__(self, ip_ranges: IPRangesResource) -> None: self.list = to_raw_response_wrapper( ip_ranges.list, ) - self.list_ips = to_raw_response_wrapper( - ip_ranges.list_ips, - ) class AsyncIPRangesResourceWithRawResponse: @@ -283,9 +179,6 @@ def __init__(self, ip_ranges: AsyncIPRangesResource) -> None: self.list = async_to_raw_response_wrapper( ip_ranges.list, ) - self.list_ips = async_to_raw_response_wrapper( - ip_ranges.list_ips, - ) class IPRangesResourceWithStreamingResponse: @@ -295,9 +188,6 @@ def __init__(self, ip_ranges: IPRangesResource) -> None: self.list = to_streamed_response_wrapper( ip_ranges.list, ) - self.list_ips = to_streamed_response_wrapper( - ip_ranges.list_ips, - ) class AsyncIPRangesResourceWithStreamingResponse: @@ -307,6 +197,3 @@ def __init__(self, ip_ranges: AsyncIPRangesResource) -> None: self.list = async_to_streamed_response_wrapper( ip_ranges.list, ) - self.list_ips = async_to_streamed_response_wrapper( - ip_ranges.list_ips, - ) diff --git a/src/gcore/resources/cdn/ips.py b/src/gcore/resources/cdn/ips.py new file mode 100644 index 00000000..5574a7bb --- /dev/null +++ b/src/gcore/resources/cdn/ips.py @@ -0,0 +1,201 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...types.cdn import ip_list_params +from ..._base_client import make_request_options +from ...types.cdn.public_ip_list import PublicIPList + +__all__ = ["IPsResource", "AsyncIPsResource"] + + +class IPsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IPsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return IPsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IPsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return IPsResourceWithStreamingResponse(self) + + def list( + self, + *, + format: Literal["json", "plain"] | Omit = omit, + accept: Literal["application/json", "text/plain"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PublicIPList: + """ + Get all IP addresses of CDN servers that can be used to pull content from your + origin. + + This list is updated periodically. If you want to use IP from this list to + configure IP ACL in your origin, you need to independently monitor its + relevance. We recommend using a script to automatically update IP ACL. + + This request does not require authorization. + + Args: + format: Optional format override. When set, this takes precedence over the `Accept` + header. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = { + **strip_not_given({"Accept": str(accept) if is_given(accept) else not_given}), + **(extra_headers or {}), + } + return self._get( + "/cdn/public-ip-list", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"format": format}, ip_list_params.IPListParams), + ), + cast_to=PublicIPList, + ) + + +class AsyncIPsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIPsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncIPsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIPsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncIPsResourceWithStreamingResponse(self) + + async def list( + self, + *, + format: Literal["json", "plain"] | Omit = omit, + accept: Literal["application/json", "text/plain"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PublicIPList: + """ + Get all IP addresses of CDN servers that can be used to pull content from your + origin. + + This list is updated periodically. If you want to use IP from this list to + configure IP ACL in your origin, you need to independently monitor its + relevance. We recommend using a script to automatically update IP ACL. + + This request does not require authorization. + + Args: + format: Optional format override. When set, this takes precedence over the `Accept` + header. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = { + **strip_not_given({"Accept": str(accept) if is_given(accept) else not_given}), + **(extra_headers or {}), + } + return await self._get( + "/cdn/public-ip-list", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"format": format}, ip_list_params.IPListParams), + ), + cast_to=PublicIPList, + ) + + +class IPsResourceWithRawResponse: + def __init__(self, ips: IPsResource) -> None: + self._ips = ips + + self.list = to_raw_response_wrapper( + ips.list, + ) + + +class AsyncIPsResourceWithRawResponse: + def __init__(self, ips: AsyncIPsResource) -> None: + self._ips = ips + + self.list = async_to_raw_response_wrapper( + ips.list, + ) + + +class IPsResourceWithStreamingResponse: + def __init__(self, ips: IPsResource) -> None: + self._ips = ips + + self.list = to_streamed_response_wrapper( + ips.list, + ) + + +class AsyncIPsResourceWithStreamingResponse: + def __init__(self, ips: AsyncIPsResource) -> None: + self._ips = ips + + self.list = async_to_streamed_response_wrapper( + ips.list, + ) diff --git a/src/gcore/types/cdn/__init__.py b/src/gcore/types/cdn/__init__.py index 92895e33..5b706659 100644 --- a/src/gcore/types/cdn/__init__.py +++ b/src/gcore/types/cdn/__init__.py @@ -12,6 +12,7 @@ from .origin_groups import OriginGroups as OriginGroups from .rule_template import RuleTemplate as RuleTemplate from .ca_certificate import CaCertificate as CaCertificate +from .ip_list_params import IPListParams as IPListParams from .public_ip_list import PublicIPList as PublicIPList from .alibaba_regions import AlibabaRegions as AlibabaRegions from .log_list_params import LogListParams as LogListParams @@ -39,7 +40,6 @@ from .certificate_list_params import CertificateListParams as CertificateListParams from .shield_aggregated_stats import ShieldAggregatedStats as ShieldAggregatedStats from .cdn_resource_list_params import CDNResourceListParams as CDNResourceListParams -from .ip_range_list_ips_params import IPRangeListIPsParams as IPRangeListIPsParams from .logs_uploader_validation import LogsUploaderValidation as LogsUploaderValidation from .origin_group_list_params import OriginGroupListParams as OriginGroupListParams from .cdn_resource_purge_params import CDNResourcePurgeParams as CDNResourcePurgeParams diff --git a/src/gcore/types/cdn/ip_range_list_ips_params.py b/src/gcore/types/cdn/ip_list_params.py similarity index 84% rename from src/gcore/types/cdn/ip_range_list_ips_params.py rename to src/gcore/types/cdn/ip_list_params.py index f10f642c..88fac54e 100644 --- a/src/gcore/types/cdn/ip_range_list_ips_params.py +++ b/src/gcore/types/cdn/ip_list_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["IPRangeListIPsParams"] +__all__ = ["IPListParams"] -class IPRangeListIPsParams(TypedDict, total=False): +class IPListParams(TypedDict, total=False): format: Literal["json", "plain"] """ Optional format override. When set, this takes precedence over the `Accept` diff --git a/tests/api_resources/cdn/test_ip_ranges.py b/tests/api_resources/cdn/test_ip_ranges.py index b4967cd6..e801f362 100644 --- a/tests/api_resources/cdn/test_ip_ranges.py +++ b/tests/api_resources/cdn/test_ip_ranges.py @@ -9,7 +9,7 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type -from gcore.types.cdn import PublicIPList, PublicNetworkList +from gcore.types.cdn import PublicNetworkList base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -50,39 +50,6 @@ def test_streaming_response_list(self, client: Gcore) -> None: assert cast(Any, response.is_closed) is True - @parametrize - def test_method_list_ips(self, client: Gcore) -> None: - ip_range = client.cdn.ip_ranges.list_ips() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - def test_method_list_ips_with_all_params(self, client: Gcore) -> None: - ip_range = client.cdn.ip_ranges.list_ips( - format="json", - accept="application/json", - ) - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - def test_raw_response_list_ips(self, client: Gcore) -> None: - response = client.cdn.ip_ranges.with_raw_response.list_ips() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ip_range = response.parse() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - def test_streaming_response_list_ips(self, client: Gcore) -> None: - with client.cdn.ip_ranges.with_streaming_response.list_ips() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ip_range = response.parse() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - assert cast(Any, response.is_closed) is True - class TestAsyncIPRanges: parametrize = pytest.mark.parametrize( @@ -121,36 +88,3 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: assert_matches_type(PublicNetworkList, ip_range, path=["response"]) assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_list_ips(self, async_client: AsyncGcore) -> None: - ip_range = await async_client.cdn.ip_ranges.list_ips() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - async def test_method_list_ips_with_all_params(self, async_client: AsyncGcore) -> None: - ip_range = await async_client.cdn.ip_ranges.list_ips( - format="json", - accept="application/json", - ) - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - async def test_raw_response_list_ips(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.ip_ranges.with_raw_response.list_ips() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ip_range = await response.parse() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - @parametrize - async def test_streaming_response_list_ips(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.ip_ranges.with_streaming_response.list_ips() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ip_range = await response.parse() - assert_matches_type(PublicIPList, ip_range, path=["response"]) - - assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/test_ips.py b/tests/api_resources/cdn/test_ips.py new file mode 100644 index 00000000..c94c2ac8 --- /dev/null +++ b/tests/api_resources/cdn/test_ips.py @@ -0,0 +1,90 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.cdn import PublicIPList + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIPs: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Gcore) -> None: + ip = client.cdn.ips.list() + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Gcore) -> None: + ip = client.cdn.ips.list( + format="json", + accept="application/json", + ) + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Gcore) -> None: + response = client.cdn.ips.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip = response.parse() + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Gcore) -> None: + with client.cdn.ips.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip = response.parse() + assert_matches_type(PublicIPList, ip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncIPs: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncGcore) -> None: + ip = await async_client.cdn.ips.list() + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: + ip = await async_client.cdn.ips.list( + format="json", + accept="application/json", + ) + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncGcore) -> None: + response = await async_client.cdn.ips.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip = await response.parse() + assert_matches_type(PublicIPList, ip, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: + async with async_client.cdn.ips.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip = await response.parse() + assert_matches_type(PublicIPList, ip, path=["response"]) + + assert cast(Any, response.is_closed) is True From c156758df6af4bc9516794adf1ab984d7f17d29e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:55:17 +0000 Subject: [PATCH 07/11] refactor(streaming)!: move playlists.list_videos to playlists.videos.list --- .stats.yml | 2 +- src/gcore/resources/streaming/api.md | 30 ++-- .../resources/streaming/playlists/__init__.py | 33 ++++ .../streaming/{ => playlists}/playlists.py | 127 +++++--------- .../resources/streaming/playlists/videos.py | 159 ++++++++++++++++++ src/gcore/resources/streaming/streaming.py | 16 +- src/gcore/types/streaming/__init__.py | 1 - .../types/streaming/playlists/__init__.py | 5 + .../video_list_response.py} | 6 +- .../streaming/playlists/__init__.py | 1 + .../streaming/playlists/test_videos.py | 86 ++++++++++ .../api_resources/streaming/test_playlists.py | 63 ------- 12 files changed, 356 insertions(+), 173 deletions(-) create mode 100644 src/gcore/resources/streaming/playlists/__init__.py rename src/gcore/resources/streaming/{ => playlists}/playlists.py (92%) create mode 100644 src/gcore/resources/streaming/playlists/videos.py create mode 100644 src/gcore/types/streaming/playlists/__init__.py rename src/gcore/types/streaming/{playlist_list_videos_response.py => playlists/video_list_response.py} (51%) create mode 100644 tests/api_resources/streaming/playlists/__init__.py create mode 100644 tests/api_resources/streaming/playlists/test_videos.py diff --git a/.stats.yml b/.stats.yml index d13fc721..5fcfa385 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 -config_hash: e29bc1c2ddc012af347f59f3ff70a81c +config_hash: 3e264ee16128fcb92256ca2b068decbb diff --git a/src/gcore/resources/streaming/api.md b/src/gcore/resources/streaming/api.md index 1e868475..a16cba9a 100644 --- a/src/gcore/resources/streaming/api.md +++ b/src/gcore/resources/streaming/api.md @@ -106,22 +106,28 @@ Methods: Types: ```python -from gcore.types.streaming import ( - Playlist, - PlaylistCreated, - PlaylistVideo, - PlaylistListVideosResponse, -) +from gcore.types.streaming import Playlist, PlaylistCreated, PlaylistVideo +``` + +Methods: + +- client.streaming.playlists.create(\*\*params) -> PlaylistCreated +- client.streaming.playlists.update(playlist_id, \*\*params) -> Playlist +- client.streaming.playlists.list(\*\*params) -> SyncPageStreaming[Playlist] +- client.streaming.playlists.delete(playlist_id) -> None +- client.streaming.playlists.get(playlist_id) -> Playlist + +### Videos + +Types: + +```python +from gcore.types.streaming.playlists import VideoListResponse ``` Methods: -- client.streaming.playlists.create(\*\*params) -> PlaylistCreated -- client.streaming.playlists.update(playlist_id, \*\*params) -> Playlist -- client.streaming.playlists.list(\*\*params) -> SyncPageStreaming[Playlist] -- client.streaming.playlists.delete(playlist_id) -> None -- client.streaming.playlists.get(playlist_id) -> Playlist -- client.streaming.playlists.list_videos(playlist_id) -> PlaylistListVideosResponse +- client.streaming.playlists.videos.list(playlist_id) -> VideoListResponse ## Videos diff --git a/src/gcore/resources/streaming/playlists/__init__.py b/src/gcore/resources/streaming/playlists/__init__.py new file mode 100644 index 00000000..32b0eee0 --- /dev/null +++ b/src/gcore/resources/streaming/playlists/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .videos import ( + VideosResource, + AsyncVideosResource, + VideosResourceWithRawResponse, + AsyncVideosResourceWithRawResponse, + VideosResourceWithStreamingResponse, + AsyncVideosResourceWithStreamingResponse, +) +from .playlists import ( + PlaylistsResource, + AsyncPlaylistsResource, + PlaylistsResourceWithRawResponse, + AsyncPlaylistsResourceWithRawResponse, + PlaylistsResourceWithStreamingResponse, + AsyncPlaylistsResourceWithStreamingResponse, +) + +__all__ = [ + "VideosResource", + "AsyncVideosResource", + "VideosResourceWithRawResponse", + "AsyncVideosResourceWithRawResponse", + "VideosResourceWithStreamingResponse", + "AsyncVideosResourceWithStreamingResponse", + "PlaylistsResource", + "AsyncPlaylistsResource", + "PlaylistsResourceWithRawResponse", + "AsyncPlaylistsResourceWithRawResponse", + "PlaylistsResourceWithStreamingResponse", + "AsyncPlaylistsResourceWithStreamingResponse", +] diff --git a/src/gcore/resources/streaming/playlists.py b/src/gcore/resources/streaming/playlists/playlists.py similarity index 92% rename from src/gcore/resources/streaming/playlists.py rename to src/gcore/resources/streaming/playlists/playlists.py index 28f15c1a..23bcdad7 100644 --- a/src/gcore/resources/streaming/playlists.py +++ b/src/gcore/resources/streaming/playlists/playlists.py @@ -7,27 +7,38 @@ import httpx -from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +from .videos import ( + VideosResource, + AsyncVideosResource, + VideosResourceWithRawResponse, + AsyncVideosResourceWithRawResponse, + VideosResourceWithStreamingResponse, + AsyncVideosResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncPageStreaming, AsyncPageStreaming -from ..._base_client import AsyncPaginator, make_request_options -from ...types.streaming import playlist_list_params, playlist_create_params, playlist_update_params -from ...types.streaming.playlist import Playlist -from ...types.streaming.playlist_created import PlaylistCreated -from ...types.streaming.playlist_list_videos_response import PlaylistListVideosResponse +from ....pagination import SyncPageStreaming, AsyncPageStreaming +from ...._base_client import AsyncPaginator, make_request_options +from ....types.streaming import playlist_list_params, playlist_create_params, playlist_update_params +from ....types.streaming.playlist import Playlist +from ....types.streaming.playlist_created import PlaylistCreated __all__ = ["PlaylistsResource", "AsyncPlaylistsResource"] class PlaylistsResource(SyncAPIResource): + @cached_property + def videos(self) -> VideosResource: + return VideosResource(self._client) + @cached_property def with_raw_response(self) -> PlaylistsResourceWithRawResponse: """ @@ -486,39 +497,12 @@ def get( cast_to=Playlist, ) - def list_videos( - self, - playlist_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PlaylistListVideosResponse: - """ - Shows ordered array of playlist videos - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - f"/streaming/playlists/{playlist_id}/videos", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=PlaylistListVideosResponse, - ) - class AsyncPlaylistsResource(AsyncAPIResource): + @cached_property + def videos(self) -> AsyncVideosResource: + return AsyncVideosResource(self._client) + @cached_property def with_raw_response(self) -> AsyncPlaylistsResourceWithRawResponse: """ @@ -977,37 +961,6 @@ async def get( cast_to=Playlist, ) - async def list_videos( - self, - playlist_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PlaylistListVideosResponse: - """ - Shows ordered array of playlist videos - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - f"/streaming/playlists/{playlist_id}/videos", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=PlaylistListVideosResponse, - ) - class PlaylistsResourceWithRawResponse: def __init__(self, playlists: PlaylistsResource) -> None: @@ -1028,9 +981,10 @@ def __init__(self, playlists: PlaylistsResource) -> None: self.get = to_raw_response_wrapper( playlists.get, ) - self.list_videos = to_raw_response_wrapper( - playlists.list_videos, - ) + + @cached_property + def videos(self) -> VideosResourceWithRawResponse: + return VideosResourceWithRawResponse(self._playlists.videos) class AsyncPlaylistsResourceWithRawResponse: @@ -1052,9 +1006,10 @@ def __init__(self, playlists: AsyncPlaylistsResource) -> None: self.get = async_to_raw_response_wrapper( playlists.get, ) - self.list_videos = async_to_raw_response_wrapper( - playlists.list_videos, - ) + + @cached_property + def videos(self) -> AsyncVideosResourceWithRawResponse: + return AsyncVideosResourceWithRawResponse(self._playlists.videos) class PlaylistsResourceWithStreamingResponse: @@ -1076,9 +1031,10 @@ def __init__(self, playlists: PlaylistsResource) -> None: self.get = to_streamed_response_wrapper( playlists.get, ) - self.list_videos = to_streamed_response_wrapper( - playlists.list_videos, - ) + + @cached_property + def videos(self) -> VideosResourceWithStreamingResponse: + return VideosResourceWithStreamingResponse(self._playlists.videos) class AsyncPlaylistsResourceWithStreamingResponse: @@ -1100,6 +1056,7 @@ def __init__(self, playlists: AsyncPlaylistsResource) -> None: self.get = async_to_streamed_response_wrapper( playlists.get, ) - self.list_videos = async_to_streamed_response_wrapper( - playlists.list_videos, - ) + + @cached_property + def videos(self) -> AsyncVideosResourceWithStreamingResponse: + return AsyncVideosResourceWithStreamingResponse(self._playlists.videos) diff --git a/src/gcore/resources/streaming/playlists/videos.py b/src/gcore/resources/streaming/playlists/videos.py new file mode 100644 index 00000000..b5478e10 --- /dev/null +++ b/src/gcore/resources/streaming/playlists/videos.py @@ -0,0 +1,159 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.streaming.playlists.video_list_response import VideoListResponse + +__all__ = ["VideosResource", "AsyncVideosResource"] + + +class VideosResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VideosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return VideosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VideosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return VideosResourceWithStreamingResponse(self) + + def list( + self, + playlist_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VideoListResponse: + """ + Shows ordered array of playlist videos + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/streaming/playlists/{playlist_id}/videos", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VideoListResponse, + ) + + +class AsyncVideosResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVideosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncVideosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVideosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncVideosResourceWithStreamingResponse(self) + + async def list( + self, + playlist_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VideoListResponse: + """ + Shows ordered array of playlist videos + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/streaming/playlists/{playlist_id}/videos", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VideoListResponse, + ) + + +class VideosResourceWithRawResponse: + def __init__(self, videos: VideosResource) -> None: + self._videos = videos + + self.list = to_raw_response_wrapper( + videos.list, + ) + + +class AsyncVideosResourceWithRawResponse: + def __init__(self, videos: AsyncVideosResource) -> None: + self._videos = videos + + self.list = async_to_raw_response_wrapper( + videos.list, + ) + + +class VideosResourceWithStreamingResponse: + def __init__(self, videos: VideosResource) -> None: + self._videos = videos + + self.list = to_streamed_response_wrapper( + videos.list, + ) + + +class AsyncVideosResourceWithStreamingResponse: + def __init__(self, videos: AsyncVideosResource) -> None: + self._videos = videos + + self.list = async_to_streamed_response_wrapper( + videos.list, + ) diff --git a/src/gcore/resources/streaming/streaming.py b/src/gcore/resources/streaming/streaming.py index 11e18d2b..1048cdef 100644 --- a/src/gcore/resources/streaming/streaming.py +++ b/src/gcore/resources/streaming/streaming.py @@ -19,14 +19,6 @@ AsyncAITasksResourceWithStreamingResponse, ) from ..._compat import cached_property -from .playlists import ( - PlaylistsResource, - AsyncPlaylistsResource, - PlaylistsResourceWithRawResponse, - AsyncPlaylistsResourceWithRawResponse, - PlaylistsResourceWithStreamingResponse, - AsyncPlaylistsResourceWithStreamingResponse, -) from .restreams import ( RestreamsResource, AsyncRestreamsResource, @@ -84,6 +76,14 @@ StreamsResourceWithStreamingResponse, AsyncStreamsResourceWithStreamingResponse, ) +from .playlists.playlists import ( + PlaylistsResource, + AsyncPlaylistsResource, + PlaylistsResourceWithRawResponse, + AsyncPlaylistsResourceWithRawResponse, + PlaylistsResourceWithStreamingResponse, + AsyncPlaylistsResourceWithStreamingResponse, +) __all__ = ["StreamingResource", "AsyncStreamingResource"] diff --git a/src/gcore/types/streaming/__init__.py b/src/gcore/types/streaming/__init__.py index ab0d0c3c..f850f3ac 100644 --- a/src/gcore/types/streaming/__init__.py +++ b/src/gcore/types/streaming/__init__.py @@ -74,7 +74,6 @@ from .statistic_get_views_params import StatisticGetViewsParams as StatisticGetViewsParams from .stream_list_clips_response import StreamListClipsResponse as StreamListClipsResponse from .video_create_multiple_params import VideoCreateMultipleParams as VideoCreateMultipleParams -from .playlist_list_videos_response import PlaylistListVideosResponse as PlaylistListVideosResponse from .statistic_get_ffprobes_params import StatisticGetFfprobesParams as StatisticGetFfprobesParams from .ai_task_get_ai_settings_params import AITaskGetAISettingsParams as AITaskGetAISettingsParams from .quality_set_set_default_params import QualitySetSetDefaultParams as QualitySetSetDefaultParams diff --git a/src/gcore/types/streaming/playlists/__init__.py b/src/gcore/types/streaming/playlists/__init__.py new file mode 100644 index 00000000..45af0b59 --- /dev/null +++ b/src/gcore/types/streaming/playlists/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .video_list_response import VideoListResponse as VideoListResponse diff --git a/src/gcore/types/streaming/playlist_list_videos_response.py b/src/gcore/types/streaming/playlists/video_list_response.py similarity index 51% rename from src/gcore/types/streaming/playlist_list_videos_response.py rename to src/gcore/types/streaming/playlists/video_list_response.py index d8b5bf93..ca66bd37 100644 --- a/src/gcore/types/streaming/playlist_list_videos_response.py +++ b/src/gcore/types/streaming/playlists/video_list_response.py @@ -3,8 +3,8 @@ from typing import List from typing_extensions import TypeAlias -from .playlist_video import PlaylistVideo +from ..playlist_video import PlaylistVideo -__all__ = ["PlaylistListVideosResponse"] +__all__ = ["VideoListResponse"] -PlaylistListVideosResponse: TypeAlias = List[PlaylistVideo] +VideoListResponse: TypeAlias = List[PlaylistVideo] diff --git a/tests/api_resources/streaming/playlists/__init__.py b/tests/api_resources/streaming/playlists/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/streaming/playlists/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/streaming/playlists/test_videos.py b/tests/api_resources/streaming/playlists/test_videos.py new file mode 100644 index 00000000..fd1ab763 --- /dev/null +++ b/tests/api_resources/streaming/playlists/test_videos.py @@ -0,0 +1,86 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.streaming.playlists import VideoListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVideos: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Gcore) -> None: + video = client.streaming.playlists.videos.list( + 0, + ) + assert_matches_type(VideoListResponse, video, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Gcore) -> None: + response = client.streaming.playlists.videos.with_raw_response.list( + 0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + video = response.parse() + assert_matches_type(VideoListResponse, video, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Gcore) -> None: + with client.streaming.playlists.videos.with_streaming_response.list( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + video = response.parse() + assert_matches_type(VideoListResponse, video, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncVideos: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncGcore) -> None: + video = await async_client.streaming.playlists.videos.list( + 0, + ) + assert_matches_type(VideoListResponse, video, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncGcore) -> None: + response = await async_client.streaming.playlists.videos.with_raw_response.list( + 0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + video = await response.parse() + assert_matches_type(VideoListResponse, video, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: + async with async_client.streaming.playlists.videos.with_streaming_response.list( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + video = await response.parse() + assert_matches_type(VideoListResponse, video, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/streaming/test_playlists.py b/tests/api_resources/streaming/test_playlists.py index 753dd073..c9e49cc2 100644 --- a/tests/api_resources/streaming/test_playlists.py +++ b/tests/api_resources/streaming/test_playlists.py @@ -13,7 +13,6 @@ from gcore.types.streaming import ( Playlist, PlaylistCreated, - PlaylistListVideosResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -213,37 +212,6 @@ def test_streaming_response_get(self, client: Gcore) -> None: assert cast(Any, response.is_closed) is True - @parametrize - def test_method_list_videos(self, client: Gcore) -> None: - playlist = client.streaming.playlists.list_videos( - 0, - ) - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - @parametrize - def test_raw_response_list_videos(self, client: Gcore) -> None: - response = client.streaming.playlists.with_raw_response.list_videos( - 0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - playlist = response.parse() - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - @parametrize - def test_streaming_response_list_videos(self, client: Gcore) -> None: - with client.streaming.playlists.with_streaming_response.list_videos( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - playlist = response.parse() - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - assert cast(Any, response.is_closed) is True - class TestAsyncPlaylists: parametrize = pytest.mark.parametrize( @@ -440,34 +408,3 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: assert_matches_type(Playlist, playlist, path=["response"]) assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_list_videos(self, async_client: AsyncGcore) -> None: - playlist = await async_client.streaming.playlists.list_videos( - 0, - ) - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - @parametrize - async def test_raw_response_list_videos(self, async_client: AsyncGcore) -> None: - response = await async_client.streaming.playlists.with_raw_response.list_videos( - 0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - playlist = await response.parse() - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - @parametrize - async def test_streaming_response_list_videos(self, async_client: AsyncGcore) -> None: - async with async_client.streaming.playlists.with_streaming_response.list_videos( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - playlist = await response.parse() - assert_matches_type(PlaylistListVideosResponse, playlist, path=["response"]) - - assert cast(Any, response.is_closed) is True From 3618fc747692a6b6921ec82cba39180b6d99021a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:56:41 +0000 Subject: [PATCH 08/11] refactor(streaming)!: move streams clip methods to streams.clips --- .stats.yml | 2 +- src/gcore/resources/streaming/api.md | 22 +- .../resources/streaming/streams/__init__.py | 14 + .../resources/streaming/streams/clips.py | 500 ++++++++++++++++++ .../resources/streaming/streams/streams.py | 453 ++-------------- src/gcore/types/streaming/__init__.py | 3 - src/gcore/types/streaming/streams/__init__.py | 3 + .../types/streaming/{ => streams}/clip.py | 2 +- .../clip_create_params.py} | 4 +- .../clip_list_response.py} | 4 +- .../streaming/streams/test_clips.py | 176 ++++++ tests/api_resources/streaming/test_streams.py | 160 ------ 12 files changed, 746 insertions(+), 597 deletions(-) create mode 100644 src/gcore/resources/streaming/streams/clips.py rename src/gcore/types/streaming/{ => streams}/clip.py (98%) rename src/gcore/types/streaming/{stream_create_clip_params.py => streams/clip_create_params.py} (96%) rename src/gcore/types/streaming/{stream_list_clips_response.py => streams/clip_list_response.py} (67%) create mode 100644 tests/api_resources/streaming/streams/test_clips.py diff --git a/.stats.yml b/.stats.yml index 5fcfa385..a58aaa95 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 -config_hash: 3e264ee16128fcb92256ca2b068decbb +config_hash: b07ea4587f9078d7da7d498163b001b5 diff --git a/src/gcore/resources/streaming/api.md b/src/gcore/resources/streaming/api.md index a16cba9a..00101c67 100644 --- a/src/gcore/resources/streaming/api.md +++ b/src/gcore/resources/streaming/api.md @@ -177,12 +177,7 @@ Methods: Types: ```python -from gcore.types.streaming import ( - Clip, - Stream, - StreamListClipsResponse, - StreamStartRecordingResponse, -) +from gcore.types.streaming import Stream, StreamStartRecordingResponse ``` Methods: @@ -192,12 +187,23 @@ Methods: - client.streaming.streams.list(\*\*params) -> SyncPageStreaming[Stream] - client.streaming.streams.delete(stream_id) -> None - client.streaming.streams.clear_dvr(stream_id) -> None -- client.streaming.streams.create_clip(stream_id, \*\*params) -> Clip - client.streaming.streams.get(stream_id) -> Stream -- client.streaming.streams.list_clips(stream_id) -> StreamListClipsResponse - client.streaming.streams.start_recording(stream_id) -> StreamStartRecordingResponse - client.streaming.streams.stop_recording(stream_id) -> Video +### Clips + +Types: + +```python +from gcore.types.streaming.streams import Clip, ClipListResponse +``` + +Methods: + +- client.streaming.streams.clips.create(stream_id, \*\*params) -> Clip +- client.streaming.streams.clips.list(stream_id) -> ClipListResponse + ### Overlays Types: diff --git a/src/gcore/resources/streaming/streams/__init__.py b/src/gcore/resources/streaming/streams/__init__.py index 49461963..10994775 100644 --- a/src/gcore/resources/streaming/streams/__init__.py +++ b/src/gcore/resources/streaming/streams/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .clips import ( + ClipsResource, + AsyncClipsResource, + ClipsResourceWithRawResponse, + AsyncClipsResourceWithRawResponse, + ClipsResourceWithStreamingResponse, + AsyncClipsResourceWithStreamingResponse, +) from .streams import ( StreamsResource, AsyncStreamsResource, @@ -18,6 +26,12 @@ ) __all__ = [ + "ClipsResource", + "AsyncClipsResource", + "ClipsResourceWithRawResponse", + "AsyncClipsResourceWithRawResponse", + "ClipsResourceWithStreamingResponse", + "AsyncClipsResourceWithStreamingResponse", "OverlaysResource", "AsyncOverlaysResource", "OverlaysResourceWithRawResponse", diff --git a/src/gcore/resources/streaming/streams/clips.py b/src/gcore/resources/streaming/streams/clips.py new file mode 100644 index 00000000..9641f759 --- /dev/null +++ b/src/gcore/resources/streaming/streams/clips.py @@ -0,0 +1,500 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.streaming.streams import clip_create_params +from ....types.streaming.streams.clip import Clip +from ....types.streaming.streams.clip_list_response import ClipListResponse + +__all__ = ["ClipsResource", "AsyncClipsResource"] + + +class ClipsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ClipsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return ClipsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ClipsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return ClipsResourceWithStreamingResponse(self) + + def create( + self, + stream_id: int, + *, + duration: int, + expiration: int | Omit = omit, + start: int | Omit = omit, + vod_required: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Clip: + """ + Create an instant clip from on-going live stream. + + Instant clips are applicable in cases where there is no time to wait for the + broadcast to be completed and recorded. For example, for quickly cutting + highlights in sport events, or cutting an important moment in the news or live + performance. + + DVR function must be enabled for clip recording. If the DVR is disabled, the + response will be error 422. + + Instant clip becomes available for viewing in the following formats: + + - HLS .m3u8, + - MP4, + - VOD in video hosting with a permanent link to watch video. + + ![HTML Overlays](https://demo-files.gvideo.io/apidocs/clip_recording_mp4_hls.gif) + + **Clip lifetime:** + + Instant clips are a copy of the stream, created from a live stream. They are + stored in memory for a limited time, after which the clip ceases to exist and + you will receive a 404 on the link. + + Limits that you should keep in mind: + + - The clip's lifespan is controlled by `expiration` parameter. + - The default expiration value is 1 hour. The value can be set from 1 minute to + 4 hours. + - If you want a video for longer or permanent viewing, then create a regular VOD + based on the clip. This way you can use the clip's link for the first time, + and immediately after the transcoded version is ready, you can change by + yourself it to a permanent link of VOD. + - The clip becomes available only after it is completely copied from the live + stream. So the clip will be available after `start + duration` exact time. If + you try to request it before this time, the response will be error code 425 + "Too Early". + + **Cutting a clip from a source:** + + In order to use clips recording feature, DVR must be enabled for a stream: + "dvr_enabled: true". The DVR serves as a source for creating clips: + + - By default live stream DVR is set to 1 hour (3600 seconds). You can create an + instant clip using any segment of this time period by specifying the desired + start time and duration. + - If you create a clip, but the DVR expires, the clip will still exist for the + specified time as a copy of the stream. + + **Getting permanent VOD:** + + To get permanent VOD version of a live clip use this parameter when making a + request to create a clip: `vod_required: true`. + + Later, when the clip is ready, grab `video_id` value from the response and query + the video by regular GET /video/{id} method. + + Args: + duration: Requested segment duration in seconds to be cut. + + Please, note that cutting is based on the idea of instantly creating a clip, + instead of precise timing. So final segment may be: + + - Less than the specified value if there is less data in the DVR than the + requested segment. + - Greater than the specified value, because segment is aligned to the first and + last key frames of already stored fragment in DVR, this way -1 and +1 chunks + can be added to left and right. + + Duration of cutted segment cannot be greater than DVR duration for this stream. + Therefore, to change the maximum, use "dvr_duration" parameter of this stream. + + expiration: Expire time of the clip via a public link. + + Unix timestamp in seconds, absolute value. + + This is the time how long the instant clip will be stored in the server memory + and can be accessed via public HLS/MP4 links. Download and/or use the instant + clip before this time expires. + + After the time has expired, the clip is deleted from memory and is no longer + available via the link. You need to create a new segment, or use + `vod_required: true` attribute. + + If value is omitted, then expiration is counted as +3600 seconds (1 hour) to the + end of the clip (i.e. `unix timestamp = + + 3600`). + + Allowed range: 1m <= expiration <= 4h. + + Example: + `24.05.2024 14:00:00 (GMT) + 60 seconds of duration + 3600 seconds of expiration = 24.05.2024 15:01:00 (GMT) is Unix timestamp = 1716562860` + + start: Starting point of the segment to cut. + + Unix timestamp in seconds, absolute value. Example: + `24.05.2024 14:00:00 (GMT) is Unix timestamp = 1716559200` + + If a value from the past is specified, it is used as the starting point for the + segment to cut. If the value is omitted, then clip will start from now. + + vod_required: Indicates if video needs to be stored also as permanent VOD + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._put( + f"/streaming/streams/{stream_id}/clip_recording", + body=maybe_transform( + { + "duration": duration, + "expiration": expiration, + "start": start, + "vod_required": vod_required, + }, + clip_create_params.ClipCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Clip, + ) + + def list( + self, + stream_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ClipListResponse: + """ + Get list of non expired instant clips for a stream. + + You can now use both MP4 just-in-time packager and HLS for all clips. Get URLs + from "hls_master" and "mp4_master". + + **How to download renditions of clips:** + + URLs contain "master" alias by default, which means maximum available quality + from ABR set (based on height metadata). There is also possibility to access + individual bitrates from ABR ladder. That works for both HLS and MP4. You can + replace manually "master" to a value from renditions list in order to get exact + bitrate/quality from the set. Example: + + - HLS 720p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.m3u8` + - HLS 720p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.m3u8` + - MP4 360p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.mp4` + - MP4 360p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.mp4` + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/streaming/streams/{stream_id}/clip_recording", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ClipListResponse, + ) + + +class AsyncClipsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncClipsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncClipsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncClipsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncClipsResourceWithStreamingResponse(self) + + async def create( + self, + stream_id: int, + *, + duration: int, + expiration: int | Omit = omit, + start: int | Omit = omit, + vod_required: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Clip: + """ + Create an instant clip from on-going live stream. + + Instant clips are applicable in cases where there is no time to wait for the + broadcast to be completed and recorded. For example, for quickly cutting + highlights in sport events, or cutting an important moment in the news or live + performance. + + DVR function must be enabled for clip recording. If the DVR is disabled, the + response will be error 422. + + Instant clip becomes available for viewing in the following formats: + + - HLS .m3u8, + - MP4, + - VOD in video hosting with a permanent link to watch video. + + ![HTML Overlays](https://demo-files.gvideo.io/apidocs/clip_recording_mp4_hls.gif) + + **Clip lifetime:** + + Instant clips are a copy of the stream, created from a live stream. They are + stored in memory for a limited time, after which the clip ceases to exist and + you will receive a 404 on the link. + + Limits that you should keep in mind: + + - The clip's lifespan is controlled by `expiration` parameter. + - The default expiration value is 1 hour. The value can be set from 1 minute to + 4 hours. + - If you want a video for longer or permanent viewing, then create a regular VOD + based on the clip. This way you can use the clip's link for the first time, + and immediately after the transcoded version is ready, you can change by + yourself it to a permanent link of VOD. + - The clip becomes available only after it is completely copied from the live + stream. So the clip will be available after `start + duration` exact time. If + you try to request it before this time, the response will be error code 425 + "Too Early". + + **Cutting a clip from a source:** + + In order to use clips recording feature, DVR must be enabled for a stream: + "dvr_enabled: true". The DVR serves as a source for creating clips: + + - By default live stream DVR is set to 1 hour (3600 seconds). You can create an + instant clip using any segment of this time period by specifying the desired + start time and duration. + - If you create a clip, but the DVR expires, the clip will still exist for the + specified time as a copy of the stream. + + **Getting permanent VOD:** + + To get permanent VOD version of a live clip use this parameter when making a + request to create a clip: `vod_required: true`. + + Later, when the clip is ready, grab `video_id` value from the response and query + the video by regular GET /video/{id} method. + + Args: + duration: Requested segment duration in seconds to be cut. + + Please, note that cutting is based on the idea of instantly creating a clip, + instead of precise timing. So final segment may be: + + - Less than the specified value if there is less data in the DVR than the + requested segment. + - Greater than the specified value, because segment is aligned to the first and + last key frames of already stored fragment in DVR, this way -1 and +1 chunks + can be added to left and right. + + Duration of cutted segment cannot be greater than DVR duration for this stream. + Therefore, to change the maximum, use "dvr_duration" parameter of this stream. + + expiration: Expire time of the clip via a public link. + + Unix timestamp in seconds, absolute value. + + This is the time how long the instant clip will be stored in the server memory + and can be accessed via public HLS/MP4 links. Download and/or use the instant + clip before this time expires. + + After the time has expired, the clip is deleted from memory and is no longer + available via the link. You need to create a new segment, or use + `vod_required: true` attribute. + + If value is omitted, then expiration is counted as +3600 seconds (1 hour) to the + end of the clip (i.e. `unix timestamp = + + 3600`). + + Allowed range: 1m <= expiration <= 4h. + + Example: + `24.05.2024 14:00:00 (GMT) + 60 seconds of duration + 3600 seconds of expiration = 24.05.2024 15:01:00 (GMT) is Unix timestamp = 1716562860` + + start: Starting point of the segment to cut. + + Unix timestamp in seconds, absolute value. Example: + `24.05.2024 14:00:00 (GMT) is Unix timestamp = 1716559200` + + If a value from the past is specified, it is used as the starting point for the + segment to cut. If the value is omitted, then clip will start from now. + + vod_required: Indicates if video needs to be stored also as permanent VOD + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._put( + f"/streaming/streams/{stream_id}/clip_recording", + body=await async_maybe_transform( + { + "duration": duration, + "expiration": expiration, + "start": start, + "vod_required": vod_required, + }, + clip_create_params.ClipCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Clip, + ) + + async def list( + self, + stream_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ClipListResponse: + """ + Get list of non expired instant clips for a stream. + + You can now use both MP4 just-in-time packager and HLS for all clips. Get URLs + from "hls_master" and "mp4_master". + + **How to download renditions of clips:** + + URLs contain "master" alias by default, which means maximum available quality + from ABR set (based on height metadata). There is also possibility to access + individual bitrates from ABR ladder. That works for both HLS and MP4. You can + replace manually "master" to a value from renditions list in order to get exact + bitrate/quality from the set. Example: + + - HLS 720p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.m3u8` + - HLS 720p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.m3u8` + - MP4 360p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.mp4` + - MP4 360p: + `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.mp4` + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/streaming/streams/{stream_id}/clip_recording", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ClipListResponse, + ) + + +class ClipsResourceWithRawResponse: + def __init__(self, clips: ClipsResource) -> None: + self._clips = clips + + self.create = to_raw_response_wrapper( + clips.create, + ) + self.list = to_raw_response_wrapper( + clips.list, + ) + + +class AsyncClipsResourceWithRawResponse: + def __init__(self, clips: AsyncClipsResource) -> None: + self._clips = clips + + self.create = async_to_raw_response_wrapper( + clips.create, + ) + self.list = async_to_raw_response_wrapper( + clips.list, + ) + + +class ClipsResourceWithStreamingResponse: + def __init__(self, clips: ClipsResource) -> None: + self._clips = clips + + self.create = to_streamed_response_wrapper( + clips.create, + ) + self.list = to_streamed_response_wrapper( + clips.list, + ) + + +class AsyncClipsResourceWithStreamingResponse: + def __init__(self, clips: AsyncClipsResource) -> None: + self._clips = clips + + self.create = async_to_streamed_response_wrapper( + clips.create, + ) + self.list = async_to_streamed_response_wrapper( + clips.list, + ) diff --git a/src/gcore/resources/streaming/streams/streams.py b/src/gcore/resources/streaming/streams/streams.py index 5fc4b7c5..e6d64810 100644 --- a/src/gcore/resources/streaming/streams/streams.py +++ b/src/gcore/resources/streaming/streams/streams.py @@ -7,6 +7,14 @@ import httpx +from .clips import ( + ClipsResource, + AsyncClipsResource, + ClipsResourceWithRawResponse, + AsyncClipsResourceWithRawResponse, + ClipsResourceWithStreamingResponse, + AsyncClipsResourceWithStreamingResponse, +) from .overlays import ( OverlaysResource, AsyncOverlaysResource, @@ -27,22 +35,19 @@ ) from ....pagination import SyncPageStreaming, AsyncPageStreaming from ...._base_client import AsyncPaginator, make_request_options -from ....types.streaming import ( - stream_list_params, - stream_create_params, - stream_update_params, - stream_create_clip_params, -) -from ....types.streaming.clip import Clip +from ....types.streaming import stream_list_params, stream_create_params, stream_update_params from ....types.streaming.video import Video from ....types.streaming.stream import Stream -from ....types.streaming.stream_list_clips_response import StreamListClipsResponse from ....types.streaming.stream_start_recording_response import StreamStartRecordingResponse __all__ = ["StreamsResource", "AsyncStreamsResource"] class StreamsResource(SyncAPIResource): + @cached_property + def clips(self) -> ClipsResource: + return ClipsResource(self._client) + @cached_property def overlays(self) -> OverlaysResource: return OverlaysResource(self._client) @@ -446,149 +451,6 @@ def clear_dvr( cast_to=NoneType, ) - def create_clip( - self, - stream_id: int, - *, - duration: int, - expiration: int | Omit = omit, - start: int | Omit = omit, - vod_required: bool | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> Clip: - """ - Create an instant clip from on-going live stream. - - Instant clips are applicable in cases where there is no time to wait for the - broadcast to be completed and recorded. For example, for quickly cutting - highlights in sport events, or cutting an important moment in the news or live - performance. - - DVR function must be enabled for clip recording. If the DVR is disabled, the - response will be error 422. - - Instant clip becomes available for viewing in the following formats: - - - HLS .m3u8, - - MP4, - - VOD in video hosting with a permanent link to watch video. - - ![HTML Overlays](https://demo-files.gvideo.io/apidocs/clip_recording_mp4_hls.gif) - - **Clip lifetime:** - - Instant clips are a copy of the stream, created from a live stream. They are - stored in memory for a limited time, after which the clip ceases to exist and - you will receive a 404 on the link. - - Limits that you should keep in mind: - - - The clip's lifespan is controlled by `expiration` parameter. - - The default expiration value is 1 hour. The value can be set from 1 minute to - 4 hours. - - If you want a video for longer or permanent viewing, then create a regular VOD - based on the clip. This way you can use the clip's link for the first time, - and immediately after the transcoded version is ready, you can change by - yourself it to a permanent link of VOD. - - The clip becomes available only after it is completely copied from the live - stream. So the clip will be available after `start + duration` exact time. If - you try to request it before this time, the response will be error code 425 - "Too Early". - - **Cutting a clip from a source:** - - In order to use clips recording feature, DVR must be enabled for a stream: - "dvr_enabled: true". The DVR serves as a source for creating clips: - - - By default live stream DVR is set to 1 hour (3600 seconds). You can create an - instant clip using any segment of this time period by specifying the desired - start time and duration. - - If you create a clip, but the DVR expires, the clip will still exist for the - specified time as a copy of the stream. - - **Getting permanent VOD:** - - To get permanent VOD version of a live clip use this parameter when making a - request to create a clip: `vod_required: true`. - - Later, when the clip is ready, grab `video_id` value from the response and query - the video by regular GET /video/{id} method. - - Args: - duration: Requested segment duration in seconds to be cut. - - Please, note that cutting is based on the idea of instantly creating a clip, - instead of precise timing. So final segment may be: - - - Less than the specified value if there is less data in the DVR than the - requested segment. - - Greater than the specified value, because segment is aligned to the first and - last key frames of already stored fragment in DVR, this way -1 and +1 chunks - can be added to left and right. - - Duration of cutted segment cannot be greater than DVR duration for this stream. - Therefore, to change the maximum, use "dvr_duration" parameter of this stream. - - expiration: Expire time of the clip via a public link. - - Unix timestamp in seconds, absolute value. - - This is the time how long the instant clip will be stored in the server memory - and can be accessed via public HLS/MP4 links. Download and/or use the instant - clip before this time expires. - - After the time has expired, the clip is deleted from memory and is no longer - available via the link. You need to create a new segment, or use - `vod_required: true` attribute. - - If value is omitted, then expiration is counted as +3600 seconds (1 hour) to the - end of the clip (i.e. `unix timestamp = + + 3600`). - - Allowed range: 1m <= expiration <= 4h. - - Example: - `24.05.2024 14:00:00 (GMT) + 60 seconds of duration + 3600 seconds of expiration = 24.05.2024 15:01:00 (GMT) is Unix timestamp = 1716562860` - - start: Starting point of the segment to cut. - - Unix timestamp in seconds, absolute value. Example: - `24.05.2024 14:00:00 (GMT) is Unix timestamp = 1716559200` - - If a value from the past is specified, it is used as the starting point for the - segment to cut. If the value is omitted, then clip will start from now. - - vod_required: Indicates if video needs to be stored also as permanent VOD - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._put( - f"/streaming/streams/{stream_id}/clip_recording", - body=maybe_transform( - { - "duration": duration, - "expiration": expiration, - "start": start, - "vod_required": vod_required, - }, - stream_create_clip_params.StreamCreateClipParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Clip, - ) - def get( self, stream_id: int, @@ -620,57 +482,6 @@ def get( cast_to=Stream, ) - def list_clips( - self, - stream_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> StreamListClipsResponse: - """ - Get list of non expired instant clips for a stream. - - You can now use both MP4 just-in-time packager and HLS for all clips. Get URLs - from "hls_master" and "mp4_master". - - **How to download renditions of clips:** - - URLs contain "master" alias by default, which means maximum available quality - from ABR set (based on height metadata). There is also possibility to access - individual bitrates from ABR ladder. That works for both HLS and MP4. You can - replace manually "master" to a value from renditions list in order to get exact - bitrate/quality from the set. Example: - - - HLS 720p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.m3u8` - - HLS 720p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.m3u8` - - MP4 360p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.mp4` - - MP4 360p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.mp4` - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - f"/streaming/streams/{stream_id}/clip_recording", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=StreamListClipsResponse, - ) - def start_recording( self, stream_id: int, @@ -781,6 +592,10 @@ def stop_recording( class AsyncStreamsResource(AsyncAPIResource): + @cached_property + def clips(self) -> AsyncClipsResource: + return AsyncClipsResource(self._client) + @cached_property def overlays(self) -> AsyncOverlaysResource: return AsyncOverlaysResource(self._client) @@ -1184,149 +999,6 @@ async def clear_dvr( cast_to=NoneType, ) - async def create_clip( - self, - stream_id: int, - *, - duration: int, - expiration: int | Omit = omit, - start: int | Omit = omit, - vod_required: bool | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> Clip: - """ - Create an instant clip from on-going live stream. - - Instant clips are applicable in cases where there is no time to wait for the - broadcast to be completed and recorded. For example, for quickly cutting - highlights in sport events, or cutting an important moment in the news or live - performance. - - DVR function must be enabled for clip recording. If the DVR is disabled, the - response will be error 422. - - Instant clip becomes available for viewing in the following formats: - - - HLS .m3u8, - - MP4, - - VOD in video hosting with a permanent link to watch video. - - ![HTML Overlays](https://demo-files.gvideo.io/apidocs/clip_recording_mp4_hls.gif) - - **Clip lifetime:** - - Instant clips are a copy of the stream, created from a live stream. They are - stored in memory for a limited time, after which the clip ceases to exist and - you will receive a 404 on the link. - - Limits that you should keep in mind: - - - The clip's lifespan is controlled by `expiration` parameter. - - The default expiration value is 1 hour. The value can be set from 1 minute to - 4 hours. - - If you want a video for longer or permanent viewing, then create a regular VOD - based on the clip. This way you can use the clip's link for the first time, - and immediately after the transcoded version is ready, you can change by - yourself it to a permanent link of VOD. - - The clip becomes available only after it is completely copied from the live - stream. So the clip will be available after `start + duration` exact time. If - you try to request it before this time, the response will be error code 425 - "Too Early". - - **Cutting a clip from a source:** - - In order to use clips recording feature, DVR must be enabled for a stream: - "dvr_enabled: true". The DVR serves as a source for creating clips: - - - By default live stream DVR is set to 1 hour (3600 seconds). You can create an - instant clip using any segment of this time period by specifying the desired - start time and duration. - - If you create a clip, but the DVR expires, the clip will still exist for the - specified time as a copy of the stream. - - **Getting permanent VOD:** - - To get permanent VOD version of a live clip use this parameter when making a - request to create a clip: `vod_required: true`. - - Later, when the clip is ready, grab `video_id` value from the response and query - the video by regular GET /video/{id} method. - - Args: - duration: Requested segment duration in seconds to be cut. - - Please, note that cutting is based on the idea of instantly creating a clip, - instead of precise timing. So final segment may be: - - - Less than the specified value if there is less data in the DVR than the - requested segment. - - Greater than the specified value, because segment is aligned to the first and - last key frames of already stored fragment in DVR, this way -1 and +1 chunks - can be added to left and right. - - Duration of cutted segment cannot be greater than DVR duration for this stream. - Therefore, to change the maximum, use "dvr_duration" parameter of this stream. - - expiration: Expire time of the clip via a public link. - - Unix timestamp in seconds, absolute value. - - This is the time how long the instant clip will be stored in the server memory - and can be accessed via public HLS/MP4 links. Download and/or use the instant - clip before this time expires. - - After the time has expired, the clip is deleted from memory and is no longer - available via the link. You need to create a new segment, or use - `vod_required: true` attribute. - - If value is omitted, then expiration is counted as +3600 seconds (1 hour) to the - end of the clip (i.e. `unix timestamp = + + 3600`). - - Allowed range: 1m <= expiration <= 4h. - - Example: - `24.05.2024 14:00:00 (GMT) + 60 seconds of duration + 3600 seconds of expiration = 24.05.2024 15:01:00 (GMT) is Unix timestamp = 1716562860` - - start: Starting point of the segment to cut. - - Unix timestamp in seconds, absolute value. Example: - `24.05.2024 14:00:00 (GMT) is Unix timestamp = 1716559200` - - If a value from the past is specified, it is used as the starting point for the - segment to cut. If the value is omitted, then clip will start from now. - - vod_required: Indicates if video needs to be stored also as permanent VOD - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._put( - f"/streaming/streams/{stream_id}/clip_recording", - body=await async_maybe_transform( - { - "duration": duration, - "expiration": expiration, - "start": start, - "vod_required": vod_required, - }, - stream_create_clip_params.StreamCreateClipParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Clip, - ) - async def get( self, stream_id: int, @@ -1358,57 +1030,6 @@ async def get( cast_to=Stream, ) - async def list_clips( - self, - stream_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> StreamListClipsResponse: - """ - Get list of non expired instant clips for a stream. - - You can now use both MP4 just-in-time packager and HLS for all clips. Get URLs - from "hls_master" and "mp4_master". - - **How to download renditions of clips:** - - URLs contain "master" alias by default, which means maximum available quality - from ABR set (based on height metadata). There is also possibility to access - individual bitrates from ABR ladder. That works for both HLS and MP4. You can - replace manually "master" to a value from renditions list in order to get exact - bitrate/quality from the set. Example: - - - HLS 720p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.m3u8` - - HLS 720p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.m3u8` - - MP4 360p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.mp4` - - MP4 360p: - `https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.mp4` - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - f"/streaming/streams/{stream_id}/clip_recording", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=StreamListClipsResponse, - ) - async def start_recording( self, stream_id: int, @@ -1537,15 +1158,9 @@ def __init__(self, streams: StreamsResource) -> None: self.clear_dvr = to_raw_response_wrapper( streams.clear_dvr, ) - self.create_clip = to_raw_response_wrapper( - streams.create_clip, - ) self.get = to_raw_response_wrapper( streams.get, ) - self.list_clips = to_raw_response_wrapper( - streams.list_clips, - ) self.start_recording = to_raw_response_wrapper( streams.start_recording, ) @@ -1553,6 +1168,10 @@ def __init__(self, streams: StreamsResource) -> None: streams.stop_recording, ) + @cached_property + def clips(self) -> ClipsResourceWithRawResponse: + return ClipsResourceWithRawResponse(self._streams.clips) + @cached_property def overlays(self) -> OverlaysResourceWithRawResponse: return OverlaysResourceWithRawResponse(self._streams.overlays) @@ -1577,15 +1196,9 @@ def __init__(self, streams: AsyncStreamsResource) -> None: self.clear_dvr = async_to_raw_response_wrapper( streams.clear_dvr, ) - self.create_clip = async_to_raw_response_wrapper( - streams.create_clip, - ) self.get = async_to_raw_response_wrapper( streams.get, ) - self.list_clips = async_to_raw_response_wrapper( - streams.list_clips, - ) self.start_recording = async_to_raw_response_wrapper( streams.start_recording, ) @@ -1593,6 +1206,10 @@ def __init__(self, streams: AsyncStreamsResource) -> None: streams.stop_recording, ) + @cached_property + def clips(self) -> AsyncClipsResourceWithRawResponse: + return AsyncClipsResourceWithRawResponse(self._streams.clips) + @cached_property def overlays(self) -> AsyncOverlaysResourceWithRawResponse: return AsyncOverlaysResourceWithRawResponse(self._streams.overlays) @@ -1617,15 +1234,9 @@ def __init__(self, streams: StreamsResource) -> None: self.clear_dvr = to_streamed_response_wrapper( streams.clear_dvr, ) - self.create_clip = to_streamed_response_wrapper( - streams.create_clip, - ) self.get = to_streamed_response_wrapper( streams.get, ) - self.list_clips = to_streamed_response_wrapper( - streams.list_clips, - ) self.start_recording = to_streamed_response_wrapper( streams.start_recording, ) @@ -1633,6 +1244,10 @@ def __init__(self, streams: StreamsResource) -> None: streams.stop_recording, ) + @cached_property + def clips(self) -> ClipsResourceWithStreamingResponse: + return ClipsResourceWithStreamingResponse(self._streams.clips) + @cached_property def overlays(self) -> OverlaysResourceWithStreamingResponse: return OverlaysResourceWithStreamingResponse(self._streams.overlays) @@ -1657,15 +1272,9 @@ def __init__(self, streams: AsyncStreamsResource) -> None: self.clear_dvr = async_to_streamed_response_wrapper( streams.clear_dvr, ) - self.create_clip = async_to_streamed_response_wrapper( - streams.create_clip, - ) self.get = async_to_streamed_response_wrapper( streams.get, ) - self.list_clips = async_to_streamed_response_wrapper( - streams.list_clips, - ) self.start_recording = async_to_streamed_response_wrapper( streams.start_recording, ) @@ -1673,6 +1282,10 @@ def __init__(self, streams: AsyncStreamsResource) -> None: streams.stop_recording, ) + @cached_property + def clips(self) -> AsyncClipsResourceWithStreamingResponse: + return AsyncClipsResourceWithStreamingResponse(self._streams.clips) + @cached_property def overlays(self) -> AsyncOverlaysResourceWithStreamingResponse: return AsyncOverlaysResourceWithStreamingResponse(self._streams.overlays) diff --git a/src/gcore/types/streaming/__init__.py b/src/gcore/types/streaming/__init__.py index f850f3ac..188bcd30 100644 --- a/src/gcore/types/streaming/__init__.py +++ b/src/gcore/types/streaming/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .clip import Clip as Clip from .video import Video as Video from .views import Views as Views from .player import Player as Player @@ -67,12 +66,10 @@ from .video_list_names_params import VideoListNamesParams as VideoListNamesParams from .direct_upload_parameters import DirectUploadParameters as DirectUploadParameters from .ai_contentmoderation_nsfw import AIContentmoderationNsfw as AIContentmoderationNsfw -from .stream_create_clip_params import StreamCreateClipParams as StreamCreateClipParams from .views_by_operating_system import ViewsByOperatingSystem as ViewsByOperatingSystem from .ai_contentmoderation_sport import AIContentmoderationSport as AIContentmoderationSport from .broadcast_spectators_count import BroadcastSpectatorsCount as BroadcastSpectatorsCount from .statistic_get_views_params import StatisticGetViewsParams as StatisticGetViewsParams -from .stream_list_clips_response import StreamListClipsResponse as StreamListClipsResponse from .video_create_multiple_params import VideoCreateMultipleParams as VideoCreateMultipleParams from .statistic_get_ffprobes_params import StatisticGetFfprobesParams as StatisticGetFfprobesParams from .ai_task_get_ai_settings_params import AITaskGetAISettingsParams as AITaskGetAISettingsParams diff --git a/src/gcore/types/streaming/streams/__init__.py b/src/gcore/types/streaming/streams/__init__.py index e5f7a9b0..040c6172 100644 --- a/src/gcore/types/streaming/streams/__init__.py +++ b/src/gcore/types/streaming/streams/__init__.py @@ -2,7 +2,10 @@ from __future__ import annotations +from .clip import Clip as Clip from .overlay import Overlay as Overlay +from .clip_create_params import ClipCreateParams as ClipCreateParams +from .clip_list_response import ClipListResponse as ClipListResponse from .overlay_create_params import OverlayCreateParams as OverlayCreateParams from .overlay_list_response import OverlayListResponse as OverlayListResponse from .overlay_update_params import OverlayUpdateParams as OverlayUpdateParams diff --git a/src/gcore/types/streaming/clip.py b/src/gcore/types/streaming/streams/clip.py similarity index 98% rename from src/gcore/types/streaming/clip.py rename to src/gcore/types/streaming/streams/clip.py index 3cab9cc9..d08894dc 100644 --- a/src/gcore/types/streaming/clip.py +++ b/src/gcore/types/streaming/streams/clip.py @@ -2,7 +2,7 @@ from typing import List, Optional -from ..._models import BaseModel +from ...._models import BaseModel __all__ = ["Clip"] diff --git a/src/gcore/types/streaming/stream_create_clip_params.py b/src/gcore/types/streaming/streams/clip_create_params.py similarity index 96% rename from src/gcore/types/streaming/stream_create_clip_params.py rename to src/gcore/types/streaming/streams/clip_create_params.py index 2a2f365a..2da2631a 100644 --- a/src/gcore/types/streaming/stream_create_clip_params.py +++ b/src/gcore/types/streaming/streams/clip_create_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["StreamCreateClipParams"] +__all__ = ["ClipCreateParams"] -class StreamCreateClipParams(TypedDict, total=False): +class ClipCreateParams(TypedDict, total=False): duration: Required[int] """Requested segment duration in seconds to be cut. diff --git a/src/gcore/types/streaming/stream_list_clips_response.py b/src/gcore/types/streaming/streams/clip_list_response.py similarity index 67% rename from src/gcore/types/streaming/stream_list_clips_response.py rename to src/gcore/types/streaming/streams/clip_list_response.py index 851546a7..24705b2a 100644 --- a/src/gcore/types/streaming/stream_list_clips_response.py +++ b/src/gcore/types/streaming/streams/clip_list_response.py @@ -5,6 +5,6 @@ from .clip import Clip -__all__ = ["StreamListClipsResponse"] +__all__ = ["ClipListResponse"] -StreamListClipsResponse: TypeAlias = List[Clip] +ClipListResponse: TypeAlias = List[Clip] diff --git a/tests/api_resources/streaming/streams/test_clips.py b/tests/api_resources/streaming/streams/test_clips.py new file mode 100644 index 00000000..8b98e4cb --- /dev/null +++ b/tests/api_resources/streaming/streams/test_clips.py @@ -0,0 +1,176 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.streaming.streams import Clip, ClipListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestClips: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Gcore) -> None: + clip = client.streaming.streams.clips.create( + stream_id=0, + duration=0, + ) + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Gcore) -> None: + clip = client.streaming.streams.clips.create( + stream_id=0, + duration=0, + expiration=0, + start=0, + vod_required=True, + ) + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Gcore) -> None: + response = client.streaming.streams.clips.with_raw_response.create( + stream_id=0, + duration=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + clip = response.parse() + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Gcore) -> None: + with client.streaming.streams.clips.with_streaming_response.create( + stream_id=0, + duration=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + clip = response.parse() + assert_matches_type(Clip, clip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_list(self, client: Gcore) -> None: + clip = client.streaming.streams.clips.list( + 0, + ) + assert_matches_type(ClipListResponse, clip, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Gcore) -> None: + response = client.streaming.streams.clips.with_raw_response.list( + 0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + clip = response.parse() + assert_matches_type(ClipListResponse, clip, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Gcore) -> None: + with client.streaming.streams.clips.with_streaming_response.list( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + clip = response.parse() + assert_matches_type(ClipListResponse, clip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncClips: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncGcore) -> None: + clip = await async_client.streaming.streams.clips.create( + stream_id=0, + duration=0, + ) + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: + clip = await async_client.streaming.streams.clips.create( + stream_id=0, + duration=0, + expiration=0, + start=0, + vod_required=True, + ) + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncGcore) -> None: + response = await async_client.streaming.streams.clips.with_raw_response.create( + stream_id=0, + duration=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + clip = await response.parse() + assert_matches_type(Clip, clip, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: + async with async_client.streaming.streams.clips.with_streaming_response.create( + stream_id=0, + duration=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + clip = await response.parse() + assert_matches_type(Clip, clip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_list(self, async_client: AsyncGcore) -> None: + clip = await async_client.streaming.streams.clips.list( + 0, + ) + assert_matches_type(ClipListResponse, clip, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncGcore) -> None: + response = await async_client.streaming.streams.clips.with_raw_response.list( + 0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + clip = await response.parse() + assert_matches_type(ClipListResponse, clip, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: + async with async_client.streaming.streams.clips.with_streaming_response.list( + 0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + clip = await response.parse() + assert_matches_type(ClipListResponse, clip, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/streaming/test_streams.py b/tests/api_resources/streaming/test_streams.py index ca08569d..0af60f1b 100644 --- a/tests/api_resources/streaming/test_streams.py +++ b/tests/api_resources/streaming/test_streams.py @@ -11,10 +11,8 @@ from tests.utils import assert_matches_type from gcore.pagination import SyncPageStreaming, AsyncPageStreaming from gcore.types.streaming import ( - Clip, Video, Stream, - StreamListClipsResponse, StreamStartRecordingResponse, ) @@ -230,54 +228,7 @@ def test_streaming_response_clear_dvr(self, client: Gcore) -> None: @pytest.mark.skip(reason="OAS example mismatch with schema") @parametrize - def test_method_create_clip(self, client: Gcore) -> None: - stream = client.streaming.streams.create_clip( - stream_id=0, - duration=0, - ) - assert_matches_type(Clip, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - def test_method_create_clip_with_all_params(self, client: Gcore) -> None: - stream = client.streaming.streams.create_clip( - stream_id=0, - duration=0, - expiration=0, - start=0, - vod_required=True, - ) - assert_matches_type(Clip, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - def test_raw_response_create_clip(self, client: Gcore) -> None: - response = client.streaming.streams.with_raw_response.create_clip( - stream_id=0, - duration=0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = response.parse() - assert_matches_type(Clip, stream, path=["response"]) - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - def test_streaming_response_create_clip(self, client: Gcore) -> None: - with client.streaming.streams.with_streaming_response.create_clip( - stream_id=0, - duration=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = response.parse() - assert_matches_type(Clip, stream, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize def test_method_get(self, client: Gcore) -> None: stream = client.streaming.streams.get( 0, @@ -310,39 +261,7 @@ def test_streaming_response_get(self, client: Gcore) -> None: @pytest.mark.skip(reason="OAS example mismatch with schema") @parametrize - def test_method_list_clips(self, client: Gcore) -> None: - stream = client.streaming.streams.list_clips( - 0, - ) - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - def test_raw_response_list_clips(self, client: Gcore) -> None: - response = client.streaming.streams.with_raw_response.list_clips( - 0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = response.parse() - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - def test_streaming_response_list_clips(self, client: Gcore) -> None: - with client.streaming.streams.with_streaming_response.list_clips( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = response.parse() - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize def test_method_start_recording(self, client: Gcore) -> None: stream = client.streaming.streams.start_recording( 0, @@ -616,54 +535,7 @@ async def test_streaming_response_clear_dvr(self, async_client: AsyncGcore) -> N @pytest.mark.skip(reason="OAS example mismatch with schema") @parametrize - async def test_method_create_clip(self, async_client: AsyncGcore) -> None: - stream = await async_client.streaming.streams.create_clip( - stream_id=0, - duration=0, - ) - assert_matches_type(Clip, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - async def test_method_create_clip_with_all_params(self, async_client: AsyncGcore) -> None: - stream = await async_client.streaming.streams.create_clip( - stream_id=0, - duration=0, - expiration=0, - start=0, - vod_required=True, - ) - assert_matches_type(Clip, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - async def test_raw_response_create_clip(self, async_client: AsyncGcore) -> None: - response = await async_client.streaming.streams.with_raw_response.create_clip( - stream_id=0, - duration=0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = await response.parse() - assert_matches_type(Clip, stream, path=["response"]) - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - async def test_streaming_response_create_clip(self, async_client: AsyncGcore) -> None: - async with async_client.streaming.streams.with_streaming_response.create_clip( - stream_id=0, - duration=0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = await response.parse() - assert_matches_type(Clip, stream, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: stream = await async_client.streaming.streams.get( 0, @@ -696,39 +568,7 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: @pytest.mark.skip(reason="OAS example mismatch with schema") @parametrize - async def test_method_list_clips(self, async_client: AsyncGcore) -> None: - stream = await async_client.streaming.streams.list_clips( - 0, - ) - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - async def test_raw_response_list_clips(self, async_client: AsyncGcore) -> None: - response = await async_client.streaming.streams.with_raw_response.list_clips( - 0, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = await response.parse() - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - @pytest.mark.skip(reason="OAS example mismatch with schema") - @parametrize - async def test_streaming_response_list_clips(self, async_client: AsyncGcore) -> None: - async with async_client.streaming.streams.with_streaming_response.list_clips( - 0, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = await response.parse() - assert_matches_type(StreamListClipsResponse, stream, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize async def test_method_start_recording(self, async_client: AsyncGcore) -> None: stream = await async_client.streaming.streams.start_recording( 0, From b1c884f463f33289b820eb5565ac9d7d74afbb2f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:58:02 +0000 Subject: [PATCH 09/11] fix(waap)!: split api_discovery methods into scan_results, openapi, and settings subresources --- .stats.yml | 2 +- src/gcore/resources/waap/api.md | 38 +- .../resources/waap/domains/api_discovery.py | 763 ------------------ .../waap/domains/api_discovery/__init__.py | 61 ++ .../domains/api_discovery/api_discovery.py | 166 ++++ .../waap/domains/api_discovery/openapi.py | 283 +++++++ .../domains/api_discovery/scan_results.py | 351 ++++++++ .../waap/domains/api_discovery/settings.py | 299 +++++++ src/gcore/resources/waap/domains/domains.py | 16 +- src/gcore/types/waap/domains/__init__.py | 8 - .../waap/domains/api_discovery/__init__.py | 10 + .../openapi_upload_params.py} | 4 +- .../scan_result_list_params.py} | 4 +- .../setting_update_params.py} | 6 +- .../waap_api_discovery_settings.py | 2 +- .../waap_api_scan_result.py | 2 +- .../{ => api_discovery}/waap_task_id.py | 2 +- .../waap/domains/api_discovery/__init__.py | 1 + .../domains/api_discovery/test_openapi.py | 160 ++++ .../api_discovery/test_scan_results.py | 197 +++++ .../domains/api_discovery/test_settings.py | 172 ++++ .../waap/domains/test_api_discovery.py | 485 ----------- 22 files changed, 1750 insertions(+), 1282 deletions(-) delete mode 100644 src/gcore/resources/waap/domains/api_discovery.py create mode 100644 src/gcore/resources/waap/domains/api_discovery/__init__.py create mode 100644 src/gcore/resources/waap/domains/api_discovery/api_discovery.py create mode 100644 src/gcore/resources/waap/domains/api_discovery/openapi.py create mode 100644 src/gcore/resources/waap/domains/api_discovery/scan_results.py create mode 100644 src/gcore/resources/waap/domains/api_discovery/settings.py create mode 100644 src/gcore/types/waap/domains/api_discovery/__init__.py rename src/gcore/types/waap/domains/{api_discovery_upload_openapi_params.py => api_discovery/openapi_upload_params.py} (79%) rename src/gcore/types/waap/domains/{api_discovery_list_scan_results_params.py => api_discovery/scan_result_list_params.py} (89%) rename src/gcore/types/waap/domains/{api_discovery_update_settings_params.py => api_discovery/setting_update_params.py} (89%) rename src/gcore/types/waap/domains/{ => api_discovery}/waap_api_discovery_settings.py (97%) rename src/gcore/types/waap/domains/{ => api_discovery}/waap_api_scan_result.py (95%) rename src/gcore/types/waap/domains/{ => api_discovery}/waap_task_id.py (86%) create mode 100644 tests/api_resources/waap/domains/api_discovery/__init__.py create mode 100644 tests/api_resources/waap/domains/api_discovery/test_openapi.py create mode 100644 tests/api_resources/waap/domains/api_discovery/test_scan_results.py create mode 100644 tests/api_resources/waap/domains/api_discovery/test_settings.py delete mode 100644 tests/api_resources/waap/domains/test_api_discovery.py diff --git a/.stats.yml b/.stats.yml index a58aaa95..a273f540 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 -config_hash: b07ea4587f9078d7da7d498163b001b5 +config_hash: a5fc65645e723807b401a8e277b7f9a7 diff --git a/src/gcore/resources/waap/api.md b/src/gcore/resources/waap/api.md index 52a55dc6..b357ca54 100644 --- a/src/gcore/resources/waap/api.md +++ b/src/gcore/resources/waap/api.md @@ -85,20 +85,44 @@ Methods: ### APIDiscovery +#### ScanResults + +Types: + +```python +from gcore.types.waap.domains.api_discovery import WaapAPIScanResult +``` + +Methods: + +- client.waap.domains.api_discovery.scan_results.list(domain_id, \*\*params) -> SyncOffsetPage[WaapAPIScanResult] +- client.waap.domains.api_discovery.scan_results.get(scan_id, \*, domain_id) -> WaapAPIScanResult + +#### OpenAPI + +Types: + +```python +from gcore.types.waap.domains.api_discovery import WaapTaskID +``` + +Methods: + +- client.waap.domains.api_discovery.openapi.scan(domain_id) -> WaapTaskID +- client.waap.domains.api_discovery.openapi.upload(domain_id, \*\*params) -> WaapTaskID + +#### Settings + Types: ```python -from gcore.types.waap.domains import WaapAPIDiscoverySettings, WaapAPIScanResult, WaapTaskID +from gcore.types.waap.domains.api_discovery import WaapAPIDiscoverySettings ``` Methods: -- client.waap.domains.api_discovery.get_scan_result(scan_id, \*, domain_id) -> WaapAPIScanResult -- client.waap.domains.api_discovery.get_settings(domain_id) -> WaapAPIDiscoverySettings -- client.waap.domains.api_discovery.list_scan_results(domain_id, \*\*params) -> SyncOffsetPage[WaapAPIScanResult] -- client.waap.domains.api_discovery.scan_openapi(domain_id) -> WaapTaskID -- client.waap.domains.api_discovery.update_settings(domain_id, \*\*params) -> WaapAPIDiscoverySettings -- client.waap.domains.api_discovery.upload_openapi(domain_id, \*\*params) -> WaapTaskID +- client.waap.domains.api_discovery.settings.update(domain_id, \*\*params) -> WaapAPIDiscoverySettings +- client.waap.domains.api_discovery.settings.get(domain_id) -> WaapAPIDiscoverySettings ### Insights diff --git a/src/gcore/resources/waap/domains/api_discovery.py b/src/gcore/resources/waap/domains/api_discovery.py deleted file mode 100644 index f83862da..00000000 --- a/src/gcore/resources/waap/domains/api_discovery.py +++ /dev/null @@ -1,763 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Optional -from typing_extensions import Literal - -import httpx - -from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....pagination import SyncOffsetPage, AsyncOffsetPage -from ...._base_client import AsyncPaginator, make_request_options -from ....types.waap.domains import ( - api_discovery_upload_openapi_params, - api_discovery_update_settings_params, - api_discovery_list_scan_results_params, -) -from ....types.waap.domains.waap_task_id import WaapTaskID -from ....types.waap.domains.waap_api_scan_result import WaapAPIScanResult -from ....types.waap.domains.waap_api_discovery_settings import WaapAPIDiscoverySettings - -__all__ = ["APIDiscoveryResource", "AsyncAPIDiscoveryResource"] - - -class APIDiscoveryResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> APIDiscoveryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers - """ - return APIDiscoveryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> APIDiscoveryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response - """ - return APIDiscoveryResourceWithStreamingResponse(self) - - def get_scan_result( - self, - scan_id: str, - *, - domain_id: int, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIScanResult: - """ - Get Scan Result - - Args: - domain_id: The domain ID - - scan_id: The scan ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not scan_id: - raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") - return self._get( - f"/waap/v1/domains/{domain_id}/api-discovery/scan-results/{scan_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIScanResult, - ) - - def get_settings( - self, - domain_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIDiscoverySettings: - """ - Retrieve the API discovery settings for a domain - - Args: - domain_id: The domain ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - f"/waap/v1/domains/{domain_id}/api-discovery/settings", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIDiscoverySettings, - ) - - def list_scan_results( - self, - domain_id: int, - *, - limit: int | Omit = omit, - message: Optional[str] | Omit = omit, - offset: int | Omit = omit, - ordering: Literal[ - "id", - "type", - "start_time", - "end_time", - "status", - "message", - "-id", - "-type", - "-start_time", - "-end_time", - "-status", - "-message", - ] - | Omit = omit, - status: Optional[Literal["SUCCESS", "FAILURE", "IN_PROGRESS"]] | Omit = omit, - type: Optional[Literal["TRAFFIC_SCAN", "API_DESCRIPTION_FILE_SCAN"]] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncOffsetPage[WaapAPIScanResult]: - """ - Get Scan Results - - Args: - domain_id: The domain ID - - limit: Number of items to return - - message: Filter by the message of the scan. Supports '\\**' as a wildcard character - - offset: Number of items to skip - - ordering: Sort the response by given field. - - status: Filter by the status of the scan - - type: Filter by the path of the scan type - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - f"/waap/v1/domains/{domain_id}/api-discovery/scan-results", - page=SyncOffsetPage[WaapAPIScanResult], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "message": message, - "offset": offset, - "ordering": ordering, - "status": status, - "type": type, - }, - api_discovery_list_scan_results_params.APIDiscoveryListScanResultsParams, - ), - ), - model=WaapAPIScanResult, - ) - - def scan_openapi( - self, - domain_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapTaskID: - """Scan an API description file hosted online. - - The file must be in YAML or JSON - format and adhere to the OpenAPI specification. The location of the API - description file should be specified in the API discovery settings. - - Args: - domain_id: The domain ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - f"/waap/v1/domains/{domain_id}/api-discovery/scan", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapTaskID, - ) - - def update_settings( - self, - domain_id: int, - *, - description_file_location: Optional[str] | Omit = omit, - description_file_scan_enabled: Optional[bool] | Omit = omit, - description_file_scan_interval_hours: Optional[int] | Omit = omit, - traffic_scan_enabled: Optional[bool] | Omit = omit, - traffic_scan_interval_hours: Optional[int] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIDiscoverySettings: - """ - Update the API discovery settings for a domain - - Args: - domain_id: The domain ID - - description_file_location: The URL of the API description file. This will be periodically scanned if - `descriptionFileScanEnabled` is enabled. Supported formats are YAML and JSON, - and it must adhere to OpenAPI versions 2, 3, or 3.1. - - description_file_scan_enabled: Indicates if periodic scan of the description file is enabled - - description_file_scan_interval_hours: The interval in hours for scanning the description file - - traffic_scan_enabled: Indicates if traffic scan is enabled - - traffic_scan_interval_hours: The interval in hours for scanning the traffic - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._patch( - f"/waap/v1/domains/{domain_id}/api-discovery/settings", - body=maybe_transform( - { - "description_file_location": description_file_location, - "description_file_scan_enabled": description_file_scan_enabled, - "description_file_scan_interval_hours": description_file_scan_interval_hours, - "traffic_scan_enabled": traffic_scan_enabled, - "traffic_scan_interval_hours": traffic_scan_interval_hours, - }, - api_discovery_update_settings_params.APIDiscoveryUpdateSettingsParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIDiscoverySettings, - ) - - def upload_openapi( - self, - domain_id: int, - *, - file_data: str, - file_name: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapTaskID: - """ - An API description file must adhere to the OpenAPI specification and be written - in YAML or JSON format. The file name should be provided as the value for the - `file_name` parameter. The contents of the file must be base64 encoded and - supplied as the value for the `file_data` parameter. - - Args: - domain_id: The domain ID - - file_data: Base64 representation of the description file. Supported formats are YAML and - JSON, and it must adhere to OpenAPI versions 2, 3, or 3.1. - - file_name: The name of the file - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - f"/waap/v1/domains/{domain_id}/api-discovery/upload", - body=maybe_transform( - { - "file_data": file_data, - "file_name": file_name, - }, - api_discovery_upload_openapi_params.APIDiscoveryUploadOpenAPIParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapTaskID, - ) - - -class AsyncAPIDiscoveryResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncAPIDiscoveryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers - """ - return AsyncAPIDiscoveryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAPIDiscoveryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response - """ - return AsyncAPIDiscoveryResourceWithStreamingResponse(self) - - async def get_scan_result( - self, - scan_id: str, - *, - domain_id: int, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIScanResult: - """ - Get Scan Result - - Args: - domain_id: The domain ID - - scan_id: The scan ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not scan_id: - raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") - return await self._get( - f"/waap/v1/domains/{domain_id}/api-discovery/scan-results/{scan_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIScanResult, - ) - - async def get_settings( - self, - domain_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIDiscoverySettings: - """ - Retrieve the API discovery settings for a domain - - Args: - domain_id: The domain ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - f"/waap/v1/domains/{domain_id}/api-discovery/settings", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIDiscoverySettings, - ) - - def list_scan_results( - self, - domain_id: int, - *, - limit: int | Omit = omit, - message: Optional[str] | Omit = omit, - offset: int | Omit = omit, - ordering: Literal[ - "id", - "type", - "start_time", - "end_time", - "status", - "message", - "-id", - "-type", - "-start_time", - "-end_time", - "-status", - "-message", - ] - | Omit = omit, - status: Optional[Literal["SUCCESS", "FAILURE", "IN_PROGRESS"]] | Omit = omit, - type: Optional[Literal["TRAFFIC_SCAN", "API_DESCRIPTION_FILE_SCAN"]] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[WaapAPIScanResult, AsyncOffsetPage[WaapAPIScanResult]]: - """ - Get Scan Results - - Args: - domain_id: The domain ID - - limit: Number of items to return - - message: Filter by the message of the scan. Supports '\\**' as a wildcard character - - offset: Number of items to skip - - ordering: Sort the response by given field. - - status: Filter by the status of the scan - - type: Filter by the path of the scan type - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - f"/waap/v1/domains/{domain_id}/api-discovery/scan-results", - page=AsyncOffsetPage[WaapAPIScanResult], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "message": message, - "offset": offset, - "ordering": ordering, - "status": status, - "type": type, - }, - api_discovery_list_scan_results_params.APIDiscoveryListScanResultsParams, - ), - ), - model=WaapAPIScanResult, - ) - - async def scan_openapi( - self, - domain_id: int, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapTaskID: - """Scan an API description file hosted online. - - The file must be in YAML or JSON - format and adhere to the OpenAPI specification. The location of the API - description file should be specified in the API discovery settings. - - Args: - domain_id: The domain ID - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - f"/waap/v1/domains/{domain_id}/api-discovery/scan", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapTaskID, - ) - - async def update_settings( - self, - domain_id: int, - *, - description_file_location: Optional[str] | Omit = omit, - description_file_scan_enabled: Optional[bool] | Omit = omit, - description_file_scan_interval_hours: Optional[int] | Omit = omit, - traffic_scan_enabled: Optional[bool] | Omit = omit, - traffic_scan_interval_hours: Optional[int] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapAPIDiscoverySettings: - """ - Update the API discovery settings for a domain - - Args: - domain_id: The domain ID - - description_file_location: The URL of the API description file. This will be periodically scanned if - `descriptionFileScanEnabled` is enabled. Supported formats are YAML and JSON, - and it must adhere to OpenAPI versions 2, 3, or 3.1. - - description_file_scan_enabled: Indicates if periodic scan of the description file is enabled - - description_file_scan_interval_hours: The interval in hours for scanning the description file - - traffic_scan_enabled: Indicates if traffic scan is enabled - - traffic_scan_interval_hours: The interval in hours for scanning the traffic - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._patch( - f"/waap/v1/domains/{domain_id}/api-discovery/settings", - body=await async_maybe_transform( - { - "description_file_location": description_file_location, - "description_file_scan_enabled": description_file_scan_enabled, - "description_file_scan_interval_hours": description_file_scan_interval_hours, - "traffic_scan_enabled": traffic_scan_enabled, - "traffic_scan_interval_hours": traffic_scan_interval_hours, - }, - api_discovery_update_settings_params.APIDiscoveryUpdateSettingsParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapAPIDiscoverySettings, - ) - - async def upload_openapi( - self, - domain_id: int, - *, - file_data: str, - file_name: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapTaskID: - """ - An API description file must adhere to the OpenAPI specification and be written - in YAML or JSON format. The file name should be provided as the value for the - `file_name` parameter. The contents of the file must be base64 encoded and - supplied as the value for the `file_data` parameter. - - Args: - domain_id: The domain ID - - file_data: Base64 representation of the description file. Supported formats are YAML and - JSON, and it must adhere to OpenAPI versions 2, 3, or 3.1. - - file_name: The name of the file - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - f"/waap/v1/domains/{domain_id}/api-discovery/upload", - body=await async_maybe_transform( - { - "file_data": file_data, - "file_name": file_name, - }, - api_discovery_upload_openapi_params.APIDiscoveryUploadOpenAPIParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapTaskID, - ) - - -class APIDiscoveryResourceWithRawResponse: - def __init__(self, api_discovery: APIDiscoveryResource) -> None: - self._api_discovery = api_discovery - - self.get_scan_result = to_raw_response_wrapper( - api_discovery.get_scan_result, - ) - self.get_settings = to_raw_response_wrapper( - api_discovery.get_settings, - ) - self.list_scan_results = to_raw_response_wrapper( - api_discovery.list_scan_results, - ) - self.scan_openapi = to_raw_response_wrapper( - api_discovery.scan_openapi, - ) - self.update_settings = to_raw_response_wrapper( - api_discovery.update_settings, - ) - self.upload_openapi = to_raw_response_wrapper( - api_discovery.upload_openapi, - ) - - -class AsyncAPIDiscoveryResourceWithRawResponse: - def __init__(self, api_discovery: AsyncAPIDiscoveryResource) -> None: - self._api_discovery = api_discovery - - self.get_scan_result = async_to_raw_response_wrapper( - api_discovery.get_scan_result, - ) - self.get_settings = async_to_raw_response_wrapper( - api_discovery.get_settings, - ) - self.list_scan_results = async_to_raw_response_wrapper( - api_discovery.list_scan_results, - ) - self.scan_openapi = async_to_raw_response_wrapper( - api_discovery.scan_openapi, - ) - self.update_settings = async_to_raw_response_wrapper( - api_discovery.update_settings, - ) - self.upload_openapi = async_to_raw_response_wrapper( - api_discovery.upload_openapi, - ) - - -class APIDiscoveryResourceWithStreamingResponse: - def __init__(self, api_discovery: APIDiscoveryResource) -> None: - self._api_discovery = api_discovery - - self.get_scan_result = to_streamed_response_wrapper( - api_discovery.get_scan_result, - ) - self.get_settings = to_streamed_response_wrapper( - api_discovery.get_settings, - ) - self.list_scan_results = to_streamed_response_wrapper( - api_discovery.list_scan_results, - ) - self.scan_openapi = to_streamed_response_wrapper( - api_discovery.scan_openapi, - ) - self.update_settings = to_streamed_response_wrapper( - api_discovery.update_settings, - ) - self.upload_openapi = to_streamed_response_wrapper( - api_discovery.upload_openapi, - ) - - -class AsyncAPIDiscoveryResourceWithStreamingResponse: - def __init__(self, api_discovery: AsyncAPIDiscoveryResource) -> None: - self._api_discovery = api_discovery - - self.get_scan_result = async_to_streamed_response_wrapper( - api_discovery.get_scan_result, - ) - self.get_settings = async_to_streamed_response_wrapper( - api_discovery.get_settings, - ) - self.list_scan_results = async_to_streamed_response_wrapper( - api_discovery.list_scan_results, - ) - self.scan_openapi = async_to_streamed_response_wrapper( - api_discovery.scan_openapi, - ) - self.update_settings = async_to_streamed_response_wrapper( - api_discovery.update_settings, - ) - self.upload_openapi = async_to_streamed_response_wrapper( - api_discovery.upload_openapi, - ) diff --git a/src/gcore/resources/waap/domains/api_discovery/__init__.py b/src/gcore/resources/waap/domains/api_discovery/__init__.py new file mode 100644 index 00000000..1c78d928 --- /dev/null +++ b/src/gcore/resources/waap/domains/api_discovery/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .openapi import ( + OpenAPIResource, + AsyncOpenAPIResource, + OpenAPIResourceWithRawResponse, + AsyncOpenAPIResourceWithRawResponse, + OpenAPIResourceWithStreamingResponse, + AsyncOpenAPIResourceWithStreamingResponse, +) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) +from .scan_results import ( + ScanResultsResource, + AsyncScanResultsResource, + ScanResultsResourceWithRawResponse, + AsyncScanResultsResourceWithRawResponse, + ScanResultsResourceWithStreamingResponse, + AsyncScanResultsResourceWithStreamingResponse, +) +from .api_discovery import ( + APIDiscoveryResource, + AsyncAPIDiscoveryResource, + APIDiscoveryResourceWithRawResponse, + AsyncAPIDiscoveryResourceWithRawResponse, + APIDiscoveryResourceWithStreamingResponse, + AsyncAPIDiscoveryResourceWithStreamingResponse, +) + +__all__ = [ + "ScanResultsResource", + "AsyncScanResultsResource", + "ScanResultsResourceWithRawResponse", + "AsyncScanResultsResourceWithRawResponse", + "ScanResultsResourceWithStreamingResponse", + "AsyncScanResultsResourceWithStreamingResponse", + "OpenAPIResource", + "AsyncOpenAPIResource", + "OpenAPIResourceWithRawResponse", + "AsyncOpenAPIResourceWithRawResponse", + "OpenAPIResourceWithStreamingResponse", + "AsyncOpenAPIResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", + "APIDiscoveryResource", + "AsyncAPIDiscoveryResource", + "APIDiscoveryResourceWithRawResponse", + "AsyncAPIDiscoveryResourceWithRawResponse", + "APIDiscoveryResourceWithStreamingResponse", + "AsyncAPIDiscoveryResourceWithStreamingResponse", +] diff --git a/src/gcore/resources/waap/domains/api_discovery/api_discovery.py b/src/gcore/resources/waap/domains/api_discovery/api_discovery.py new file mode 100644 index 00000000..e9303956 --- /dev/null +++ b/src/gcore/resources/waap/domains/api_discovery/api_discovery.py @@ -0,0 +1,166 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .openapi import ( + OpenAPIResource, + AsyncOpenAPIResource, + OpenAPIResourceWithRawResponse, + AsyncOpenAPIResourceWithRawResponse, + OpenAPIResourceWithStreamingResponse, + AsyncOpenAPIResourceWithStreamingResponse, +) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) +from ....._compat import cached_property +from .scan_results import ( + ScanResultsResource, + AsyncScanResultsResource, + ScanResultsResourceWithRawResponse, + AsyncScanResultsResourceWithRawResponse, + ScanResultsResourceWithStreamingResponse, + AsyncScanResultsResourceWithStreamingResponse, +) +from ....._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["APIDiscoveryResource", "AsyncAPIDiscoveryResource"] + + +class APIDiscoveryResource(SyncAPIResource): + @cached_property + def scan_results(self) -> ScanResultsResource: + return ScanResultsResource(self._client) + + @cached_property + def openapi(self) -> OpenAPIResource: + return OpenAPIResource(self._client) + + @cached_property + def settings(self) -> SettingsResource: + return SettingsResource(self._client) + + @cached_property + def with_raw_response(self) -> APIDiscoveryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return APIDiscoveryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> APIDiscoveryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return APIDiscoveryResourceWithStreamingResponse(self) + + +class AsyncAPIDiscoveryResource(AsyncAPIResource): + @cached_property + def scan_results(self) -> AsyncScanResultsResource: + return AsyncScanResultsResource(self._client) + + @cached_property + def openapi(self) -> AsyncOpenAPIResource: + return AsyncOpenAPIResource(self._client) + + @cached_property + def settings(self) -> AsyncSettingsResource: + return AsyncSettingsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAPIDiscoveryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncAPIDiscoveryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAPIDiscoveryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncAPIDiscoveryResourceWithStreamingResponse(self) + + +class APIDiscoveryResourceWithRawResponse: + def __init__(self, api_discovery: APIDiscoveryResource) -> None: + self._api_discovery = api_discovery + + @cached_property + def scan_results(self) -> ScanResultsResourceWithRawResponse: + return ScanResultsResourceWithRawResponse(self._api_discovery.scan_results) + + @cached_property + def openapi(self) -> OpenAPIResourceWithRawResponse: + return OpenAPIResourceWithRawResponse(self._api_discovery.openapi) + + @cached_property + def settings(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self._api_discovery.settings) + + +class AsyncAPIDiscoveryResourceWithRawResponse: + def __init__(self, api_discovery: AsyncAPIDiscoveryResource) -> None: + self._api_discovery = api_discovery + + @cached_property + def scan_results(self) -> AsyncScanResultsResourceWithRawResponse: + return AsyncScanResultsResourceWithRawResponse(self._api_discovery.scan_results) + + @cached_property + def openapi(self) -> AsyncOpenAPIResourceWithRawResponse: + return AsyncOpenAPIResourceWithRawResponse(self._api_discovery.openapi) + + @cached_property + def settings(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self._api_discovery.settings) + + +class APIDiscoveryResourceWithStreamingResponse: + def __init__(self, api_discovery: APIDiscoveryResource) -> None: + self._api_discovery = api_discovery + + @cached_property + def scan_results(self) -> ScanResultsResourceWithStreamingResponse: + return ScanResultsResourceWithStreamingResponse(self._api_discovery.scan_results) + + @cached_property + def openapi(self) -> OpenAPIResourceWithStreamingResponse: + return OpenAPIResourceWithStreamingResponse(self._api_discovery.openapi) + + @cached_property + def settings(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self._api_discovery.settings) + + +class AsyncAPIDiscoveryResourceWithStreamingResponse: + def __init__(self, api_discovery: AsyncAPIDiscoveryResource) -> None: + self._api_discovery = api_discovery + + @cached_property + def scan_results(self) -> AsyncScanResultsResourceWithStreamingResponse: + return AsyncScanResultsResourceWithStreamingResponse(self._api_discovery.scan_results) + + @cached_property + def openapi(self) -> AsyncOpenAPIResourceWithStreamingResponse: + return AsyncOpenAPIResourceWithStreamingResponse(self._api_discovery.openapi) + + @cached_property + def settings(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self._api_discovery.settings) diff --git a/src/gcore/resources/waap/domains/api_discovery/openapi.py b/src/gcore/resources/waap/domains/api_discovery/openapi.py new file mode 100644 index 00000000..1bc07a1b --- /dev/null +++ b/src/gcore/resources/waap/domains/api_discovery/openapi.py @@ -0,0 +1,283 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.waap.domains.api_discovery import openapi_upload_params +from .....types.waap.domains.api_discovery.waap_task_id import WaapTaskID + +__all__ = ["OpenAPIResource", "AsyncOpenAPIResource"] + + +class OpenAPIResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OpenAPIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return OpenAPIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OpenAPIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return OpenAPIResourceWithStreamingResponse(self) + + def scan( + self, + domain_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapTaskID: + """Scan an API description file hosted online. + + The file must be in YAML or JSON + format and adhere to the OpenAPI specification. The location of the API + description file should be specified in the API discovery settings. + + Args: + domain_id: The domain ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + f"/waap/v1/domains/{domain_id}/api-discovery/scan", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapTaskID, + ) + + def upload( + self, + domain_id: int, + *, + file_data: str, + file_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapTaskID: + """ + An API description file must adhere to the OpenAPI specification and be written + in YAML or JSON format. The file name should be provided as the value for the + `file_name` parameter. The contents of the file must be base64 encoded and + supplied as the value for the `file_data` parameter. + + Args: + domain_id: The domain ID + + file_data: Base64 representation of the description file. Supported formats are YAML and + JSON, and it must adhere to OpenAPI versions 2, 3, or 3.1. + + file_name: The name of the file + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + f"/waap/v1/domains/{domain_id}/api-discovery/upload", + body=maybe_transform( + { + "file_data": file_data, + "file_name": file_name, + }, + openapi_upload_params.OpenAPIUploadParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapTaskID, + ) + + +class AsyncOpenAPIResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOpenAPIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncOpenAPIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOpenAPIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncOpenAPIResourceWithStreamingResponse(self) + + async def scan( + self, + domain_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapTaskID: + """Scan an API description file hosted online. + + The file must be in YAML or JSON + format and adhere to the OpenAPI specification. The location of the API + description file should be specified in the API discovery settings. + + Args: + domain_id: The domain ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + f"/waap/v1/domains/{domain_id}/api-discovery/scan", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapTaskID, + ) + + async def upload( + self, + domain_id: int, + *, + file_data: str, + file_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapTaskID: + """ + An API description file must adhere to the OpenAPI specification and be written + in YAML or JSON format. The file name should be provided as the value for the + `file_name` parameter. The contents of the file must be base64 encoded and + supplied as the value for the `file_data` parameter. + + Args: + domain_id: The domain ID + + file_data: Base64 representation of the description file. Supported formats are YAML and + JSON, and it must adhere to OpenAPI versions 2, 3, or 3.1. + + file_name: The name of the file + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + f"/waap/v1/domains/{domain_id}/api-discovery/upload", + body=await async_maybe_transform( + { + "file_data": file_data, + "file_name": file_name, + }, + openapi_upload_params.OpenAPIUploadParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapTaskID, + ) + + +class OpenAPIResourceWithRawResponse: + def __init__(self, openapi: OpenAPIResource) -> None: + self._openapi = openapi + + self.scan = to_raw_response_wrapper( + openapi.scan, + ) + self.upload = to_raw_response_wrapper( + openapi.upload, + ) + + +class AsyncOpenAPIResourceWithRawResponse: + def __init__(self, openapi: AsyncOpenAPIResource) -> None: + self._openapi = openapi + + self.scan = async_to_raw_response_wrapper( + openapi.scan, + ) + self.upload = async_to_raw_response_wrapper( + openapi.upload, + ) + + +class OpenAPIResourceWithStreamingResponse: + def __init__(self, openapi: OpenAPIResource) -> None: + self._openapi = openapi + + self.scan = to_streamed_response_wrapper( + openapi.scan, + ) + self.upload = to_streamed_response_wrapper( + openapi.upload, + ) + + +class AsyncOpenAPIResourceWithStreamingResponse: + def __init__(self, openapi: AsyncOpenAPIResource) -> None: + self._openapi = openapi + + self.scan = async_to_streamed_response_wrapper( + openapi.scan, + ) + self.upload = async_to_streamed_response_wrapper( + openapi.upload, + ) diff --git a/src/gcore/resources/waap/domains/api_discovery/scan_results.py b/src/gcore/resources/waap/domains/api_discovery/scan_results.py new file mode 100644 index 00000000..31193f33 --- /dev/null +++ b/src/gcore/resources/waap/domains/api_discovery/scan_results.py @@ -0,0 +1,351 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .....pagination import SyncOffsetPage, AsyncOffsetPage +from ....._base_client import AsyncPaginator, make_request_options +from .....types.waap.domains.api_discovery import scan_result_list_params +from .....types.waap.domains.api_discovery.waap_api_scan_result import WaapAPIScanResult + +__all__ = ["ScanResultsResource", "AsyncScanResultsResource"] + + +class ScanResultsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ScanResultsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return ScanResultsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ScanResultsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return ScanResultsResourceWithStreamingResponse(self) + + def list( + self, + domain_id: int, + *, + limit: int | Omit = omit, + message: Optional[str] | Omit = omit, + offset: int | Omit = omit, + ordering: Literal[ + "id", + "type", + "start_time", + "end_time", + "status", + "message", + "-id", + "-type", + "-start_time", + "-end_time", + "-status", + "-message", + ] + | Omit = omit, + status: Optional[Literal["SUCCESS", "FAILURE", "IN_PROGRESS"]] | Omit = omit, + type: Optional[Literal["TRAFFIC_SCAN", "API_DESCRIPTION_FILE_SCAN"]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncOffsetPage[WaapAPIScanResult]: + """ + Get Scan Results + + Args: + domain_id: The domain ID + + limit: Number of items to return + + message: Filter by the message of the scan. Supports '\\**' as a wildcard character + + offset: Number of items to skip + + ordering: Sort the response by given field. + + status: Filter by the status of the scan + + type: Filter by the path of the scan type + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + f"/waap/v1/domains/{domain_id}/api-discovery/scan-results", + page=SyncOffsetPage[WaapAPIScanResult], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "message": message, + "offset": offset, + "ordering": ordering, + "status": status, + "type": type, + }, + scan_result_list_params.ScanResultListParams, + ), + ), + model=WaapAPIScanResult, + ) + + def get( + self, + scan_id: str, + *, + domain_id: int, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIScanResult: + """ + Get Scan Result + + Args: + domain_id: The domain ID + + scan_id: The scan ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not scan_id: + raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") + return self._get( + f"/waap/v1/domains/{domain_id}/api-discovery/scan-results/{scan_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIScanResult, + ) + + +class AsyncScanResultsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncScanResultsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncScanResultsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncScanResultsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncScanResultsResourceWithStreamingResponse(self) + + def list( + self, + domain_id: int, + *, + limit: int | Omit = omit, + message: Optional[str] | Omit = omit, + offset: int | Omit = omit, + ordering: Literal[ + "id", + "type", + "start_time", + "end_time", + "status", + "message", + "-id", + "-type", + "-start_time", + "-end_time", + "-status", + "-message", + ] + | Omit = omit, + status: Optional[Literal["SUCCESS", "FAILURE", "IN_PROGRESS"]] | Omit = omit, + type: Optional[Literal["TRAFFIC_SCAN", "API_DESCRIPTION_FILE_SCAN"]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[WaapAPIScanResult, AsyncOffsetPage[WaapAPIScanResult]]: + """ + Get Scan Results + + Args: + domain_id: The domain ID + + limit: Number of items to return + + message: Filter by the message of the scan. Supports '\\**' as a wildcard character + + offset: Number of items to skip + + ordering: Sort the response by given field. + + status: Filter by the status of the scan + + type: Filter by the path of the scan type + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + f"/waap/v1/domains/{domain_id}/api-discovery/scan-results", + page=AsyncOffsetPage[WaapAPIScanResult], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "message": message, + "offset": offset, + "ordering": ordering, + "status": status, + "type": type, + }, + scan_result_list_params.ScanResultListParams, + ), + ), + model=WaapAPIScanResult, + ) + + async def get( + self, + scan_id: str, + *, + domain_id: int, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIScanResult: + """ + Get Scan Result + + Args: + domain_id: The domain ID + + scan_id: The scan ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not scan_id: + raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") + return await self._get( + f"/waap/v1/domains/{domain_id}/api-discovery/scan-results/{scan_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIScanResult, + ) + + +class ScanResultsResourceWithRawResponse: + def __init__(self, scan_results: ScanResultsResource) -> None: + self._scan_results = scan_results + + self.list = to_raw_response_wrapper( + scan_results.list, + ) + self.get = to_raw_response_wrapper( + scan_results.get, + ) + + +class AsyncScanResultsResourceWithRawResponse: + def __init__(self, scan_results: AsyncScanResultsResource) -> None: + self._scan_results = scan_results + + self.list = async_to_raw_response_wrapper( + scan_results.list, + ) + self.get = async_to_raw_response_wrapper( + scan_results.get, + ) + + +class ScanResultsResourceWithStreamingResponse: + def __init__(self, scan_results: ScanResultsResource) -> None: + self._scan_results = scan_results + + self.list = to_streamed_response_wrapper( + scan_results.list, + ) + self.get = to_streamed_response_wrapper( + scan_results.get, + ) + + +class AsyncScanResultsResourceWithStreamingResponse: + def __init__(self, scan_results: AsyncScanResultsResource) -> None: + self._scan_results = scan_results + + self.list = async_to_streamed_response_wrapper( + scan_results.list, + ) + self.get = async_to_streamed_response_wrapper( + scan_results.get, + ) diff --git a/src/gcore/resources/waap/domains/api_discovery/settings.py b/src/gcore/resources/waap/domains/api_discovery/settings.py new file mode 100644 index 00000000..1b4b35eb --- /dev/null +++ b/src/gcore/resources/waap/domains/api_discovery/settings.py @@ -0,0 +1,299 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.waap.domains.api_discovery import setting_update_params +from .....types.waap.domains.api_discovery.waap_api_discovery_settings import WaapAPIDiscoverySettings + +__all__ = ["SettingsResource", "AsyncSettingsResource"] + + +class SettingsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return SettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return SettingsResourceWithStreamingResponse(self) + + def update( + self, + domain_id: int, + *, + description_file_location: Optional[str] | Omit = omit, + description_file_scan_enabled: Optional[bool] | Omit = omit, + description_file_scan_interval_hours: Optional[int] | Omit = omit, + traffic_scan_enabled: Optional[bool] | Omit = omit, + traffic_scan_interval_hours: Optional[int] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIDiscoverySettings: + """ + Update the API discovery settings for a domain + + Args: + domain_id: The domain ID + + description_file_location: The URL of the API description file. This will be periodically scanned if + `descriptionFileScanEnabled` is enabled. Supported formats are YAML and JSON, + and it must adhere to OpenAPI versions 2, 3, or 3.1. + + description_file_scan_enabled: Indicates if periodic scan of the description file is enabled + + description_file_scan_interval_hours: The interval in hours for scanning the description file + + traffic_scan_enabled: Indicates if traffic scan is enabled + + traffic_scan_interval_hours: The interval in hours for scanning the traffic + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._patch( + f"/waap/v1/domains/{domain_id}/api-discovery/settings", + body=maybe_transform( + { + "description_file_location": description_file_location, + "description_file_scan_enabled": description_file_scan_enabled, + "description_file_scan_interval_hours": description_file_scan_interval_hours, + "traffic_scan_enabled": traffic_scan_enabled, + "traffic_scan_interval_hours": traffic_scan_interval_hours, + }, + setting_update_params.SettingUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIDiscoverySettings, + ) + + def get( + self, + domain_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIDiscoverySettings: + """ + Retrieve the API discovery settings for a domain + + Args: + domain_id: The domain ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/waap/v1/domains/{domain_id}/api-discovery/settings", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIDiscoverySettings, + ) + + +class AsyncSettingsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncSettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncSettingsResourceWithStreamingResponse(self) + + async def update( + self, + domain_id: int, + *, + description_file_location: Optional[str] | Omit = omit, + description_file_scan_enabled: Optional[bool] | Omit = omit, + description_file_scan_interval_hours: Optional[int] | Omit = omit, + traffic_scan_enabled: Optional[bool] | Omit = omit, + traffic_scan_interval_hours: Optional[int] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIDiscoverySettings: + """ + Update the API discovery settings for a domain + + Args: + domain_id: The domain ID + + description_file_location: The URL of the API description file. This will be periodically scanned if + `descriptionFileScanEnabled` is enabled. Supported formats are YAML and JSON, + and it must adhere to OpenAPI versions 2, 3, or 3.1. + + description_file_scan_enabled: Indicates if periodic scan of the description file is enabled + + description_file_scan_interval_hours: The interval in hours for scanning the description file + + traffic_scan_enabled: Indicates if traffic scan is enabled + + traffic_scan_interval_hours: The interval in hours for scanning the traffic + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._patch( + f"/waap/v1/domains/{domain_id}/api-discovery/settings", + body=await async_maybe_transform( + { + "description_file_location": description_file_location, + "description_file_scan_enabled": description_file_scan_enabled, + "description_file_scan_interval_hours": description_file_scan_interval_hours, + "traffic_scan_enabled": traffic_scan_enabled, + "traffic_scan_interval_hours": traffic_scan_interval_hours, + }, + setting_update_params.SettingUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIDiscoverySettings, + ) + + async def get( + self, + domain_id: int, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapAPIDiscoverySettings: + """ + Retrieve the API discovery settings for a domain + + Args: + domain_id: The domain ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/waap/v1/domains/{domain_id}/api-discovery/settings", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapAPIDiscoverySettings, + ) + + +class SettingsResourceWithRawResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.update = to_raw_response_wrapper( + settings.update, + ) + self.get = to_raw_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithRawResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.update = async_to_raw_response_wrapper( + settings.update, + ) + self.get = async_to_raw_response_wrapper( + settings.get, + ) + + +class SettingsResourceWithStreamingResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.update = to_streamed_response_wrapper( + settings.update, + ) + self.get = to_streamed_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithStreamingResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.update = async_to_streamed_response_wrapper( + settings.update, + ) + self.get = async_to_streamed_response_wrapper( + settings.get, + ) diff --git a/src/gcore/resources/waap/domains/domains.py b/src/gcore/resources/waap/domains/domains.py index 644191c1..d8be440c 100644 --- a/src/gcore/resources/waap/domains/domains.py +++ b/src/gcore/resources/waap/domains/domains.py @@ -59,14 +59,6 @@ ) from ....pagination import SyncOffsetPage, AsyncOffsetPage from ....types.waap import domain_list_params, domain_update_params -from .api_discovery import ( - APIDiscoveryResource, - AsyncAPIDiscoveryResource, - APIDiscoveryResourceWithRawResponse, - AsyncAPIDiscoveryResourceWithRawResponse, - APIDiscoveryResourceWithStreamingResponse, - AsyncAPIDiscoveryResourceWithStreamingResponse, -) from .advanced_rules import ( AdvancedRulesResource, AsyncAdvancedRulesResource, @@ -100,6 +92,14 @@ InsightSilencesResourceWithStreamingResponse, AsyncInsightSilencesResourceWithStreamingResponse, ) +from .api_discovery.api_discovery import ( + APIDiscoveryResource, + AsyncAPIDiscoveryResource, + APIDiscoveryResourceWithRawResponse, + AsyncAPIDiscoveryResourceWithRawResponse, + APIDiscoveryResourceWithStreamingResponse, + AsyncAPIDiscoveryResourceWithStreamingResponse, +) from ....types.waap.waap_policy_mode import WaapPolicyMode from ....types.waap.waap_summary_domain import WaapSummaryDomain from ....types.waap.waap_detailed_domain import WaapDetailedDomain diff --git a/src/gcore/types/waap/domains/__init__.py b/src/gcore/types/waap/domains/__init__.py index 905ada2a..709597b3 100644 --- a/src/gcore/types/waap/domains/__init__.py +++ b/src/gcore/types/waap/domains/__init__.py @@ -3,7 +3,6 @@ from __future__ import annotations from .waap_insight import WaapInsight as WaapInsight -from .waap_task_id import WaapTaskID as WaapTaskID from .waap_api_path import WaapAPIPath as WaapAPIPath from .waap_ddos_info import WaapDDOSInfo as WaapDDOSInfo from .waap_custom_rule import WaapCustomRule as WaapCustomRule @@ -13,7 +12,6 @@ from .api_path_group_list import APIPathGroupList as APIPathGroupList from .insight_list_params import InsightListParams as InsightListParams from .api_path_list_params import APIPathListParams as APIPathListParams -from .waap_api_scan_result import WaapAPIScanResult as WaapAPIScanResult from .waap_insight_silence import WaapInsightSilence as WaapInsightSilence from .waap_request_details import WaapRequestDetails as WaapRequestDetails from .waap_request_summary import WaapRequestSummary as WaapRequestSummary @@ -35,23 +33,17 @@ from .firewall_rule_create_params import FirewallRuleCreateParams as FirewallRuleCreateParams from .firewall_rule_update_params import FirewallRuleUpdateParams as FirewallRuleUpdateParams from .insight_silence_list_params import InsightSilenceListParams as InsightSilenceListParams -from .waap_api_discovery_settings import WaapAPIDiscoverySettings as WaapAPIDiscoverySettings from .insight_silence_create_params import InsightSilenceCreateParams as InsightSilenceCreateParams from .insight_silence_update_params import InsightSilenceUpdateParams as InsightSilenceUpdateParams from .statistic_get_ddos_info_params import StatisticGetDDOSInfoParams as StatisticGetDDOSInfoParams from .statistic_get_ddos_attacks_params import StatisticGetDDOSAttacksParams as StatisticGetDDOSAttacksParams from .custom_rule_delete_multiple_params import CustomRuleDeleteMultipleParams as CustomRuleDeleteMultipleParams -from .api_discovery_upload_openapi_params import APIDiscoveryUploadOpenAPIParams as APIDiscoveryUploadOpenAPIParams from .statistic_get_traffic_series_params import StatisticGetTrafficSeriesParams as StatisticGetTrafficSeriesParams -from .api_discovery_update_settings_params import APIDiscoveryUpdateSettingsParams as APIDiscoveryUpdateSettingsParams from .firewall_rule_delete_multiple_params import FirewallRuleDeleteMultipleParams as FirewallRuleDeleteMultipleParams from .statistic_get_requests_series_params import StatisticGetRequestsSeriesParams as StatisticGetRequestsSeriesParams from .statistic_get_traffic_series_response import ( StatisticGetTrafficSeriesResponse as StatisticGetTrafficSeriesResponse, ) -from .api_discovery_list_scan_results_params import ( - APIDiscoveryListScanResultsParams as APIDiscoveryListScanResultsParams, -) from .statistic_get_events_aggregated_params import ( StatisticGetEventsAggregatedParams as StatisticGetEventsAggregatedParams, ) diff --git a/src/gcore/types/waap/domains/api_discovery/__init__.py b/src/gcore/types/waap/domains/api_discovery/__init__.py new file mode 100644 index 00000000..bdcc757d --- /dev/null +++ b/src/gcore/types/waap/domains/api_discovery/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .waap_task_id import WaapTaskID as WaapTaskID +from .waap_api_scan_result import WaapAPIScanResult as WaapAPIScanResult +from .openapi_upload_params import OpenAPIUploadParams as OpenAPIUploadParams +from .setting_update_params import SettingUpdateParams as SettingUpdateParams +from .scan_result_list_params import ScanResultListParams as ScanResultListParams +from .waap_api_discovery_settings import WaapAPIDiscoverySettings as WaapAPIDiscoverySettings diff --git a/src/gcore/types/waap/domains/api_discovery_upload_openapi_params.py b/src/gcore/types/waap/domains/api_discovery/openapi_upload_params.py similarity index 79% rename from src/gcore/types/waap/domains/api_discovery_upload_openapi_params.py rename to src/gcore/types/waap/domains/api_discovery/openapi_upload_params.py index 0bf87add..825e62e2 100644 --- a/src/gcore/types/waap/domains/api_discovery_upload_openapi_params.py +++ b/src/gcore/types/waap/domains/api_discovery/openapi_upload_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["APIDiscoveryUploadOpenAPIParams"] +__all__ = ["OpenAPIUploadParams"] -class APIDiscoveryUploadOpenAPIParams(TypedDict, total=False): +class OpenAPIUploadParams(TypedDict, total=False): file_data: Required[str] """Base64 representation of the description file. diff --git a/src/gcore/types/waap/domains/api_discovery_list_scan_results_params.py b/src/gcore/types/waap/domains/api_discovery/scan_result_list_params.py similarity index 89% rename from src/gcore/types/waap/domains/api_discovery_list_scan_results_params.py rename to src/gcore/types/waap/domains/api_discovery/scan_result_list_params.py index 28b05065..af3397b2 100644 --- a/src/gcore/types/waap/domains/api_discovery_list_scan_results_params.py +++ b/src/gcore/types/waap/domains/api_discovery/scan_result_list_params.py @@ -5,10 +5,10 @@ from typing import Optional from typing_extensions import Literal, TypedDict -__all__ = ["APIDiscoveryListScanResultsParams"] +__all__ = ["ScanResultListParams"] -class APIDiscoveryListScanResultsParams(TypedDict, total=False): +class ScanResultListParams(TypedDict, total=False): limit: int """Number of items to return""" diff --git a/src/gcore/types/waap/domains/api_discovery_update_settings_params.py b/src/gcore/types/waap/domains/api_discovery/setting_update_params.py similarity index 89% rename from src/gcore/types/waap/domains/api_discovery_update_settings_params.py rename to src/gcore/types/waap/domains/api_discovery/setting_update_params.py index 3274d926..768a69f1 100644 --- a/src/gcore/types/waap/domains/api_discovery_update_settings_params.py +++ b/src/gcore/types/waap/domains/api_discovery/setting_update_params.py @@ -5,12 +5,12 @@ from typing import Optional from typing_extensions import Annotated, TypedDict -from ...._utils import PropertyInfo +from ....._utils import PropertyInfo -__all__ = ["APIDiscoveryUpdateSettingsParams"] +__all__ = ["SettingUpdateParams"] -class APIDiscoveryUpdateSettingsParams(TypedDict, total=False): +class SettingUpdateParams(TypedDict, total=False): description_file_location: Annotated[Optional[str], PropertyInfo(alias="descriptionFileLocation")] """The URL of the API description file. diff --git a/src/gcore/types/waap/domains/waap_api_discovery_settings.py b/src/gcore/types/waap/domains/api_discovery/waap_api_discovery_settings.py similarity index 97% rename from src/gcore/types/waap/domains/waap_api_discovery_settings.py rename to src/gcore/types/waap/domains/api_discovery/waap_api_discovery_settings.py index 3b6339d8..6b63295d 100644 --- a/src/gcore/types/waap/domains/waap_api_discovery_settings.py +++ b/src/gcore/types/waap/domains/api_discovery/waap_api_discovery_settings.py @@ -4,7 +4,7 @@ from pydantic import Field as FieldInfo -from ...._models import BaseModel +from ....._models import BaseModel __all__ = ["WaapAPIDiscoverySettings"] diff --git a/src/gcore/types/waap/domains/waap_api_scan_result.py b/src/gcore/types/waap/domains/api_discovery/waap_api_scan_result.py similarity index 95% rename from src/gcore/types/waap/domains/waap_api_scan_result.py rename to src/gcore/types/waap/domains/api_discovery/waap_api_scan_result.py index c2bb18fa..2befca0e 100644 --- a/src/gcore/types/waap/domains/waap_api_scan_result.py +++ b/src/gcore/types/waap/domains/api_discovery/waap_api_scan_result.py @@ -4,7 +4,7 @@ from datetime import datetime from typing_extensions import Literal -from ...._models import BaseModel +from ....._models import BaseModel __all__ = ["WaapAPIScanResult"] diff --git a/src/gcore/types/waap/domains/waap_task_id.py b/src/gcore/types/waap/domains/api_discovery/waap_task_id.py similarity index 86% rename from src/gcore/types/waap/domains/waap_task_id.py rename to src/gcore/types/waap/domains/api_discovery/waap_task_id.py index 22f383c7..2fe0b65a 100644 --- a/src/gcore/types/waap/domains/waap_task_id.py +++ b/src/gcore/types/waap/domains/api_discovery/waap_task_id.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from ...._models import BaseModel +from ....._models import BaseModel __all__ = ["WaapTaskID"] diff --git a/tests/api_resources/waap/domains/api_discovery/__init__.py b/tests/api_resources/waap/domains/api_discovery/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/waap/domains/api_discovery/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/waap/domains/api_discovery/test_openapi.py b/tests/api_resources/waap/domains/api_discovery/test_openapi.py new file mode 100644 index 00000000..ff9d5b84 --- /dev/null +++ b/tests/api_resources/waap/domains/api_discovery/test_openapi.py @@ -0,0 +1,160 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.waap.domains.api_discovery import WaapTaskID + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOpenAPI: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_scan(self, client: Gcore) -> None: + openapi = client.waap.domains.api_discovery.openapi.scan( + 1, + ) + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + def test_raw_response_scan(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.openapi.with_raw_response.scan( + 1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + openapi = response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + def test_streaming_response_scan(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.openapi.with_streaming_response.scan( + 1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + openapi = response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_upload(self, client: Gcore) -> None: + openapi = client.waap.domains.api_discovery.openapi.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + def test_raw_response_upload(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.openapi.with_raw_response.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + openapi = response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + def test_streaming_response_upload(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.openapi.with_streaming_response.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + openapi = response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncOpenAPI: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_scan(self, async_client: AsyncGcore) -> None: + openapi = await async_client.waap.domains.api_discovery.openapi.scan( + 1, + ) + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + async def test_raw_response_scan(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.openapi.with_raw_response.scan( + 1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + openapi = await response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + async def test_streaming_response_scan(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.openapi.with_streaming_response.scan( + 1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + openapi = await response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_upload(self, async_client: AsyncGcore) -> None: + openapi = await async_client.waap.domains.api_discovery.openapi.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + async def test_raw_response_upload(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.openapi.with_raw_response.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + openapi = await response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + @parametrize + async def test_streaming_response_upload(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.openapi.with_streaming_response.upload( + domain_id=1, + file_data="file_data", + file_name="file_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + openapi = await response.parse() + assert_matches_type(WaapTaskID, openapi, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/waap/domains/api_discovery/test_scan_results.py b/tests/api_resources/waap/domains/api_discovery/test_scan_results.py new file mode 100644 index 00000000..efc354b4 --- /dev/null +++ b/tests/api_resources/waap/domains/api_discovery/test_scan_results.py @@ -0,0 +1,197 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.pagination import SyncOffsetPage, AsyncOffsetPage +from gcore.types.waap.domains.api_discovery import WaapAPIScanResult + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestScanResults: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Gcore) -> None: + scan_result = client.waap.domains.api_discovery.scan_results.list( + domain_id=1, + ) + assert_matches_type(SyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Gcore) -> None: + scan_result = client.waap.domains.api_discovery.scan_results.list( + domain_id=1, + limit=0, + message="message", + offset=0, + ordering="id", + status="SUCCESS", + type="TRAFFIC_SCAN", + ) + assert_matches_type(SyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.scan_results.with_raw_response.list( + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + scan_result = response.parse() + assert_matches_type(SyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.scan_results.with_streaming_response.list( + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + scan_result = response.parse() + assert_matches_type(SyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_get(self, client: Gcore) -> None: + scan_result = client.waap.domains.api_discovery.scan_results.get( + scan_id="scan_id", + domain_id=1, + ) + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.scan_results.with_raw_response.get( + scan_id="scan_id", + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + scan_result = response.parse() + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.scan_results.with_streaming_response.get( + scan_id="scan_id", + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + scan_result = response.parse() + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Gcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `scan_id` but received ''"): + client.waap.domains.api_discovery.scan_results.with_raw_response.get( + scan_id="", + domain_id=1, + ) + + +class TestAsyncScanResults: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncGcore) -> None: + scan_result = await async_client.waap.domains.api_discovery.scan_results.list( + domain_id=1, + ) + assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: + scan_result = await async_client.waap.domains.api_discovery.scan_results.list( + domain_id=1, + limit=0, + message="message", + offset=0, + ordering="id", + status="SUCCESS", + type="TRAFFIC_SCAN", + ) + assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.scan_results.with_raw_response.list( + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + scan_result = await response.parse() + assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.scan_results.with_streaming_response.list( + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + scan_result = await response.parse() + assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], scan_result, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_get(self, async_client: AsyncGcore) -> None: + scan_result = await async_client.waap.domains.api_discovery.scan_results.get( + scan_id="scan_id", + domain_id=1, + ) + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.scan_results.with_raw_response.get( + scan_id="scan_id", + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + scan_result = await response.parse() + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.scan_results.with_streaming_response.get( + scan_id="scan_id", + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + scan_result = await response.parse() + assert_matches_type(WaapAPIScanResult, scan_result, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncGcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `scan_id` but received ''"): + await async_client.waap.domains.api_discovery.scan_results.with_raw_response.get( + scan_id="", + domain_id=1, + ) diff --git a/tests/api_resources/waap/domains/api_discovery/test_settings.py b/tests/api_resources/waap/domains/api_discovery/test_settings.py new file mode 100644 index 00000000..afd2fa3e --- /dev/null +++ b/tests/api_resources/waap/domains/api_discovery/test_settings.py @@ -0,0 +1,172 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.waap.domains.api_discovery import WaapAPIDiscoverySettings + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSettings: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Gcore) -> None: + setting = client.waap.domains.api_discovery.settings.update( + domain_id=1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Gcore) -> None: + setting = client.waap.domains.api_discovery.settings.update( + domain_id=1, + description_file_location="descriptionFileLocation", + description_file_scan_enabled=True, + description_file_scan_interval_hours=1, + traffic_scan_enabled=True, + traffic_scan_interval_hours=1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.settings.with_raw_response.update( + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.settings.with_streaming_response.update( + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_get(self, client: Gcore) -> None: + setting = client.waap.domains.api_discovery.settings.get( + 1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Gcore) -> None: + response = client.waap.domains.api_discovery.settings.with_raw_response.get( + 1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Gcore) -> None: + with client.waap.domains.api_discovery.settings.with_streaming_response.get( + 1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncSettings: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_update(self, async_client: AsyncGcore) -> None: + setting = await async_client.waap.domains.api_discovery.settings.update( + domain_id=1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None: + setting = await async_client.waap.domains.api_discovery.settings.update( + domain_id=1, + description_file_location="descriptionFileLocation", + description_file_scan_enabled=True, + description_file_scan_interval_hours=1, + traffic_scan_enabled=True, + traffic_scan_interval_hours=1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.settings.with_raw_response.update( + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.settings.with_streaming_response.update( + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_get(self, async_client: AsyncGcore) -> None: + setting = await async_client.waap.domains.api_discovery.settings.get( + 1, + ) + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.api_discovery.settings.with_raw_response.get( + 1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.api_discovery.settings.with_streaming_response.get( + 1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(WaapAPIDiscoverySettings, setting, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/waap/domains/test_api_discovery.py b/tests/api_resources/waap/domains/test_api_discovery.py deleted file mode 100644 index 7fd4e461..00000000 --- a/tests/api_resources/waap/domains/test_api_discovery.py +++ /dev/null @@ -1,485 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from gcore import Gcore, AsyncGcore -from tests.utils import assert_matches_type -from gcore.pagination import SyncOffsetPage, AsyncOffsetPage -from gcore.types.waap.domains import ( - WaapTaskID, - WaapAPIScanResult, - WaapAPIDiscoverySettings, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestAPIDiscovery: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_get_scan_result(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - @parametrize - def test_raw_response_get_scan_result(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_get_scan_result(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get_scan_result(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `scan_id` but received ''"): - client.waap.domains.api_discovery.with_raw_response.get_scan_result( - scan_id="", - domain_id=1, - ) - - @parametrize - def test_method_get_settings(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.get_settings( - 1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - def test_raw_response_get_settings(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.get_settings( - 1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_get_settings(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.get_settings( - 1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_list_scan_results(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.list_scan_results( - domain_id=1, - ) - assert_matches_type(SyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - def test_method_list_scan_results_with_all_params(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.list_scan_results( - domain_id=1, - limit=0, - message="message", - offset=0, - ordering="id", - status="SUCCESS", - type="TRAFFIC_SCAN", - ) - assert_matches_type(SyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - def test_raw_response_list_scan_results(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.list_scan_results( - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(SyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_list_scan_results(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.list_scan_results( - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(SyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_scan_openapi(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.scan_openapi( - 1, - ) - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - def test_raw_response_scan_openapi(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.scan_openapi( - 1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_scan_openapi(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.scan_openapi( - 1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_update_settings(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.update_settings( - domain_id=1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - def test_method_update_settings_with_all_params(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.update_settings( - domain_id=1, - description_file_location="descriptionFileLocation", - description_file_scan_enabled=True, - description_file_scan_interval_hours=1, - traffic_scan_enabled=True, - traffic_scan_interval_hours=1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - def test_raw_response_update_settings(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.update_settings( - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_update_settings(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.update_settings( - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_upload_openapi(self, client: Gcore) -> None: - api_discovery = client.waap.domains.api_discovery.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - def test_raw_response_upload_openapi(self, client: Gcore) -> None: - response = client.waap.domains.api_discovery.with_raw_response.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - def test_streaming_response_upload_openapi(self, client: Gcore) -> None: - with client.waap.domains.api_discovery.with_streaming_response.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - -class TestAsyncAPIDiscovery: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @parametrize - async def test_method_get_scan_result(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_get_scan_result(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_get_scan_result(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.get_scan_result( - scan_id="scan_id", - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(WaapAPIScanResult, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get_scan_result(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `scan_id` but received ''"): - await async_client.waap.domains.api_discovery.with_raw_response.get_scan_result( - scan_id="", - domain_id=1, - ) - - @parametrize - async def test_method_get_settings(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.get_settings( - 1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_get_settings(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.get_settings( - 1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_get_settings(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.get_settings( - 1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_list_scan_results(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.list_scan_results( - domain_id=1, - ) - assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - async def test_method_list_scan_results_with_all_params(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.list_scan_results( - domain_id=1, - limit=0, - message="message", - offset=0, - ordering="id", - status="SUCCESS", - type="TRAFFIC_SCAN", - ) - assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_list_scan_results(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.list_scan_results( - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_list_scan_results(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.list_scan_results( - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(AsyncOffsetPage[WaapAPIScanResult], api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_scan_openapi(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.scan_openapi( - 1, - ) - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_scan_openapi(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.scan_openapi( - 1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_scan_openapi(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.scan_openapi( - 1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_update_settings(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.update_settings( - domain_id=1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - async def test_method_update_settings_with_all_params(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.update_settings( - domain_id=1, - description_file_location="descriptionFileLocation", - description_file_scan_enabled=True, - description_file_scan_interval_hours=1, - traffic_scan_enabled=True, - traffic_scan_interval_hours=1, - ) - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_update_settings(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.update_settings( - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_update_settings(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.update_settings( - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(WaapAPIDiscoverySettings, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_upload_openapi(self, async_client: AsyncGcore) -> None: - api_discovery = await async_client.waap.domains.api_discovery.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - async def test_raw_response_upload_openapi(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.api_discovery.with_raw_response.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - api_discovery = await response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - @parametrize - async def test_streaming_response_upload_openapi(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.api_discovery.with_streaming_response.upload_openapi( - domain_id=1, - file_data="file_data", - file_name="file_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - api_discovery = await response.parse() - assert_matches_type(WaapTaskID, api_discovery, path=["response"]) - - assert cast(Any, response.is_closed) is True From e17429ad3e37a2eef866b61833b1176cfac5b6d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:59:26 +0000 Subject: [PATCH 10/11] refactor(waap)!: move domains.toggle_policy to domains.policies.toggle --- .stats.yml | 2 +- src/gcore/resources/waap/api.md | 14 +- src/gcore/resources/waap/domains/__init__.py | 14 ++ src/gcore/resources/waap/domains/domains.py | 121 ++++-------- src/gcore/resources/waap/domains/policies.py | 173 ++++++++++++++++++ src/gcore/types/waap/__init__.py | 1 - src/gcore/types/waap/domains/__init__.py | 1 + .../waap/{ => domains}/waap_policy_mode.py | 2 +- .../waap/domains/test_policies.py | 108 +++++++++++ tests/api_resources/waap/test_domains.py | 85 --------- 10 files changed, 342 insertions(+), 179 deletions(-) create mode 100644 src/gcore/resources/waap/domains/policies.py rename src/gcore/types/waap/{ => domains}/waap_policy_mode.py (88%) create mode 100644 tests/api_resources/waap/domains/test_policies.py diff --git a/.stats.yml b/.stats.yml index a273f540..c64069a9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-691d7fc7d687ca367474bc78eb880f6f964454dc82259cdbb75fb90bd92c67ec.yml openapi_spec_hash: 97a4cbc8d7b05b1dc58319331717e8e7 -config_hash: a5fc65645e723807b401a8e277b7f9a7 +config_hash: cb5d9734170464c1bc79afaeb951cc24 diff --git a/src/gcore/resources/waap/api.md b/src/gcore/resources/waap/api.md index b357ca54..883cd8b2 100644 --- a/src/gcore/resources/waap/api.md +++ b/src/gcore/resources/waap/api.md @@ -32,7 +32,6 @@ from gcore.types.waap import ( WaapDomainAPISettings, WaapDomainDDOSSettings, WaapDomainSettingsModel, - WaapPolicyMode, WaapRuleSet, WaapSummaryDomain, DomainListRuleSetsResponse, @@ -46,7 +45,18 @@ Methods: - client.waap.domains.delete(domain_id) -> None - client.waap.domains.get(domain_id) -> WaapDetailedDomain - client.waap.domains.list_rule_sets(domain_id) -> DomainListRuleSetsResponse -- client.waap.domains.toggle_policy(policy_id, \*, domain_id) -> WaapPolicyMode + +### Policies + +Types: + +```python +from gcore.types.waap.domains import WaapPolicyMode +``` + +Methods: + +- client.waap.domains.policies.toggle(policy_id, \*, domain_id) -> WaapPolicyMode ### Settings diff --git a/src/gcore/resources/waap/domains/__init__.py b/src/gcore/resources/waap/domains/__init__.py index 33cc8323..2f91d228 100644 --- a/src/gcore/resources/waap/domains/__init__.py +++ b/src/gcore/resources/waap/domains/__init__.py @@ -16,6 +16,14 @@ InsightsResourceWithStreamingResponse, AsyncInsightsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from .settings import ( SettingsResource, AsyncSettingsResource, @@ -90,6 +98,12 @@ ) __all__ = [ + "PoliciesResource", + "AsyncPoliciesResource", + "PoliciesResourceWithRawResponse", + "AsyncPoliciesResourceWithRawResponse", + "PoliciesResourceWithStreamingResponse", + "AsyncPoliciesResourceWithStreamingResponse", "SettingsResource", "AsyncSettingsResource", "SettingsResourceWithRawResponse", diff --git a/src/gcore/resources/waap/domains/domains.py b/src/gcore/resources/waap/domains/domains.py index d8be440c..c366f47e 100644 --- a/src/gcore/resources/waap/domains/domains.py +++ b/src/gcore/resources/waap/domains/domains.py @@ -15,6 +15,14 @@ InsightsResourceWithStreamingResponse, AsyncInsightsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from .settings import ( SettingsResource, AsyncSettingsResource, @@ -100,7 +108,6 @@ APIDiscoveryResourceWithStreamingResponse, AsyncAPIDiscoveryResourceWithStreamingResponse, ) -from ....types.waap.waap_policy_mode import WaapPolicyMode from ....types.waap.waap_summary_domain import WaapSummaryDomain from ....types.waap.waap_detailed_domain import WaapDetailedDomain from ....types.waap.domain_list_rule_sets_response import DomainListRuleSetsResponse @@ -109,6 +116,10 @@ class DomainsResource(SyncAPIResource): + @cached_property + def policies(self) -> PoliciesResource: + return PoliciesResource(self._client) + @cached_property def settings(self) -> SettingsResource: return SettingsResource(self._client) @@ -371,46 +382,12 @@ def list_rule_sets( cast_to=DomainListRuleSetsResponse, ) - def toggle_policy( - self, - policy_id: str, - *, - domain_id: int, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapPolicyMode: - """ - Modify the activation state of a policy associated with a domain - - Args: - domain_id: The domain ID - - policy_id: The ID of the policy to toggle - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return self._patch( - f"/waap/v1/domains/{domain_id}/policies/{policy_id}/toggle", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapPolicyMode, - ) - class AsyncDomainsResource(AsyncAPIResource): + @cached_property + def policies(self) -> AsyncPoliciesResource: + return AsyncPoliciesResource(self._client) + @cached_property def settings(self) -> AsyncSettingsResource: return AsyncSettingsResource(self._client) @@ -673,44 +650,6 @@ async def list_rule_sets( cast_to=DomainListRuleSetsResponse, ) - async def toggle_policy( - self, - policy_id: str, - *, - domain_id: int, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WaapPolicyMode: - """ - Modify the activation state of a policy associated with a domain - - Args: - domain_id: The domain ID - - policy_id: The ID of the policy to toggle - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return await self._patch( - f"/waap/v1/domains/{domain_id}/policies/{policy_id}/toggle", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=WaapPolicyMode, - ) - class DomainsResourceWithRawResponse: def __init__(self, domains: DomainsResource) -> None: @@ -731,9 +670,10 @@ def __init__(self, domains: DomainsResource) -> None: self.list_rule_sets = to_raw_response_wrapper( domains.list_rule_sets, ) - self.toggle_policy = to_raw_response_wrapper( - domains.toggle_policy, - ) + + @cached_property + def policies(self) -> PoliciesResourceWithRawResponse: + return PoliciesResourceWithRawResponse(self._domains.policies) @cached_property def settings(self) -> SettingsResourceWithRawResponse: @@ -795,9 +735,10 @@ def __init__(self, domains: AsyncDomainsResource) -> None: self.list_rule_sets = async_to_raw_response_wrapper( domains.list_rule_sets, ) - self.toggle_policy = async_to_raw_response_wrapper( - domains.toggle_policy, - ) + + @cached_property + def policies(self) -> AsyncPoliciesResourceWithRawResponse: + return AsyncPoliciesResourceWithRawResponse(self._domains.policies) @cached_property def settings(self) -> AsyncSettingsResourceWithRawResponse: @@ -859,9 +800,10 @@ def __init__(self, domains: DomainsResource) -> None: self.list_rule_sets = to_streamed_response_wrapper( domains.list_rule_sets, ) - self.toggle_policy = to_streamed_response_wrapper( - domains.toggle_policy, - ) + + @cached_property + def policies(self) -> PoliciesResourceWithStreamingResponse: + return PoliciesResourceWithStreamingResponse(self._domains.policies) @cached_property def settings(self) -> SettingsResourceWithStreamingResponse: @@ -923,9 +865,10 @@ def __init__(self, domains: AsyncDomainsResource) -> None: self.list_rule_sets = async_to_streamed_response_wrapper( domains.list_rule_sets, ) - self.toggle_policy = async_to_streamed_response_wrapper( - domains.toggle_policy, - ) + + @cached_property + def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: + return AsyncPoliciesResourceWithStreamingResponse(self._domains.policies) @cached_property def settings(self) -> AsyncSettingsResourceWithStreamingResponse: diff --git a/src/gcore/resources/waap/domains/policies.py b/src/gcore/resources/waap/domains/policies.py new file mode 100644 index 00000000..c4af1f74 --- /dev/null +++ b/src/gcore/resources/waap/domains/policies.py @@ -0,0 +1,173 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.waap.domains.waap_policy_mode import WaapPolicyMode + +__all__ = ["PoliciesResource", "AsyncPoliciesResource"] + + +class PoliciesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PoliciesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return PoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return PoliciesResourceWithStreamingResponse(self) + + def toggle( + self, + policy_id: str, + *, + domain_id: int, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapPolicyMode: + """ + Modify the activation state of a policy associated with a domain + + Args: + domain_id: The domain ID + + policy_id: The ID of the policy to toggle + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return self._patch( + f"/waap/v1/domains/{domain_id}/policies/{policy_id}/toggle", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapPolicyMode, + ) + + +class AsyncPoliciesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/G-Core/gcore-python#accessing-raw-response-data-eg-headers + """ + return AsyncPoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response + """ + return AsyncPoliciesResourceWithStreamingResponse(self) + + async def toggle( + self, + policy_id: str, + *, + domain_id: int, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WaapPolicyMode: + """ + Modify the activation state of a policy associated with a domain + + Args: + domain_id: The domain ID + + policy_id: The ID of the policy to toggle + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return await self._patch( + f"/waap/v1/domains/{domain_id}/policies/{policy_id}/toggle", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WaapPolicyMode, + ) + + +class PoliciesResourceWithRawResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.toggle = to_raw_response_wrapper( + policies.toggle, + ) + + +class AsyncPoliciesResourceWithRawResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.toggle = async_to_raw_response_wrapper( + policies.toggle, + ) + + +class PoliciesResourceWithStreamingResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.toggle = to_streamed_response_wrapper( + policies.toggle, + ) + + +class AsyncPoliciesResourceWithStreamingResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.toggle = async_to_streamed_response_wrapper( + policies.toggle, + ) diff --git a/src/gcore/types/waap/__init__.py b/src/gcore/types/waap/__init__.py index b90f2d8b..09c8023e 100644 --- a/src/gcore/types/waap/__init__.py +++ b/src/gcore/types/waap/__init__.py @@ -7,7 +7,6 @@ from .waap_top_url import WaapTopURL as WaapTopURL from .waap_rule_set import WaapRuleSet as WaapRuleSet from .tag_list_params import TagListParams as TagListParams -from .waap_policy_mode import WaapPolicyMode as WaapPolicyMode from .waap_top_session import WaapTopSession as WaapTopSession from .waap_insight_type import WaapInsightType as WaapInsightType from .waap_organization import WaapOrganization as WaapOrganization diff --git a/src/gcore/types/waap/domains/__init__.py b/src/gcore/types/waap/domains/__init__.py index 709597b3..c2e3dc86 100644 --- a/src/gcore/types/waap/domains/__init__.py +++ b/src/gcore/types/waap/domains/__init__.py @@ -7,6 +7,7 @@ from .waap_ddos_info import WaapDDOSInfo as WaapDDOSInfo from .waap_custom_rule import WaapCustomRule as WaapCustomRule from .waap_ddos_attack import WaapDDOSAttack as WaapDDOSAttack +from .waap_policy_mode import WaapPolicyMode as WaapPolicyMode from .waap_advanced_rule import WaapAdvancedRule as WaapAdvancedRule from .waap_firewall_rule import WaapFirewallRule as WaapFirewallRule from .api_path_group_list import APIPathGroupList as APIPathGroupList diff --git a/src/gcore/types/waap/waap_policy_mode.py b/src/gcore/types/waap/domains/waap_policy_mode.py similarity index 88% rename from src/gcore/types/waap/waap_policy_mode.py rename to src/gcore/types/waap/domains/waap_policy_mode.py index 14faca49..ed78f2d0 100644 --- a/src/gcore/types/waap/waap_policy_mode.py +++ b/src/gcore/types/waap/domains/waap_policy_mode.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from ..._models import BaseModel +from ...._models import BaseModel __all__ = ["WaapPolicyMode"] diff --git a/tests/api_resources/waap/domains/test_policies.py b/tests/api_resources/waap/domains/test_policies.py new file mode 100644 index 00000000..10d7e384 --- /dev/null +++ b/tests/api_resources/waap/domains/test_policies.py @@ -0,0 +1,108 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from gcore import Gcore, AsyncGcore +from tests.utils import assert_matches_type +from gcore.types.waap.domains import WaapPolicyMode + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPolicies: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_toggle(self, client: Gcore) -> None: + policy = client.waap.domains.policies.toggle( + policy_id="policy_id", + domain_id=1, + ) + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + @parametrize + def test_raw_response_toggle(self, client: Gcore) -> None: + response = client.waap.domains.policies.with_raw_response.toggle( + policy_id="policy_id", + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + @parametrize + def test_streaming_response_toggle(self, client: Gcore) -> None: + with client.waap.domains.policies.with_streaming_response.toggle( + policy_id="policy_id", + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_toggle(self, client: Gcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.waap.domains.policies.with_raw_response.toggle( + policy_id="", + domain_id=1, + ) + + +class TestAsyncPolicies: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_toggle(self, async_client: AsyncGcore) -> None: + policy = await async_client.waap.domains.policies.toggle( + policy_id="policy_id", + domain_id=1, + ) + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + @parametrize + async def test_raw_response_toggle(self, async_client: AsyncGcore) -> None: + response = await async_client.waap.domains.policies.with_raw_response.toggle( + policy_id="policy_id", + domain_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + @parametrize + async def test_streaming_response_toggle(self, async_client: AsyncGcore) -> None: + async with async_client.waap.domains.policies.with_streaming_response.toggle( + policy_id="policy_id", + domain_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = await response.parse() + assert_matches_type(WaapPolicyMode, policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_toggle(self, async_client: AsyncGcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.waap.domains.policies.with_raw_response.toggle( + policy_id="", + domain_id=1, + ) diff --git a/tests/api_resources/waap/test_domains.py b/tests/api_resources/waap/test_domains.py index 9c3d9c26..58702fcb 100644 --- a/tests/api_resources/waap/test_domains.py +++ b/tests/api_resources/waap/test_domains.py @@ -11,7 +11,6 @@ from tests.utils import assert_matches_type from gcore.pagination import SyncOffsetPage, AsyncOffsetPage from gcore.types.waap import ( - WaapPolicyMode, WaapSummaryDomain, WaapDetailedDomain, DomainListRuleSetsResponse, @@ -187,48 +186,6 @@ def test_streaming_response_list_rule_sets(self, client: Gcore) -> None: assert cast(Any, response.is_closed) is True - @parametrize - def test_method_toggle_policy(self, client: Gcore) -> None: - domain = client.waap.domains.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - @parametrize - def test_raw_response_toggle_policy(self, client: Gcore) -> None: - response = client.waap.domains.with_raw_response.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - domain = response.parse() - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - @parametrize - def test_streaming_response_toggle_policy(self, client: Gcore) -> None: - with client.waap.domains.with_streaming_response.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - domain = response.parse() - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_toggle_policy(self, client: Gcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.waap.domains.with_raw_response.toggle_policy( - policy_id="", - domain_id=1, - ) - class TestAsyncDomains: parametrize = pytest.mark.parametrize( @@ -398,45 +355,3 @@ async def test_streaming_response_list_rule_sets(self, async_client: AsyncGcore) assert_matches_type(DomainListRuleSetsResponse, domain, path=["response"]) assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_toggle_policy(self, async_client: AsyncGcore) -> None: - domain = await async_client.waap.domains.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - @parametrize - async def test_raw_response_toggle_policy(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.with_raw_response.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - domain = await response.parse() - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - @parametrize - async def test_streaming_response_toggle_policy(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.with_streaming_response.toggle_policy( - policy_id="policy_id", - domain_id=1, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - domain = await response.parse() - assert_matches_type(WaapPolicyMode, domain, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_toggle_policy(self, async_client: AsyncGcore) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.waap.domains.with_raw_response.toggle_policy( - policy_id="", - domain_id=1, - ) From f603054b82673efad0af342975fe208d2710c366 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:59:47 +0000 Subject: [PATCH 11/11] release: 0.34.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- src/gcore/_version.py | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 57dc0c3d..e4e1c3ce 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.33.0" + ".": "0.34.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba1bd12..6c081a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.34.0 (2026-02-18) + +Full Changelog: [v0.33.0...v0.34.0](https://github.com/G-Core/gcore-python/compare/v0.33.0...v0.34.0) + +### ⚠ BREAKING CHANGES + +* **waap:** move domains.toggle_policy to domains.policies.toggle +* **waap:** split api_discovery methods into scan_results, openapi, and settings subresources +* **streaming:** move streams clip methods to streams.clips +* **streaming:** move playlists.list_videos to playlists.videos.list +* **cdn:** move ip_ranges.list_ips to ips.list + +### Features + +* **api:** aggregated API specs update ([34d65c1](https://github.com/G-Core/gcore-python/commit/34d65c17e2438ba6ab5d60907936eb5d12181a31)) +* **api:** aggregated API specs update ([079e24c](https://github.com/G-Core/gcore-python/commit/079e24cd6522792e9d841a2e0f408e21e617e05e)) +* **api:** aggregated API specs update ([9255354](https://github.com/G-Core/gcore-python/commit/925535479aea739b6abbd1fa76ea892d342fc355)) + + +### Bug Fixes + +* **storage:** update storage type and ignore deprecation in examples ([df7fbed](https://github.com/G-Core/gcore-python/commit/df7fbed9dca33894eaf3111bf7d87b0a1aa16977)) +* **waap:** split api_discovery methods into scan_results, openapi, and settings subresources ([b1c884f](https://github.com/G-Core/gcore-python/commit/b1c884f463f33289b820eb5565ac9d7d74afbb2f)) + + +### Refactors + +* **cdn:** move ip_ranges.list_ips to ips.list ([d86c213](https://github.com/G-Core/gcore-python/commit/d86c21322c7ea98ba5ada8ddb6e93843ac2c7719)) +* **streaming:** move playlists.list_videos to playlists.videos.list ([c156758](https://github.com/G-Core/gcore-python/commit/c156758df6af4bc9516794adf1ab984d7f17d29e)) +* **streaming:** move streams clip methods to streams.clips ([3618fc7](https://github.com/G-Core/gcore-python/commit/3618fc747692a6b6921ec82cba39180b6d99021a)) +* **waap:** move domains.toggle_policy to domains.policies.toggle ([e17429a](https://github.com/G-Core/gcore-python/commit/e17429ad3e37a2eef866b61833b1176cfac5b6d1)) + ## 0.33.0 (2026-02-16) Full Changelog: [v0.32.0...v0.33.0](https://github.com/G-Core/gcore-python/compare/v0.32.0...v0.33.0) diff --git a/pyproject.toml b/pyproject.toml index 3c044082..30f18d33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gcore" -version = "0.33.0" +version = "0.34.0" description = "The official Python library for the gcore API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/gcore/_version.py b/src/gcore/_version.py index f2c32ca0..506bfca7 100644 --- a/src/gcore/_version.py +++ b/src/gcore/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "gcore" -__version__ = "0.33.0" # x-release-please-version +__version__ = "0.34.0" # x-release-please-version