UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

70 lines • 2.75 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 BaseLifecycle = /* @__PURE__ */ (() => { class BaseLifecycle extends APIResource { /** * Replaces the object lifecycle rules for an R2 bucket. Rules match object-key * prefixes and can expire objects, abort incomplete multipart uploads, or * transition objects to Infrequent Access storage. * * @example * ```ts * const lifecycle = await client.r2.buckets.lifecycle.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}/lifecycle`, { body, ...options, headers: buildHeaders([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Get object lifecycle rules for a bucket. * * @example * ```ts * const lifecycle = await client.r2.buckets.lifecycle.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}/lifecycle`, { ...options, headers: buildHeaders([ { ...(cfR2Jurisdiction?.toString() != null ? { 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } } BaseLifecycle._key = Object.freeze([ 'r2', 'buckets', 'lifecycle', ]); return BaseLifecycle; })(); export class Lifecycle extends BaseLifecycle { } //# sourceMappingURL=lifecycle.mjs.map