Skip to content

Commit 8f3ac3d

Browse files
chore(api): update composite API spec
1 parent f59a327 commit 8f3ac3d

8 files changed

Lines changed: 78 additions & 40 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 2013
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-47182e36d18529e4e1ef4528a8357dd54320a127f8951bd59e65f0bfc644d087.yml
3-
openapi_spec_hash: bdb0da399347091b2e6c2a4e3b4a553c
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-83f49bc3fa9273ef989d3e8bcd27f6fdaa7d04ae2519a91f4878f46acc501bb9.yml
3+
openapi_spec_hash: 3f4be3af6f51eea4787dc8345f9ca9c1
44
config_hash: 0c792bb64d06ffbdec9629c954299519

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7604,7 +7604,7 @@ from cloudflare.types.radar.ai import ToMarkdownCreateResponse
76047604

76057605
Methods:
76067606

7607-
- <code title="post /accounts/{account_id}/ai/tomarkdown">client.radar.ai.to_markdown.<a href="./src/cloudflare/resources/radar/ai/to_markdown.py">create</a>(body, \*, account_id, \*\*<a href="src/cloudflare/types/radar/ai/to_markdown_create_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/ai/to_markdown_create_response.py">SyncSinglePage[ToMarkdownCreateResponse]</a></code>
7607+
- <code title="post /accounts/{account_id}/ai/tomarkdown">client.radar.ai.to_markdown.<a href="./src/cloudflare/resources/radar/ai/to_markdown.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/radar/ai/to_markdown_create_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/ai/to_markdown_create_response.py">SyncSinglePage[ToMarkdownCreateResponse]</a></code>
76087608

76097609
### Inference
76107610

@@ -10642,7 +10642,7 @@ from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransform
1064210642
Methods:
1064310643

1064410644
- <code title="get /accounts/{account_id}/ai/tomarkdown/supported">client.ai.to_markdown.<a href="./src/cloudflare/resources/ai/to_markdown.py">supported</a>(\*, account_id) -> <a href="./src/cloudflare/types/ai/to_markdown_supported_response.py">SyncSinglePage[ToMarkdownSupportedResponse]</a></code>
10645-
- <code title="post /accounts/{account_id}/ai/tomarkdown">client.ai.to_markdown.<a href="./src/cloudflare/resources/ai/to_markdown.py">transform</a>(file, \*, account_id, \*\*<a href="src/cloudflare/types/ai/to_markdown_transform_params.py">params</a>) -> <a href="./src/cloudflare/types/ai/to_markdown_transform_response.py">SyncSinglePage[ToMarkdownTransformResponse]</a></code>
10645+
- <code title="post /accounts/{account_id}/ai/tomarkdown">client.ai.to_markdown.<a href="./src/cloudflare/resources/ai/to_markdown.py">transform</a>(\*, account_id, \*\*<a href="src/cloudflare/types/ai/to_markdown_transform_params.py">params</a>) -> <a href="./src/cloudflare/types/ai/to_markdown_transform_response.py">SyncSinglePage[ToMarkdownTransformResponse]</a></code>
1064610646

1064710647
# AISearch
1064810648

src/cloudflare/resources/ai/to_markdown.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
from __future__ import annotations
44

5-
import os
5+
from typing import Mapping, cast
66

77
import httpx
88

9-
from ..._files import read_file_content
10-
from ..._types import Body, Query, Headers, NotGiven, BinaryTypes, FileContent, not_given
9+
from ..._types import Body, Query, Headers, NotGiven, not_given
10+
from ..._utils import extract_files, maybe_transform, deepcopy_minimal
1111
from ..._compat import cached_property
12+
from ...types.ai import to_markdown_transform_params
1213
from ..._resource import SyncAPIResource, AsyncAPIResource
1314
from ..._response import (
1415
to_raw_response_wrapper,
@@ -80,9 +81,9 @@ def supported(
8081

8182
def transform(
8283
self,
83-
file: FileContent | BinaryTypes,
8484
*,
8585
account_id: str,
86+
file: to_markdown_transform_params.File,
8687
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8788
# The extra values given here take precedence over values defined on the client or passed to this method.
8889
extra_headers: Headers | None = None,
@@ -104,11 +105,17 @@ def transform(
104105
"""
105106
if not account_id:
106107
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
107-
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
108+
body = deepcopy_minimal(file)
109+
files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
110+
# It should be noted that the actual Content-Type header that will be
111+
# sent to the server will contain a `boundary` parameter, e.g.
112+
# multipart/form-data; boundary=---abc--
113+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
108114
return self._get_api_list(
109115
f"/accounts/{account_id}/ai/tomarkdown",
110116
page=SyncSinglePage[ToMarkdownTransformResponse],
111-
content=read_file_content(file) if isinstance(file, os.PathLike) else file,
117+
body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams),
118+
files=files,
112119
options=make_request_options(
113120
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
114121
),
@@ -173,9 +180,9 @@ def supported(
173180

174181
def transform(
175182
self,
176-
file: FileContent | BinaryTypes,
177183
*,
178184
account_id: str,
185+
file: to_markdown_transform_params.File,
179186
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
180187
# The extra values given here take precedence over values defined on the client or passed to this method.
181188
extra_headers: Headers | None = None,
@@ -197,11 +204,17 @@ def transform(
197204
"""
198205
if not account_id:
199206
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
200-
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
207+
body = deepcopy_minimal(file)
208+
files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
209+
# It should be noted that the actual Content-Type header that will be
210+
# sent to the server will contain a `boundary` parameter, e.g.
211+
# multipart/form-data; boundary=---abc--
212+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
201213
return self._get_api_list(
202214
f"/accounts/{account_id}/ai/tomarkdown",
203215
page=AsyncSinglePage[ToMarkdownTransformResponse],
204-
content=read_file_content(file) if isinstance(file, os.PathLike) else file,
216+
body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams),
217+
files=files,
205218
options=make_request_options(
206219
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
207220
),

src/cloudflare/resources/radar/ai/to_markdown.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
from __future__ import annotations
44

5-
import os
65
import typing_extensions
6+
from typing import Mapping, cast
77

88
import httpx
99

10-
from ...._files import read_file_content
1110
from ...._types import (
1211
Body,
1312
Query,
1413
Headers,
1514
NotGiven,
16-
BinaryTypes,
17-
FileContent,
15+
FileTypes,
16+
SequenceNotStr,
1817
not_given,
1918
)
19+
from ...._utils import extract_files, maybe_transform, deepcopy_minimal
2020
from ...._compat import cached_property
2121
from ...._resource import SyncAPIResource, AsyncAPIResource
2222
from ...._response import (
@@ -27,6 +27,7 @@
2727
)
2828
from ....pagination import SyncSinglePage, AsyncSinglePage
2929
from ...._base_client import AsyncPaginator, make_request_options
30+
from ....types.radar.ai import to_markdown_create_params
3031
from ....types.radar.ai.to_markdown_create_response import ToMarkdownCreateResponse
3132

3233
__all__ = ["ToMarkdownResource", "AsyncToMarkdownResource"]
@@ -57,9 +58,9 @@ def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse:
5758
)
5859
def create(
5960
self,
60-
body: FileContent | BinaryTypes,
6161
*,
6262
account_id: str,
63+
files: SequenceNotStr[FileTypes],
6364
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6465
# The extra values given here take precedence over values defined on the client or passed to this method.
6566
extra_headers: Headers | None = None,
@@ -81,11 +82,17 @@ def create(
8182
"""
8283
if not account_id:
8384
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
84-
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
85+
body = deepcopy_minimal({"files": files})
86+
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
87+
# It should be noted that the actual Content-Type header that will be
88+
# sent to the server will contain a `boundary` parameter, e.g.
89+
# multipart/form-data; boundary=---abc--
90+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
8591
return self._get_api_list(
8692
f"/accounts/{account_id}/ai/tomarkdown",
8793
page=SyncSinglePage[ToMarkdownCreateResponse],
88-
content=read_file_content(body) if isinstance(body, os.PathLike) else body,
94+
body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams),
95+
files=extracted_files,
8996
options=make_request_options(
9097
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
9198
),
@@ -119,9 +126,9 @@ def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingRespons
119126
)
120127
def create(
121128
self,
122-
body: FileContent | BinaryTypes,
123129
*,
124130
account_id: str,
131+
files: SequenceNotStr[FileTypes],
125132
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
126133
# The extra values given here take precedence over values defined on the client or passed to this method.
127134
extra_headers: Headers | None = None,
@@ -143,11 +150,17 @@ def create(
143150
"""
144151
if not account_id:
145152
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
146-
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
153+
body = deepcopy_minimal({"files": files})
154+
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
155+
# It should be noted that the actual Content-Type header that will be
156+
# sent to the server will contain a `boundary` parameter, e.g.
157+
# multipart/form-data; boundary=---abc--
158+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
147159
return self._get_api_list(
148160
f"/accounts/{account_id}/ai/tomarkdown",
149161
page=AsyncSinglePage[ToMarkdownCreateResponse],
150-
content=read_file_content(body) if isinstance(body, os.PathLike) else body,
162+
body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams),
163+
files=extracted_files,
151164
options=make_request_options(
152165
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
153166
),

src/cloudflare/types/ai/to_markdown_transform_params.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44

55
from typing_extensions import Required, TypedDict
66

7-
__all__ = ["ToMarkdownTransformParams"]
7+
from ..._types import FileTypes, SequenceNotStr
8+
9+
__all__ = ["ToMarkdownTransformParams", "File"]
810

911

1012
class ToMarkdownTransformParams(TypedDict, total=False):
1113
account_id: Required[str]
14+
15+
file: Required[File]
16+
17+
18+
class File(TypedDict, total=False):
19+
files: Required[SequenceNotStr[FileTypes]]

src/cloudflare/types/radar/ai/to_markdown_create_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
from typing_extensions import Required, TypedDict
66

7+
from ...._types import FileTypes, SequenceNotStr
8+
79
__all__ = ["ToMarkdownCreateParams"]
810

911

1012
class ToMarkdownCreateParams(TypedDict, total=False):
1113
account_id: Required[str]
14+
15+
files: Required[SequenceNotStr[FileTypes]]

tests/api_resources/ai/test_to_markdown.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ def test_path_params_supported(self, client: Cloudflare) -> None:
5959
@parametrize
6060
def test_method_transform(self, client: Cloudflare) -> None:
6161
to_markdown = client.ai.to_markdown.transform(
62-
file=b"raw file contents",
6362
account_id="023e105f4ecef8ad9ca31a8372d0c353",
63+
file={"files": [b"raw file contents"]},
6464
)
6565
assert_matches_type(SyncSinglePage[ToMarkdownTransformResponse], to_markdown, path=["response"])
6666

6767
@parametrize
6868
def test_raw_response_transform(self, client: Cloudflare) -> None:
6969
response = client.ai.to_markdown.with_raw_response.transform(
70-
file=b"raw file contents",
7170
account_id="023e105f4ecef8ad9ca31a8372d0c353",
71+
file={"files": [b"raw file contents"]},
7272
)
7373

7474
assert response.is_closed is True
@@ -79,8 +79,8 @@ def test_raw_response_transform(self, client: Cloudflare) -> None:
7979
@parametrize
8080
def test_streaming_response_transform(self, client: Cloudflare) -> None:
8181
with client.ai.to_markdown.with_streaming_response.transform(
82-
file=b"raw file contents",
8382
account_id="023e105f4ecef8ad9ca31a8372d0c353",
83+
file={"files": [b"raw file contents"]},
8484
) as response:
8585
assert not response.is_closed
8686
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -94,8 +94,8 @@ def test_streaming_response_transform(self, client: Cloudflare) -> None:
9494
def test_path_params_transform(self, client: Cloudflare) -> None:
9595
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
9696
client.ai.to_markdown.with_raw_response.transform(
97-
file=b"raw file contents",
9897
account_id="",
98+
file={"files": [b"raw file contents"]},
9999
)
100100

101101

@@ -145,16 +145,16 @@ async def test_path_params_supported(self, async_client: AsyncCloudflare) -> Non
145145
@parametrize
146146
async def test_method_transform(self, async_client: AsyncCloudflare) -> None:
147147
to_markdown = await async_client.ai.to_markdown.transform(
148-
file=b"raw file contents",
149148
account_id="023e105f4ecef8ad9ca31a8372d0c353",
149+
file={"files": [b"raw file contents"]},
150150
)
151151
assert_matches_type(AsyncSinglePage[ToMarkdownTransformResponse], to_markdown, path=["response"])
152152

153153
@parametrize
154154
async def test_raw_response_transform(self, async_client: AsyncCloudflare) -> None:
155155
response = await async_client.ai.to_markdown.with_raw_response.transform(
156-
file=b"raw file contents",
157156
account_id="023e105f4ecef8ad9ca31a8372d0c353",
157+
file={"files": [b"raw file contents"]},
158158
)
159159

160160
assert response.is_closed is True
@@ -165,8 +165,8 @@ async def test_raw_response_transform(self, async_client: AsyncCloudflare) -> No
165165
@parametrize
166166
async def test_streaming_response_transform(self, async_client: AsyncCloudflare) -> None:
167167
async with async_client.ai.to_markdown.with_streaming_response.transform(
168-
file=b"raw file contents",
169168
account_id="023e105f4ecef8ad9ca31a8372d0c353",
169+
file={"files": [b"raw file contents"]},
170170
) as response:
171171
assert not response.is_closed
172172
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -180,6 +180,6 @@ async def test_streaming_response_transform(self, async_client: AsyncCloudflare)
180180
async def test_path_params_transform(self, async_client: AsyncCloudflare) -> None:
181181
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
182182
await async_client.ai.to_markdown.with_raw_response.transform(
183-
file=b"raw file contents",
184183
account_id="",
184+
file={"files": [b"raw file contents"]},
185185
)

tests/api_resources/radar/ai/test_to_markdown.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TestToMarkdown:
2525
def test_method_create(self, client: Cloudflare) -> None:
2626
with pytest.warns(DeprecationWarning):
2727
to_markdown = client.radar.ai.to_markdown.create(
28-
body=b"raw file contents",
2928
account_id="023e105f4ecef8ad9ca31a8372d0c353",
29+
files=[b"raw file contents"],
3030
)
3131

3232
assert_matches_type(SyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"])
@@ -36,8 +36,8 @@ def test_method_create(self, client: Cloudflare) -> None:
3636
def test_raw_response_create(self, client: Cloudflare) -> None:
3737
with pytest.warns(DeprecationWarning):
3838
response = client.radar.ai.to_markdown.with_raw_response.create(
39-
body=b"raw file contents",
4039
account_id="023e105f4ecef8ad9ca31a8372d0c353",
40+
files=[b"raw file contents"],
4141
)
4242

4343
assert response.is_closed is True
@@ -50,8 +50,8 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
5050
def test_streaming_response_create(self, client: Cloudflare) -> None:
5151
with pytest.warns(DeprecationWarning):
5252
with client.radar.ai.to_markdown.with_streaming_response.create(
53-
body=b"raw file contents",
5453
account_id="023e105f4ecef8ad9ca31a8372d0c353",
54+
files=[b"raw file contents"],
5555
) as response:
5656
assert not response.is_closed
5757
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -67,8 +67,8 @@ def test_path_params_create(self, client: Cloudflare) -> None:
6767
with pytest.warns(DeprecationWarning):
6868
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
6969
client.radar.ai.to_markdown.with_raw_response.create(
70-
body=b"raw file contents",
7170
account_id="",
71+
files=[b"raw file contents"],
7272
)
7373

7474

@@ -82,8 +82,8 @@ class TestAsyncToMarkdown:
8282
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
8383
with pytest.warns(DeprecationWarning):
8484
to_markdown = await async_client.radar.ai.to_markdown.create(
85-
body=b"raw file contents",
8685
account_id="023e105f4ecef8ad9ca31a8372d0c353",
86+
files=[b"raw file contents"],
8787
)
8888

8989
assert_matches_type(AsyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"])
@@ -93,8 +93,8 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
9393
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
9494
with pytest.warns(DeprecationWarning):
9595
response = await async_client.radar.ai.to_markdown.with_raw_response.create(
96-
body=b"raw file contents",
9796
account_id="023e105f4ecef8ad9ca31a8372d0c353",
97+
files=[b"raw file contents"],
9898
)
9999

100100
assert response.is_closed is True
@@ -107,8 +107,8 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
107107
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
108108
with pytest.warns(DeprecationWarning):
109109
async with async_client.radar.ai.to_markdown.with_streaming_response.create(
110-
body=b"raw file contents",
111110
account_id="023e105f4ecef8ad9ca31a8372d0c353",
111+
files=[b"raw file contents"],
112112
) as response:
113113
assert not response.is_closed
114114
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -124,6 +124,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
124124
with pytest.warns(DeprecationWarning):
125125
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
126126
await async_client.radar.ai.to_markdown.with_raw_response.create(
127-
body=b"raw file contents",
128127
account_id="",
128+
files=[b"raw file contents"],
129129
)

0 commit comments

Comments
 (0)