cloudflare
Version:
The official TypeScript library for the Cloudflare API
122 lines • 4.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sinkholes = exports.BaseSinkholes = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const IngressesAPI = tslib_1.__importStar(require("./ingresses.js"));
const ingresses_1 = require("./ingresses.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseSinkholes = /* @__PURE__ */ (() => {
class BaseSinkholes extends resource_1.APIResource {
/**
* Create a new sinkhole. Logs of large request bodies will be truncated, but the
* full request body can be recorded in R2. If you wish to record large request
* bodies in R2, include the R2 key ID, key secret, and bucket name in the request
* body.
*
* @example
* ```ts
* const sinkhole = await client.intel.sinkholes.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'name',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/intel/sinkholes`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Replaces the name or R2 configuration of the specified sinkhole. This is a full
* replacement. All fields, including r2_secret, must be re-supplied. Omitting
* r2_secret overwrites the stored value with an empty string.
*
* @example
* ```ts
* const sinkhole = await client.intel.sinkholes.update(
* '93defa6e909e464e8c89a85859f36d3c',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'name',
* },
* );
* ```
*/
update(sinkholeID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/intel/sinkholes/${sinkholeID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists sinkholes owned by the account for redirecting malicious traffic.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const sinkhole of client.intel.sinkholes.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* })) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/intel/sinkholes`, (pagination_1.SinglePage), options);
}
/**
* Delete the specified sinkhole. The sinkhole must not have any active ingress
* rules defined. A 409 response code indicates that this condition is not met.
*
* @example
* ```ts
* const sinkhole = await client.intel.sinkholes.delete(
* '93defa6e909e464e8c89a85859f36d3c',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(sinkholeID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/intel/sinkholes/${sinkholeID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get the specified sinkhole by its unique identifier.
*
* @example
* ```ts
* const sinkhole = await client.intel.sinkholes.get(
* '93defa6e909e464e8c89a85859f36d3c',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(sinkholeID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/intel/sinkholes/${sinkholeID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSinkholes._key = Object.freeze([
'intel',
'sinkholes',
]);
return BaseSinkholes;
})();
exports.BaseSinkholes = BaseSinkholes;
var Sinkholes = /* @__PURE__ */ (() => {
class Sinkholes extends BaseSinkholes {
constructor() {
super(...arguments);
this.ingresses = new IngressesAPI.Ingresses(this._client);
}
}
Sinkholes.Ingresses = ingresses_1.Ingresses;
Sinkholes.BaseIngresses = ingresses_1.BaseIngresses;
return Sinkholes;
})();
exports.Sinkholes = Sinkholes;
//# sourceMappingURL=sinkholes.js.map