feat(api): update via SDK Studio (#1118)

This commit is contained in:
stainless-app[bot] 2024-06-20 23:15:27 +00:00 committed by stainless-bot
parent 5d7efed605
commit 8bc99ae689
39 changed files with 4617 additions and 44 deletions

View file

@ -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

39
api.md
View file

@ -3988,25 +3988,40 @@ Methods:
Types:
```python
from cloudflare.types.magic_transit import CfInterconnectListResponse
from cloudflare.types.magic_transit import (
CfInterconnectUpdateResponse,
CfInterconnectListResponse,
CfInterconnectGetResponse,
)
```
Methods:
- <code title="put /accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}">client.magic_transit.cf_interconnects.<a href="./src/cloudflare/resources/magic_transit/cf_interconnects.py">update</a>(cf_interconnect_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/cf_interconnect_update_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/cf_interconnect_update_response.py">CfInterconnectUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/magic/cf_interconnects">client.magic_transit.cf_interconnects.<a href="./src/cloudflare/resources/magic_transit/cf_interconnects.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/magic_transit/cf_interconnect_list_response.py">CfInterconnectListResponse</a></code>
- <code title="get /accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}">client.magic_transit.cf_interconnects.<a href="./src/cloudflare/resources/magic_transit/cf_interconnects.py">get</a>(cf_interconnect_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/cf_interconnect_get_response.py">CfInterconnectGetResponse</a></code>
## GRETunnels
Types:
```python
from cloudflare.types.magic_transit import GRETunnelCreateResponse, GRETunnelListResponse
from cloudflare.types.magic_transit import (
GRETunnelCreateResponse,
GRETunnelUpdateResponse,
GRETunnelListResponse,
GRETunnelDeleteResponse,
GRETunnelGetResponse,
)
```
Methods:
- <code title="post /accounts/{account_id}/magic/gre_tunnels">client.magic_transit.gre_tunnels.<a href="./src/cloudflare/resources/magic_transit/gre_tunnels.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/gre_tunnel_create_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/gre_tunnel_create_response.py">GRETunnelCreateResponse</a></code>
- <code title="put /accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}">client.magic_transit.gre_tunnels.<a href="./src/cloudflare/resources/magic_transit/gre_tunnels.py">update</a>(gre_tunnel_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/gre_tunnel_update_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/gre_tunnel_update_response.py">GRETunnelUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/magic/gre_tunnels">client.magic_transit.gre_tunnels.<a href="./src/cloudflare/resources/magic_transit/gre_tunnels.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/magic_transit/gre_tunnel_list_response.py">GRETunnelListResponse</a></code>
- <code title="delete /accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}">client.magic_transit.gre_tunnels.<a href="./src/cloudflare/resources/magic_transit/gre_tunnels.py">delete</a>(gre_tunnel_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py">GRETunnelDeleteResponse</a></code>
- <code title="get /accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}">client.magic_transit.gre_tunnels.<a href="./src/cloudflare/resources/magic_transit/gre_tunnels.py">get</a>(gre_tunnel_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/gre_tunnel_get_response.py">GRETunnelGetResponse</a></code>
## IPSECTunnels
@ -4016,14 +4031,22 @@ Types:
from cloudflare.types.magic_transit import (
PSKMetadata,
IPSECTunnelCreateResponse,
IPSECTunnelUpdateResponse,
IPSECTunnelListResponse,
IPSECTunnelDeleteResponse,
IPSECTunnelGetResponse,
IPSECTunnelPSKGenerateResponse,
)
```
Methods:
- <code title="post /accounts/{account_id}/magic/ipsec_tunnels">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_create_response.py">IPSECTunnelCreateResponse</a></code>
- <code title="put /accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">update</a>(ipsec_tunnel_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py">IPSECTunnelUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/magic/ipsec_tunnels">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_list_response.py">IPSECTunnelListResponse</a></code>
- <code title="delete /accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">delete</a>(ipsec_tunnel_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py">IPSECTunnelDeleteResponse</a></code>
- <code title="get /accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">get</a>(ipsec_tunnel_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py">IPSECTunnelGetResponse</a></code>
- <code title="post /accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate">client.magic_transit.ipsec_tunnels.<a href="./src/cloudflare/resources/magic_transit/ipsec_tunnels.py">psk_generate</a>(ipsec_tunnel_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py">IPSECTunnelPSKGenerateResponse</a></code>
## Routes
@ -4033,16 +4056,22 @@ Types:
from cloudflare.types.magic_transit import (
Scope,
RouteCreateResponse,
RouteUpdateResponse,
RouteListResponse,
RouteDeleteResponse,
RouteEmptyResponse,
RouteGetResponse,
)
```
Methods:
- <code title="post /accounts/{account_id}/magic/routes">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/route_create_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/route_create_response.py">RouteCreateResponse</a></code>
- <code title="put /accounts/{account_id}/magic/routes/{route_id}">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">update</a>(route_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/route_update_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/route_update_response.py">RouteUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/magic/routes">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/magic_transit/route_list_response.py">RouteListResponse</a></code>
- <code title="delete /accounts/{account_id}/magic/routes/{route_id}">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">delete</a>(route_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/route_delete_response.py">RouteDeleteResponse</a></code>
- <code title="delete /accounts/{account_id}/magic/routes">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">empty</a>(\*, account_id) -> <a href="./src/cloudflare/types/magic_transit/route_empty_response.py">RouteEmptyResponse</a></code>
- <code title="get /accounts/{account_id}/magic/routes/{route_id}">client.magic_transit.routes.<a href="./src/cloudflare/resources/magic_transit/routes.py">get</a>(route_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/route_get_response.py">RouteGetResponse</a></code>
## Sites
@ -4072,7 +4101,11 @@ from cloudflare.types.magic_transit.sites import ACL, ACLConfiguration, AllowedP
Methods:
- <code title="post /accounts/{account_id}/magic/sites/{site_id}/acls">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">create</a>(site_id, \*, account_id, \*\*<a href="src/cloudflare/types/magic_transit/sites/acl_create_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">ACL</a></code>
- <code title="put /accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">update</a>(acl_id, \*, account_id, site_id, \*\*<a href="src/cloudflare/types/magic_transit/sites/acl_update_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">ACL</a></code>
- <code title="get /accounts/{account_id}/magic/sites/{site_id}/acls">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">list</a>(site_id, \*, account_id) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">SyncSinglePage[ACL]</a></code>
- <code title="delete /accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">delete</a>(acl_id, \*, account_id, site_id) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">ACL</a></code>
- <code title="patch /accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">edit</a>(acl_id, \*, account_id, site_id, \*\*<a href="src/cloudflare/types/magic_transit/sites/acl_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">ACL</a></code>
- <code title="get /accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}">client.magic_transit.sites.acls.<a href="./src/cloudflare/resources/magic_transit/sites/acls.py">get</a>(acl_id, \*, account_id, site_id) -> <a href="./src/cloudflare/types/magic_transit/sites/acl.py">ACL</a></code>
### LANs
@ -7858,7 +7891,7 @@ from cloudflare.types.ai_gateway import LogListResponse
Methods:
- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs">client.ai_gateway.logs.<a href="./src/cloudflare/resources/ai_gateway/logs/logs.py">list</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/ai_gateway/log_list_params.py">params</a>) -> <a href="./src/cloudflare/types/ai_gateway/log_list_response.py">SyncV4PagePaginationArray[LogListResponse]</a></code>
- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs">client.ai_gateway.logs.<a href="./src/cloudflare/resources/ai_gateway/logs.py">list</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/ai_gateway/log_list_params.py">params</a>) -> <a href="./src/cloudflare/types/ai_gateway/log_list_response.py">SyncV4PagePaginationArray[LogListResponse]</a></code>
# IAM

View file

@ -21,7 +21,6 @@ from ..._utils import (
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,

View file

@ -8,23 +8,23 @@ from typing_extensions import Literal
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"]

View file

@ -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",
]

View file

@ -7,6 +7,10 @@ from typing import Type, cast
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 ..._wrappers import ResultWrapper
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 @@ class CfInterconnectsResource(SyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class CfInterconnectsResource(SyncAPIResource):
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 @@ class AsyncCfInterconnectsResource(AsyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class AsyncCfInterconnectsResource(AsyncAPIResource):
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,
)

View file

@ -23,9 +23,13 @@ from ..._wrappers import ResultWrapper
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 @@ class GRETunnelsResource(SyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class GRETunnelsResource(SyncAPIResource):
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 @@ class AsyncGRETunnelsResource(AsyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class AsyncGRETunnelsResource(AsyncAPIResource):
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 @@ class GRETunnelsResourceWithRawResponse:
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 @@ class AsyncGRETunnelsResourceWithRawResponse:
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 @@ class GRETunnelsResourceWithStreamingResponse:
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 @@ class AsyncGRETunnelsResourceWithStreamingResponse:
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,
)

View file

@ -23,10 +23,18 @@ from ..._wrappers import ResultWrapper
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 @@ class IPSECTunnelsResource(SyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class IPSECTunnelsResource(SyncAPIResource):
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 @@ class AsyncIPSECTunnelsResource(AsyncAPIResource):
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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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 @@ class AsyncIPSECTunnelsResource(AsyncAPIResource):
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 @@ class IPSECTunnelsResourceWithRawResponse:
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 @@ class AsyncIPSECTunnelsResourceWithRawResponse:
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 @@ class IPSECTunnelsResourceWithStreamingResponse:
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 @@ class AsyncIPSECTunnelsResourceWithStreamingResponse:
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,
)

View file

@ -23,10 +23,14 @@ from ..._wrappers import ResultWrapper
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 @@ class RoutesResource(SyncAPIResource):
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 @@ class RoutesResource(SyncAPIResource):
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 @@ class RoutesResource(SyncAPIResource):
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 @@ class AsyncRoutesResource(AsyncAPIResource):
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 @@ class AsyncRoutesResource(AsyncAPIResource):
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 @@ class AsyncRoutesResource(AsyncAPIResource):
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 @@ class RoutesResourceWithRawResponse:
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 @@ class AsyncRoutesResourceWithRawResponse:
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 @@ class RoutesResourceWithStreamingResponse:
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 @@ class AsyncRoutesResourceWithStreamingResponse:
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,
)

View file

@ -25,7 +25,7 @@ from ...._base_client import (
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 @@ class ACLsResource(SyncAPIResource):
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 @@ class ACLsResource(SyncAPIResource):
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 @@ class AsyncACLsResource(AsyncAPIResource):
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 @@ class AsyncACLsResource(AsyncAPIResource):
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 @@ class ACLsResourceWithRawResponse:
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 @@ class AsyncACLsResourceWithRawResponse:
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 @@ class ACLsResourceWithStreamingResponse:
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 @@ class AsyncACLsResourceWithStreamingResponse:
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,
)

View file

@ -1,3 +0,0 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations

View file

@ -4,6 +4,7 @@ from __future__ import annotations
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 .app_update_params import AppUpdateParams as AppUpdateParams
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_delete_response import AppDeleteResponse as AppDeleteResponse
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

View file

@ -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

View file

@ -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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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`."""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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."""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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]

View file

@ -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."""

View file

@ -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.010.255.255.255, 172.16.0.0172.31.255.255, 192.168.0.0192.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.
"""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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."""

View file

@ -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

View file

@ -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."""

View file

@ -12,12 +12,14 @@ from .dhcp_relay import DHCPRelay as DHCPRelay
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

View file

@ -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]

View file

@ -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]

View file

@ -1 +0,0 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

View file

@ -10,7 +10,9 @@ import pytest
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 @@ class TestACLs:
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 @@ class TestACLs:
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 @@ class TestAsyncACLs:
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 @@ class TestAsyncACLs:
"",
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",
)

View file

@ -9,7 +9,11 @@ import pytest
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 @@ base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
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 @@ class TestCfInterconnects:
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 @@ class TestAsyncCfInterconnects:
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",
)

View file

@ -9,7 +9,13 @@ import pytest
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 @@ class TestGRETunnels:
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 @@ class TestGRETunnels:
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 @@ class TestAsyncGRETunnels:
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 @@ class TestAsyncGRETunnels:
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",
)

View file

@ -10,8 +10,12 @@ import pytest
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 @@ class TestIPSECTunnels:
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 @@ class TestIPSECTunnels:
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 @@ class TestAsyncIPSECTunnels:
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 @@ class TestAsyncIPSECTunnels:
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={},
)

View file

@ -10,9 +10,12 @@ import pytest
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 @@ class TestRoutes:
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 @@ class TestRoutes:
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 @@ class TestRoutes:
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 @@ class TestAsyncRoutes:
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 @@ class TestAsyncRoutes:
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 @@ class TestAsyncRoutes:
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",
)