Skip to content

Commit 8a99cf5

Browse files
feat(api): api update
1 parent 4ec7e83 commit 8a99cf5

6 files changed

Lines changed: 27 additions & 44 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: 1777
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9629020f23f4c564925a52c46cdf5a93581a3f6bf35bf8050b0792467f642d33.yml
3-
openapi_spec_hash: 58db5ad168eaa03ed1c9a028636c58f6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d4d577be5bc8f4a0303c10df020efdc8823f02867d8f74e414c75e747c10e8e2.yml
3+
openapi_spec_hash: 523313d2ea7487505e7913769ecd7e53
44
config_hash: bafeb7666d2b7868c9d4ab8f0cc686e1

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3361,7 +3361,7 @@ from cloudflare.types.brand_protection import (
33613361
Methods:
33623362

33633363
- <code title="post /accounts/{account_id}/brand-protection/submit">client.brand_protection.<a href="./src/cloudflare/resources/brand_protection/brand_protection.py">submit</a>(\*, account_id) -> <a href="./src/cloudflare/types/brand_protection/brand_protection_submit_response.py">BrandProtectionSubmitResponse</a></code>
3364-
- <code title="get /accounts/{account_id}/brand-protection/url-info">client.brand_protection.<a href="./src/cloudflare/resources/brand_protection/brand_protection.py">url_info</a>(\*, account_id) -> <a href="./src/cloudflare/types/brand_protection/brand_protection_url_info_response.py">BrandProtectionURLInfoResponse</a></code>
3364+
- <code title="get /accounts/{account_id}/brand-protection/url-info">client.brand_protection.<a href="./src/cloudflare/resources/brand_protection/brand_protection.py">url_info</a>(\*, account_id) -> <a href="./src/cloudflare/types/brand_protection/brand_protection_url_info_response.py">SyncSinglePage[BrandProtectionURLInfoResponse]</a></code>
33653365

33663366
## Queries
33673367

src/cloudflare/resources/brand_protection/brand_protection.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
async_to_raw_response_wrapper,
3838
async_to_streamed_response_wrapper,
3939
)
40+
from ...pagination import SyncSinglePage, AsyncSinglePage
4041
from .logo_matches import (
4142
LogoMatchesResource,
4243
AsyncLogoMatchesResource,
@@ -45,7 +46,7 @@
4546
LogoMatchesResourceWithStreamingResponse,
4647
AsyncLogoMatchesResourceWithStreamingResponse,
4748
)
48-
from ..._base_client import make_request_options
49+
from ..._base_client import AsyncPaginator, make_request_options
4950
from ...types.brand_protection.brand_protection_submit_response import BrandProtectionSubmitResponse
5051
from ...types.brand_protection.brand_protection_url_info_response import BrandProtectionURLInfoResponse
5152

