diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a7130553..d52d2b97 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.12.0" + ".": "0.13.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index bf75ef97..8d64ea87 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 523 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-fa5e3eb5c4c01c6be5a8d036640779fa59a1931c596245748ed28601213caa3b.yml -openapi_spec_hash: 2ad55753d983df577077b3ce156ac4ca -config_hash: 94a708396796faa210065e6aa3afebc2 +configured_endpoints: 524 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-3721d496395e684887e9ba0386375910a4fe68253893ccfce4e79c2e8a5b84af.yml +openapi_spec_hash: f95b9f70ed1b3b8230ef3a092c6acedd +config_hash: bfac9dcd59fec1e54559dc11fcba758e diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fcdfcb5..e7b72504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 0.13.0 (2025-09-16) + +Full Changelog: [v0.12.0...v0.13.0](https://github.com/G-Core/gcore-python/compare/v0.12.0...v0.13.0) + +### ⚠ BREAKING CHANGES + +* **waap:** model references + +### Features + +* **api:** aggregated API specs update ([2954990](https://github.com/G-Core/gcore-python/commit/295499000a8e2b1ef24ae497cb34fafbf38f2149)) +* **api:** aggregated API specs update ([09db4dd](https://github.com/G-Core/gcore-python/commit/09db4dde07cbec7bb8e94348c6ef78578c3022d3)) +* **api:** aggregated API specs update ([a2de60c](https://github.com/G-Core/gcore-python/commit/a2de60c773c01aeb6223001a0d8bff5463fa82ef)) +* **api:** aggregated API specs update ([ccf4739](https://github.com/G-Core/gcore-python/commit/ccf4739750f27e01ece2ff147458dd7fe9305437)) +* **api:** aggregated API specs update ([484ee11](https://github.com/G-Core/gcore-python/commit/484ee1144558b56f40d5bc41b9613370dc74c42e)) +* **cloud:** support floating IPs update ([28a8882](https://github.com/G-Core/gcore-python/commit/28a888260878577e697004da02077ef96a8616ad)) +* **dns:** replace post with get in check delegation status ([ddd12bd](https://github.com/G-Core/gcore-python/commit/ddd12bd4782b8883d82b97a45d043ad3970ee31a)) + + +### Bug Fixes + +* **cloud:** floating ips examples ([bf8a5dd](https://github.com/G-Core/gcore-python/commit/bf8a5ddff3e777441db47163dc03b73052d99ecd)) +* **waap:** model references ([4f69e7e](https://github.com/G-Core/gcore-python/commit/4f69e7e5aa778cf82357d7d097e874100bfa9e0d)) + ## 0.12.0 (2025-09-11) Full Changelog: [v0.11.0...v0.12.0](https://github.com/G-Core/gcore-python/compare/v0.11.0...v0.12.0) diff --git a/api.md b/api.md index 7a3fa350..56d6038b 100644 --- a/api.md +++ b/api.md @@ -397,6 +397,7 @@ from gcore.types.cloud import FloatingIPDetailed Methods: - client.cloud.floating_ips.create(\*, project_id, region_id, \*\*params) -> TaskIDList +- client.cloud.floating_ips.update(floating_ip_id, \*, project_id, region_id, \*\*params) -> FloatingIP - client.cloud.floating_ips.list(\*, project_id, region_id, \*\*params) -> SyncOffsetPage[FloatingIPDetailed] - client.cloud.floating_ips.delete(floating_ip_id, \*, project_id, region_id) -> TaskIDList - client.cloud.floating_ips.assign(floating_ip_id, \*, project_id, region_id, \*\*params) -> FloatingIP @@ -1289,13 +1290,14 @@ Types: from gcore.types.waap import ( WaapIPCountryAttack, WaapIPDDOSInfoModel, + WaapIPInfo, WaapRuleBlockedRequests, WaapTimeSeriesAttack, WaapTopSession, + WaapTopURL, WaapTopUserAgent, IPInfoGetAttackTimeSeriesResponse, IPInfoGetBlockedRequestsResponse, - IPInfoGetIPInfoResponse, IPInfoGetTopURLsResponse, IPInfoGetTopUserAgentsResponse, IPInfoGetTopUserSessionsResponse, @@ -1308,7 +1310,7 @@ Methods: - client.waap.ip_info.get_attack_time_series(\*\*params) -> IPInfoGetAttackTimeSeriesResponse - client.waap.ip_info.get_blocked_requests(\*\*params) -> IPInfoGetBlockedRequestsResponse - client.waap.ip_info.get_ddos_attack_series(\*\*params) -> WaapIPDDOSInfoModel -- client.waap.ip_info.get_ip_info(\*\*params) -> IPInfoGetIPInfoResponse +- client.waap.ip_info.get_ip_info(\*\*params) -> WaapIPInfo - client.waap.ip_info.get_top_urls(\*\*params) -> IPInfoGetTopURLsResponse - client.waap.ip_info.get_top_user_agents(\*\*params) -> IPInfoGetTopUserAgentsResponse - client.waap.ip_info.get_top_user_sessions(\*\*params) -> IPInfoGetTopUserSessionsResponse @@ -1932,7 +1934,7 @@ Methods: - client.dns.zones.create(\*\*params) -> ZoneCreateResponse - client.dns.zones.list(\*\*params) -> ZoneListResponse - client.dns.zones.delete(name) -> object -- client.dns.zones.check_delegation_status(name) -> ZoneCheckDelegationStatusResponse +- client.dns.zones.check_delegation_status(name) -> ZoneCheckDelegationStatusResponse - client.dns.zones.disable(name) -> object - client.dns.zones.enable(name) -> object - client.dns.zones.export(zone_name) -> ZoneExportResponse diff --git a/examples/cloud/floating_ips.py b/examples/cloud/floating_ips.py index 70777db7..ed5dd2c2 100644 --- a/examples/cloud/floating_ips.py +++ b/examples/cloud/floating_ips.py @@ -34,8 +34,6 @@ def main() -> None: def create_floating_ip(*, client: Gcore) -> str: print("\n=== CREATE FLOATING IP ===") floating_ip = client.cloud.floating_ips.create_and_poll(tags={"name": "gcore-go-example"}) - if floating_ip.id is None: - raise RuntimeError("Failed to create floating IP") print(f"Created Floating IP: ID={floating_ip.id}") print("========================") return floating_ip.id diff --git a/examples/cloud/floating_ips_async.py b/examples/cloud/floating_ips_async.py index 7e41623d..f79c81ef 100644 --- a/examples/cloud/floating_ips_async.py +++ b/examples/cloud/floating_ips_async.py @@ -35,8 +35,6 @@ async def main() -> None: async def create_floating_ip(*, client: AsyncGcore) -> str: print("\n=== CREATE FLOATING IP ===") floating_ip = await client.cloud.floating_ips.create_and_poll(tags={"name": "gcore-go-example"}) - if floating_ip.id is None: - raise RuntimeError("Failed to create floating IP") print(f"Created floating IP: ID={floating_ip.id}") print("========================") return floating_ip.id diff --git a/pyproject.toml b/pyproject.toml index 29e96268..4e7dd1c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gcore" -version = "0.12.0" +version = "0.13.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 7f12d5d7..30d62a13 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.12.0" # x-release-please-version +__version__ = "0.13.0" # x-release-please-version diff --git a/src/gcore/resources/cloud/floating_ips.py b/src/gcore/resources/cloud/floating_ips.py index 85d1e774..1ed214df 100644 --- a/src/gcore/resources/cloud/floating_ips.py +++ b/src/gcore/resources/cloud/floating_ips.py @@ -17,11 +17,17 @@ async_to_streamed_response_wrapper, ) from ...pagination import SyncOffsetPage, AsyncOffsetPage -from ...types.cloud import floating_ip_list_params, floating_ip_assign_params, floating_ip_create_params +from ...types.cloud import ( + floating_ip_list_params, + floating_ip_assign_params, + floating_ip_create_params, + floating_ip_update_params, +) from ..._base_client import AsyncPaginator, make_request_options from ...types.cloud.floating_ip import FloatingIP from ...types.cloud.task_id_list import TaskIDList from ...types.cloud.floating_ip_detailed import FloatingIPDetailed +from ...types.cloud.tag_update_map_param import TagUpdateMapParam __all__ = ["FloatingIPsResource", "AsyncFloatingIPsResource"] @@ -109,6 +115,73 @@ def create( cast_to=TaskIDList, ) + def update( + self, + floating_ip_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + tags: Optional[TagUpdateMapParam] | NotGiven = NOT_GIVEN, + # 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, + ) -> FloatingIP: + """ + Update floating IP + + Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + + tags: Update key-value tags using JSON Merge Patch semantics (RFC 7386). Provide + key-value pairs to add or update tags. Set tag values to `null` to remove tags. + Unspecified tags remain unchanged. Read-only tags are always preserved and + cannot be modified. **Examples:** + + - **Add/update tags:** + `{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or + updates existing ones. + - **Delete tags:** `{'tags': {'`old_tag`': null}}` removes specific tags. + - **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only + tags are preserved). + - **Partial update:** `{'tags': {'environment': 'staging'}}` only updates + specified tags. + - **Mixed operations:** + `{'tags': {'environment': 'production', '`cost_center`': 'engineering', '`deprecated_tag`': null}}` + adds/updates 'environment' and '`cost_center`' while removing + '`deprecated_tag`', preserving other existing tags. + - **Replace all:** first delete existing tags with null values, then add new + ones in the same request. + + 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 project_id is None: + project_id = self._client._get_cloud_project_id_path_param() + if region_id is None: + region_id = self._client._get_cloud_region_id_path_param() + if not floating_ip_id: + raise ValueError(f"Expected a non-empty value for `floating_ip_id` but received {floating_ip_id!r}") + return self._patch( + f"/cloud/v1/floatingips/{project_id}/{region_id}/{floating_ip_id}", + body=maybe_transform({"tags": tags}, floating_ip_update_params.FloatingIPUpdateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FloatingIP, + ) + def list( self, *, @@ -192,6 +265,12 @@ def delete( Delete floating IP Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -283,6 +362,12 @@ def get( Get floating IP Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -512,6 +597,73 @@ async def create( cast_to=TaskIDList, ) + async def update( + self, + floating_ip_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + tags: Optional[TagUpdateMapParam] | NotGiven = NOT_GIVEN, + # 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, + ) -> FloatingIP: + """ + Update floating IP + + Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + + tags: Update key-value tags using JSON Merge Patch semantics (RFC 7386). Provide + key-value pairs to add or update tags. Set tag values to `null` to remove tags. + Unspecified tags remain unchanged. Read-only tags are always preserved and + cannot be modified. **Examples:** + + - **Add/update tags:** + `{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or + updates existing ones. + - **Delete tags:** `{'tags': {'`old_tag`': null}}` removes specific tags. + - **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only + tags are preserved). + - **Partial update:** `{'tags': {'environment': 'staging'}}` only updates + specified tags. + - **Mixed operations:** + `{'tags': {'environment': 'production', '`cost_center`': 'engineering', '`deprecated_tag`': null}}` + adds/updates 'environment' and '`cost_center`' while removing + '`deprecated_tag`', preserving other existing tags. + - **Replace all:** first delete existing tags with null values, then add new + ones in the same request. + + 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 project_id is None: + project_id = self._client._get_cloud_project_id_path_param() + if region_id is None: + region_id = self._client._get_cloud_region_id_path_param() + if not floating_ip_id: + raise ValueError(f"Expected a non-empty value for `floating_ip_id` but received {floating_ip_id!r}") + return await self._patch( + f"/cloud/v1/floatingips/{project_id}/{region_id}/{floating_ip_id}", + body=await async_maybe_transform({"tags": tags}, floating_ip_update_params.FloatingIPUpdateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FloatingIP, + ) + def list( self, *, @@ -595,6 +747,12 @@ async def delete( Delete floating IP Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -686,6 +844,12 @@ async def get( Get floating IP Args: + project_id: Project ID + + region_id: Region ID + + floating_ip_id: Floating IP ID + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -839,6 +1003,9 @@ def __init__(self, floating_ips: FloatingIPsResource) -> None: self.create = to_raw_response_wrapper( floating_ips.create, ) + self.update = to_raw_response_wrapper( + floating_ips.update, + ) self.list = to_raw_response_wrapper( floating_ips.list, ) @@ -869,6 +1036,9 @@ def __init__(self, floating_ips: AsyncFloatingIPsResource) -> None: self.create = async_to_raw_response_wrapper( floating_ips.create, ) + self.update = async_to_raw_response_wrapper( + floating_ips.update, + ) self.list = async_to_raw_response_wrapper( floating_ips.list, ) @@ -899,6 +1069,9 @@ def __init__(self, floating_ips: FloatingIPsResource) -> None: self.create = to_streamed_response_wrapper( floating_ips.create, ) + self.update = to_streamed_response_wrapper( + floating_ips.update, + ) self.list = to_streamed_response_wrapper( floating_ips.list, ) @@ -929,6 +1102,9 @@ def __init__(self, floating_ips: AsyncFloatingIPsResource) -> None: self.create = async_to_streamed_response_wrapper( floating_ips.create, ) + self.update = async_to_streamed_response_wrapper( + floating_ips.update, + ) self.list = async_to_streamed_response_wrapper( floating_ips.list, ) diff --git a/src/gcore/resources/dns/zones/zones.py b/src/gcore/resources/dns/zones/zones.py index 75e11dde..2bef8d84 100644 --- a/src/gcore/resources/dns/zones/zones.py +++ b/src/gcore/resources/dns/zones/zones.py @@ -317,7 +317,7 @@ def check_delegation_status( """ if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return self._post( + return self._get( f"/dns/v2/analyze/{name}/delegation-status", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -943,7 +943,7 @@ async def check_delegation_status( """ if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return await self._post( + return await self._get( f"/dns/v2/analyze/{name}/delegation-status", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/gcore/resources/waap/ip_info/ip_info.py b/src/gcore/resources/waap/ip_info/ip_info.py index 7d4d5f1b..e721bf7d 100644 --- a/src/gcore/resources/waap/ip_info/ip_info.py +++ b/src/gcore/resources/waap/ip_info/ip_info.py @@ -33,8 +33,8 @@ ip_info_list_attacked_countries_params, ) from ...._base_client import make_request_options +from ....types.waap.waap_ip_info import WaapIPInfo from ....types.waap.waap_ip_ddos_info_model import WaapIPDDOSInfoModel -from ....types.waap.ip_info_get_ip_info_response import IPInfoGetIPInfoResponse from ....types.waap.ip_info_get_top_urls_response import IPInfoGetTopURLsResponse from ....types.waap.ip_info_get_top_user_agents_response import IPInfoGetTopUserAgentsResponse from ....types.waap.ip_info_get_blocked_requests_response import IPInfoGetBlockedRequestsResponse @@ -212,7 +212,7 @@ def get_ip_info( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> IPInfoGetIPInfoResponse: + ) -> WaapIPInfo: """ Fetch details about a particular IP address, including WHOIS data, risk score, and additional tags. @@ -237,7 +237,7 @@ def get_ip_info( timeout=timeout, query=maybe_transform({"ip": ip}, ip_info_get_ip_info_params.IPInfoGetIPInfoParams), ), - cast_to=IPInfoGetIPInfoResponse, + cast_to=WaapIPInfo, ) def get_top_urls( @@ -596,7 +596,7 @@ async def get_ip_info( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> IPInfoGetIPInfoResponse: + ) -> WaapIPInfo: """ Fetch details about a particular IP address, including WHOIS data, risk score, and additional tags. @@ -621,7 +621,7 @@ async def get_ip_info( timeout=timeout, query=await async_maybe_transform({"ip": ip}, ip_info_get_ip_info_params.IPInfoGetIPInfoParams), ), - cast_to=IPInfoGetIPInfoResponse, + cast_to=WaapIPInfo, ) async def get_top_urls( diff --git a/src/gcore/types/cloud/__init__.py b/src/gcore/types/cloud/__init__.py index 586c4473..21972950 100644 --- a/src/gcore/types/cloud/__init__.py +++ b/src/gcore/types/cloud/__init__.py @@ -122,6 +122,7 @@ from .load_balancer_statistics import LoadBalancerStatistics as LoadBalancerStatistics from .floating_ip_assign_params import FloatingIPAssignParams as FloatingIPAssignParams from .floating_ip_create_params import FloatingIPCreateParams as FloatingIPCreateParams +from .floating_ip_update_params import FloatingIPUpdateParams as FloatingIPUpdateParams from .inference_region_capacity import InferenceRegionCapacity as InferenceRegionCapacity from .load_balancer_flavor_list import LoadBalancerFlavorList as LoadBalancerFlavorList from .load_balancer_list_params import LoadBalancerListParams as LoadBalancerListParams diff --git a/src/gcore/types/cloud/floating_ip.py b/src/gcore/types/cloud/floating_ip.py index ffcc744a..61d3995d 100644 --- a/src/gcore/types/cloud/floating_ip.py +++ b/src/gcore/types/cloud/floating_ip.py @@ -11,7 +11,7 @@ class FloatingIP(BaseModel): - id: Optional[str] = None + id: str """Floating IP ID""" created_at: datetime diff --git a/src/gcore/types/cloud/floating_ip_detailed.py b/src/gcore/types/cloud/floating_ip_detailed.py index 2f4c6a3c..1692fc87 100644 --- a/src/gcore/types/cloud/floating_ip_detailed.py +++ b/src/gcore/types/cloud/floating_ip_detailed.py @@ -153,7 +153,7 @@ class Instance(BaseModel): class FloatingIPDetailed(BaseModel): - id: Optional[str] = None + id: str """Floating IP ID""" created_at: datetime diff --git a/src/gcore/types/cloud/floating_ip_update_params.py b/src/gcore/types/cloud/floating_ip_update_params.py new file mode 100644 index 00000000..79377f4b --- /dev/null +++ b/src/gcore/types/cloud/floating_ip_update_params.py @@ -0,0 +1,41 @@ +# 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 TypedDict + +from .tag_update_map_param import TagUpdateMapParam + +__all__ = ["FloatingIPUpdateParams"] + + +class FloatingIPUpdateParams(TypedDict, total=False): + project_id: int + """Project ID""" + + region_id: int + """Region ID""" + + tags: Optional[TagUpdateMapParam] + """Update key-value tags using JSON Merge Patch semantics (RFC 7386). + + Provide key-value pairs to add or update tags. Set tag values to `null` to + remove tags. Unspecified tags remain unchanged. Read-only tags are always + preserved and cannot be modified. **Examples:** + + - **Add/update tags:** + `{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or + updates existing ones. + - **Delete tags:** `{'tags': {'`old_tag`': null}}` removes specific tags. + - **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only + tags are preserved). + - **Partial update:** `{'tags': {'environment': 'staging'}}` only updates + specified tags. + - **Mixed operations:** + `{'tags': {'environment': 'production', '`cost_center`': 'engineering', '`deprecated_tag`': null}}` + adds/updates 'environment' and '`cost_center`' while removing + '`deprecated_tag`', preserving other existing tags. + - **Replace all:** first delete existing tags with null values, then add new + ones in the same request. + """ diff --git a/src/gcore/types/waap/__init__.py b/src/gcore/types/waap/__init__.py index 29b9b772..b90f2d8b 100644 --- a/src/gcore/types/waap/__init__.py +++ b/src/gcore/types/waap/__init__.py @@ -3,6 +3,8 @@ from __future__ import annotations from .waap_tag import WaapTag as WaapTag +from .waap_ip_info import WaapIPInfo as WaapIPInfo +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 @@ -30,7 +32,6 @@ from .waap_rule_blocked_requests import WaapRuleBlockedRequests as WaapRuleBlockedRequests from .custom_page_set_list_params import CustomPageSetListParams as CustomPageSetListParams from .ip_info_get_top_urls_params import IPInfoGetTopURLsParams as IPInfoGetTopURLsParams -from .ip_info_get_ip_info_response import IPInfoGetIPInfoResponse as IPInfoGetIPInfoResponse from .custom_page_set_create_params import CustomPageSetCreateParams as CustomPageSetCreateParams from .custom_page_set_update_params import CustomPageSetUpdateParams as CustomPageSetUpdateParams from .ip_info_get_top_urls_response import IPInfoGetTopURLsResponse as IPInfoGetTopURLsResponse diff --git a/src/gcore/types/waap/ip_info_get_top_urls_response.py b/src/gcore/types/waap/ip_info_get_top_urls_response.py index 0db2c8ce..76dc6cdb 100644 --- a/src/gcore/types/waap/ip_info_get_top_urls_response.py +++ b/src/gcore/types/waap/ip_info_get_top_urls_response.py @@ -3,17 +3,8 @@ from typing import List from typing_extensions import TypeAlias -from ..._models import BaseModel +from .waap_top_url import WaapTopURL -__all__ = ["IPInfoGetTopURLsResponse", "IPInfoGetTopURLsResponseItem"] +__all__ = ["IPInfoGetTopURLsResponse"] - -class IPInfoGetTopURLsResponseItem(BaseModel): - count: int - """The number of attacks to the URL""" - - url: str - """The URL that was attacked""" - - -IPInfoGetTopURLsResponse: TypeAlias = List[IPInfoGetTopURLsResponseItem] +IPInfoGetTopURLsResponse: TypeAlias = List[WaapTopURL] diff --git a/src/gcore/types/waap/ip_info_get_ip_info_response.py b/src/gcore/types/waap/waap_ip_info.py similarity index 93% rename from src/gcore/types/waap/ip_info_get_ip_info_response.py rename to src/gcore/types/waap/waap_ip_info.py index 82fc8e8d..741e7e2f 100644 --- a/src/gcore/types/waap/ip_info_get_ip_info_response.py +++ b/src/gcore/types/waap/waap_ip_info.py @@ -5,7 +5,7 @@ from ..._models import BaseModel -__all__ = ["IPInfoGetIPInfoResponse", "Whois"] +__all__ = ["WaapIPInfo", "Whois"] class Whois(BaseModel): @@ -46,7 +46,7 @@ class Whois(BaseModel): """The state""" -class IPInfoGetIPInfoResponse(BaseModel): +class WaapIPInfo(BaseModel): risk_score: Literal["NO_RISK", "LOW", "MEDIUM", "HIGH", "EXTREME", "NOT_ENOUGH_DATA"] """The risk score of the IP address""" diff --git a/src/gcore/types/waap/waap_top_url.py b/src/gcore/types/waap/waap_top_url.py new file mode 100644 index 00000000..88d761f8 --- /dev/null +++ b/src/gcore/types/waap/waap_top_url.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from ..._models import BaseModel + +__all__ = ["WaapTopURL"] + + +class WaapTopURL(BaseModel): + count: int + """The number of attacks to the URL""" + + url: str + """The URL that was attacked""" diff --git a/tests/api_resources/cloud/test_floating_ips.py b/tests/api_resources/cloud/test_floating_ips.py index a0772131..4b31820b 100644 --- a/tests/api_resources/cloud/test_floating_ips.py +++ b/tests/api_resources/cloud/test_floating_ips.py @@ -67,6 +67,62 @@ def test_streaming_response_create(self, client: Gcore) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_method_update(self, client: Gcore) -> None: + floating_ip = client.cloud.floating_ips.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Gcore) -> None: + floating_ip = client.cloud.floating_ips.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + tags={"foo": "my-tag-value"}, + ) + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Gcore) -> None: + response = client.cloud.floating_ips.with_raw_response.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + floating_ip = response.parse() + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Gcore) -> None: + with client.cloud.floating_ips.with_streaming_response.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + floating_ip = response.parse() + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Gcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): + client.cloud.floating_ips.with_raw_response.update( + floating_ip_id="", + project_id=1, + region_id=1, + ) + @parametrize def test_method_list(self, client: Gcore) -> None: floating_ip = client.cloud.floating_ips.list( @@ -116,18 +172,18 @@ def test_streaming_response_list(self, client: Gcore) -> None: @parametrize def test_method_delete(self, client: Gcore) -> None: floating_ip = client.cloud.floating_ips.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) @parametrize def test_raw_response_delete(self, client: Gcore) -> None: response = client.cloud.floating_ips.with_raw_response.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert response.is_closed is True @@ -138,9 +194,9 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: with client.cloud.floating_ips.with_streaming_response.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -155,8 +211,8 @@ def test_path_params_delete(self, client: Gcore) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): client.cloud.floating_ips.with_raw_response.delete( floating_ip_id="", - project_id=0, - region_id=0, + project_id=1, + region_id=1, ) @parametrize @@ -223,18 +279,18 @@ def test_path_params_assign(self, client: Gcore) -> None: @parametrize def test_method_get(self, client: Gcore) -> None: floating_ip = client.cloud.floating_ips.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert_matches_type(FloatingIP, floating_ip, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: response = client.cloud.floating_ips.with_raw_response.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert response.is_closed is True @@ -245,9 +301,9 @@ def test_raw_response_get(self, client: Gcore) -> None: @parametrize def test_streaming_response_get(self, client: Gcore) -> None: with client.cloud.floating_ips.with_streaming_response.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -262,8 +318,8 @@ def test_path_params_get(self, client: Gcore) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): client.cloud.floating_ips.with_raw_response.get( floating_ip_id="", - project_id=0, - region_id=0, + project_id=1, + region_id=1, ) @parametrize @@ -363,6 +419,62 @@ async def test_streaming_response_create(self, async_client: AsyncGcore) -> None assert cast(Any, response.is_closed) is True + @parametrize + async def test_method_update(self, async_client: AsyncGcore) -> None: + floating_ip = await async_client.cloud.floating_ips.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None: + floating_ip = await async_client.cloud.floating_ips.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + tags={"foo": "my-tag-value"}, + ) + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncGcore) -> None: + response = await async_client.cloud.floating_ips.with_raw_response.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + floating_ip = await response.parse() + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncGcore) -> None: + async with async_client.cloud.floating_ips.with_streaming_response.update( + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + floating_ip = await response.parse() + assert_matches_type(FloatingIP, floating_ip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncGcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): + await async_client.cloud.floating_ips.with_raw_response.update( + floating_ip_id="", + project_id=1, + region_id=1, + ) + @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: floating_ip = await async_client.cloud.floating_ips.list( @@ -412,18 +524,18 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: floating_ip = await async_client.cloud.floating_ips.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert_matches_type(TaskIDList, floating_ip, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: response = await async_client.cloud.floating_ips.with_raw_response.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert response.is_closed is True @@ -434,9 +546,9 @@ 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.cloud.floating_ips.with_streaming_response.delete( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -451,8 +563,8 @@ async def test_path_params_delete(self, async_client: AsyncGcore) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): await async_client.cloud.floating_ips.with_raw_response.delete( floating_ip_id="", - project_id=0, - region_id=0, + project_id=1, + region_id=1, ) @parametrize @@ -519,18 +631,18 @@ async def test_path_params_assign(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: floating_ip = await async_client.cloud.floating_ips.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert_matches_type(FloatingIP, floating_ip, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: response = await async_client.cloud.floating_ips.with_raw_response.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) assert response.is_closed is True @@ -541,9 +653,9 @@ 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.cloud.floating_ips.with_streaming_response.get( - floating_ip_id="floating_ip_id", - project_id=0, - region_id=0, + floating_ip_id="c64e5db1-5f1f-43ec-a8d9-5090df85b82d", + project_id=1, + region_id=1, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -558,8 +670,8 @@ async def test_path_params_get(self, async_client: AsyncGcore) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `floating_ip_id` but received ''"): await async_client.cloud.floating_ips.with_raw_response.get( floating_ip_id="", - project_id=0, - region_id=0, + project_id=1, + region_id=1, ) @parametrize diff --git a/tests/api_resources/waap/test_ip_info.py b/tests/api_resources/waap/test_ip_info.py index 49b4f4f3..e3b42484 100644 --- a/tests/api_resources/waap/test_ip_info.py +++ b/tests/api_resources/waap/test_ip_info.py @@ -10,8 +10,8 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type from gcore.types.waap import ( + WaapIPInfo, WaapIPDDOSInfoModel, - IPInfoGetIPInfoResponse, IPInfoGetTopURLsResponse, IPInfoGetTopUserAgentsResponse, IPInfoGetBlockedRequestsResponse, @@ -127,7 +127,7 @@ def test_method_get_ip_info(self, client: Gcore) -> None: ip_info = client.waap.ip_info.get_ip_info( ip="192.168.1.1", ) - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) @parametrize def test_raw_response_get_ip_info(self, client: Gcore) -> None: @@ -138,7 +138,7 @@ def test_raw_response_get_ip_info(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" ip_info = response.parse() - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) @parametrize def test_streaming_response_get_ip_info(self, client: Gcore) -> None: @@ -149,7 +149,7 @@ def test_streaming_response_get_ip_info(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" ip_info = response.parse() - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) assert cast(Any, response.is_closed) is True @@ -393,7 +393,7 @@ async def test_method_get_ip_info(self, async_client: AsyncGcore) -> None: ip_info = await async_client.waap.ip_info.get_ip_info( ip="192.168.1.1", ) - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) @parametrize async def test_raw_response_get_ip_info(self, async_client: AsyncGcore) -> None: @@ -404,7 +404,7 @@ async def test_raw_response_get_ip_info(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" ip_info = await response.parse() - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) @parametrize async def test_streaming_response_get_ip_info(self, async_client: AsyncGcore) -> None: @@ -415,7 +415,7 @@ async def test_streaming_response_get_ip_info(self, async_client: AsyncGcore) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" ip_info = await response.parse() - assert_matches_type(IPInfoGetIPInfoResponse, ip_info, path=["response"]) + assert_matches_type(WaapIPInfo, ip_info, path=["response"]) assert cast(Any, response.is_closed) is True