mirror of
https://github.com/cloudflare/cloudflare-python.git
synced 2026-01-16 23:01:03 +00:00
fix(urlscanner): don't unwwrap scan response
This commit is contained in:
parent
bfc0dd8d66
commit
5fe7ea9b5b
5 changed files with 46 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
configured_endpoints: 1727
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-105c951ba258677316a9de215473e319b6dac8e744576078a682c231a783e0d2.yml
|
||||
openapi_spec_hash: a26fc12e3f2b4ed90e6867b24a4b9da9
|
||||
config_hash: 3c780adf47c2d58e68dc5b7404d7b925
|
||||
config_hash: 250d2921080a7a91b4f76b1618f8f8ab
|
||||
|
|
|
|||
2
api.md
2
api.md
|
|
@ -7099,7 +7099,7 @@ from cloudflare.types.url_scanner import (
|
|||
|
||||
Methods:
|
||||
|
||||
- <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>
|
||||
- <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>
|
||||
- <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>
|
||||
- <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>
|
||||
- <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>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Type, Iterable, cast
|
||||
from typing import Dict, List, Iterable
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
|
@ -25,7 +25,6 @@ from ..._response import (
|
|||
async_to_custom_raw_response_wrapper,
|
||||
async_to_custom_streamed_response_wrapper,
|
||||
)
|
||||
from ..._wrappers import ResultWrapper
|
||||
from ..._base_client import make_request_options
|
||||
from ...types.url_scanner import scan_list_params, scan_create_params, scan_screenshot_params, scan_bulk_create_params
|
||||
from ...types.url_scanner.scan_get_response import ScanGetResponse
|
||||
|
|
@ -271,7 +270,7 @@ class ScansResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> str:
|
||||
) -> ScanCreateResponse:
|
||||
"""Submit a URL to scan.
|
||||
|
||||
Check limits at
|
||||
|
|
@ -315,13 +314,9 @@ class ScansResource(SyncAPIResource):
|
|||
scan_create_params.ScanCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[ScanCreateResponse]._unwrapper,
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=cast(Type[str], ResultWrapper[str]),
|
||||
cast_to=ScanCreateResponse,
|
||||
)
|
||||
|
||||
def list(
|
||||
|
|
@ -833,7 +828,7 @@ class AsyncScansResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> str:
|
||||
) -> ScanCreateResponse:
|
||||
"""Submit a URL to scan.
|
||||
|
||||
Check limits at
|
||||
|
|
@ -877,13 +872,9 @@ class AsyncScansResource(AsyncAPIResource):
|
|||
scan_create_params.ScanCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[ScanCreateResponse]._unwrapper,
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=cast(Type[str], ResultWrapper[str]),
|
||||
cast_to=ScanCreateResponse,
|
||||
)
|
||||
|
||||
async def list(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,32 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing_extensions import TypeAlias
|
||||
from typing import Optional
|
||||
|
||||
__all__ = ["ScanCreateResponse"]
|
||||
from ..._models import BaseModel
|
||||
|
||||
ScanCreateResponse: TypeAlias = str
|
||||
__all__ = ["ScanCreateResponse", "Options"]
|
||||
|
||||
|
||||
class Options(BaseModel):
|
||||
useragent: Optional[str] = None
|
||||
|
||||
|
||||
class ScanCreateResponse(BaseModel):
|
||||
api: str
|
||||
"""URL to api report."""
|
||||
|
||||
message: str
|
||||
|
||||
result: str
|
||||
"""URL to report."""
|
||||
|
||||
url: str
|
||||
"""Canonical form of submitted URL. Use this if you want to later search by URL."""
|
||||
|
||||
uuid: str
|
||||
"""Scan ID."""
|
||||
|
||||
visibility: str
|
||||
"""Submitted visibility status."""
|
||||
|
||||
options: Optional[Options] = None
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from cloudflare.types.url_scanner import (
|
|||
ScanGetResponse,
|
||||
ScanHARResponse,
|
||||
ScanListResponse,
|
||||
ScanCreateResponse,
|
||||
ScanBulkCreateResponse,
|
||||
)
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ class TestScans:
|
|||
account_id="account_id",
|
||||
url="https://www.example.com",
|
||||
)
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
|
||||
|
|
@ -50,7 +51,7 @@ class TestScans:
|
|||
screenshots_resolutions=["desktop"],
|
||||
visibility="Public",
|
||||
)
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_create(self, client: Cloudflare) -> None:
|
||||
|
|
@ -62,7 +63,7 @@ class TestScans:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
scan = response.parse()
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_create(self, client: Cloudflare) -> None:
|
||||
|
|
@ -74,7 +75,7 @@ class TestScans:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
scan = response.parse()
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -428,7 +429,7 @@ class TestAsyncScans:
|
|||
account_id="account_id",
|
||||
url="https://www.example.com",
|
||||
)
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -442,7 +443,7 @@ class TestAsyncScans:
|
|||
screenshots_resolutions=["desktop"],
|
||||
visibility="Public",
|
||||
)
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -454,7 +455,7 @@ class TestAsyncScans:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
scan = await response.parse()
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -466,7 +467,7 @@ class TestAsyncScans:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
scan = await response.parse()
|
||||
assert_matches_type(str, scan, path=["response"])
|
||||
assert_matches_type(ScanCreateResponse, scan, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue