cloudflare
Version:
The official TypeScript library for the Cloudflare API
83 lines • 3.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Delegations = exports.BaseDelegations = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseDelegations = /* @__PURE__ */ (() => {
class BaseDelegations extends resource_1.APIResource {
/**
* Create a new account delegation for a given IP prefix.
*
* @example
* ```ts
* const delegations =
* await client.addressing.prefixes.delegations.create(
* '2af39739cc4e3b5910c918468bb89828',
* {
* account_id: '258def64c72dae45f3e4c8516e2111f2',
* cidr: '192.0.2.0/24',
* delegated_account_id:
* 'b1946ac92492d2347c6235b4d2611184',
* },
* );
* ```
*/
create(prefixID, params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/addressing/prefixes/${prefixID}/delegations`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List all delegations for a given account IP prefix.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const delegations of client.addressing.prefixes.delegations.list(
* '2af39739cc4e3b5910c918468bb89828',
* { account_id: '258def64c72dae45f3e4c8516e2111f2' },
* )) {
* // ...
* }
* ```
*/
list(prefixID, params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/addressing/prefixes/${prefixID}/delegations`, (pagination_1.SinglePage), options);
}
/**
* Delete an account delegation for a given IP prefix.
*
* @example
* ```ts
* const delegation =
* await client.addressing.prefixes.delegations.delete(
* 'd933b1530bc56c9953cf8ce166da8004',
* {
* account_id: '258def64c72dae45f3e4c8516e2111f2',
* prefix_id: '2af39739cc4e3b5910c918468bb89828',
* },
* );
* ```
*/
delete(delegationID, params, options) {
const { account_id, prefix_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/addressing/prefixes/${prefix_id}/delegations/${delegationID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDelegations._key = Object.freeze([
'addressing',
'prefixes',
'delegations',
]);
return BaseDelegations;
})();
exports.BaseDelegations = BaseDelegations;
class Delegations extends BaseDelegations {
}
exports.Delegations = Delegations;
//# sourceMappingURL=delegations.js.map