cloudflare
Version:
The official TypeScript library for the Cloudflare API
118 lines • 4.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Variants = exports.BaseVariants = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseVariants = /* @__PURE__ */ (() => {
class BaseVariants extends resource_1.APIResource {
/**
* Create a CF Images variant that allows you to resize images for different use
* cases.
*
* @example
* ```ts
* const variant = await client.images.v1.variants.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* id: 'hero',
* options: {
* fit: 'scale-down',
* height: 768,
* metadata: 'none',
* width: 1366,
* },
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/images/v1/variants`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List existing CF Images variants.
*
* @example
* ```ts
* const variant = await client.images.v1.variants.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/images/v1/variants`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Delete a CF Images variant. This will purge the cache for all images associated
* with the variant.
*
* @example
* ```ts
* const variant = await client.images.v1.variants.delete(
* 'hero',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(variantID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/images/v1/variants/${variantID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Update a CF Images variant. This will purge the cache for all images associated
* with the variant.
*
* @example
* ```ts
* const response = await client.images.v1.variants.edit(
* 'hero',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* options: {
* fit: 'scale-down',
* height: 768,
* metadata: 'none',
* width: 1366,
* },
* },
* );
* ```
*/
edit(variantID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/images/v1/variants/${variantID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetch details for a CF Images variant.
*
* @example
* ```ts
* const variant = await client.images.v1.variants.get(
* 'hero',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(variantID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/images/v1/variants/${variantID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseVariants._key = Object.freeze([
'images',
'v1',
'variants',
]);
return BaseVariants;
})();
exports.BaseVariants = BaseVariants;
class Variants extends BaseVariants {
}
exports.Variants = Variants;
//# sourceMappingURL=variants.js.map