UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

164 lines • 6.4 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import { buildHeaders } from "../../../../internal/headers.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseCustom = /* @__PURE__ */ (() => { class BaseCustom extends 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(path `/accounts/${account_id}/r2/buckets/${bucketName}/domains/custom`, { body, ...options, headers: 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(path `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { body, ...options, headers: 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(path `/accounts/${account_id}/r2/buckets/${bucketName}/domains/custom`, { ...options, headers: 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(path `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { ...options, headers: 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(path `/accounts/${account_id}/r2/buckets/${bucket_name}/domains/custom/${domain}`, { ...options, headers: 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; })(); export class Custom extends BaseCustom { } //# sourceMappingURL=custom.mjs.map