cloudflare
Version:
The official TypeScript library for the Cloudflare API
97 lines • 3.87 kB
JavaScript
// 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 BaseSippyResource = /* @__PURE__ */ (() => {
class BaseSippyResource extends APIResource {
/**
* Configures and enables Sippy on-demand migration for an R2 bucket. When a
* requested object is missing from R2, Sippy serves it from the configured source
* storage provider and copies it to R2.
*
* @example
* ```ts
* const sippy = await client.r2.buckets.sippy.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}/sippy`, {
body,
...options,
headers: buildHeaders([
{
...(cfR2Jurisdiction?.toString() != null ?
{ 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() }
: undefined),
},
options?.headers,
]),
})._thenUnwrap((obj) => obj.result);
}
/**
* Disables Sippy on-demand migration for an R2 bucket. Requests no longer fetch
* missing objects from the source storage provider. Objects already copied to R2
* remain in the bucket.
*
* @example
* ```ts
* const sippy = await client.r2.buckets.sippy.delete(
* 'example-bucket',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(bucketName, params, options) {
const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params;
return this._client.delete(path `/accounts/${account_id}/r2/buckets/${bucketName}/sippy`, {
...options,
headers: buildHeaders([
{
...(cfR2Jurisdiction?.toString() != null ?
{ 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() }
: undefined),
},
options?.headers,
]),
})._thenUnwrap((obj) => obj.result);
}
/**
* Gets configuration for Sippy for an existing R2 bucket.
*
* @example
* ```ts
* const sippy = await client.r2.buckets.sippy.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}/sippy`, {
...options,
headers: buildHeaders([
{
...(cfR2Jurisdiction?.toString() != null ?
{ 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() }
: undefined),
},
options?.headers,
]),
})._thenUnwrap((obj) => obj.result);
}
}
BaseSippyResource._key = Object.freeze([
'r2',
'buckets',
'sippy',
]);
return BaseSippyResource;
})();
export class SippyResource extends BaseSippyResource {
}
//# sourceMappingURL=sippy.mjs.map