cloudflare
Version:
The official TypeScript library for the Cloudflare API
82 lines • 3.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Managed = exports.BaseManaged = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const headers_1 = require("../../../../internal/headers.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseManaged = /* @__PURE__ */ (() => {
class BaseManaged extends resource_1.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((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/domains/managed`, {
body,
...options,
headers: (0, headers_1.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((0, path_1.path) `/accounts/${account_id}/r2/buckets/${bucketName}/domains/managed`, {
...options,
headers: (0, headers_1.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;
})();
exports.BaseManaged = BaseManaged;
class Managed extends BaseManaged {
}
exports.Managed = Managed;
//# sourceMappingURL=managed.js.map