cloudflare
Version:
The official TypeScript library for the Cloudflare API
108 lines • 4.03 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { V4PagePaginationArray, } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BasePacfiles = /* @__PURE__ */ (() => {
class BasePacfiles extends APIResource {
/**
* Create a new Zero Trust Gateway PAC file.
*
* @example
* ```ts
* const pacfile =
* await client.zeroTrust.gateway.pacfiles.create({
* account_id: '699d98642c564d2e855e9661899b7252',
* contents:
* 'function FindProxyForURL(url, host) { return "DIRECT"; }',
* name: 'Devops team',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/gateway/pacfiles`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Update a configured Zero Trust Gateway PAC file.
*
* @example
* ```ts
* const pacfile =
* await client.zeroTrust.gateway.pacfiles.update(
* 'ed35569b41ce4d1facfe683550f54086',
* {
* account_id: '699d98642c564d2e855e9661899b7252',
* contents:
* 'function FindProxyForURL(url, host) { return "DIRECT"; }',
* description: 'PAC file for Devops team',
* name: 'Devops team',
* },
* );
* ```
*/
update(pacfileID, params, options) {
const { account_id, ...body } = params;
return this._client.put(path `/accounts/${account_id}/gateway/pacfiles/${pacfileID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List all Zero Trust Gateway PAC files for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const pacfileListResponse of client.zeroTrust.gateway.pacfiles.list(
* { account_id: '699d98642c564d2e855e9661899b7252' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/gateway/pacfiles`, (V4PagePaginationArray), { query, ...options });
}
/**
* Delete a configured Zero Trust Gateway PAC file.
*
* @example
* ```ts
* const pacfile =
* await client.zeroTrust.gateway.pacfiles.delete(
* 'ed35569b41ce4d1facfe683550f54086',
* { account_id: '699d98642c564d2e855e9661899b7252' },
* );
* ```
*/
delete(pacfileID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/gateway/pacfiles/${pacfileID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get a single Zero Trust Gateway PAC file.
*
* @example
* ```ts
* const pacfile = await client.zeroTrust.gateway.pacfiles.get(
* 'ed35569b41ce4d1facfe683550f54086',
* { account_id: '699d98642c564d2e855e9661899b7252' },
* );
* ```
*/
get(pacfileID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/gateway/pacfiles/${pacfileID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePacfiles._key = Object.freeze([
'zeroTrust',
'gateway',
'pacfiles',
]);
return BasePacfiles;
})();
export class Pacfiles extends BasePacfiles {
}
//# sourceMappingURL=pacfiles.mjs.map