@@ -131,7 +132,7 @@ def url_info(
131132
extra_query: Query | None = None,
132133
extra_body: Body | None = None,
133134
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
134-
) -> BrandProtectionURLInfoResponse:
135+
) -> SyncSinglePage[BrandProtectionURLInfoResponse]:
135136
"""
136137
Return submitted URLs based on ID
137138
@@ -146,12 +147,13 @@ def url_info(
146147
"""
147148
if not account_id:
148149
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
149-
return self._get(
150+
return self._get_api_list(
150151
f"/accounts/{account_id}/brand-protection/url-info",
152+
page=SyncSinglePage[BrandProtectionURLInfoResponse],
151153
options=make_request_options(
152154
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
153155
),
154-
cast_to=BrandProtectionURLInfoResponse,
156+
model=BrandProtectionURLInfoResponse,
155157
)
156158

157159

@@ -224,7 +226,7 @@ async def submit(
224226
cast_to=BrandProtectionSubmitResponse,
225227
)
226228

227-
async def url_info(
229+
def url_info(
228230
self,
229231
*,
230232
account_id: str,
@@ -234,7 +236,7 @@ async def url_info(
234236
extra_query: Query | None = None,
235237
extra_body: Body | None = None,
236238
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
237-
) -> BrandProtectionURLInfoResponse:
239+
) -> AsyncPaginator[BrandProtectionURLInfoResponse, AsyncSinglePage[BrandProtectionURLInfoResponse]]:
238240
"""
239241
Return submitted URLs based on ID
240242
@@ -249,12 +251,13 @@ async def url_info(
249251
"""
250252
if not account_id:
251253
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
252-
return await self._get(
254+
return self._get_api_list(
253255
f"/accounts/{account_id}/brand-protection/url-info",
256+
page=AsyncSinglePage[BrandProtectionURLInfoResponse],
254257
options=make_request_options(
255258
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
256259
),
257-
cast_to=BrandProtectionURLInfoResponse,
260+
model=BrandProtectionURLInfoResponse,
258261
)
259262

260263

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, Optional
3+
from typing import Dict, List, Optional
44

55
from ..._models import BaseModel
66

77
__all__ = ["BrandProtectionSubmitResponse"]
88

99

1010
class BrandProtectionSubmitResponse(BaseModel):
11-
code: Optional[int] = None
12-
"""Error code"""
11+
skipped_urls: Optional[List[Dict[str, object]]] = None
1312

14-
errors: Optional[Dict[str, object]] = None
15-
"""Errors"""
16-
17-
message: Optional[str] = None
18-
"""Error message"""
19-
20-
status: Optional[str] = None
21-
"""Error name"""
13+
submitted_urls: Optional[List[Dict[str, object]]] = None
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, Optional
4-
5-
from ..._models import BaseModel
3+
from typing import Dict
4+
from typing_extensions import TypeAlias
65

76
__all__ = ["BrandProtectionURLInfoResponse"]
87

9-
10-
class BrandProtectionURLInfoResponse(BaseModel):
11-
code: Optional[int] = None
12-
"""Error code"""
13-
14-
errors: Optional[Dict[str, object]] = None
15-
"""Errors"""
16-
17-
message: Optional[str] = None
18-
"""Error message"""
19-
20-
status: Optional[str] = None
21-
"""Error name"""
8+
BrandProtectionURLInfoResponse: TypeAlias = Dict[str, object]

tests/api_resources/test_brand_protection.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12+
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
1213
from cloudflare.types.brand_protection import BrandProtectionSubmitResponse, BrandProtectionURLInfoResponse
1314

1415
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -60,7 +61,7 @@ def test_method_url_info(self, client: Cloudflare) -> None:
6061
brand_protection = client.brand_protection.url_info(
6162
account_id="x",
6263
)
63-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
64+
assert_matches_type(SyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
6465

6566
@parametrize
6667
def test_raw_response_url_info(self, client: Cloudflare) -> None:
@@ -71,7 +72,7 @@ def test_raw_response_url_info(self, client: Cloudflare) -> None:
7172
assert response.is_closed is True
7273
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
7374
brand_protection = response.parse()
74-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
75+
assert_matches_type(SyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
7576

7677
@parametrize
7778
def test_streaming_response_url_info(self, client: Cloudflare) -> None:
@@ -82,7 +83,7 @@ def test_streaming_response_url_info(self, client: Cloudflare) -> None:
8283
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
8384

8485
brand_protection = response.parse()
85-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
86+
assert_matches_type(SyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
8687

8788
assert cast(Any, response.is_closed) is True
8889

@@ -142,7 +143,7 @@ async def test_method_url_info(self, async_client: AsyncCloudflare) -> None:
142143
brand_protection = await async_client.brand_protection.url_info(
143144
account_id="x",
144145
)
145-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
146+
assert_matches_type(AsyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
146147

147148
@parametrize
148149
async def test_raw_response_url_info(self, async_client: AsyncCloudflare) -> None:
@@ -153,7 +154,7 @@ async def test_raw_response_url_info(self, async_client: AsyncCloudflare) -> Non
153154
assert response.is_closed is True
154155
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
155156
brand_protection = await response.parse()
156-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
157+
assert_matches_type(AsyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
157158

158159
@parametrize
159160
async def test_streaming_response_url_info(self, async_client: AsyncCloudflare) -> None:
@@ -164,7 +165,7 @@ async def test_streaming_response_url_info(self, async_client: AsyncCloudflare)
164165
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
165166

166167
brand_protection = await response.parse()
167-
assert_matches_type(BrandProtectionURLInfoResponse, brand_protection, path=["response"])
168+
assert_matches_type(AsyncSinglePage[BrandProtectionURLInfoResponse], brand_protection, path=["response"])
168169

169170
assert cast(Any, response.is_closed) is True
170171

0 commit comments

Comments
 (0)