cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 3.36 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 BaseTemporaryCredentials extends APIResource {
static readonly _key: readonly ['r2', 'temporaryCredentials'];
/**
* Creates temporary access credentials on a bucket that can be optionally scoped
* to prefixes or objects.
*
* @example
* ```ts
* const temporaryCredential =
* await client.r2.temporaryCredentials.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* bucket: 'example-bucket',
* parentAccessKeyId: 'example-access-key-id',
* permission: 'object-read-write',
* ttlSeconds: 3600,
* });
* ```
*/
create(params: TemporaryCredentialCreateParams, options?: RequestOptions): APIPromise<TemporaryCredentialCreateResponse>;
}
export declare class TemporaryCredentials extends BaseTemporaryCredentials {
}
export interface TemporaryCredential {
/**
* Name of the R2 bucket.
*/
bucket: string;
/**
* Access key ID of the parent R2 API token. The temporary credentials cannot
* exceed this token's permissions.
*/
parentAccessKeyId: string;
/**
* Permissions allowed on the credentials.
*/
permission: 'admin-read-write' | 'admin-read-only' | 'object-read-write' | 'object-read-only';
/**
* Lifetime of the temporary credentials in seconds, up to 604800 seconds (7 days).
*/
ttlSeconds: number;
/**
* Optional object paths to scope the credentials to.
*/
objects?: Array<string>;
/**
* Optional prefix paths to scope the credentials to.
*/
prefixes?: Array<string>;
}
export interface TemporaryCredentialCreateResponse {
/**
* ID for new access key.
*/
accessKeyId?: string;
/**
* Secret access key.
*/
secretAccessKey?: string;
/**
* Security token.
*/
sessionToken?: string;
}
export interface TemporaryCredentialCreateParams {
/**
* Path param: Cloudflare account ID that owns the R2 resource.
*/
account_id: string;
/**
* Body param: Name of the R2 bucket.
*/
bucket: string;
/**
* Body param: Access key ID of the parent R2 API token. The temporary credentials
* cannot exceed this token's permissions.
*/
parentAccessKeyId: string;
/**
* Body param: Permissions allowed on the credentials.
*/
permission: 'admin-read-write' | 'admin-read-only' | 'object-read-write' | 'object-read-only';
/**
* Body param: Lifetime of the temporary credentials in seconds, up to 604800
* seconds (7 days).
*/
ttlSeconds: number;
/**
* Body param: Optional object paths to scope the credentials to.
*/
objects?: Array<string>;
/**
* Body param: Optional prefix paths to scope the credentials to.
*/
prefixes?: Array<string>;
}
export declare namespace TemporaryCredentials {
export { type TemporaryCredential as TemporaryCredential, type TemporaryCredentialCreateResponse as TemporaryCredentialCreateResponse, type TemporaryCredentialCreateParams as TemporaryCredentialCreateParams, };
}
//# sourceMappingURL=temporary-credentials.d.mts.map