cloudflare
Version:
The official TypeScript library for the Cloudflare API
105 lines • 3.91 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as ItemsAPI from "./items.mjs";
import { BaseItems, Items, } from "./items.mjs";
import { SinglePage, V4PagePaginationArray, } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BasePrefixes = /* @__PURE__ */ (() => {
class BasePrefixes extends APIResource {
/**
* Create a prefix for an account.
*
* @example
* ```ts
* const prefix =
* await client.DDoSProtection.advancedTCPProtection.prefixes.create(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* comment: 'comment',
* excluded: true,
* prefix: '192.0.2.0/24',
* },
* );
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List all prefixes for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const prefixListResponse of client.DDoSProtection.advancedTCPProtection.prefixes.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes`, (V4PagePaginationArray), { query, ...options });
}
/**
* Create multiple prefixes for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const prefixBulkCreateResponse of client.DDoSProtection.advancedTCPProtection.prefixes.bulkCreate(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* body: [
* {
* comment: 'comment',
* excluded: true,
* prefix: '192.0.2.0/24',
* },
* ],
* },
* )) {
* // ...
* }
* ```
*/
bulkCreate(params, options) {
const { account_id, body } = params;
return this._client.getAPIList(path `/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes/bulk`, (SinglePage), { body: body, method: 'post', ...options });
}
/**
* Delete all prefixes for an account.
*
* @example
* ```ts
* const response =
* await client.DDoSProtection.advancedTCPProtection.prefixes.bulkDelete(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
bulkDelete(params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes`, options);
}
}
BasePrefixes._key = Object.freeze(['DDoSProtection', 'advancedTCPProtection', 'prefixes']);
return BasePrefixes;
})();
export var Prefixes = /* @__PURE__ */ (() => {
class Prefixes extends BasePrefixes {
constructor() {
super(...arguments);
this.items = new ItemsAPI.Items(this._client);
}
}
Prefixes.Items = Items;
Prefixes.BaseItems = BaseItems;
return Prefixes;
})();
//# sourceMappingURL=prefixes.mjs.map