cloudflare
Version:
The official TypeScript library for the Cloudflare API
119 lines • 4.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.V1 = exports.BaseV1 = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const BlobsAPI = tslib_1.__importStar(require("./blobs.js"));
const blobs_1 = require("./blobs.js");
const KeysAPI = tslib_1.__importStar(require("./keys.js"));
const keys_1 = require("./keys.js");
const StatsAPI = tslib_1.__importStar(require("./stats.js"));
const stats_1 = require("./stats.js");
const VariantsAPI = tslib_1.__importStar(require("./variants.js"));
const variants_1 = require("./variants.js");
const pagination_1 = require("../../../core/pagination.js");
const uploads_1 = require("../../../internal/uploads.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseV1 = /* @__PURE__ */ (() => {
class BaseV1 extends resource_1.APIResource {
/**
* Upload an image to CF Images. Images up to 10 Megabytes can be uploaded using a
* single HTTP POST (multipart/form-data) request by sending an image file or
* passing a URL accessible to the API.
*
* @example
* ```ts
* const image = await client.images.v1.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/images/v1`, (0, uploads_1.multipartFormRequestOptions)({ body, ...options }, this._client))._thenUnwrap((obj) => obj.result);
}
/**
* List up to 100 images with one request. Use the optional parameters below to get
* a specific range of images.
*
* @deprecated
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/images/v1`, (pagination_1.V4PagePagination), { query, ...options });
}
/**
* Delete an image on Cloudflare Images. On success, all copies of the image are
* deleted and purged from cache.
*
* @example
* ```ts
* const v1 = await client.images.v1.delete('image_id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
delete(imageID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/images/v1/${imageID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Update a CF Images image's metadata, creator, or access control. On access
* control change, all copies of the image are purged from cache.
*
* @example
* ```ts
* const image = await client.images.v1.edit('image_id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
edit(imageID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/images/v1/${imageID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetch details for a CF Images image.
*
* @example
* ```ts
* const image = await client.images.v1.get('image_id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
get(imageID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/images/v1/${imageID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseV1._key = Object.freeze(['images', 'v1']);
return BaseV1;
})();
exports.BaseV1 = BaseV1;
var V1 = /* @__PURE__ */ (() => {
class V1 extends BaseV1 {
constructor() {
super(...arguments);
this.keys = new KeysAPI.Keys(this._client);
this.stats = new StatsAPI.Stats(this._client);
this.variants = new VariantsAPI.Variants(this._client);
this.blobs = new BlobsAPI.Blobs(this._client);
}
}
V1.Keys = keys_1.Keys;
V1.BaseKeys = keys_1.BaseKeys;
V1.Stats = stats_1.Stats;
V1.BaseStats = stats_1.BaseStats;
V1.Variants = variants_1.Variants;
V1.BaseVariants = variants_1.BaseVariants;
V1.Blobs = blobs_1.Blobs;
V1.BaseBlobs = blobs_1.BaseBlobs;
return V1;
})();
exports.V1 = V1;
//# sourceMappingURL=v1.js.map