cloudflare
Version:
The official TypeScript library for the Cloudflare API
113 lines • 4.44 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as BlobsAPI from "./blobs.mjs";
import { BaseBlobs, Blobs } from "./blobs.mjs";
import * as KeysAPI from "./keys.mjs";
import { BaseKeys, Keys, } from "./keys.mjs";
import * as StatsAPI from "./stats.mjs";
import { BaseStats, Stats } from "./stats.mjs";
import * as VariantsAPI from "./variants.mjs";
import { BaseVariants, Variants, } from "./variants.mjs";
import { V4PagePagination } from "../../../core/pagination.mjs";
import { multipartFormRequestOptions } from "../../../internal/uploads.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseV1 = /* @__PURE__ */ (() => {
class BaseV1 extends 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(path `/accounts/${account_id}/images/v1`, 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(path `/accounts/${account_id}/images/v1`, (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(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(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(path `/accounts/${account_id}/images/v1/${imageID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseV1._key = Object.freeze(['images', 'v1']);
return BaseV1;
})();
export 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;
V1.BaseKeys = BaseKeys;
V1.Stats = Stats;
V1.BaseStats = BaseStats;
V1.Variants = Variants;
V1.BaseVariants = BaseVariants;
V1.Blobs = Blobs;
V1.BaseBlobs = BaseBlobs;
return V1;
})();
//# sourceMappingURL=v1.mjs.map