cloudflare
Version:
The official TypeScript library for the Cloudflare API
103 lines • 3.83 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 BaseHostnameRoutes = /* @__PURE__ */ (() => {
class BaseHostnameRoutes extends APIResource {
/**
* Create a hostname route.
*
* @example
* ```ts
* const hostnameRoute =
* await client.zeroTrust.networks.hostnameRoutes.create({
* account_id: '699d98642c564d2e855e9661899b7252',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/zerotrust/routes/hostname`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists and filters hostname routes in an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const hostnameRoute of client.zeroTrust.networks.hostnameRoutes.list(
* { account_id: '699d98642c564d2e855e9661899b7252' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/zerotrust/routes/hostname`, (V4PagePaginationArray), { query, ...options });
}
/**
* Delete a hostname route.
*
* @example
* ```ts
* const hostnameRoute =
* await client.zeroTrust.networks.hostnameRoutes.delete(
* 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415',
* { account_id: '699d98642c564d2e855e9661899b7252' },
* );
* ```
*/
delete(hostnameRouteID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates a hostname route.
*
* @example
* ```ts
* const hostnameRoute =
* await client.zeroTrust.networks.hostnameRoutes.edit(
* 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415',
* { account_id: '699d98642c564d2e855e9661899b7252' },
* );
* ```
*/
edit(hostnameRouteID, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Get a hostname route.
*
* @example
* ```ts
* const hostnameRoute =
* await client.zeroTrust.networks.hostnameRoutes.get(
* 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415',
* { account_id: '699d98642c564d2e855e9661899b7252' },
* );
* ```
*/
get(hostnameRouteID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseHostnameRoutes._key = Object.freeze([
'zeroTrust',
'networks',
'hostnameRoutes',
]);
return BaseHostnameRoutes;
})();
export class HostnameRoutes extends BaseHostnameRoutes {
}
//# sourceMappingURL=hostname-routes.mjs.map