cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 3.48 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { V4PagePagination } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseRules = /* @__PURE__ */ (() => {
class BaseRules extends APIResource {
/**
* Create a DEX Rule.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dex.rules.create({
* account_id: '01a7362d577a6c3019a474fd6f485823',
* match: 'match',
* name: 'name',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/dex/rules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Update a DEX Rule.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dex.rules.update(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '01a7362d577a6c3019a474fd6f485823' },
* );
* ```
*/
update(ruleID, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/dex/rules/${ruleID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List DEX Rules.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const ruleListResponse of client.zeroTrust.dex.rules.list(
* {
* account_id: '01a7362d577a6c3019a474fd6f485823',
* page: 1,
* per_page: 10,
* },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/dex/rules`, (V4PagePagination), { query, ...options });
}
/**
* Delete a DEX Rule.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dex.rules.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '01a7362d577a6c3019a474fd6f485823' },
* );
* ```
*/
delete(ruleID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/dex/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get details for a DEX Rule.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dex.rules.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '01a7362d577a6c3019a474fd6f485823' },
* );
* ```
*/
get(ruleID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/dex/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRules._key = Object.freeze([
'zeroTrust',
'dex',
'rules',
]);
return BaseRules;
})();
export class Rules extends BaseRules {
}
//# sourceMappingURL=rules.mjs.map