Skip to content

Commit 0451c1c

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 10fcf9c commit 0451c1c

File tree

6 files changed

+85
-2
lines changed

6 files changed

+85
-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
@@ -8798,13 +8798,15 @@ Types:
87988798
- <code><a href="./src/resources/leaked-credential-checks/detections.ts">DetectionUpdateResponse</a></code>
87998799
- <code><a href="./src/resources/leaked-credential-checks/detections.ts">DetectionListResponse</a></code>
88008800
- <code><a href="./src/resources/leaked-credential-checks/detections.ts">DetectionDeleteResponse</a></code>
8801+
- <code><a href="./src/resources/leaked-credential-checks/detections.ts">DetectionGetResponse</a></code>
88018802

88028803
Methods:
88038804

88048805
- <code title="post /zones/{zone_id}/leaked-credential-checks/detections">client.leakedCredentialChecks.detections.<a href="./src/resources/leaked-credential-checks/detections.ts">create</a>({ ...params }) -> DetectionCreateResponse</code>
88058806
- <code title="put /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leakedCredentialChecks.detections.<a href="./src/resources/leaked-credential-checks/detections.ts">update</a>(detectionId, { ...params }) -> DetectionUpdateResponse</code>
88068807
- <code title="get /zones/{zone_id}/leaked-credential-checks/detections">client.leakedCredentialChecks.detections.<a href="./src/resources/leaked-credential-checks/detections.ts">list</a>({ ...params }) -> DetectionListResponsesSinglePage</code>
88078808
- <code title="delete /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leakedCredentialChecks.detections.<a href="./src/resources/leaked-credential-checks/detections.ts">delete</a>(detectionId, { ...params }) -> DetectionDeleteResponse</code>
8809+
- <code title="get /zones/{zone_id}/leaked-credential-checks/detections/{detection_id}">client.leakedCredentialChecks.detections.<a href="./src/resources/leaked-credential-checks/detections.ts">get</a>(detectionId, { ...params }) -> DetectionGetResponse</code>
88088810

88098811
# ContentScanning
88108812

src/resources/leaked-credential-checks/detections.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ export class Detections extends APIResource {
105105
) as Core.APIPromise<{ result: DetectionDeleteResponse }>
106106
)._thenUnwrap((obj) => obj.result);
107107
}
108+
109+
/**
110+
* Get user-defined detection pattern for Leaked Credential Checks.
111+
*
112+
* @example
113+
* ```ts
114+
* const detection =
115+
* await client.leakedCredentialChecks.detections.get(
116+
* '18a14bafaa8eb1df04ce683ec18c765e',
117+
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
118+
* );
119+
* ```
120+
*/
121+
get(
122+
detectionId: string,
123+
params: DetectionGetParams,
124+
options?: Core.RequestOptions,
125+
): Core.APIPromise<DetectionGetResponse> {
126+
const { zone_id } = params;
127+
return (
128+
this._client.get(
129+
`/zones/${zone_id}/leaked-credential-checks/detections/${detectionId}`,
130+
options,
131+
) as Core.APIPromise<{ result: DetectionGetResponse }>
132+
)._thenUnwrap((obj) => obj.result);
133+
}
108134
}
109135

