Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 31, 2024
1 parent dfa69f4 commit 1dffe01
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1321
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f68e176f43592631364d94df7670824a599296f6734ca70ffa94454c58da466.yml
5 changes: 3 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6031,16 +6031,17 @@ from cloudflare.types.zero_trust.gateway import (
GatewayIPs,
ProxyEndpoint,
ProxyEndpointDeleteResponse,
ProxyEndpointGetResponse,
)
```

Methods:

- <code title="post /accounts/{account_id}/gateway/proxy_endpoints">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/gateway/proxy_endpoint_create_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint.py">Optional</a></code>
- <code title="get /accounts/{account_id}/gateway/proxy_endpoints">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint.py">SyncSinglePage[ProxyEndpoint]</a></code>
- <code title="get /accounts/{account_id}/gateway/proxy_endpoints">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint.py">Optional</a></code>
- <code title="delete /accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">delete</a>(proxy_endpoint_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint_delete_response.py">Optional</a></code>
- <code title="patch /accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">edit</a>(proxy_endpoint_id, \*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/gateway/proxy_endpoint_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint.py">Optional</a></code>
- <code title="get /accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">get</a>(proxy_endpoint_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint.py">Optional</a></code>
- <code title="get /accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}">client.zero_trust.gateway.proxy_endpoints.<a href="./src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py">get</a>(proxy_endpoint_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/gateway/proxy_endpoint_get_response.py">Optional</a></code>

### Rules

Expand Down
51 changes: 28 additions & 23 deletions src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncSinglePage, AsyncSinglePage
from ...._base_client import (
AsyncPaginator,
make_request_options,
)
from ....types.zero_trust.gateway import proxy_endpoint_edit_params, proxy_endpoint_create_params
from ....types.zero_trust.gateway.gateway_ips import GatewayIPs
from ....types.zero_trust.gateway.proxy_endpoint import ProxyEndpoint
from ....types.zero_trust.gateway.proxy_endpoint_get_response import ProxyEndpointGetResponse
from ....types.zero_trust.gateway.proxy_endpoint_delete_response import ProxyEndpointDeleteResponse

__all__ = ["ProxyEndpointsResource", "AsyncProxyEndpointsResource"]
Expand Down Expand Up @@ -102,9 +101,9 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncSinglePage[ProxyEndpoint]:
) -> Optional[ProxyEndpoint]:
"""
Fetches a single Zero Trust Gateway proxy endpoint.
Fetches all Zero Trust Gateway proxy endpoints for an account.
Args:
extra_headers: Send extra headers
Expand All @@ -117,13 +116,16 @@ def list(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
return self._get(
f"/accounts/{account_id}/gateway/proxy_endpoints",
page=SyncSinglePage[ProxyEndpoint],
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper,
),
model=ProxyEndpoint,
cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]),
)

def delete(
Expand Down Expand Up @@ -235,9 +237,9 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ProxyEndpoint]:
) -> Optional[ProxyEndpointGetResponse]:
"""
Fetches all Zero Trust Gateway proxy endpoints for an account.
Fetches a single Zero Trust Gateway proxy endpoint.
Args:
extra_headers: Send extra headers
Expand All @@ -259,9 +261,9 @@ def get(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper,
post_parser=ResultWrapper[Optional[ProxyEndpointGetResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]),
cast_to=cast(Type[Optional[ProxyEndpointGetResponse]], ResultWrapper[ProxyEndpointGetResponse]),
)


Expand Down Expand Up @@ -324,7 +326,7 @@ async def create(
cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]),
)

def list(
async def list(
self,
*,
account_id: str,
Expand All @@ -334,9 +336,9 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[ProxyEndpoint, AsyncSinglePage[ProxyEndpoint]]:
) -> Optional[ProxyEndpoint]:
"""
Fetches a single Zero Trust Gateway proxy endpoint.
Fetches all Zero Trust Gateway proxy endpoints for an account.
Args:
extra_headers: Send extra headers
Expand All @@ -349,13 +351,16 @@ def list(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
return await self._get(
f"/accounts/{account_id}/gateway/proxy_endpoints",
page=AsyncSinglePage[ProxyEndpoint],
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper,
),
model=ProxyEndpoint,
cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]),
)

async def delete(
Expand Down Expand Up @@ -467,9 +472,9 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ProxyEndpoint]:
) -> Optional[ProxyEndpointGetResponse]:
"""
Fetches all Zero Trust Gateway proxy endpoints for an account.
Fetches a single Zero Trust Gateway proxy endpoint.
Args:
extra_headers: Send extra headers
Expand All @@ -491,9 +496,9 @@ async def get(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper,
post_parser=ResultWrapper[Optional[ProxyEndpointGetResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]),
cast_to=cast(Type[Optional[ProxyEndpointGetResponse]], ResultWrapper[ProxyEndpointGetResponse]),
)


Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/zero_trust/gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams
from .custom_certificate_settings import CustomCertificateSettings as CustomCertificateSettings
from .notification_settings_param import NotificationSettingsParam as NotificationSettingsParam
from .proxy_endpoint_get_response import ProxyEndpointGetResponse as ProxyEndpointGetResponse
from .body_scanning_settings_param import BodyScanningSettingsParam as BodyScanningSettingsParam
from .proxy_endpoint_create_params import ProxyEndpointCreateParams as ProxyEndpointCreateParams
from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List

from .proxy_endpoint import ProxyEndpoint

__all__ = ["ProxyEndpointGetResponse"]

ProxyEndpointGetResponse = List[ProxyEndpoint]
26 changes: 13 additions & 13 deletions tests/api_resources/zero_trust/gateway/test_proxy_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
from cloudflare.types.zero_trust.gateway import (
ProxyEndpoint,
ProxyEndpointGetResponse,
ProxyEndpointDeleteResponse,
)

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_method_list(self, client: Cloudflare) -> None:
proxy_endpoint = client.zero_trust.gateway.proxy_endpoints.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
Expand All @@ -83,7 +83,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
proxy_endpoint = response.parse()
assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
Expand All @@ -94,7 +94,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

proxy_endpoint = response.parse()
assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -217,7 +217,7 @@ def test_method_get(self, client: Cloudflare) -> None:
"ed35569b41ce4d1facfe683550f54086",
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
Expand All @@ -229,7 +229,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
proxy_endpoint = response.parse()
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
Expand All @@ -241,7 +241,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

proxy_endpoint = response.parse()
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -314,7 +314,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
proxy_endpoint = await async_client.zero_trust.gateway.proxy_endpoints.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -325,7 +325,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
proxy_endpoint = await response.parse()
assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -336,7 +336,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

proxy_endpoint = await response.parse()
assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -459,7 +459,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
"ed35569b41ce4d1facfe683550f54086",
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -471,7 +471,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
proxy_endpoint = await response.parse()
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -483,7 +483,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

proxy_endpoint = await response.parse()
assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"])
assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down

0 comments on commit 1dffe01

Please sign in to comment.