cloudflare
Version:
The official TypeScript library for the Cloudflare API
116 lines • 4.54 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as IngressesAPI from "./ingresses.mjs";
import { BaseIngresses, Ingresses, } from "./ingresses.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseSinkholes = /* @__PURE__ */ (() => {
class BaseSinkholes extends 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(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(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(path `/accounts/${account_id}/intel/sinkholes`, (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(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(path `/accounts/${account_id}/intel/sinkholes/${sinkholeID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSinkholes._key = Object.freeze([
'intel',
'sinkholes',
]);
return BaseSinkholes;
})();
export var Sinkholes = /* @__PURE__ */ (() => {
class Sinkholes extends BaseSinkholes {
constructor() {
super(...arguments);
this.ingresses = new IngressesAPI.Ingresses(this._client);
}
}
Sinkholes.Ingresses = Ingresses;
Sinkholes.BaseIngresses = BaseIngresses;
return Sinkholes;
})();
//# sourceMappingURL=sinkholes.mjs.map