110136
export class DetectionListResponsesSinglePage extends SinglePage<DetectionListResponse> {}
@@ -174,6 +200,27 @@ export interface DetectionListResponse {
174200

175201
export type DetectionDeleteResponse = unknown;
176202

203+
/**
204+
* Defines a custom set of username/password expressions to match Leaked Credential
205+
* Checks on.
206+
*/
207+
export interface DetectionGetResponse {
208+
/**
209+
* Defines the unique ID for this custom detection.
210+
*/
211+
id?: string;
212+
213+
/**
214+
* Defines ehe ruleset expression to use in matching the password in a request.
215+
*/
216+
password?: string;
217+
218+
/**
219+
* Defines the ruleset expression to use in matching the username in a request.
220+
*/
221+
username?: string;
222+
}
223+
177224
export interface DetectionCreateParams {
178225
/**
179226
* Path param: Defines an identifier.
@@ -226,6 +273,13 @@ export interface DetectionDeleteParams {
226273
zone_id: string;
227274
}
228275

276+
export interface DetectionGetParams {
277+
/**
278+
* Defines an identifier.
279+
*/
280+
zone_id: string;
281+
}
282+
229283
Detections.DetectionListResponsesSinglePage = DetectionListResponsesSinglePage;
230284

231285
export declare namespace Detections {
@@ -234,10 +288,12 @@ export declare namespace Detections {
234288
type DetectionUpdateResponse as DetectionUpdateResponse,
235289
type DetectionListResponse as DetectionListResponse,
236290
type DetectionDeleteResponse as DetectionDeleteResponse,
291+
type DetectionGetResponse as DetectionGetResponse,
237292
DetectionListResponsesSinglePage as DetectionListResponsesSinglePage,
238293
type DetectionCreateParams as DetectionCreateParams,
239294
type DetectionUpdateParams as DetectionUpdateParams,
240295
type DetectionListParams as DetectionListParams,
241296
type DetectionDeleteParams as DetectionDeleteParams,
297+
type DetectionGetParams as DetectionGetParams,
242298
};
243299
}

src/resources/leaked-credential-checks/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ export {
77
type DetectionUpdateResponse,
88
type DetectionListResponse,
99
type DetectionDeleteResponse,
10+
type DetectionGetResponse,
1011
type DetectionCreateParams,
1112
type DetectionUpdateParams,
1213
type DetectionListParams,
1314
type DetectionDeleteParams,
15+
type DetectionGetParams,
1416
} from './detections';
1517
export { LeakedCredentialChecks } from './leaked-credential-checks';

src/resources/leaked-credential-checks/leaked-credential-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
DetectionCreateResponse,
99
DetectionDeleteParams,
1010
DetectionDeleteResponse,
11+
DetectionGetParams,
12+
DetectionGetResponse,
1113
DetectionListParams,
1214
DetectionListResponse,
1315
DetectionListResponsesSinglePage,
@@ -123,10 +125,12 @@ export declare namespace LeakedCredentialChecks {
123125
type DetectionUpdateResponse as DetectionUpdateResponse,
124126
type DetectionListResponse as DetectionListResponse,
125127
type DetectionDeleteResponse as DetectionDeleteResponse,
128+
type DetectionGetResponse as DetectionGetResponse,
126129
DetectionListResponsesSinglePage as DetectionListResponsesSinglePage,
127130
type DetectionCreateParams as DetectionCreateParams,
128131
type DetectionUpdateParams as DetectionUpdateParams,
129132
type DetectionListParams as DetectionListParams,
130133
type DetectionDeleteParams as DetectionDeleteParams,
134+
type DetectionGetParams as DetectionGetParams,
131135
};
132136
}

tests/api-resources/leaked-credential-checks/detections.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,23 @@ describe('resource detections', () => {
9595
{ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
9696
);
9797
});
98+
99+
test('get: only required params', async () => {
100+
const responsePromise = client.leakedCredentialChecks.detections.get('18a14bafaa8eb1df04ce683ec18c765e', {
101+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
102+
});
103+
const rawResponse = await responsePromise.asResponse();
104+
expect(rawResponse).toBeInstanceOf(Response);
105+
const response = await responsePromise;
106+
expect(response).not.toBeInstanceOf(Response);
107+
const dataAndResponse = await responsePromise.withResponse();
108+
expect(dataAndResponse.data).toBe(response);
109+
expect(dataAndResponse.response).toBe(rawResponse);
110+
});
111+
112+
test('get: required and optional params', async () => {
113+
const response = await client.leakedCredentialChecks.detections.get('18a14bafaa8eb1df04ce683ec18c765e', {
114+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
115+
});
116+
});
98117
});

0 commit comments

Comments
 (0)