UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

95 lines 3.3 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../resource.mjs"; import { V4PagePaginationArray } from "../../../pagination.mjs"; export class HostnameRoutes 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(`/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); } } export class HostnameRoutesV4PagePaginationArray extends V4PagePaginationArray { } HostnameRoutes.HostnameRoutesV4PagePaginationArray = HostnameRoutesV4PagePaginationArray; //# sourceMappingURL=hostname-routes.mjs.map