Skip to content

Commit 6a4f824

Browse files
feat: feat(tomarkdown): add new markdown supported endpoint
1 parent bf0d4bb commit 6a4f824

File tree

6 files changed

+176
-4
lines changed

6 files changed

+176
-4
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1891
1+
configured_endpoints: 1892
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-aa2c3728465401b156b0ae35cb80cfef39ae398866f7b44b52dba8dd04d7df0c.yml
33
openapi_spec_hash: afffe386ef9475dfec98d1c26d8225d4
4-
config_hash: f8ad41a1e87119e46c6452f8f1ea0440
4+
config_hash: 002f3cbea44c410d7ee7e31fa9b0058a

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10126,11 +10126,12 @@ Methods:
1012610126
Types:
1012710127

1012810128
```python
10129-
from cloudflare.types.ai import ToMarkdownTransformResponse
10129+
from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransformResponse
1013010130
```
1013110131

1013210132
Methods:
1013310133

10134+
- <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>
1013410135
- <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>
1013510136

1013610137
# SecurityCenter

src/cloudflare/resources/ai/to_markdown.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
)
1717
from ...pagination import SyncSinglePage, AsyncSinglePage
1818
from ..._base_client import AsyncPaginator, make_request_options
19+
from ...types.ai.to_markdown_supported_response import ToMarkdownSupportedResponse
1920
from ...types.ai.to_markdown_transform_response import ToMarkdownTransformResponse
2021

2122
__all__ = ["ToMarkdownResource", "AsyncToMarkdownResource"]
@@ -41,6 +42,40 @@ def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse:
4142
"""
4243
return ToMarkdownResourceWithStreamingResponse(self)
4344

45+
def supported(
46+
self,
47+
*,
48+
account_id: str,
49+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
50+
# The extra values given here take precedence over values defined on the client or passed to this method.
51+
extra_headers: Headers | None = None,
52+
extra_query: Query | None = None,
53+
extra_body: Body | None = None,
54+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
55+
) -> SyncSinglePage[ToMarkdownSupportedResponse]:
56+
"""
57+
Get all converted formats supported
58+
59+
Args:
60+
extra_headers: Send extra headers
61+
62+
extra_query: Add additional query parameters to the request
63+
64+
extra_body: Add additional JSON properties to the request
65+
66+
timeout: Override the client-level default timeout for this request, in seconds
67+
"""
68+
if not account_id:
69+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
70+
return self._get_api_list(
71+
f"/accounts/{account_id}/ai/tomarkdown/supported",
72+
page=SyncSinglePage[ToMarkdownSupportedResponse],
73+
options=make_request_options(
74+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
75+
),
76+
model=ToMarkdownSupportedResponse,
77+
)
78+
4479
def transform(
4580
self,
4681
file: FileContent,
@@ -100,6 +135,40 @@ def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingRespons
100135
"""
101136
return AsyncToMarkdownResourceWithStreamingResponse(self)
102137

