cloudflare
Version:
The official TypeScript library for the Cloudflare API
113 lines • 4.67 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { SinglePage } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseDetections = /* @__PURE__ */ (() => {
class BaseDetections extends APIResource {
/**
* Create a detection location for credentials that the default scan locations do
* not cover, using Rules language expressions such as
* `lookup_json_string(http.request.body.raw, "user")`. Only the username
* expression is required, and Leaked Credential Checks must be enabled on the
* zone.
*
* @example
* ```ts
* const detection =
* await client.leakedCredentialChecks.detections.create({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post(path `/zones/${zone_id}/leaked-credential-checks/detections`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Update the username and password expressions of an existing detection location,
* identified by its detection ID. Both expressions are overwritten, so omitting
* the password expression clears it.
*
* @example
* ```ts
* const detection =
* await client.leakedCredentialChecks.detections.update(
* '18a14bafaa8eb1df04ce683ec18c765e',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(detectionID, params, options) {
const { zone_id, ...body } = params;
return this._client.put(path `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List the user-defined detection locations configured for Leaked Credential
* Checks, each with its own identifier. A custom detection location tells the WAF
* where to find the username and password in requests to your application.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const detectionListResponse of client.leakedCredentialChecks.detections.list(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { zone_id } = params;
return this._client.getAPIList(path `/zones/${zone_id}/leaked-credential-checks/detections`, (SinglePage), options);
}
/**
* Delete a user-defined detection location, identified by its detection ID.
* Incoming requests are then scanned using only the default scan locations and the
* detection locations that remain.
*
* @example
* ```ts
* const detection =
* await client.leakedCredentialChecks.detections.delete(
* '18a14bafaa8eb1df04ce683ec18c765e',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(detectionID, params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get the username and password expressions of a single user-defined detection
* location, identified by its detection ID.
*
* @example
* ```ts
* const detection =
* await client.leakedCredentialChecks.detections.get(
* '18a14bafaa8eb1df04ce683ec18c765e',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(detectionID, params, options) {
const { zone_id } = params;
return this._client.get(path `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDetections._key = Object.freeze([
'leakedCredentialChecks',
'detections',
]);
return BaseDetections;
})();
export class Detections extends BaseDetections {
}
//# sourceMappingURL=detections.mjs.map