UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

100 lines 3.58 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.HostnameRoutesV4PagePaginationArray = exports.HostnameRoutes = void 0; const resource_1 = require("../../../resource.js"); const pagination_1 = require("../../../pagination.js"); class HostnameRoutes extends resource_1.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(`/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(`/accounts/${account_id}/zerotrust/routes/hostname`, HostnameRoutesV4PagePaginationArray, { 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(`/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(`/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(`/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteId}`, options)._thenUnwrap((obj) => obj.result); } } exports.HostnameRoutes = HostnameRoutes; class HostnameRoutesV4PagePaginationArray extends pagination_1.V4PagePaginationArray { } exports.HostnameRoutesV4PagePaginationArray = HostnameRoutesV4PagePaginationArray; HostnameRoutes.HostnameRoutesV4PagePaginationArray = HostnameRoutesV4PagePaginationArray; //# sourceMappingURL=hostname-routes.js.map