Skip to content

Commit 94440c3

Browse files
chore(internal): codegen related update
1 parent 5fbdcbf commit 94440c3

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

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

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

55
import httpx
66

7-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
8-
from ...._utils import maybe_transform
7+
from ...._files import read_file_content
8+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileContent
99
from ...._compat import cached_property
1010
from ...._resource import SyncAPIResource, AsyncAPIResource
1111
from ...._response import (
@@ -16,7 +16,6 @@
1616
)
1717
from ....pagination import SyncSinglePage, AsyncSinglePage
1818
from ...._base_client import AsyncPaginator, make_request_options
19-
from ....types.radar.ai import to_markdown_create_params
2019
from ....types.radar.ai.to_markdown_create_response import ToMarkdownCreateResponse
2120

2221
__all__ = ["ToMarkdownResource", "AsyncToMarkdownResource"]
@@ -44,7 +43,7 @@ def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse:
4443

4544
def create(
4645
self,
47-
body: FileTypes | NotGiven = NOT_GIVEN,
46+
body: FileContent,
4847
*,
4948
account_id: str,
5049
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -68,10 +67,11 @@ def create(
6867
"""
6968
if not account_id:
7069
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
70+
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
7171
return self._get_api_list(
7272
f"/accounts/{account_id}/ai/tomarkdown",
7373
page=SyncSinglePage[ToMarkdownCreateResponse],
74-
body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams),
74+
body=read_file_content(body),
7575
options=make_request_options(
7676
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
7777
),
@@ -102,7 +102,7 @@ def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingRespons
102102

103103
def create(
104104
self,
105-
body: FileTypes | NotGiven = NOT_GIVEN,
105+
body: FileContent,
106106
*,
107107
account_id: str,
108108
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -126,10 +126,11 @@ def create(
126126
"""
127127
if not account_id:
128128
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
129+
extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})}
129130
return self._get_api_list(
130131
f"/accounts/{account_id}/ai/tomarkdown",
131132
page=AsyncSinglePage[ToMarkdownCreateResponse],
132-
body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams),
133+
body=read_file_content(body),
133134
options=make_request_options(
134135
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
135136
),

tests/api_resources/radar/ai/test_to_markdown.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ class TestToMarkdown:
2121
@pytest.mark.skip(reason="TODO: investigate prism error for invalid security scheme used")
2222
@parametrize
2323
def test_method_create(self, client: Cloudflare) -> None:
24-
to_markdown = client.radar.ai.to_markdown.create(
25-
account_id="023e105f4ecef8ad9ca31a8372d0c353",
26-
)
27-
assert_matches_type(SyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"])
28-
29-
@pytest.mark.skip(reason="TODO: investigate prism error for invalid security scheme used")
30-
@parametrize
31-
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
3224
to_markdown = client.radar.ai.to_markdown.create(
3325
body=b"raw file contents",
3426
account_id="023e105f4ecef8ad9ca31a8372d0c353",
@@ -39,6 +31,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
3931
@parametrize
4032
def test_raw_response_create(self, client: Cloudflare) -> None:
4133
response = client.radar.ai.to_markdown.with_raw_response.create(
34+
body=b"raw file contents",
4235
account_id="023e105f4ecef8ad9ca31a8372d0c353",
4336
)
4437

@@ -51,6 +44,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
5144
@parametrize
5245
def test_streaming_response_create(self, client: Cloudflare) -> None:
5346
with client.radar.ai.to_markdown.with_streaming_response.create(
47+
body=b"raw file contents",
5448
account_id="023e105f4ecef8ad9ca31a8372d0c353",
5549
) as response:
5650
assert not response.is_closed
@@ -66,6 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
6660
def test_path_params_create(self, client: Cloudflare) -> None:
6761
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
6862
client.radar.ai.to_markdown.with_raw_response.create(
63+
body=b"raw file contents",
6964
account_id="",
7065
)
7166

@@ -78,14 +73,6 @@ class TestAsyncToMarkdown:
7873
@pytest.mark.skip(reason="TODO: investigate prism error for invalid security scheme used")
7974
@parametrize
8075
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
81-
to_markdown = await async_client.radar.ai.to_markdown.create(
82-
account_id="023e105f4ecef8ad9ca31a8372d0c353",
83-
)
84-
assert_matches_type(AsyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"])
85-
86-
@pytest.mark.skip(reason="TODO: investigate prism error for invalid security scheme used")
87-
@parametrize
88-
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
8976
to_markdown = await async_client.radar.ai.to_markdown.create(
9077
body=b"raw file contents",
9178
account_id="023e105f4ecef8ad9ca31a8372d0c353",
@@ -96,6 +83,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
9683
@parametrize
9784
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
9885
response = await async_client.radar.ai.to_markdown.with_raw_response.create(
86+
body=b"raw file contents",
9987
account_id="023e105f4ecef8ad9ca31a8372d0c353",
10088
)
10189

@@ -108,6 +96,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
10896
@parametrize
10997
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
11098
async with async_client.radar.ai.to_markdown.with_streaming_response.create(
99+
body=b"raw file contents",
111100
account_id="023e105f4ecef8ad9ca31a8372d0c353",
112101
) as response:
113102
assert not response.is_closed
@@ -123,5 +112,6 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
123112
async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
124113
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
125114
await async_client.radar.ai.to_markdown.with_raw_response.create(
115+
body=b"raw file contents",
126116
account_id="",
127117
)

0 commit comments

Comments
 (0)