UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

169 lines • 6.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Custom = exports.BaseCustom = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../../core/resource.js"); const headers_1 = require("../../../../internal/headers.js"); const path_1 = require("../../../../internal/utils/path.js"); var BaseCustom = /* @__PURE__ */ (() => { class BaseCustom extends resource_1.APIResource { /** * Register a new custom domain for an existing R2 bucket. * * @example * ```ts * const custom = * await client.r2.buckets.domains.custom.create( * 'example-bucket', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * domain: 'prefix.example-domain.com', * enabled: true, * zoneId: '36ca64a6d92827b8a6b90be344bb1bfd', * }, * ); * ``` */ create(bucketName, params, options) { const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/domains/custom`, { body, ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Edit the configuration for a custom domain on an existing R2 bucket. * * @example * ```ts * const custom = * await client.r2.buckets.domains.custom.update( * 'example-domain/custom-domain.com', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * bucket_name: 'example-bucket', * }, * ); * ``` */ update(domain, params, options) { const { account_id, bucket_name, 'cf-r2-jurisdiction': cfR2Jurisdiction, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { body, ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Gets a list of all custom domains registered with an existing R2 bucket. * * @example * ```ts * const customs = await client.r2.buckets.domains.custom.list( * 'example-bucket', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ list(bucketName, params, options) { const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/domains/custom`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Disconnects a custom domain from an R2 bucket and removes its configuration. * Access through other enabled custom domains or the bucket's r2.dev domain is * unaffected. * * @example * ```ts * const custom = * await client.r2.buckets.domains.custom.delete( * 'example-domain/custom-domain.com', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * bucket_name: 'example-bucket', * }, * ); * ``` */ delete(domain, params, options) { const { account_id, bucket_name, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Get the configuration for a custom domain on an existing R2 bucket. * * @example * ```ts * const custom = await client.r2.buckets.domains.custom.get( * 'example-domain/custom-domain.com', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * bucket_name: 'example-bucket', * }, * ); * ``` */ get(domain, params, options) { const { account_id, bucket_name, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } } BaseCustom._key = Object.freeze([ 'r2', 'buckets', 'domains', 'custom', ]); return BaseCustom; })(); exports.BaseCustom = BaseCustom; class Custom extends BaseCustom { } exports.Custom = Custom; //# sourceMappingURL=custom.js.map