Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 650366e

Browse files
committedMar 17, 2025·
feat(ai_gateway): add urls support (#2539)
1 parent fa4981b commit 650366e

File tree

8 files changed

+398
-1
lines changed

8 files changed

+398
-1
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1611
1+
configured_endpoints: 1612
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8103ad52977aa9c1ce4655e2afd3ade7f6e891aafaa9bd1fbf4630348bc3fd02.yml

‎api.md

+12
Original file line numberDiff line numberDiff line change
@@ -8792,6 +8792,18 @@ Methods:
87928792
- <code title="delete /accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}">client.ai_gateway.evaluations.<a href="./src/cloudflare/resources/ai_gateway/evaluations.py">delete</a>(id, \*, account_id, gateway_id) -> <a href="./src/cloudflare/types/ai_gateway/evaluation_delete_response.py">EvaluationDeleteResponse</a></code>
87938793
- <code title="get /accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}">client.ai_gateway.evaluations.<a href="./src/cloudflare/resources/ai_gateway/evaluations.py">get</a>(id, \*, account_id, gateway_id) -> <a href="./src/cloudflare/types/ai_gateway/evaluation_get_response.py">EvaluationGetResponse</a></code>
87948794

8795+
## URLs
8796+
8797+
Types:
8798+
8799+
```python
8800+
from cloudflare.types.ai_gateway import URLGetResponse
8801+
```
8802+
8803+
Methods:
8804+
8805+
- <code title="get /accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}">client.ai_gateway.urls.<a href="./src/cloudflare/resources/ai_gateway/urls.py">get</a>(provider, \*, account_id, gateway_id) -> <a href="./src/cloudflare/types/ai_gateway/url_get_response.py">str</a></code>
8806+
87958807
# IAM
87968808

87978809
## PermissionGroups

‎src/cloudflare/resources/ai_gateway/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
LogsResourceWithStreamingResponse,
99
AsyncLogsResourceWithStreamingResponse,
1010
)
11+
from .urls import (
12+
URLsResource,
13+
AsyncURLsResource,
14+
URLsResourceWithRawResponse,
15+
AsyncURLsResourceWithRawResponse,
16+
URLsResourceWithStreamingResponse,
17+
AsyncURLsResourceWithStreamingResponse,
18+
)
1119
from .datasets import (
1220
DatasetsResource,
1321
AsyncDatasetsResource,
@@ -66,6 +74,12 @@
6674
"AsyncEvaluationsResourceWithRawResponse",
6775
"EvaluationsResourceWithStreamingResponse",
6876
"AsyncEvaluationsResourceWithStreamingResponse",
77+
"URLsResource",
78+
"AsyncURLsResource",
79+
"URLsResourceWithRawResponse",
80+
"AsyncURLsResourceWithRawResponse",
81+
"URLsResourceWithStreamingResponse",
82+
"AsyncURLsResourceWithStreamingResponse",
6983
"AIGatewayResource",
7084
"AsyncAIGatewayResource",
7185
"AIGatewayResourceWithRawResponse",

‎src/cloudflare/resources/ai_gateway/ai_gateway.py

+32
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
LogsResourceWithStreamingResponse,
1616
AsyncLogsResourceWithStreamingResponse,
1717
)
18+
from .urls import (
19+
URLsResource,
20+
AsyncURLsResource,
21+
URLsResourceWithRawResponse,
22+
AsyncURLsResourceWithRawResponse,
23+
URLsResourceWithStreamingResponse,
24+
AsyncURLsResourceWithStreamingResponse,
25+
)
1826
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1927
from ..._utils import (
2028
maybe_transform,
@@ -82,6 +90,10 @@ def datasets(self) -> DatasetsResource:
8290
def evaluations(self) -> EvaluationsResource:
8391
return EvaluationsResource(self._client)
8492

93+
@cached_property
94+
def urls(self) -> URLsResource:
95+
return URLsResource(self._client)
96+
8597
@cached_property
8698
def with_raw_response(self) -> AIGatewayResourceWithRawResponse:
8799
"""
@@ -390,6 +402,10 @@ def datasets(self) -> AsyncDatasetsResource:
390402
def evaluations(self) -> AsyncEvaluationsResource:
391403
return AsyncEvaluationsResource(self._client)
392404

405+
@cached_property
406+
def urls(self) -> AsyncURLsResource:
407+
return AsyncURLsResource(self._client)
408+
393409
@cached_property
394410
def with_raw_response(self) -> AsyncAIGatewayResourceWithRawResponse:
395411
"""
@@ -717,6 +733,10 @@ def datasets(self) -> DatasetsResourceWithRawResponse:
717733
def evaluations(self) -> EvaluationsResourceWithRawResponse:
718734
return EvaluationsResourceWithRawResponse(self._ai_gateway.evaluations)
719735

736+
@cached_property
737+
def urls(self) -> URLsResourceWithRawResponse:
738+
return URLsResourceWithRawResponse(self._ai_gateway.urls)
739+
720740

721741
class AsyncAIGatewayResourceWithRawResponse:
722742
def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None:
@@ -754,6 +774,10 @@ def datasets(self) -> AsyncDatasetsResourceWithRawResponse:
754774
def evaluations(self) -> AsyncEvaluationsResourceWithRawResponse:
755775
return AsyncEvaluationsResourceWithRawResponse(self._ai_gateway.evaluations)
756776

777+
@cached_property
778+
def urls(self) -> AsyncURLsResourceWithRawResponse:
779+
return AsyncURLsResourceWithRawResponse(self._ai_gateway.urls)
780+
757781

758782
class AIGatewayResourceWithStreamingResponse:
759783
def __init__(self, ai_gateway: AIGatewayResource) -> None:
@@ -791,6 +815,10 @@ def datasets(self) -> DatasetsResourceWithStreamingResponse:
791815
def evaluations(self) -> EvaluationsResourceWithStreamingResponse:
792816
return EvaluationsResourceWithStreamingResponse(self._ai_gateway.evaluations)
793817

818+
@cached_property
819+
def urls(self) -> URLsResourceWithStreamingResponse:
820+
return URLsResourceWithStreamingResponse(self._ai_gateway.urls)
821+
794822

795823
class AsyncAIGatewayResourceWithStreamingResponse:
796824
def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None:
@@ -827,3 +855,7 @@ def datasets(self) -> AsyncDatasetsResourceWithStreamingResponse:
827855
@cached_property
828856
def evaluations(self) -> AsyncEvaluationsResourceWithStreamingResponse:
829857
return AsyncEvaluationsResourceWithStreamingResponse(self._ai_gateway.evaluations)
858+
859+
@cached_property
860+
def urls(self) -> AsyncURLsResourceWithStreamingResponse:
861+
return AsyncURLsResourceWithStreamingResponse(self._ai_gateway.urls)
+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Type, cast
6+
7+
import httpx
8+
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ..._compat import cached_property
11+
from ..._resource import SyncAPIResource, AsyncAPIResource
12+
from ..._response import (
13+
to_raw_response_wrapper,
14+
to_streamed_response_wrapper,
15+
async_to_raw_response_wrapper,
16+
async_to_streamed_response_wrapper,
17+
)
18+
from ..._wrappers import ResultWrapper
19+
from ..._base_client import make_request_options
20+
from ...types.ai_gateway.url_get_response import URLGetResponse
21+
22+
__all__ = ["URLsResource", "AsyncURLsResource"]
23+
24+
25+
class URLsResource(SyncAPIResource):
26+
@cached_property
27+
def with_raw_response(self) -> URLsResourceWithRawResponse:
28+
"""
29+
This property can be used as a prefix for any HTTP method call to return
30+
the raw response object instead of the parsed content.
31+
32+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
33+
"""
34+
return URLsResourceWithRawResponse(self)
35+
36+
@cached_property
37+
def with_streaming_response(self) -> URLsResourceWithStreamingResponse:
38+
"""
39+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
40+
41+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
42+
"""
43+
return URLsResourceWithStreamingResponse(self)
44+
45+
def get(
46+
self,
47+
provider: str,
48+
*,
49+
account_id: str,
50+
gateway_id: str,
51+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
52+
# The extra values given here take precedence over values defined on the client or passed to this method.
53+
extra_headers: Headers | None = None,
54+
extra_query: Query | None = None,
55+
extra_body: Body | None = None,
56+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
57+
) -> str:
58+
"""
59+
Get Gateway URL
60+
61+
Args:
62+
gateway_id: gateway id
63+
64+
extra_headers: Send extra headers
65+
66+
extra_query: Add additional query parameters to the request
67+
68+
extra_body: Add additional JSON properties to the request
69+
70+
timeout: Override the client-level default timeout for this request, in seconds
71+
"""
72+
if not account_id:
73+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
74+
if not gateway_id:
75+
raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}")
76+
if not provider:
77+
raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
78+
return self._get(
79+
f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}",
80+
options=make_request_options(
81+
extra_headers=extra_headers,
82+
extra_query=extra_query,
83+
extra_body=extra_body,
84+
timeout=timeout,
85+
post_parser=ResultWrapper[URLGetResponse]._unwrapper,
86+
),
87+
cast_to=cast(Type[str], ResultWrapper[str]),
88+
)
89+
90+
91+
class AsyncURLsResource(AsyncAPIResource):
92+
@cached_property
93+
def with_raw_response(self) -> AsyncURLsResourceWithRawResponse:
94+
"""
95+
This property can be used as a prefix for any HTTP method call to return
96+
the raw response object instead of the parsed content.
97+
98+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
99+
"""
100+
return AsyncURLsResourceWithRawResponse(self)
101+
102+
@cached_property
103+
def with_streaming_response(self) -> AsyncURLsResourceWithStreamingResponse:
104+
"""
105+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
106+
107+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
108+
"""
109+
return AsyncURLsResourceWithStreamingResponse(self)
110+
111+
async def get(
112+
self,
113+
provider: str,
114+
*,
115+
account_id: str,
116+
gateway_id: str,
117+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
118+
# The extra values given here take precedence over values defined on the client or passed to this method.
119+
extra_headers: Headers | None = None,
120+
extra_query: Query | None = None,
121+
extra_body: Body | None = None,
122+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
123+
) -> str:
124+
"""
125+
Get Gateway URL
126+
127+
Args:
128+
gateway_id: gateway id
129+
130+
extra_headers: Send extra headers
131+
132+
extra_query: Add additional query parameters to the request
133+
134+
extra_body: Add additional JSON properties to the request
135+
136+
timeout: Override the client-level default timeout for this request, in seconds
137+
"""
138+
if not account_id:
139+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
140+
if not gateway_id:
141+
raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}")
142+
if not provider:
143+
raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
144+
return await self._get(
145+
f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}",
146+
options=make_request_options(
147+
extra_headers=extra_headers,
148+
extra_query=extra_query,
149+
extra_body=extra_body,
150+
timeout=timeout,
151+
post_parser=ResultWrapper[URLGetResponse]._unwrapper,
152+
),
153+
cast_to=cast(Type[str], ResultWrapper[str]),
154+
)
155+
156+
157+
class URLsResourceWithRawResponse:
158+
def __init__(self, urls: URLsResource) -> None:
159+
self._urls = urls
160+
161+
self.get = to_raw_response_wrapper(
162+
urls.get,
163+
)
164+
165+
166+
class AsyncURLsResourceWithRawResponse:
167+
def __init__(self, urls: AsyncURLsResource) -> None:
168+
self._urls = urls
169+
170+
self.get = async_to_raw_response_wrapper(
171+
urls.get,
172+
)
173+
174+
175+
class URLsResourceWithStreamingResponse:
176+
def __init__(self, urls: URLsResource) -> None:
177+
self._urls = urls
178+
179+
self.get = to_streamed_response_wrapper(
180+
urls.get,
181+
)
182+
183+
184+
class AsyncURLsResourceWithStreamingResponse:
185+
def __init__(self, urls: AsyncURLsResource) -> None:
186+
self._urls = urls
187+
188+
self.get = async_to_streamed_response_wrapper(
189+
urls.get,
190+
)

‎src/cloudflare/types/ai_gateway/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .log_edit_params import LogEditParams as LogEditParams
66
from .log_list_params import LogListParams as LogListParams
77
from .log_get_response import LogGetResponse as LogGetResponse
8+
from .url_get_response import URLGetResponse as URLGetResponse
89
from .log_delete_params import LogDeleteParams as LogDeleteParams
910
from .log_list_response import LogListResponse as LogListResponse
1011
from .dataset_list_params import DatasetListParams as DatasetListParams
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import TypeAlias
4+
5+
__all__ = ["URLGetResponse"]
6+
7+
URLGetResponse: TypeAlias = str

0 commit comments

Comments
 (0)
Please sign in to comment.