diff --git a/.stats.yml b/.stats.yml index 0735ab69b20..eaf5c444b01 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1337 +configured_endpoints: 1353 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-411fc42706796f9d708196eed9f4ad709877cf110b7c3a7a1ec4254ea41e1767.yml diff --git a/api.md b/api.md index c3139edde1c..5cf9fd9a98e 100644 --- a/api.md +++ b/api.md @@ -3988,25 +3988,40 @@ Methods: Types: ```python -from cloudflare.types.magic_transit import CfInterconnectListResponse +from cloudflare.types.magic_transit import ( + CfInterconnectUpdateResponse, + CfInterconnectListResponse, + CfInterconnectGetResponse, +) ``` Methods: +- client.magic_transit.cf_interconnects.update(cf_interconnect_id, \*, account_id, \*\*params) -> CfInterconnectUpdateResponse - client.magic_transit.cf_interconnects.list(\*, account_id) -> CfInterconnectListResponse +- client.magic_transit.cf_interconnects.get(cf_interconnect_id, \*, account_id) -> CfInterconnectGetResponse ## GRETunnels Types: ```python -from cloudflare.types.magic_transit import GRETunnelCreateResponse, GRETunnelListResponse +from cloudflare.types.magic_transit import ( + GRETunnelCreateResponse, + GRETunnelUpdateResponse, + GRETunnelListResponse, + GRETunnelDeleteResponse, + GRETunnelGetResponse, +) ``` Methods: - client.magic_transit.gre_tunnels.create(\*, account_id, \*\*params) -> GRETunnelCreateResponse +- client.magic_transit.gre_tunnels.update(gre_tunnel_id, \*, account_id, \*\*params) -> GRETunnelUpdateResponse - client.magic_transit.gre_tunnels.list(\*, account_id) -> GRETunnelListResponse +- client.magic_transit.gre_tunnels.delete(gre_tunnel_id, \*, account_id) -> GRETunnelDeleteResponse +- client.magic_transit.gre_tunnels.get(gre_tunnel_id, \*, account_id) -> GRETunnelGetResponse ## IPSECTunnels @@ -4016,14 +4031,22 @@ Types: from cloudflare.types.magic_transit import ( PSKMetadata, IPSECTunnelCreateResponse, + IPSECTunnelUpdateResponse, IPSECTunnelListResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelGetResponse, + IPSECTunnelPSKGenerateResponse, ) ``` Methods: - client.magic_transit.ipsec_tunnels.create(\*, account_id, \*\*params) -> IPSECTunnelCreateResponse +- client.magic_transit.ipsec_tunnels.update(ipsec_tunnel_id, \*, account_id, \*\*params) -> IPSECTunnelUpdateResponse - client.magic_transit.ipsec_tunnels.list(\*, account_id) -> IPSECTunnelListResponse +- client.magic_transit.ipsec_tunnels.delete(ipsec_tunnel_id, \*, account_id) -> IPSECTunnelDeleteResponse +- client.magic_transit.ipsec_tunnels.get(ipsec_tunnel_id, \*, account_id) -> IPSECTunnelGetResponse +- client.magic_transit.ipsec_tunnels.psk_generate(ipsec_tunnel_id, \*, account_id, \*\*params) -> IPSECTunnelPSKGenerateResponse ## Routes @@ -4033,16 +4056,22 @@ Types: from cloudflare.types.magic_transit import ( Scope, RouteCreateResponse, + RouteUpdateResponse, RouteListResponse, + RouteDeleteResponse, RouteEmptyResponse, + RouteGetResponse, ) ``` Methods: - client.magic_transit.routes.create(\*, account_id, \*\*params) -> RouteCreateResponse +- client.magic_transit.routes.update(route_id, \*, account_id, \*\*params) -> RouteUpdateResponse - client.magic_transit.routes.list(\*, account_id) -> RouteListResponse +- client.magic_transit.routes.delete(route_id, \*, account_id) -> RouteDeleteResponse - client.magic_transit.routes.empty(\*, account_id) -> RouteEmptyResponse +- client.magic_transit.routes.get(route_id, \*, account_id) -> RouteGetResponse ## Sites @@ -4072,7 +4101,11 @@ from cloudflare.types.magic_transit.sites import ACL, ACLConfiguration, AllowedP Methods: - client.magic_transit.sites.acls.create(site_id, \*, account_id, \*\*params) -> ACL +- client.magic_transit.sites.acls.update(acl_id, \*, account_id, site_id, \*\*params) -> ACL - client.magic_transit.sites.acls.list(site_id, \*, account_id) -> SyncSinglePage[ACL] +- client.magic_transit.sites.acls.delete(acl_id, \*, account_id, site_id) -> ACL +- client.magic_transit.sites.acls.edit(acl_id, \*, account_id, site_id, \*\*params) -> ACL +- client.magic_transit.sites.acls.get(acl_id, \*, account_id, site_id) -> ACL ### LANs @@ -7858,7 +7891,7 @@ from cloudflare.types.ai_gateway import LogListResponse Methods: -- client.ai_gateway.logs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse] +- client.ai_gateway.logs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse] # IAM diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 2d11d809968..ac5a9237f0b 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -21,7 +21,6 @@ async_maybe_transform, ) from ..._compat import cached_property -from .logs.logs import LogsResource, AsyncLogsResource from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, diff --git a/src/cloudflare/resources/ai_gateway/logs/logs.py b/src/cloudflare/resources/ai_gateway/logs.py similarity index 94% rename from src/cloudflare/resources/ai_gateway/logs/logs.py rename to src/cloudflare/resources/ai_gateway/logs.py index d640bb36e6a..58f38d09fbc 100644 --- a/src/cloudflare/resources/ai_gateway/logs/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -8,23 +8,23 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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 SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ...._base_client import ( +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import ( AsyncPaginator, make_request_options, ) -from ....types.ai_gateway import log_list_params -from ....types.ai_gateway.log_list_response import LogListResponse +from ...types.ai_gateway import log_list_params +from ...types.ai_gateway.log_list_response import LogListResponse __all__ = ["LogsResource", "AsyncLogsResource"] diff --git a/src/cloudflare/resources/ai_gateway/logs/__init__.py b/src/cloudflare/resources/ai_gateway/logs/__init__.py deleted file mode 100644 index 30876fab694..00000000000 --- a/src/cloudflare/resources/ai_gateway/logs/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .logs import ( - LogsResource, - AsyncLogsResource, - LogsResourceWithRawResponse, - AsyncLogsResourceWithRawResponse, - LogsResourceWithStreamingResponse, - AsyncLogsResourceWithStreamingResponse, -) - -__all__ = [ - "LogsResource", - "AsyncLogsResource", - "LogsResourceWithRawResponse", - "AsyncLogsResourceWithRawResponse", - "LogsResourceWithStreamingResponse", - "AsyncLogsResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/magic_transit/cf_interconnects.py b/src/cloudflare/resources/magic_transit/cf_interconnects.py index 18f79e0181f..e06f3339eaa 100644 --- a/src/cloudflare/resources/magic_transit/cf_interconnects.py +++ b/src/cloudflare/resources/magic_transit/cf_interconnects.py @@ -7,6 +7,10 @@ import httpx from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -19,7 +23,10 @@ from ..._base_client import ( make_request_options, ) +from ...types.magic_transit import cf_interconnect_update_params +from ...types.magic_transit.cf_interconnect_get_response import CfInterconnectGetResponse from ...types.magic_transit.cf_interconnect_list_response import CfInterconnectListResponse +from ...types.magic_transit.cf_interconnect_update_response import CfInterconnectUpdateResponse __all__ = ["CfInterconnectsResource", "AsyncCfInterconnectsResource"] @@ -33,6 +40,79 @@ def with_raw_response(self) -> CfInterconnectsResourceWithRawResponse: def with_streaming_response(self) -> CfInterconnectsResourceWithStreamingResponse: return CfInterconnectsResourceWithStreamingResponse(self) + def update( + self, + cf_interconnect_id: str, + *, + account_id: str, + description: str | NotGiven = NOT_GIVEN, + gre: cf_interconnect_update_params.GRE | NotGiven = NOT_GIVEN, + health_check: cf_interconnect_update_params.HealthCheck | NotGiven = NOT_GIVEN, + interface_address: str | NotGiven = NOT_GIVEN, + mtu: int | 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, + ) -> CfInterconnectUpdateResponse: + """Updates a specific interconnect associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + cf_interconnect_id: Identifier + + description: An optional description of the interconnect. + + gre: The configuration specific to GRE interconnects. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + mtu: The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + value is 576. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not cf_interconnect_id: + raise ValueError(f"Expected a non-empty value for `cf_interconnect_id` but received {cf_interconnect_id!r}") + return self._put( + f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + body=maybe_transform( + { + "description": description, + "gre": gre, + "health_check": health_check, + "interface_address": interface_address, + "mtu": mtu, + }, + cf_interconnect_update_params.CfInterconnectUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CfInterconnectUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[CfInterconnectUpdateResponse], ResultWrapper[CfInterconnectUpdateResponse]), + ) + def list( self, *, @@ -72,6 +152,50 @@ def list( cast_to=cast(Type[CfInterconnectListResponse], ResultWrapper[CfInterconnectListResponse]), ) + def get( + self, + cf_interconnect_id: str, + *, + account_id: 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, + ) -> CfInterconnectGetResponse: + """ + Lists details for a specific interconnect. + + Args: + account_id: Identifier + + cf_interconnect_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not cf_interconnect_id: + raise ValueError(f"Expected a non-empty value for `cf_interconnect_id` but received {cf_interconnect_id!r}") + return self._get( + f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CfInterconnectGetResponse]._unwrapper, + ), + cast_to=cast(Type[CfInterconnectGetResponse], ResultWrapper[CfInterconnectGetResponse]), + ) + class AsyncCfInterconnectsResource(AsyncAPIResource): @cached_property @@ -82,6 +206,79 @@ def with_raw_response(self) -> AsyncCfInterconnectsResourceWithRawResponse: def with_streaming_response(self) -> AsyncCfInterconnectsResourceWithStreamingResponse: return AsyncCfInterconnectsResourceWithStreamingResponse(self) + async def update( + self, + cf_interconnect_id: str, + *, + account_id: str, + description: str | NotGiven = NOT_GIVEN, + gre: cf_interconnect_update_params.GRE | NotGiven = NOT_GIVEN, + health_check: cf_interconnect_update_params.HealthCheck | NotGiven = NOT_GIVEN, + interface_address: str | NotGiven = NOT_GIVEN, + mtu: int | 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, + ) -> CfInterconnectUpdateResponse: + """Updates a specific interconnect associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + cf_interconnect_id: Identifier + + description: An optional description of the interconnect. + + gre: The configuration specific to GRE interconnects. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + mtu: The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + value is 576. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not cf_interconnect_id: + raise ValueError(f"Expected a non-empty value for `cf_interconnect_id` but received {cf_interconnect_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + body=await async_maybe_transform( + { + "description": description, + "gre": gre, + "health_check": health_check, + "interface_address": interface_address, + "mtu": mtu, + }, + cf_interconnect_update_params.CfInterconnectUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CfInterconnectUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[CfInterconnectUpdateResponse], ResultWrapper[CfInterconnectUpdateResponse]), + ) + async def list( self, *, @@ -121,38 +318,106 @@ async def list( cast_to=cast(Type[CfInterconnectListResponse], ResultWrapper[CfInterconnectListResponse]), ) + async def get( + self, + cf_interconnect_id: str, + *, + account_id: 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, + ) -> CfInterconnectGetResponse: + """ + Lists details for a specific interconnect. + + Args: + account_id: Identifier + + cf_interconnect_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not cf_interconnect_id: + raise ValueError(f"Expected a non-empty value for `cf_interconnect_id` but received {cf_interconnect_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[CfInterconnectGetResponse]._unwrapper, + ), + cast_to=cast(Type[CfInterconnectGetResponse], ResultWrapper[CfInterconnectGetResponse]), + ) + class CfInterconnectsResourceWithRawResponse: def __init__(self, cf_interconnects: CfInterconnectsResource) -> None: self._cf_interconnects = cf_interconnects + self.update = to_raw_response_wrapper( + cf_interconnects.update, + ) self.list = to_raw_response_wrapper( cf_interconnects.list, ) + self.get = to_raw_response_wrapper( + cf_interconnects.get, + ) class AsyncCfInterconnectsResourceWithRawResponse: def __init__(self, cf_interconnects: AsyncCfInterconnectsResource) -> None: self._cf_interconnects = cf_interconnects + self.update = async_to_raw_response_wrapper( + cf_interconnects.update, + ) self.list = async_to_raw_response_wrapper( cf_interconnects.list, ) + self.get = async_to_raw_response_wrapper( + cf_interconnects.get, + ) class CfInterconnectsResourceWithStreamingResponse: def __init__(self, cf_interconnects: CfInterconnectsResource) -> None: self._cf_interconnects = cf_interconnects + self.update = to_streamed_response_wrapper( + cf_interconnects.update, + ) self.list = to_streamed_response_wrapper( cf_interconnects.list, ) + self.get = to_streamed_response_wrapper( + cf_interconnects.get, + ) class AsyncCfInterconnectsResourceWithStreamingResponse: def __init__(self, cf_interconnects: AsyncCfInterconnectsResource) -> None: self._cf_interconnects = cf_interconnects + self.update = async_to_streamed_response_wrapper( + cf_interconnects.update, + ) self.list = async_to_streamed_response_wrapper( cf_interconnects.list, ) + self.get = async_to_streamed_response_wrapper( + cf_interconnects.get, + ) diff --git a/src/cloudflare/resources/magic_transit/gre_tunnels.py b/src/cloudflare/resources/magic_transit/gre_tunnels.py index fcb6f9c3a58..0a0ecac6b40 100644 --- a/src/cloudflare/resources/magic_transit/gre_tunnels.py +++ b/src/cloudflare/resources/magic_transit/gre_tunnels.py @@ -23,9 +23,13 @@ from ..._base_client import ( make_request_options, ) -from ...types.magic_transit import gre_tunnel_create_params +from ...types.magic_transit import gre_tunnel_create_params, gre_tunnel_update_params +from ...types.magic_transit.health_check_param import HealthCheckParam +from ...types.magic_transit.gre_tunnel_get_response import GRETunnelGetResponse from ...types.magic_transit.gre_tunnel_list_response import GRETunnelListResponse from ...types.magic_transit.gre_tunnel_create_response import GRETunnelCreateResponse +from ...types.magic_transit.gre_tunnel_delete_response import GRETunnelDeleteResponse +from ...types.magic_transit.gre_tunnel_update_response import GRETunnelUpdateResponse __all__ = ["GRETunnelsResource", "AsyncGRETunnelsResource"] @@ -82,6 +86,91 @@ def create( cast_to=cast(Type[GRETunnelCreateResponse], ResultWrapper[GRETunnelCreateResponse]), ) + def update( + self, + gre_tunnel_id: str, + *, + account_id: str, + cloudflare_gre_endpoint: str, + customer_gre_endpoint: str, + interface_address: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + health_check: HealthCheckParam | NotGiven = NOT_GIVEN, + mtu: int | NotGiven = NOT_GIVEN, + ttl: int | 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, + ) -> GRETunnelUpdateResponse: + """Updates a specific GRE tunnel. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + cloudflare_gre_endpoint: The IP address assigned to the Cloudflare side of the GRE tunnel. + + customer_gre_endpoint: The IP address assigned to the customer side of the GRE tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the tunnel. The name cannot contain spaces or special characters, + must be 15 characters or less, and cannot share a name with another GRE tunnel. + + description: An optional description of the GRE tunnel. + + mtu: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + is 576. + + ttl: Time To Live (TTL) in number of hops of the GRE tunnel. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return self._put( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + body=maybe_transform( + { + "cloudflare_gre_endpoint": cloudflare_gre_endpoint, + "customer_gre_endpoint": customer_gre_endpoint, + "interface_address": interface_address, + "name": name, + "description": description, + "health_check": health_check, + "mtu": mtu, + "ttl": ttl, + }, + gre_tunnel_update_params.GRETunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelUpdateResponse], ResultWrapper[GRETunnelUpdateResponse]), + ) + def list( self, *, @@ -121,6 +210,96 @@ def list( cast_to=cast(Type[GRETunnelListResponse], ResultWrapper[GRETunnelListResponse]), ) + def delete( + self, + gre_tunnel_id: str, + *, + account_id: 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, + ) -> GRETunnelDeleteResponse: + """Disables and removes a specific static GRE tunnel. + + Use `?validate_only=true` as + an optional query parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelDeleteResponse], ResultWrapper[GRETunnelDeleteResponse]), + ) + + def get( + self, + gre_tunnel_id: str, + *, + account_id: 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, + ) -> GRETunnelGetResponse: + """ + Lists informtion for a specific GRE tunnel. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return self._get( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelGetResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelGetResponse], ResultWrapper[GRETunnelGetResponse]), + ) + class AsyncGRETunnelsResource(AsyncAPIResource): @cached_property @@ -174,6 +353,91 @@ async def create( cast_to=cast(Type[GRETunnelCreateResponse], ResultWrapper[GRETunnelCreateResponse]), ) + async def update( + self, + gre_tunnel_id: str, + *, + account_id: str, + cloudflare_gre_endpoint: str, + customer_gre_endpoint: str, + interface_address: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + health_check: HealthCheckParam | NotGiven = NOT_GIVEN, + mtu: int | NotGiven = NOT_GIVEN, + ttl: int | 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, + ) -> GRETunnelUpdateResponse: + """Updates a specific GRE tunnel. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + cloudflare_gre_endpoint: The IP address assigned to the Cloudflare side of the GRE tunnel. + + customer_gre_endpoint: The IP address assigned to the customer side of the GRE tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the tunnel. The name cannot contain spaces or special characters, + must be 15 characters or less, and cannot share a name with another GRE tunnel. + + description: An optional description of the GRE tunnel. + + mtu: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + is 576. + + ttl: Time To Live (TTL) in number of hops of the GRE tunnel. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + body=await async_maybe_transform( + { + "cloudflare_gre_endpoint": cloudflare_gre_endpoint, + "customer_gre_endpoint": customer_gre_endpoint, + "interface_address": interface_address, + "name": name, + "description": description, + "health_check": health_check, + "mtu": mtu, + "ttl": ttl, + }, + gre_tunnel_update_params.GRETunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelUpdateResponse], ResultWrapper[GRETunnelUpdateResponse]), + ) + async def list( self, *, @@ -213,6 +477,96 @@ async def list( cast_to=cast(Type[GRETunnelListResponse], ResultWrapper[GRETunnelListResponse]), ) + async def delete( + self, + gre_tunnel_id: str, + *, + account_id: 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, + ) -> GRETunnelDeleteResponse: + """Disables and removes a specific static GRE tunnel. + + Use `?validate_only=true` as + an optional query parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelDeleteResponse], ResultWrapper[GRETunnelDeleteResponse]), + ) + + async def get( + self, + gre_tunnel_id: str, + *, + account_id: 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, + ) -> GRETunnelGetResponse: + """ + Lists informtion for a specific GRE tunnel. + + Args: + account_id: Identifier + + gre_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gre_tunnel_id: + raise ValueError(f"Expected a non-empty value for `gre_tunnel_id` but received {gre_tunnel_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[GRETunnelGetResponse]._unwrapper, + ), + cast_to=cast(Type[GRETunnelGetResponse], ResultWrapper[GRETunnelGetResponse]), + ) + class GRETunnelsResourceWithRawResponse: def __init__(self, gre_tunnels: GRETunnelsResource) -> None: @@ -221,9 +575,18 @@ def __init__(self, gre_tunnels: GRETunnelsResource) -> None: self.create = to_raw_response_wrapper( gre_tunnels.create, ) + self.update = to_raw_response_wrapper( + gre_tunnels.update, + ) self.list = to_raw_response_wrapper( gre_tunnels.list, ) + self.delete = to_raw_response_wrapper( + gre_tunnels.delete, + ) + self.get = to_raw_response_wrapper( + gre_tunnels.get, + ) class AsyncGRETunnelsResourceWithRawResponse: @@ -233,9 +596,18 @@ def __init__(self, gre_tunnels: AsyncGRETunnelsResource) -> None: self.create = async_to_raw_response_wrapper( gre_tunnels.create, ) + self.update = async_to_raw_response_wrapper( + gre_tunnels.update, + ) self.list = async_to_raw_response_wrapper( gre_tunnels.list, ) + self.delete = async_to_raw_response_wrapper( + gre_tunnels.delete, + ) + self.get = async_to_raw_response_wrapper( + gre_tunnels.get, + ) class GRETunnelsResourceWithStreamingResponse: @@ -245,9 +617,18 @@ def __init__(self, gre_tunnels: GRETunnelsResource) -> None: self.create = to_streamed_response_wrapper( gre_tunnels.create, ) + self.update = to_streamed_response_wrapper( + gre_tunnels.update, + ) self.list = to_streamed_response_wrapper( gre_tunnels.list, ) + self.delete = to_streamed_response_wrapper( + gre_tunnels.delete, + ) + self.get = to_streamed_response_wrapper( + gre_tunnels.get, + ) class AsyncGRETunnelsResourceWithStreamingResponse: @@ -257,6 +638,15 @@ def __init__(self, gre_tunnels: AsyncGRETunnelsResource) -> None: self.create = async_to_streamed_response_wrapper( gre_tunnels.create, ) + self.update = async_to_streamed_response_wrapper( + gre_tunnels.update, + ) self.list = async_to_streamed_response_wrapper( gre_tunnels.list, ) + self.delete = async_to_streamed_response_wrapper( + gre_tunnels.delete, + ) + self.get = async_to_streamed_response_wrapper( + gre_tunnels.get, + ) diff --git a/src/cloudflare/resources/magic_transit/ipsec_tunnels.py b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py index 847d54acb25..5628e089a81 100644 --- a/src/cloudflare/resources/magic_transit/ipsec_tunnels.py +++ b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py @@ -23,10 +23,18 @@ from ..._base_client import ( make_request_options, ) -from ...types.magic_transit import ipsec_tunnel_create_params +from ...types.magic_transit import ( + ipsec_tunnel_create_params, + ipsec_tunnel_update_params, + ipsec_tunnel_psk_generate_params, +) from ...types.magic_transit.health_check_param import HealthCheckParam +from ...types.magic_transit.ipsec_tunnel_get_response import IPSECTunnelGetResponse from ...types.magic_transit.ipsec_tunnel_list_response import IPSECTunnelListResponse from ...types.magic_transit.ipsec_tunnel_create_response import IPSECTunnelCreateResponse +from ...types.magic_transit.ipsec_tunnel_delete_response import IPSECTunnelDeleteResponse +from ...types.magic_transit.ipsec_tunnel_update_response import IPSECTunnelUpdateResponse +from ...types.magic_transit.ipsec_tunnel_psk_generate_response import IPSECTunnelPSKGenerateResponse __all__ = ["IPSECTunnelsResource", "AsyncIPSECTunnelsResource"] @@ -121,6 +129,92 @@ def create( cast_to=cast(Type[IPSECTunnelCreateResponse], ResultWrapper[IPSECTunnelCreateResponse]), ) + def update( + self, + ipsec_tunnel_id: str, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: HealthCheckParam | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: bool | 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, + ) -> IPSECTunnelUpdateResponse: + """Updates a specific IPsec tunnel associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. Not required, + but must be set for proactive traceroutes to work. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return self._put( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + body=maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_update_params.IPSECTunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelUpdateResponse], ResultWrapper[IPSECTunnelUpdateResponse]), + ) + def list( self, *, @@ -160,6 +254,146 @@ def list( cast_to=cast(Type[IPSECTunnelListResponse], ResultWrapper[IPSECTunnelListResponse]), ) + def delete( + self, + ipsec_tunnel_id: str, + *, + account_id: 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, + ) -> IPSECTunnelDeleteResponse: + """ + Disables and removes a specific static IPsec Tunnel associated with an account. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelDeleteResponse], ResultWrapper[IPSECTunnelDeleteResponse]), + ) + + def get( + self, + ipsec_tunnel_id: str, + *, + account_id: 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, + ) -> IPSECTunnelGetResponse: + """ + Lists details for a specific IPsec tunnel. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelGetResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelGetResponse], ResultWrapper[IPSECTunnelGetResponse]), + ) + + def psk_generate( + self, + ipsec_tunnel_id: str, + *, + account_id: str, + body: object, + # 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, + ) -> IPSECTunnelPSKGenerateResponse: + """ + Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. After a PSK is generated, the PSK is immediately + persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a + safe place. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + body=maybe_transform(body, ipsec_tunnel_psk_generate_params.IPSECTunnelPSKGenerateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelPSKGenerateResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelPSKGenerateResponse], ResultWrapper[IPSECTunnelPSKGenerateResponse]), + ) + class AsyncIPSECTunnelsResource(AsyncAPIResource): @cached_property @@ -251,6 +485,92 @@ async def create( cast_to=cast(Type[IPSECTunnelCreateResponse], ResultWrapper[IPSECTunnelCreateResponse]), ) + async def update( + self, + ipsec_tunnel_id: str, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: HealthCheckParam | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: bool | 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, + ) -> IPSECTunnelUpdateResponse: + """Updates a specific IPsec tunnel associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. Not required, + but must be set for proactive traceroutes to work. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + body=await async_maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_update_params.IPSECTunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelUpdateResponse], ResultWrapper[IPSECTunnelUpdateResponse]), + ) + async def list( self, *, @@ -290,6 +610,146 @@ async def list( cast_to=cast(Type[IPSECTunnelListResponse], ResultWrapper[IPSECTunnelListResponse]), ) + async def delete( + self, + ipsec_tunnel_id: str, + *, + account_id: 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, + ) -> IPSECTunnelDeleteResponse: + """ + Disables and removes a specific static IPsec Tunnel associated with an account. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelDeleteResponse], ResultWrapper[IPSECTunnelDeleteResponse]), + ) + + async def get( + self, + ipsec_tunnel_id: str, + *, + account_id: 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, + ) -> IPSECTunnelGetResponse: + """ + Lists details for a specific IPsec tunnel. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelGetResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelGetResponse], ResultWrapper[IPSECTunnelGetResponse]), + ) + + async def psk_generate( + self, + ipsec_tunnel_id: str, + *, + account_id: str, + body: object, + # 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, + ) -> IPSECTunnelPSKGenerateResponse: + """ + Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. After a PSK is generated, the PSK is immediately + persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a + safe place. + + Args: + account_id: Identifier + + ipsec_tunnel_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not ipsec_tunnel_id: + raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + body=await async_maybe_transform(body, ipsec_tunnel_psk_generate_params.IPSECTunnelPSKGenerateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPSECTunnelPSKGenerateResponse]._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelPSKGenerateResponse], ResultWrapper[IPSECTunnelPSKGenerateResponse]), + ) + class IPSECTunnelsResourceWithRawResponse: def __init__(self, ipsec_tunnels: IPSECTunnelsResource) -> None: @@ -298,9 +758,21 @@ def __init__(self, ipsec_tunnels: IPSECTunnelsResource) -> None: self.create = to_raw_response_wrapper( ipsec_tunnels.create, ) + self.update = to_raw_response_wrapper( + ipsec_tunnels.update, + ) self.list = to_raw_response_wrapper( ipsec_tunnels.list, ) + self.delete = to_raw_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = to_raw_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = to_raw_response_wrapper( + ipsec_tunnels.psk_generate, + ) class AsyncIPSECTunnelsResourceWithRawResponse: @@ -310,9 +782,21 @@ def __init__(self, ipsec_tunnels: AsyncIPSECTunnelsResource) -> None: self.create = async_to_raw_response_wrapper( ipsec_tunnels.create, ) + self.update = async_to_raw_response_wrapper( + ipsec_tunnels.update, + ) self.list = async_to_raw_response_wrapper( ipsec_tunnels.list, ) + self.delete = async_to_raw_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = async_to_raw_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = async_to_raw_response_wrapper( + ipsec_tunnels.psk_generate, + ) class IPSECTunnelsResourceWithStreamingResponse: @@ -322,9 +806,21 @@ def __init__(self, ipsec_tunnels: IPSECTunnelsResource) -> None: self.create = to_streamed_response_wrapper( ipsec_tunnels.create, ) + self.update = to_streamed_response_wrapper( + ipsec_tunnels.update, + ) self.list = to_streamed_response_wrapper( ipsec_tunnels.list, ) + self.delete = to_streamed_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = to_streamed_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = to_streamed_response_wrapper( + ipsec_tunnels.psk_generate, + ) class AsyncIPSECTunnelsResourceWithStreamingResponse: @@ -334,6 +830,18 @@ def __init__(self, ipsec_tunnels: AsyncIPSECTunnelsResource) -> None: self.create = async_to_streamed_response_wrapper( ipsec_tunnels.create, ) + self.update = async_to_streamed_response_wrapper( + ipsec_tunnels.update, + ) self.list = async_to_streamed_response_wrapper( ipsec_tunnels.list, ) + self.delete = async_to_streamed_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = async_to_streamed_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = async_to_streamed_response_wrapper( + ipsec_tunnels.psk_generate, + ) diff --git a/src/cloudflare/resources/magic_transit/routes.py b/src/cloudflare/resources/magic_transit/routes.py index f8c1f1bb62a..be721725cbc 100644 --- a/src/cloudflare/resources/magic_transit/routes.py +++ b/src/cloudflare/resources/magic_transit/routes.py @@ -23,10 +23,14 @@ from ..._base_client import ( make_request_options, ) -from ...types.magic_transit import route_create_params +from ...types.magic_transit import route_create_params, route_update_params +from ...types.magic_transit.scope_param import ScopeParam +from ...types.magic_transit.route_get_response import RouteGetResponse from ...types.magic_transit.route_list_response import RouteListResponse from ...types.magic_transit.route_empty_response import RouteEmptyResponse from ...types.magic_transit.route_create_response import RouteCreateResponse +from ...types.magic_transit.route_delete_response import RouteDeleteResponse +from ...types.magic_transit.route_update_response import RouteUpdateResponse __all__ = ["RoutesResource", "AsyncRoutesResource"] @@ -83,6 +87,81 @@ def create( cast_to=cast(Type[RouteCreateResponse], ResultWrapper[RouteCreateResponse]), ) + def update( + self, + route_id: str, + *, + account_id: str, + nexthop: str, + prefix: str, + priority: int, + description: str | NotGiven = NOT_GIVEN, + scope: ScopeParam | NotGiven = NOT_GIVEN, + weight: int | 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, + ) -> RouteUpdateResponse: + """Update a specific Magic static route. + + Use `?validate_only=true` as an optional + query parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + route_id: Identifier + + nexthop: The next-hop IP Address for the static route. + + prefix: IP Prefix in Classless Inter-Domain Routing format. + + priority: Priority of the static route. + + description: An optional human provided description of the static route. + + scope: Used only for ECMP routes. + + weight: Optional weight of the ECMP scope - if provided. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return self._put( + f"/accounts/{account_id}/magic/routes/{route_id}", + body=maybe_transform( + { + "nexthop": nexthop, + "prefix": prefix, + "priority": priority, + "description": description, + "scope": scope, + "weight": weight, + }, + route_update_params.RouteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[RouteUpdateResponse], ResultWrapper[RouteUpdateResponse]), + ) + def list( self, *, @@ -122,6 +201,50 @@ def list( cast_to=cast(Type[RouteListResponse], ResultWrapper[RouteListResponse]), ) + def delete( + self, + route_id: str, + *, + account_id: 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, + ) -> RouteDeleteResponse: + """ + Disable and remove a specific Magic static route. + + Args: + account_id: Identifier + + route_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/routes/{route_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RouteDeleteResponse], ResultWrapper[RouteDeleteResponse]), + ) + def empty( self, *, @@ -161,6 +284,50 @@ def empty( cast_to=cast(Type[RouteEmptyResponse], ResultWrapper[RouteEmptyResponse]), ) + def get( + self, + route_id: str, + *, + account_id: 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, + ) -> RouteGetResponse: + """ + Get a specific Magic static route. + + Args: + account_id: Identifier + + route_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return self._get( + f"/accounts/{account_id}/magic/routes/{route_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteGetResponse]._unwrapper, + ), + cast_to=cast(Type[RouteGetResponse], ResultWrapper[RouteGetResponse]), + ) + class AsyncRoutesResource(AsyncAPIResource): @cached_property @@ -214,6 +381,81 @@ async def create( cast_to=cast(Type[RouteCreateResponse], ResultWrapper[RouteCreateResponse]), ) + async def update( + self, + route_id: str, + *, + account_id: str, + nexthop: str, + prefix: str, + priority: int, + description: str | NotGiven = NOT_GIVEN, + scope: ScopeParam | NotGiven = NOT_GIVEN, + weight: int | 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, + ) -> RouteUpdateResponse: + """Update a specific Magic static route. + + Use `?validate_only=true` as an optional + query parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + route_id: Identifier + + nexthop: The next-hop IP Address for the static route. + + prefix: IP Prefix in Classless Inter-Domain Routing format. + + priority: Priority of the static route. + + description: An optional human provided description of the static route. + + scope: Used only for ECMP routes. + + weight: Optional weight of the ECMP scope - if provided. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/routes/{route_id}", + body=await async_maybe_transform( + { + "nexthop": nexthop, + "prefix": prefix, + "priority": priority, + "description": description, + "scope": scope, + "weight": weight, + }, + route_update_params.RouteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[RouteUpdateResponse], ResultWrapper[RouteUpdateResponse]), + ) + async def list( self, *, @@ -253,6 +495,50 @@ async def list( cast_to=cast(Type[RouteListResponse], ResultWrapper[RouteListResponse]), ) + async def delete( + self, + route_id: str, + *, + account_id: 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, + ) -> RouteDeleteResponse: + """ + Disable and remove a specific Magic static route. + + Args: + account_id: Identifier + + route_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/routes/{route_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RouteDeleteResponse], ResultWrapper[RouteDeleteResponse]), + ) + async def empty( self, *, @@ -292,6 +578,50 @@ async def empty( cast_to=cast(Type[RouteEmptyResponse], ResultWrapper[RouteEmptyResponse]), ) + async def get( + self, + route_id: str, + *, + account_id: 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, + ) -> RouteGetResponse: + """ + Get a specific Magic static route. + + Args: + account_id: Identifier + + route_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_id: + raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/routes/{route_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RouteGetResponse]._unwrapper, + ), + cast_to=cast(Type[RouteGetResponse], ResultWrapper[RouteGetResponse]), + ) + class RoutesResourceWithRawResponse: def __init__(self, routes: RoutesResource) -> None: @@ -300,12 +630,21 @@ def __init__(self, routes: RoutesResource) -> None: self.create = to_raw_response_wrapper( routes.create, ) + self.update = to_raw_response_wrapper( + routes.update, + ) self.list = to_raw_response_wrapper( routes.list, ) + self.delete = to_raw_response_wrapper( + routes.delete, + ) self.empty = to_raw_response_wrapper( routes.empty, ) + self.get = to_raw_response_wrapper( + routes.get, + ) class AsyncRoutesResourceWithRawResponse: @@ -315,12 +654,21 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.create = async_to_raw_response_wrapper( routes.create, ) + self.update = async_to_raw_response_wrapper( + routes.update, + ) self.list = async_to_raw_response_wrapper( routes.list, ) + self.delete = async_to_raw_response_wrapper( + routes.delete, + ) self.empty = async_to_raw_response_wrapper( routes.empty, ) + self.get = async_to_raw_response_wrapper( + routes.get, + ) class RoutesResourceWithStreamingResponse: @@ -330,12 +678,21 @@ def __init__(self, routes: RoutesResource) -> None: self.create = to_streamed_response_wrapper( routes.create, ) + self.update = to_streamed_response_wrapper( + routes.update, + ) self.list = to_streamed_response_wrapper( routes.list, ) + self.delete = to_streamed_response_wrapper( + routes.delete, + ) self.empty = to_streamed_response_wrapper( routes.empty, ) + self.get = to_streamed_response_wrapper( + routes.get, + ) class AsyncRoutesResourceWithStreamingResponse: @@ -345,9 +702,18 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.create = async_to_streamed_response_wrapper( routes.create, ) + self.update = async_to_streamed_response_wrapper( + routes.update, + ) self.list = async_to_streamed_response_wrapper( routes.list, ) + self.delete = async_to_streamed_response_wrapper( + routes.delete, + ) self.empty = async_to_streamed_response_wrapper( routes.empty, ) + self.get = async_to_streamed_response_wrapper( + routes.get, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/acls.py b/src/cloudflare/resources/magic_transit/sites/acls.py index c5ac6f1d672..6d675b5378a 100644 --- a/src/cloudflare/resources/magic_transit/sites/acls.py +++ b/src/cloudflare/resources/magic_transit/sites/acls.py @@ -25,7 +25,7 @@ AsyncPaginator, make_request_options, ) -from ....types.magic_transit.sites import acl_create_params +from ....types.magic_transit.sites import acl_edit_params, acl_create_params, acl_update_params from ....types.magic_transit.sites.acl import ACL from ....types.magic_transit.sites.allowed_protocol import AllowedProtocol from ....types.magic_transit.sites.acl_configuration_param import ACLConfigurationParam @@ -112,6 +112,81 @@ def create( cast_to=cast(Type[ACL], ResultWrapper[ACL]), ) + def update( + self, + acl_id: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Update a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic Connector. If not included in request, will default + to false. + + name: The name of the ACL. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + body=maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_update_params.ACLUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + def list( self, site_id: str, @@ -153,6 +228,179 @@ def list( model=ACL, ) + def delete( + self, + acl_id: str, + *, + account_id: str, + site_id: 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, + ) -> ACL: + """ + Remove a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + + def edit( + self, + acl_id: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Patch a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic Connector. If not included in request, will default + to false. + + name: The name of the ACL. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + body=maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_edit_params.ACLEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + + def get( + self, + acl_id: str, + *, + account_id: str, + site_id: 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, + ) -> ACL: + """ + Get a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + class AsyncACLsResource(AsyncAPIResource): @cached_property @@ -233,6 +481,81 @@ async def create( cast_to=cast(Type[ACL], ResultWrapper[ACL]), ) + async def update( + self, + acl_id: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Update a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic Connector. If not included in request, will default + to false. + + name: The name of the ACL. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + body=await async_maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_update_params.ACLUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + def list( self, site_id: str, @@ -274,6 +597,179 @@ def list( model=ACL, ) + async def delete( + self, + acl_id: str, + *, + account_id: str, + site_id: 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, + ) -> ACL: + """ + Remove a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + + async def edit( + self, + acl_id: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Patch a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic Connector. If not included in request, will default + to false. + + name: The name of the ACL. + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return await self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + body=await async_maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_edit_params.ACLEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + + async def get( + self, + acl_id: str, + *, + account_id: str, + site_id: 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, + ) -> ACL: + """ + Get a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_id: + raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + class ACLsResourceWithRawResponse: def __init__(self, acls: ACLsResource) -> None: @@ -282,9 +778,21 @@ def __init__(self, acls: ACLsResource) -> None: self.create = to_raw_response_wrapper( acls.create, ) + self.update = to_raw_response_wrapper( + acls.update, + ) self.list = to_raw_response_wrapper( acls.list, ) + self.delete = to_raw_response_wrapper( + acls.delete, + ) + self.edit = to_raw_response_wrapper( + acls.edit, + ) + self.get = to_raw_response_wrapper( + acls.get, + ) class AsyncACLsResourceWithRawResponse: @@ -294,9 +802,21 @@ def __init__(self, acls: AsyncACLsResource) -> None: self.create = async_to_raw_response_wrapper( acls.create, ) + self.update = async_to_raw_response_wrapper( + acls.update, + ) self.list = async_to_raw_response_wrapper( acls.list, ) + self.delete = async_to_raw_response_wrapper( + acls.delete, + ) + self.edit = async_to_raw_response_wrapper( + acls.edit, + ) + self.get = async_to_raw_response_wrapper( + acls.get, + ) class ACLsResourceWithStreamingResponse: @@ -306,9 +826,21 @@ def __init__(self, acls: ACLsResource) -> None: self.create = to_streamed_response_wrapper( acls.create, ) + self.update = to_streamed_response_wrapper( + acls.update, + ) self.list = to_streamed_response_wrapper( acls.list, ) + self.delete = to_streamed_response_wrapper( + acls.delete, + ) + self.edit = to_streamed_response_wrapper( + acls.edit, + ) + self.get = to_streamed_response_wrapper( + acls.get, + ) class AsyncACLsResourceWithStreamingResponse: @@ -318,6 +850,18 @@ def __init__(self, acls: AsyncACLsResource) -> None: self.create = async_to_streamed_response_wrapper( acls.create, ) + self.update = async_to_streamed_response_wrapper( + acls.update, + ) self.list = async_to_streamed_response_wrapper( acls.list, ) + self.delete = async_to_streamed_response_wrapper( + acls.delete, + ) + self.edit = async_to_streamed_response_wrapper( + acls.edit, + ) + self.get = async_to_streamed_response_wrapper( + acls.get, + ) diff --git a/src/cloudflare/types/ai_gateway/logs/__init__.py b/src/cloudflare/types/ai_gateway/logs/__init__.py deleted file mode 100644 index f8ee8b14b1c..00000000000 --- a/src/cloudflare/types/ai_gateway/logs/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index 446a433bc84..ad2327c5724 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -4,6 +4,7 @@ from .site import Site as Site from .scope import Scope as Scope +from .scope_param import ScopeParam as ScopeParam from .health_check import HealthCheck as HealthCheck from .psk_metadata import PSKMetadata as PSKMetadata from .site_location import SiteLocation as SiteLocation @@ -15,6 +16,7 @@ from .health_check_rate import HealthCheckRate as HealthCheckRate from .health_check_type import HealthCheckType as HealthCheckType from .health_check_param import HealthCheckParam as HealthCheckParam +from .route_get_response import RouteGetResponse as RouteGetResponse from .site_create_params import SiteCreateParams as SiteCreateParams from .site_update_params import SiteUpdateParams as SiteUpdateParams from .app_create_response import AppCreateResponse as AppCreateResponse @@ -22,19 +24,35 @@ from .app_update_response import AppUpdateResponse as AppUpdateResponse from .route_create_params import RouteCreateParams as RouteCreateParams from .route_list_response import RouteListResponse as RouteListResponse +from .route_update_params import RouteUpdateParams as RouteUpdateParams from .site_location_param import SiteLocationParam as SiteLocationParam from .route_empty_response import RouteEmptyResponse as RouteEmptyResponse from .connector_edit_params import ConnectorEditParams as ConnectorEditParams from .route_create_response import RouteCreateResponse as RouteCreateResponse +from .route_delete_response import RouteDeleteResponse as RouteDeleteResponse +from .route_update_response import RouteUpdateResponse as RouteUpdateResponse from .connector_get_response import ConnectorGetResponse as ConnectorGetResponse from .connector_edit_response import ConnectorEditResponse as ConnectorEditResponse from .connector_list_response import ConnectorListResponse as ConnectorListResponse from .connector_update_params import ConnectorUpdateParams as ConnectorUpdateParams +from .gre_tunnel_get_response import GRETunnelGetResponse as GRETunnelGetResponse from .gre_tunnel_create_params import GRETunnelCreateParams as GRETunnelCreateParams from .gre_tunnel_list_response import GRETunnelListResponse as GRETunnelListResponse +from .gre_tunnel_update_params import GRETunnelUpdateParams as GRETunnelUpdateParams from .connector_update_response import ConnectorUpdateResponse as ConnectorUpdateResponse +from .ipsec_tunnel_get_response import IPSECTunnelGetResponse as IPSECTunnelGetResponse from .gre_tunnel_create_response import GRETunnelCreateResponse as GRETunnelCreateResponse +from .gre_tunnel_delete_response import GRETunnelDeleteResponse as GRETunnelDeleteResponse +from .gre_tunnel_update_response import GRETunnelUpdateResponse as GRETunnelUpdateResponse from .ipsec_tunnel_create_params import IPSECTunnelCreateParams as IPSECTunnelCreateParams from .ipsec_tunnel_list_response import IPSECTunnelListResponse as IPSECTunnelListResponse +from .ipsec_tunnel_update_params import IPSECTunnelUpdateParams as IPSECTunnelUpdateParams +from .cf_interconnect_get_response import CfInterconnectGetResponse as CfInterconnectGetResponse from .ipsec_tunnel_create_response import IPSECTunnelCreateResponse as IPSECTunnelCreateResponse +from .ipsec_tunnel_delete_response import IPSECTunnelDeleteResponse as IPSECTunnelDeleteResponse +from .ipsec_tunnel_update_response import IPSECTunnelUpdateResponse as IPSECTunnelUpdateResponse from .cf_interconnect_list_response import CfInterconnectListResponse as CfInterconnectListResponse +from .cf_interconnect_update_params import CfInterconnectUpdateParams as CfInterconnectUpdateParams +from .cf_interconnect_update_response import CfInterconnectUpdateResponse as CfInterconnectUpdateResponse +from .ipsec_tunnel_psk_generate_params import IPSECTunnelPSKGenerateParams as IPSECTunnelPSKGenerateParams +from .ipsec_tunnel_psk_generate_response import IPSECTunnelPSKGenerateResponse as IPSECTunnelPSKGenerateResponse diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py b/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py new file mode 100644 index 00000000000..1693571a82a --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["CfInterconnectGetResponse"] + + +class CfInterconnectGetResponse(BaseModel): + interconnect: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py new file mode 100644 index 00000000000..00fca27a8f2 --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py @@ -0,0 +1,63 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .health_check_rate import HealthCheckRate +from .health_check_type import HealthCheckType + +__all__ = ["CfInterconnectUpdateParams", "GRE", "HealthCheck"] + + +class CfInterconnectUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + description: str + """An optional description of the interconnect.""" + + gre: GRE + """The configuration specific to GRE interconnects.""" + + health_check: HealthCheck + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + mtu: int + """The Maximum Transmission Unit (MTU) in bytes for the interconnect. + + The minimum value is 576. + """ + + +class GRE(TypedDict, total=False): + cloudflare_endpoint: str + """ + The IP address assigned to the Cloudflare side of the GRE tunnel created as part + of the Interconnect. + """ + + +class HealthCheck(TypedDict, total=False): + enabled: bool + """Determines whether to run healthchecks for a tunnel.""" + + rate: HealthCheckRate + """How frequent the health check is run. The default value is `mid`.""" + + target: str + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. + """ + + type: HealthCheckType + """The type of healthcheck to run, reply or request. The default value is `reply`.""" diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py b/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py new file mode 100644 index 00000000000..e21d22dbd40 --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["CfInterconnectUpdateResponse"] + + +class CfInterconnectUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_interconnect: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py new file mode 100644 index 00000000000..5165f2dcc3b --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelDeleteResponse"] + + +class GRETunnelDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py new file mode 100644 index 00000000000..141c70992f1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelGetResponse"] + + +class GRETunnelGetResponse(BaseModel): + gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py new file mode 100644 index 00000000000..6d891bbe546 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .health_check_param import HealthCheckParam + +__all__ = ["GRETunnelUpdateParams"] + + +class GRETunnelUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + cloudflare_gre_endpoint: Required[str] + """The IP address assigned to the Cloudflare side of the GRE tunnel.""" + + customer_gre_endpoint: Required[str] + """The IP address assigned to the customer side of the GRE tunnel.""" + + interface_address: Required[str] + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: Required[str] + """The name of the tunnel. + + The name cannot contain spaces or special characters, must be 15 characters or + less, and cannot share a name with another GRE tunnel. + """ + + description: str + """An optional description of the GRE tunnel.""" + + health_check: HealthCheckParam + + mtu: int + """Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. + + The minimum value is 576. + """ + + ttl: int + """Time To Live (TTL) in number of hops of the GRE tunnel.""" diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py new file mode 100644 index 00000000000..c84ba582d7e --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelUpdateResponse"] + + +class GRETunnelUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py new file mode 100644 index 00000000000..b39ba183f72 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelDeleteResponse"] + + +class IPSECTunnelDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py new file mode 100644 index 00000000000..816098c9ead --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelGetResponse"] + + +class IPSECTunnelGetResponse(BaseModel): + ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py new file mode 100644 index 00000000000..1066fa603d1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["IPSECTunnelPSKGenerateParams"] + + +class IPSECTunnelPSKGenerateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py new file mode 100644 index 00000000000..9c4438b1456 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel +from .psk_metadata import PSKMetadata + +__all__ = ["IPSECTunnelPSKGenerateResponse"] + + +class IPSECTunnelPSKGenerateResponse(BaseModel): + ipsec_tunnel_id: Optional[str] = None + """Identifier""" + + psk: Optional[str] = None + """A randomly generated or provided string for use in the IPsec tunnel.""" + + psk_metadata: Optional[PSKMetadata] = None + """The PSK metadata that includes when the PSK was generated.""" diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py new file mode 100644 index 00000000000..8a0170e0345 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .health_check_param import HealthCheckParam + +__all__ = ["IPSECTunnelUpdateParams"] + + +class IPSECTunnelUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + cloudflare_endpoint: Required[str] + """The IP address assigned to the Cloudflare side of the IPsec tunnel.""" + + interface_address: Required[str] + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: Required[str] + """The name of the IPsec tunnel. The name cannot share a name with other tunnels.""" + + customer_endpoint: str + """The IP address assigned to the customer side of the IPsec tunnel. + + Not required, but must be set for proactive traceroutes to work. + """ + + description: str + """An optional description forthe IPsec tunnel.""" + + health_check: HealthCheckParam + + psk: str + """A randomly generated or provided string for use in the IPsec tunnel.""" + + replay_protection: bool + """ + If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + """ diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py new file mode 100644 index 00000000000..8a7b92e2b11 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelUpdateResponse"] + + +class IPSECTunnelUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_delete_response.py b/src/cloudflare/types/magic_transit/route_delete_response.py new file mode 100644 index 00000000000..096e4ece8f1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteDeleteResponse"] + + +class RouteDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_get_response.py b/src/cloudflare/types/magic_transit/route_get_response.py new file mode 100644 index 00000000000..f23ba2c2ec4 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteGetResponse"] + + +class RouteGetResponse(BaseModel): + route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_update_params.py b/src/cloudflare/types/magic_transit/route_update_params.py new file mode 100644 index 00000000000..14d10ad42c0 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_update_params.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .scope_param import ScopeParam + +__all__ = ["RouteUpdateParams"] + + +class RouteUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + nexthop: Required[str] + """The next-hop IP Address for the static route.""" + + prefix: Required[str] + """IP Prefix in Classless Inter-Domain Routing format.""" + + priority: Required[int] + """Priority of the static route.""" + + description: str + """An optional human provided description of the static route.""" + + scope: ScopeParam + """Used only for ECMP routes.""" + + weight: int + """Optional weight of the ECMP scope - if provided.""" diff --git a/src/cloudflare/types/magic_transit/route_update_response.py b/src/cloudflare/types/magic_transit/route_update_response.py new file mode 100644 index 00000000000..33b497d969f --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteUpdateResponse"] + + +class RouteUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/scope_param.py b/src/cloudflare/types/magic_transit/scope_param.py new file mode 100644 index 00000000000..95df559e364 --- /dev/null +++ b/src/cloudflare/types/magic_transit/scope_param.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import TypedDict + +__all__ = ["ScopeParam"] + + +class ScopeParam(TypedDict, total=False): + colo_names: List[str] + """List of colo names for the ECMP scope.""" + + colo_regions: List[str] + """List of colo regions for the ECMP scope.""" diff --git a/src/cloudflare/types/magic_transit/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/__init__.py index 14816eed960..38f592bb4e6 100644 --- a/src/cloudflare/types/magic_transit/sites/__init__.py +++ b/src/cloudflare/types/magic_transit/sites/__init__.py @@ -12,12 +12,14 @@ from .dhcp_server import DHCPServer as DHCPServer from .subnet_param import SubnetParam as SubnetParam from .routed_subnet import RoutedSubnet as RoutedSubnet +from .acl_edit_params import ACLEditParams as ACLEditParams from .lan_edit_params import LANEditParams as LANEditParams from .wan_edit_params import WANEditParams as WANEditParams from .allowed_protocol import AllowedProtocol as AllowedProtocol from .dhcp_relay_param import DHCPRelayParam as DHCPRelayParam from .acl_configuration import ACLConfiguration as ACLConfiguration from .acl_create_params import ACLCreateParams as ACLCreateParams +from .acl_update_params import ACLUpdateParams as ACLUpdateParams from .dhcp_server_param import DHCPServerParam as DHCPServerParam from .lan_create_params import LANCreateParams as LANCreateParams from .lan_update_params import LANUpdateParams as LANUpdateParams diff --git a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py new file mode 100644 index 00000000000..8a6c7b0f5c6 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +from .allowed_protocol import AllowedProtocol +from .acl_configuration_param import ACLConfigurationParam + +__all__ = ["ACLEditParams"] + + +class ACLEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + description: str + """Description for the ACL.""" + + forward_locally: bool + """The desired forwarding action for this ACL policy. + + If set to "false", the policy will forward traffic to Cloudflare. If set to + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. + """ + + lan_1: ACLConfigurationParam + + lan_2: ACLConfigurationParam + + name: str + """The name of the ACL.""" + + protocols: List[AllowedProtocol] diff --git a/src/cloudflare/types/magic_transit/sites/acl_update_params.py b/src/cloudflare/types/magic_transit/sites/acl_update_params.py new file mode 100644 index 00000000000..5abc70c2329 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_update_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +from .allowed_protocol import AllowedProtocol +from .acl_configuration_param import ACLConfigurationParam + +__all__ = ["ACLUpdateParams"] + + +class ACLUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + description: str + """Description for the ACL.""" + + forward_locally: bool + """The desired forwarding action for this ACL policy. + + If set to "false", the policy will forward traffic to Cloudflare. If set to + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. + """ + + lan_1: ACLConfigurationParam + + lan_2: ACLConfigurationParam + + name: str + """The name of the ACL.""" + + protocols: List[AllowedProtocol] diff --git a/tests/api_resources/ai_gateway/logs/__init__.py b/tests/api_resources/ai_gateway/logs/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/ai_gateway/logs/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/magic_transit/sites/test_acls.py b/tests/api_resources/magic_transit/sites/test_acls.py index 10ffc357c63..9cac4c6dee6 100644 --- a/tests/api_resources/magic_transit/sites/test_acls.py +++ b/tests/api_resources/magic_transit/sites/test_acls.py @@ -10,7 +10,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.magic_transit.sites import ACL +from cloudflare.types.magic_transit.sites import ( + ACL, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -105,6 +107,91 @@ def test_path_params_create(self, client: Cloudflare) -> None: name="PIN Pad - Cash Register", ) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: acl = client.magic_transit.sites.acls.list( @@ -153,6 +240,211 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncACLs: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -244,6 +536,91 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: name="PIN Pad - Cash Register", ) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: acl = await async_client.magic_transit.sites.acls.list( @@ -291,3 +668,208 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: "", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_cf_interconnects.py b/tests/api_resources/magic_transit/test_cf_interconnects.py index 836520620fb..efb8610882b 100644 --- a/tests/api_resources/magic_transit/test_cf_interconnects.py +++ b/tests/api_resources/magic_transit/test_cf_interconnects.py @@ -9,7 +9,11 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.magic_transit import CfInterconnectListResponse +from cloudflare.types.magic_transit import ( + CfInterconnectGetResponse, + CfInterconnectListResponse, + CfInterconnectUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -17,6 +21,72 @@ class TestCfInterconnects: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Tunnel for Interconnect to ORD", + gre={"cloudflare_endpoint": "203.0.113.1"}, + health_check={ + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + interface_address="192.0.2.0/31", + mtu=0, + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.cf_interconnects.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cf_interconnect_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: cf_interconnect = client.magic_transit.cf_interconnects.list( @@ -55,10 +125,124 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.cf_interconnects.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cf_interconnect_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncCfInterconnects: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Tunnel for Interconnect to ORD", + gre={"cloudflare_endpoint": "203.0.113.1"}, + health_check={ + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + interface_address="192.0.2.0/31", + mtu=0, + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.cf_interconnects.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cf_interconnect_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: cf_interconnect = await async_client.magic_transit.cf_interconnects.list( @@ -96,3 +280,51 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.magic_transit.cf_interconnects.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.cf_interconnects.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cf_interconnect_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_gre_tunnels.py b/tests/api_resources/magic_transit/test_gre_tunnels.py index 7cbc640a0f5..512d2d01880 100644 --- a/tests/api_resources/magic_transit/test_gre_tunnels.py +++ b/tests/api_resources/magic_transit/test_gre_tunnels.py @@ -9,7 +9,13 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.magic_transit import GRETunnelListResponse, GRETunnelCreateResponse +from cloudflare.types.magic_transit import ( + GRETunnelGetResponse, + GRETunnelListResponse, + GRETunnelCreateResponse, + GRETunnelDeleteResponse, + GRETunnelUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -63,6 +69,96 @@ def test_path_params_create(self, client: Cloudflare) -> None: body={}, ) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + mtu=0, + ttl=0, + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: gre_tunnel = client.magic_transit.gre_tunnels.list( @@ -101,6 +197,102 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncGRETunnels: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -151,6 +343,96 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: body={}, ) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + mtu=0, + ttl=0, + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: gre_tunnel = await async_client.magic_transit.gre_tunnels.list( @@ -188,3 +470,99 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.magic_transit.gre_tunnels.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `gre_tunnel_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_ipsec_tunnels.py b/tests/api_resources/magic_transit/test_ipsec_tunnels.py index 9f0d27fcfa5..18965ec738e 100644 --- a/tests/api_resources/magic_transit/test_ipsec_tunnels.py +++ b/tests/api_resources/magic_transit/test_ipsec_tunnels.py @@ -10,8 +10,12 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.magic_transit import ( + IPSECTunnelGetResponse, IPSECTunnelListResponse, IPSECTunnelCreateResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelUpdateResponse, + IPSECTunnelPSKGenerateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -91,6 +95,91 @@ def test_path_params_create(self, client: Cloudflare) -> None: name="IPsec_1", ) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: ipsec_tunnel = client.magic_transit.ipsec_tunnels.list( @@ -129,6 +218,155 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_psk_generate(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_raw_response_psk_generate(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + def test_streaming_response_psk_generate(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_psk_generate(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + class TestAsyncIPSECTunnels: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -204,6 +442,91 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: name="IPsec_1", ) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.list( @@ -241,3 +564,152 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.magic_transit.ipsec_tunnels.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_psk_generate(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_raw_response_psk_generate(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @parametrize + async def test_streaming_response_psk_generate(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_psk_generate(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ipsec_tunnel_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) diff --git a/tests/api_resources/magic_transit/test_routes.py b/tests/api_resources/magic_transit/test_routes.py index 78985a57c3d..c72aba2ffde 100644 --- a/tests/api_resources/magic_transit/test_routes.py +++ b/tests/api_resources/magic_transit/test_routes.py @@ -10,9 +10,12 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.magic_transit import ( + RouteGetResponse, RouteListResponse, RouteEmptyResponse, RouteCreateResponse, + RouteDeleteResponse, + RouteUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -67,6 +70,86 @@ def test_path_params_create(self, client: Cloudflare) -> None: body={}, ) + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + description="New route for new prefix 203.0.113.1", + scope={ + "colo_names": ["den01", "den01", "den01"], + "colo_regions": ["APAC", "APAC", "APAC"], + }, + weight=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + client.magic_transit.routes.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + @parametrize def test_method_list(self, client: Cloudflare) -> None: route = client.magic_transit.routes.list( @@ -105,6 +188,54 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + client.magic_transit.routes.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_empty(self, client: Cloudflare) -> None: route = client.magic_transit.routes.empty( @@ -143,6 +274,54 @@ def test_path_params_empty(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + client.magic_transit.routes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncRoutes: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -193,6 +372,86 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: body={}, ) + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + description="New route for new prefix 203.0.113.1", + scope={ + "colo_names": ["den01", "den01", "den01"], + "colo_regions": ["APAC", "APAC", "APAC"], + }, + weight=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: route = await async_client.magic_transit.routes.list( @@ -231,6 +490,54 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_empty(self, async_client: AsyncCloudflare) -> None: route = await async_client.magic_transit.routes.empty( @@ -268,3 +575,51 @@ async def test_path_params_empty(self, async_client: AsyncCloudflare) -> None: await async_client.magic_transit.routes.with_raw_response.empty( account_id="", ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + )