cloudflare
Version:
The official TypeScript library for the Cloudflare API
77 lines • 3 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 BaseManaged = /* @__PURE__ */ (() => {
class BaseManaged extends APIResource {
/**
* Enables or disables public access to the R2 bucket through its managed r2.dev
* domain. Custom domain access is unaffected. The r2.dev domain is rate-limited
* and intended for development use.
*
* @example
* ```ts
* const managed =
* await client.r2.buckets.domains.managed.update(
* 'example-bucket',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* enabled: true,
* },
* );
* ```
*/
update(bucketName, params, options) {
const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction, ...body } = params;
return this._client.put(path `/accounts/${account_id}/r2/buckets/${bucketName}/domains/managed`, {
body,
...options,
headers: buildHeaders([
{
...(cfR2Jurisdiction?.toString() != null ?
{ 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() }
: undefined),
},
options?.headers,
]),
})._thenUnwrap((obj) => obj.result);
}
/**
* Gets the R2 bucket's managed r2.dev domain and whether public access is enabled.
* The r2.dev domain is rate-limited and intended for development use.
*
* @example
* ```ts
* const manageds =
* await client.r2.buckets.domains.managed.list(
* 'example-bucket',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
list(bucketName, params, options) {
const { account_id, 'cf-r2-jurisdiction': cfR2Jurisdiction } = params;
return this._client.get(path `/accounts/${account_id}/r2/buckets/${bucketName}/domains/managed`, {
...options,
headers: buildHeaders([
{
...(cfR2Jurisdiction?.toString() != null ?
{ 'cf-r2-jurisdiction': cfR2Jurisdiction?.toString() }
: undefined),
},
options?.headers,
]),
})._thenUnwrap((obj) => obj.result);
}
}
BaseManaged._key = Object.freeze([
'r2',
'buckets',
'domains',
'managed',
]);
return BaseManaged;
})();
export class Managed extends BaseManaged {
}
//# sourceMappingURL=managed.mjs.map