UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

108 lines • 3.9 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as IPFSUniversalPathsAPI from "./ipfs-universal-paths/ipfs-universal-paths.mjs"; import { BaseIPFSUniversalPaths, IPFSUniversalPaths } from "./ipfs-universal-paths/ipfs-universal-paths.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseHostnames = /* @__PURE__ */ (() => { class BaseHostnames extends APIResource { /** * Create Web3 Hostname * * @example * ```ts * const hostname = await client.web3.hostnames.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'gateway.example.com', * target: 'ipfs', * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post(path `/zones/${zone_id}/web3/hostnames`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * List Web3 Hostnames * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const hostname of client.web3.hostnames.list({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { zone_id } = params; return this._client.getAPIList(path `/zones/${zone_id}/web3/hostnames`, (SinglePage), options); } /** * Delete Web3 Hostname * * @example * ```ts * const hostname = await client.web3.hostnames.delete( * '023e105f4ecef8ad9ca31a8372d0c353', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(identifier, params, options) { const { zone_id } = params; return this._client.delete(path `/zones/${zone_id}/web3/hostnames/${identifier}`, options)._thenUnwrap((obj) => obj.result); } /** * Edit Web3 Hostname * * @example * ```ts * const hostname = await client.web3.hostnames.edit( * '023e105f4ecef8ad9ca31a8372d0c353', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(identifier, params, options) { const { zone_id, ...body } = params; return this._client.patch(path `/zones/${zone_id}/web3/hostnames/${identifier}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Web3 Hostname Details * * @example * ```ts * const hostname = await client.web3.hostnames.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(identifier, params, options) { const { zone_id } = params; return this._client.get(path `/zones/${zone_id}/web3/hostnames/${identifier}`, options)._thenUnwrap((obj) => obj.result); } } BaseHostnames._key = Object.freeze([ 'web3', 'hostnames', ]); return BaseHostnames; })(); export var Hostnames = /* @__PURE__ */ (() => { class Hostnames extends BaseHostnames { constructor() { super(...arguments); this.ipfsUniversalPaths = new IPFSUniversalPathsAPI.IPFSUniversalPaths(this._client); } } Hostnames.IPFSUniversalPaths = IPFSUniversalPaths; Hostnames.BaseIPFSUniversalPaths = BaseIPFSUniversalPaths; return Hostnames; })(); //# sourceMappingURL=hostnames.mjs.map