Skip to content

Commit 2f1981a

Browse files
feat: feat(leaked_credentials_check): Add GET endpoint for leaked_credentials_check/detections
* feat(leaked_credentials_check): Add GET endpoint for leaked_credentials_check/detections
1 parent be9579e commit 2f1981a

File tree

6 files changed

+225
-2
lines changed

6 files changed

+225
-2
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: 1924
1+
configured_endpoints: 1925
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5fc91fe703941755eabe8e53f6d53056d31c38bff2f098dfa2389512e52b586f.yml
33
openapi_spec_hash: 7d4707f46e5b07408d6a083bfe164f51
4-
config_hash: d300d915a7b88f436c0498af4048e337
4+
config_hash: 93c66810e920a180099213f0e36aacbd

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10123,6 +10123,7 @@ from cloudflare.types.leaked_credential_checks import (
1012310123
DetectionCreateResponse,
1012410124
DetectionUpdateResponse,
1012510125
DetectionListResponse,
10126+
DetectionGetResponse,
1012610127
)
1012710128
```
1012810129

@@ -10132,6 +10133,7 @@ Methods:
1013210133
- <code title="put /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leaked_credential_checks.detections.<a href="./src/cloudflare/resources/leaked_credential_checks/detections.py">update</a>(detection_id, \*, zone_id, \*\*<a href="src/cloudflare/types/leaked_credential_checks/detection_update_params.py">params</a>) -> <a href="./src/cloudflare/types/leaked_credential_checks/detection_update_response.py">DetectionUpdateResponse</a></code>
1013310134
- <code title="get /zones/{zone_id}/leaked-credential-checks/detections">client.leaked_credential_checks.detections.<a href="./src/cloudflare/resources/leaked_credential_checks/detections.py">list</a>(\*, zone_id) -> <a href="./src/cloudflare/types/leaked_credential_checks/detection_list_response.py">SyncSinglePage[DetectionListResponse]</a></code>
1013410135
- <code title="delete /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leaked_credential_checks.detections.<a href="./src/cloudflare/resources/leaked_credential_checks/detections.py">delete</a>(detection_id, \*, zone_id) -> object</code>
10136+
- <code title="get /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leaked_credential_checks.detections.<a href="./src/cloudflare/resources/leaked_credential_checks/detections.py">get</a>(detection_id, \*, zone_id) -> <a href="./src/cloudflare/types/leaked_credential_checks/detection_get_response.py">DetectionGetResponse</a></code>
1013510137

1013610138
# ContentScanning
1013710139

src/cloudflare/resources/leaked_credential_checks/detections.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ...pagination import SyncSinglePage, AsyncSinglePage
2121
from ..._base_client import AsyncPaginator, make_request_options
2222
from ...types.leaked_credential_checks import detection_create_params, detection_update_params
23+
from ...types.leaked_credential_checks.detection_get_response import DetectionGetResponse
2324
from ...types.leaked_credential_checks.detection_list_response import DetectionListResponse
2425
from ...types.leaked_credential_checks.detection_create_response import DetectionCreateResponse
2526
from ...types.leaked_credential_checks.detection_update_response import DetectionUpdateResponse
@@ -236,6 +237,50 @@ def delete(
236237
cast_to=cast(Type[object], ResultWrapper[object]),
237238
)
238239

240+
def get(
241+
self,
242+
detection_id: str,
243+
*,
244+
zone_id: str,
245+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246+
# The extra values given here take precedence over values defined on the client or passed to this method.
247+
extra_headers: Headers | None = None,
248+
extra_query: Query | None = None,
249+
extra_body: Body | None = None,
250+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
251+
) -> DetectionGetResponse:
252+
"""
253+
Get user-defined detection pattern for Leaked Credential Checks.
254+
255+
Args:
256+
zone_id: Defines an identifier.
257+
258+
detection_id: Defines the unique ID for this custom detection.
259+
260+
extra_headers: Send extra headers
261+
262+
extra_query: Add additional query parameters to the request
263+
264+
extra_body: Add additional JSON properties to the request
265+
266+
timeout: Override the client-level default timeout for this request, in seconds
267+
"""
268+
if not zone_id:
269+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
270+
if not detection_id:
271+
raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}")
272+
return self._get(
273+
f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}",
274+
options=make_request_options(
275+
extra_headers=extra_headers,
276+
extra_query=extra_query,
277+
extra_body=extra_body,
278+
timeout=timeout,
279+
post_parser=ResultWrapper[DetectionGetResponse]._unwrapper,
280+
),
281+
cast_to=cast(Type[DetectionGetResponse], ResultWrapper[DetectionGetResponse]),
282+
)
283+
239284

240285
class AsyncDetectionsResource(AsyncAPIResource):
241286
@cached_property
@@ -446,6 +491,50 @@ async def delete(
446491
cast_to=cast(Type[object], ResultWrapper[object]),
447492
)
448493

494+
async def get(
495+
self,
496+
detection_id: str,
497+
*,
498+
zone_id: str,
499+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
500+
# The extra values given here take precedence over values defined on the client or passed to this method.
501+
extra_headers: Headers | None = None,
502+
extra_query: Query | None = None,
503+
extra_body: Body | None = None,
504+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
505+
) -> DetectionGetResponse:
506+
"""
507+
Get user-defined detection pattern for Leaked Credential Checks.
508+
509+
Args:
510+
zone_id: Defines an identifier.
511+
512+
detection_id: Defines the unique ID for this custom detection.
513+
514+
extra_headers: Send extra headers
515+
516+
extra_query: Add additional query parameters to the request
517+
518+
extra_body: Add additional JSON properties to the request
519+
520+
timeout: Override the client-level default timeout for this request, in seconds
521+
"""
522+
if not zone_id:
523+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
524+
if not detection_id:
525+
raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}")
526+
return await self._get(
527+
f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}",
528+
options=make_request_options(
529+
extra_headers=extra_headers,
530+
extra_query=extra_query,
531+
extra_body=extra_body,
532+
timeout=timeout,
533+
post_parser=ResultWrapper[DetectionGetResponse]._unwrapper,
534+
),
535+
cast_to=cast(Type[DetectionGetResponse], ResultWrapper[DetectionGetResponse]),
536+
)
537+
449538

450539
class DetectionsResourceWithRawResponse:
451540
def __init__(self, detections: DetectionsResource) -> None:
@@ -463,6 +552,9 @@ def __init__(self, detections: DetectionsResource) -> None:
463552
self.delete = to_raw_response_wrapper(
464553
detections.delete,
465554
)
555+
self.get = to_raw_response_wrapper(
556+
detections.get,
557+
)
466558

467559

468560
class AsyncDetectionsResourceWithRawResponse:
@@ -481,6 +573,9 @@ def __init__(self, detections: AsyncDetectionsResource) -> None:
481573
self.delete = async_to_raw_response_wrapper(
482574
detections.delete,
483575
)
576+
self.get = async_to_raw_response_wrapper(
577+
detections.get,
578+
)
484579

485580

486581
class DetectionsResourceWithStreamingResponse:
@@ -499,6 +594,9 @@ def __init__(self, detections: DetectionsResource) -> None:
499594
self.delete = to_streamed_response_wrapper(
500595
detections.delete,
501596
)
597+
self.get = to_streamed_response_wrapper(
598+
detections.get,
599+
)
502600

503601

504602
class AsyncDetectionsResourceWithStreamingResponse:
@@ -517,3 +615,6 @@ def __init__(self, detections: AsyncDetectionsResource) -> None:
517615
self.delete = async_to_streamed_response_wrapper(
518616
detections.delete,
519617
)
618+
self.get = async_to_streamed_response_wrapper(
619+
detections.get,
620+
)

src/cloudflare/types/leaked_credential_checks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from .detection_get_response import DetectionGetResponse as DetectionGetResponse
56
from .detection_create_params import DetectionCreateParams as DetectionCreateParams
67
from .detection_list_response import DetectionListResponse as DetectionListResponse
78
from .detection_update_params import DetectionUpdateParams as DetectionUpdateParams
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Optional
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["DetectionGetResponse"]
8+
9+
10+
class DetectionGetResponse(BaseModel):
11+
"""
12+
Defines a custom set of username/password expressions to match Leaked Credential Checks on.
13+
"""
14+
15+
id: Optional[str] = None
16+
"""Defines the unique ID for this custom detection."""
17+
18+
password: Optional[str] = None
19+
"""Defines ehe ruleset expression to use in matching the password in a request."""
20+
21+
username: Optional[str] = None
22+
"""Defines the ruleset expression to use in matching the username in a request."""

tests/api_resources/leaked_credential_checks/test_detections.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from tests.utils import assert_matches_type
1212
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
1313
from cloudflare.types.leaked_credential_checks import (
14+
DetectionGetResponse,
1415
DetectionListResponse,
1516
DetectionCreateResponse,
1617
DetectionUpdateResponse,
@@ -213,6 +214,54 @@ def test_path_params_delete(self, client: Cloudflare) -> None:
213214
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
214215
)
215216

217+
@parametrize
218+
def test_method_get(self, client: Cloudflare) -> None:
219+
detection = client.leaked_credential_checks.detections.get(
220+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
221+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
222+
)
223+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
224+
225+
@parametrize
226+
def test_raw_response_get(self, client: Cloudflare) -> None:
227+
response = client.leaked_credential_checks.detections.with_raw_response.get(
228+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
229+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
230+
)
231+
232+
assert response.is_closed is True
233+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
234+
detection = response.parse()
235+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
236+
237+
@parametrize
238+
def test_streaming_response_get(self, client: Cloudflare) -> None:
239+
with client.leaked_credential_checks.detections.with_streaming_response.get(
240+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
241+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
242+
) as response:
243+
assert not response.is_closed
244+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
245+
246+
detection = response.parse()
247+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
248+
249+
assert cast(Any, response.is_closed) is True
250+
251+
@parametrize
252+
def test_path_params_get(self, client: Cloudflare) -> None:
253+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
254+
client.leaked_credential_checks.detections.with_raw_response.get(
255+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
256+
zone_id="",
257+
)
258+
259+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `detection_id` but received ''"):
260+
client.leaked_credential_checks.detections.with_raw_response.get(
261+
detection_id="",
262+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
263+
)
264+
216265

217266
class TestAsyncDetections:
218267
parametrize = pytest.mark.parametrize(
@@ -409,3 +458,51 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
409458
detection_id="",
410459
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
411460
)
461+
462+
@parametrize
463+
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
464+
detection = await async_client.leaked_credential_checks.detections.get(
465+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
466+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
467+
)
468+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
469+
470+
@parametrize
471+
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
472+
response = await async_client.leaked_credential_checks.detections.with_raw_response.get(
473+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
474+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
475+
)
476+
477+
assert response.is_closed is True
478+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
479+
detection = await response.parse()
480+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
481+
482+
@parametrize
483+
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
484+
async with async_client.leaked_credential_checks.detections.with_streaming_response.get(
485+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
486+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
487+
) as response:
488+
assert not response.is_closed
489+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
490+
491+
detection = await response.parse()
492+
assert_matches_type(DetectionGetResponse, detection, path=["response"])
493+
494+
assert cast(Any, response.is_closed) is True
495+
496+
@parametrize
497+
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
498+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
499+
await async_client.leaked_credential_checks.detections.with_raw_response.get(
500+
detection_id="18a14bafaa8eb1df04ce683ec18c765e",
501+
zone_id="",
502+
)
503+
504+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `detection_id` but received ''"):
505+
await async_client.leaked_credential_checks.detections.with_raw_response.get(
506+
detection_id="",
507+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
508+
)

0 commit comments

Comments
 (0)