10000 fix(urlscanner): don't unwwrap scan response · cloudflare/cloudflare-python@5fe7ea9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fe7ea9

Browse files
fix(urlscanner): don't unwwrap scan response
1 parent bfc0dd8 commit 5fe7ea9

File tree

5 files changed

+46
-29
lines changed

5 files changed

+46
-29
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1727
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-105c951ba258677316a9de215473e319b6dac8e744576078a682c231a783e0d2.yml
33
openapi_spec_hash: a26fc12e3f2b4ed90e6867b24a4b9da9
4-
config_hash: 3c780adf47c2d58e68dc5b7404d7b925
4+
config_hash: 250d2921080a7a91b4f76b1618f8f8ab

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7099,7 +7099,7 @@ from cloudflare.types.url_scanner import (
70997099

71007100
Methods:
71017101

7102-
- <code title="post /accounts/{account_id}/urlscanner/v2/scan">client.url_scanner.scans.<a href="./src/cloudflare/resources/url_scanner/scans.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/url_scanner/scan_create_params.py">params</a>) -> <a href="./src/cloudflare/types/url_scanner/scan_create_response.py">str</a></code>
7102+
- <code title="post /accounts/{account_id}/urlscanner/v2/scan">client.url_scanner.scans.<a href="./src/cloudflare/resources/url_scanner/scans.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/url_scanner/scan_create_params.py">params</a>) -> <a href="./src/cloudflare/types/url_scanner/scan_create_response.py">ScanCreateResponse</a></code>
71037103
- <code title="get /accounts/{account_id}/urlscanner/v2/search">client.url_scanner.scans.<a href="./src/cloudflare/resources/url_scanner/scans.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/url_scanner/scan_list_params.py">params</a>) -> <a href="./src/cloudflare/types/url_scanner/scan_list_response.py">ScanListResponse</a></code>
71047104
- <code title="post /accounts/{account_id}/urlscanner/v2/bulk">client.url_scanner.scans.<a href="./src/cloudflare/resources/url_scanner/scans.py">bulk_create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/url_scanner/scan_bulk_create_params.py">params</a>) -> <a href="./src/cloudflare/types/url_scanner/scan_bulk_create_response.py">ScanBulkCreateResponse</a></code>
71057105
- <code title="get /accounts/{account_id}/urlscanner/v2/dom/{scan_id}">client.url_scanner.scans.<a href="./src/cloudflare/resources/url_scanner/scans.py">dom</a>(scan_id, \*, account_id) -> str</code>

src/cloudflare/resources/url_scanner/scans.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Type, Iterable, cast
5+
from typing import Dict, List, Iterable
66
from typing_extensions import Literal
77

88
import httpx
@@ -25,7 +25,6 @@
2525
async_to_custom_raw_response_wrapper,
2626
async_to_custom_streamed_response_wrapper,
2727
)
28-
from ..._wrappers import ResultWrapper
2928
from ..._base_client import make_request_options
3029
from ...types.url_scanner import scan_list_params, scan_create_params, scan_screenshot_params, scan_bulk_create_params
3130
from ...types.url_scanner.scan_get_response import ScanGetResponse
@@ -271,7 +270,7 @@ def create(
271270
extra_query: Query | None = None,
272271
extra_body: Body | None = None,
273272
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
274-
) -> str:
273+
) -> ScanCreateResponse:
275274
"""Submit a URL to scan.
276275
277276
Check limits at
@@ -315,13 +314,9 @@ def create(
315314
scan_create_params.ScanCreateParams,
316315
),
317316
options=make_request_options(
318-
extra_headers=extra_headers,
319-
extra_query=extra_query,
320-
extra_body=extra_body,
321-
timeout=timeout,
322-
post_parser=ResultWrapper[ScanCreateResponse]._unwrapper,
317+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
323318
),
324-
cast_to=cast(Type[str], ResultWrapper[str]),
319+
cast_to=ScanCreateResponse,
325320
)
326321

327322
def list(
@@ -833,7 +828,7 @@ async def create(
833828
extra_query: Query | None = None,
834829
extra_body: Body | None = None,
835830
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
836-
) -> str:
831+
) -> ScanCreateResponse:
837832
"""Submit a URL to scan.
838833
839834
Check limits at
@@ -877,13 +872,9 @@ async def create(
877872
scan_create_params.ScanCreateParams,
878873
),
879874
options=make_request_options(
880-
extra_headers=extra_headers,
881-
extra_query=extra_query,
882-
extra_body=extra_body,
883-
timeout=timeout,
884-
post_parser=ResultWrapper[ScanCreateResponse]._unwrapper,
875+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
885876
),
886-
cast_to=cast(Type[str], ResultWrapper[str]),
877+
cast_to=ScanCreateResponse,
887878
)
888879

889880
async def list(
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing_extensions import TypeAlias
3+
from typing import Optional
44

5-
__all__ = ["ScanCreateResponse"]
5+
from ..._models import BaseModel
66

7-
ScanCreateResponse: TypeAlias = str
7+
__all__ = ["ScanCreateResponse", "Options"]
8+
9+
10+
class Options(BaseModel):
11+
useragent: Optional[str] = None
12+
13+
14+
class ScanCreateResponse(BaseModel):
15+
api: str
16+
"""URL to api report."""
17+
18+
message: str
19+
20+
result: str
21+
"""URL to report."""
22+
23+
url: str
24+
"""Canonical form of submitted URL. Use this if you want to later search by URL."""
25+
26+
uuid: str
27+
"""Scan ID."""
28+
29+
visibility: str
30+
"""Submitted visibility status."""
31+
32+
options: Optional[Options] = None

tests/api_resources/url_scanner/test_scans.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ScanGetResponse,
2222
ScanHARResponse,
2323
ScanListResponse,
24+
ScanCreateResponse,
2425
ScanBulkCreateResponse,
2526
)
2627

@@ -36,7 +37,7 @@ def test_method_create(self, client: Cloudflare) -> None:
3637
account_id="account_id",
3738
url="https://www.example.com",
3839
)
39-
assert_matches_type(str, scan, path=["response"])
40+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
4041

4142
@parametrize
4243
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
@@ -50,7 +51,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
5051
screenshots_resolutions=["desktop"],
5152
visibility="Public",
5253
)
53-
assert_matches_type(str, scan, path=["response"])
54+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
5455

5556
@parametrize
5657
def test_raw_response_create(self, client: Cloudflare) -> None:
@@ -62,7 +63,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
6263
assert response.is_closed is True
6364
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
6465
scan = response.parse()
65-
assert_matches_type(str, scan, path=["response"])
66+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
6667

6768
@parametrize
6869
def test_streaming_response_create(self, client: Cloudflare) -> None:
@@ -74,7 +75,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
7475
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
7576

7677
scan = response.parse()
77-
assert_matches_type(str, scan, path=["response"])
78+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
7879

7980
assert cast(Any, response.is_closed) is True
8081

@@ -428,7 +429,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
428429
account_id="account_id",
429430
url="https://www.example.com",
430431
)
431-
assert_matches_type(str, scan, path=["response"])
432+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
432433

433434
@parametrize
434435
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
@@ -442,7 +443,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
442443
screenshots_resolutions=["desktop"],
443444
visibility="Public",
444445
)
445-
assert_matches_type(str, scan, path=["response"])
446+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
446447

447448
@parametrize
448449
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
@@ -454,7 +455,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
454455
assert response.is_closed is True
455456
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
456457
scan = await response.parse()
457-
assert_matches_type(str, scan, path=["response"])
458+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
458459

459460
@parametrize
460461
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
@@ -466,7 +467,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
466467
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
467468

468469
scan = await response.parse()
469-
assert_matches_type(str, scan, path=["response"])
470+
assert_matches_type(ScanCreateResponse, scan, path=["response"])
470471

471472
assert cast(Any, response.is_closed) is True
472473

0 commit comments

Comments
 (0)
0