138+
def supported(
139+
self,
140+
*,
141+
account_id: str,
142+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143+
# The extra values given here take precedence over values defined on the client or passed to this method.
144+
extra_headers: Headers | None = None,
145+
extra_query: Query | None = None,
146+
extra_body: Body | None = None,
147+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
148+
) -> AsyncPaginator[ToMarkdownSupportedResponse, AsyncSinglePage[ToMarkdownSupportedResponse]]:
149+
"""
150+
Get all converted formats supported
151+
152+
Args:
153+
extra_headers: Send extra headers
154+
155+
extra_query: Add additional query parameters to the request
156+
157+
extra_body: Add additional JSON properties to the request
158+
159+
timeout: Override the client-level default timeout for this request, in seconds
160+
"""
161+
if not account_id:
162+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
163+
return self._get_api_list(
164+
f"/accounts/{account_id}/ai/tomarkdown/supported",
165+
page=AsyncSinglePage[ToMarkdownSupportedResponse],
166+
options=make_request_options(
167+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
168+
),
169+
model=ToMarkdownSupportedResponse,
170+
)
171+
103172
def transform(
104173
self,
105174
file: FileContent,
@@ -143,6 +212,9 @@ class ToMarkdownResourceWithRawResponse:
143212
def __init__(self, to_markdown: ToMarkdownResource) -> None:
144213
self._to_markdown = to_markdown
145214

215+
self.supported = to_raw_response_wrapper(
216+
to_markdown.supported,
217+
)
146218
self.transform = to_raw_response_wrapper(
147219
to_markdown.transform,
148220
)
@@ -152,6 +224,9 @@ class AsyncToMarkdownResourceWithRawResponse:
152224
def __init__(self, to_markdown: AsyncToMarkdownResource) -> None:
153225
self._to_markdown = to_markdown
154226

227+
self.supported = async_to_raw_response_wrapper(
228+
to_markdown.supported,
229+
)
155230
self.transform = async_to_raw_response_wrapper(
156231
to_markdown.transform,
157232
)
@@ -161,6 +236,9 @@ class ToMarkdownResourceWithStreamingResponse:
161236
def __init__(self, to_markdown: ToMarkdownResource) -> None:
162237
self._to_markdown = to_markdown
163238

239+
self.supported = to_streamed_response_wrapper(
240+
to_markdown.supported,
241+
)
164242
self.transform = to_streamed_response_wrapper(
165243
to_markdown.transform,
166244
)
@@ -170,6 +248,9 @@ class AsyncToMarkdownResourceWithStreamingResponse:
170248
def __init__(self, to_markdown: AsyncToMarkdownResource) -> None:
171249
self._to_markdown = to_markdown
172250

251+
self.supported = async_to_streamed_response_wrapper(
252+
to_markdown.supported,
253+
)
173254
self.transform = async_to_streamed_response_wrapper(
174255
to_markdown.transform,
175256
)

src/cloudflare/types/ai/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
from .finetune_list_response import FinetuneListResponse as FinetuneListResponse
1010
from .finetune_create_response import FinetuneCreateResponse as FinetuneCreateResponse
1111
from .to_markdown_transform_params import ToMarkdownTransformParams as ToMarkdownTransformParams
12+
from .to_markdown_supported_response import ToMarkdownSupportedResponse as ToMarkdownSupportedResponse
1213
from .to_markdown_transform_response import ToMarkdownTransformResponse as ToMarkdownTransformResponse
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from pydantic import Field as FieldInfo
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["ToMarkdownSupportedResponse"]
8+
9+
10+
class ToMarkdownSupportedResponse(BaseModel):
11+
extension: str
12+
13+
mime_type: str = FieldInfo(alias="mimeType")

tests/api_resources/ai/test_to_markdown.py

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12-
from cloudflare.types.ai import ToMarkdownTransformResponse
12+
from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransformResponse
1313
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
1414

1515
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -18,6 +18,44 @@
1818
class TestToMarkdown:
1919
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2020

21+
@parametrize
22+
def test_method_supported(self, client: Cloudflare) -> None:
23+
to_markdown = client.ai.to_markdown.supported(
24+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
25+
)
26+
assert_matches_type(SyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
27+
28+
@parametrize
29+
def test_raw_response_supported(self, client: Cloudflare) -> None:
30+
response = client.ai.to_markdown.with_raw_response.supported(
31+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
32+
)
33+
34+
assert response.is_closed is True
35+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
36+
to_markdown = response.parse()
37+
assert_matches_type(SyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
38+
39+
@parametrize
40+
def test_streaming_response_supported(self, client: Cloudflare) -> None:
41+
with client.ai.to_markdown.with_streaming_response.supported(
42+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
43+
) as response:
44+
assert not response.is_closed
45+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
46+
47+
to_markdown = response.parse()
48+
assert_matches_type(SyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
49+
50+
assert cast(Any, response.is_closed) is True
51+
52+
@parametrize
53+
def test_path_params_supported(self, client: Cloudflare) -> None:
54+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
55+
client.ai.to_markdown.with_raw_response.supported(
56+
account_id="",
57+
)
58+
2159
@parametrize
2260
def test_method_transform(self, client: Cloudflare) -> None:
2361
to_markdown = client.ai.to_markdown.transform(
@@ -66,6 +104,44 @@ class TestAsyncToMarkdown:
66104
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
67105
)
68106

107+
@parametrize
108+
async def test_method_supported(self, async_client: AsyncCloudflare) -> None:
109+
to_markdown = await async_client.ai.to_markdown.supported(
110+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
111+
)
112+
assert_matches_type(AsyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
113+
114+
@parametrize
115+
async def test_raw_response_supported(self, async_client: AsyncCloudflare) -> None:
116+
response = await async_client.ai.to_markdown.with_raw_response.supported(
117+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
118+
)
119+
120+
assert response.is_closed is True
121+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
122+
to_markdown = await response.parse()
123+
assert_matches_type(AsyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
124+
125+
@parametrize
126+
async def test_streaming_response_supported(self, async_client: AsyncCloudflare) -> None:
127+
async with async_client.ai.to_markdown.with_streaming_response.supported(
128+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
129+
) as response:
130+
assert not response.is_closed
131+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
132+
133+
to_markdown = await response.parse()
134+
assert_matches_type(AsyncSinglePage[ToMarkdownSupportedResponse], to_markdown, path=["response"])
135+
136+
assert cast(Any, response.is_closed) is True
137+
138+
@parametrize
139+
async def test_path_params_supported(self, async_client: AsyncCloudflare) -> None:
140+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
141+
await async_client.ai.to_markdown.with_raw_response.supported(
142+
account_id="",
143+
)
144+
69145
@parametrize
70146
async def test_method_transform(self, async_client: AsyncCloudflare) -> None:
71147
to_markdown = await async_client.ai.to_markdown.transform(

0 commit comments

Comments
 (0)