UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

75 lines • 2.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Locks = exports.BaseLocks = 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 BaseLocks = /* @__PURE__ */ (() => { class BaseLocks extends resource_1.APIResource { /** * Replaces the lock rules for an R2 bucket. Enabled rules prevent matching objects * from being overwritten or deleted for a duration, until a date, or indefinitely. * Rules apply to existing and newly uploaded objects. * * @example * ```ts * const lock = await client.r2.buckets.locks.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}/lock`, { body, ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Get lock rules for a bucket. * * @example * ```ts * const lock = await client.r2.buckets.locks.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}/lock`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } } BaseLocks._key = Object.freeze([ 'r2', 'buckets', 'locks', ]); return BaseLocks; })(); exports.BaseLocks = BaseLocks; class Locks extends BaseLocks { } exports.Locks = Locks; //# sourceMappingURL=locks.js.map