cloudflare
Version:
The official TypeScript library for the Cloudflare API
154 lines • 5.08 kB
text/typescript
import { APIResource } from "../../../core/resource.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class BaseLocks extends APIResource {
static readonly _key: readonly ['r2', 'buckets', 'locks'];
/**
* 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: string, params: LockUpdateParams, options?: RequestOptions): APIPromise<LockUpdateResponse>;
/**
* Get lock rules for a bucket.
*
* @example
* ```ts
* const lock = await client.r2.buckets.locks.get(
* 'example-bucket',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(bucketName: string, params: LockGetParams, options?: RequestOptions): APIPromise<LockGetResponse>;
}
export declare class Locks extends BaseLocks {
}
export type LockUpdateResponse = unknown;
export interface LockGetResponse {
rules?: Array<LockGetResponse.Rule>;
}
export declare namespace LockGetResponse {
interface Rule {
/**
* Unique identifier for this rule.
*/
id: string;
/**
* Condition to apply a lock rule to an object for how long in seconds.
*/
condition: Rule.R2LockRuleAgeCondition | Rule.R2LockRuleDateCondition | Rule.R2LockRuleIndefiniteCondition;
/**
* Whether or not this rule is in effect.
*/
enabled: boolean;
/**
* Rule will only apply to objects/uploads in the bucket that start with the given
* prefix, an empty prefix can be provided to scope rule to all objects/uploads.
*/
prefix?: string;
}
namespace Rule {
/**
* Condition to apply a lock rule to an object for how long in seconds.
*/
interface R2LockRuleAgeCondition {
maxAgeSeconds: number;
type: 'Age';
}
/**
* Condition to apply a lock rule to an object until a specific date.
*/
interface R2LockRuleDateCondition {
date: string;
type: 'Date';
}
/**
* Condition to apply a lock rule indefinitely.
*/
interface R2LockRuleIndefiniteCondition {
type: 'Indefinite';
}
}
}
export interface LockUpdateParams {
/**
* Path param: Cloudflare account ID that owns the R2 resource.
*/
account_id: string;
/**
* Body param
*/
rules?: Array<LockUpdateParams.Rule>;
/**
* Header param: Jurisdiction where objects in this bucket are guaranteed to be
* stored.
*/
'cf-r2-jurisdiction'?: 'default' | 'eu' | 'us' | 'fedramp' | 'fedramp-high';
}
export declare namespace LockUpdateParams {
interface Rule {
/**
* Unique identifier for this rule.
*/
id: string;
/**
* Condition to apply a lock rule to an object for how long in seconds.
*/
condition: Rule.R2LockRuleAgeCondition | Rule.R2LockRuleDateCondition | Rule.R2LockRuleIndefiniteCondition;
/**
* Whether or not this rule is in effect.
*/
enabled: boolean;
/**
* Rule will only apply to objects/uploads in the bucket that start with the given
* prefix, an empty prefix can be provided to scope rule to all objects/uploads.
*/
prefix?: string;
}
namespace Rule {
/**
* Condition to apply a lock rule to an object for how long in seconds.
*/
interface R2LockRuleAgeCondition {
maxAgeSeconds: number;
type: 'Age';
}
/**
* Condition to apply a lock rule to an object until a specific date.
*/
interface R2LockRuleDateCondition {
date: string;
type: 'Date';
}
/**
* Condition to apply a lock rule indefinitely.
*/
interface R2LockRuleIndefiniteCondition {
type: 'Indefinite';
}
}
}
export interface LockGetParams {
/**
* Path param: Cloudflare account ID that owns the R2 resource.
*/
account_id: string;
/**
* Header param: Jurisdiction where objects in this bucket are guaranteed to be
* stored.
*/
'cf-r2-jurisdiction'?: 'default' | 'eu' | 'us' | 'fedramp' | 'fedramp-high';
}
export declare namespace Locks {
export { type LockUpdateResponse as LockUpdateResponse, type LockGetResponse as LockGetResponse, type LockUpdateParams as LockUpdateParams, type LockGetParams as LockGetParams, };
}
//# sourceMappingURL=locks.d.mts.map