UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

102 lines • 4.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SippyResource = exports.BaseSippyResource = 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 BaseSippyResource = /* @__PURE__ */ (() => { class BaseSippyResource extends resource_1.APIResource { /** * Configures and enables Sippy on-demand migration for an R2 bucket. When a * requested object is missing from R2, Sippy serves it from the configured source * storage provider and copies it to R2. * * @example * ```ts * const sippy = await client.r2.buckets.sippy.update( * 'example-bucket', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(bucketName, params, options) { const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/sippy`, { body, ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Disables Sippy on-demand migration for an R2 bucket. Requests no longer fetch * missing objects from the source storage provider. Objects already copied to R2 * remain in the bucket. * * @example * ```ts * const sippy = await client.r2.buckets.sippy.delete( * 'example-bucket', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(bucketName, params, options) { const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/sippy`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Gets configuration for Sippy for an existing R2 bucket. * * @example * ```ts * const sippy = await client.r2.buckets.sippy.get( * 'example-bucket', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(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}/sippy`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } } BaseSippyResource._key = Object.freeze([ 'r2', 'buckets', 'sippy', ]); return BaseSippyResource; })(); exports.BaseSippyResource = BaseSippyResource; class SippyResource extends BaseSippyResource { } exports.SippyResource = SippyResource; //# sourceMappingURL=sippy.js.map