UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

70 lines • 2.69 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 BaseLocks = /* @__PURE__ */ (() => { class BaseLocks extends 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(path `/accounts/${account_id}/r2/buckets/${bucketName}/lock`, { body, ...options, headers: 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(path `/accounts/${account_id}/r2/buckets/${bucketName}/lock`, { ...options, headers: 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; })(); export class Locks extends BaseLocks { } //# sourceMappingURL=locks.mjs.map