UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

74 lines 3.12 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from 'cloudflare/resource'; import * as V1API from 'cloudflare/resources/images/v1/v1'; import * as BlobsAPI from 'cloudflare/resources/images/v1/blobs'; import * as KeysAPI from 'cloudflare/resources/images/v1/keys'; import * as StatsAPI from 'cloudflare/resources/images/v1/stats'; import * as VariantsAPI from 'cloudflare/resources/images/v1/variants'; import { multipartFormRequestOptions } from 'cloudflare/core'; import { V4PagePagination } from 'cloudflare/pagination'; export class V1 extends APIResource { 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); } /** * Upload an image with up to 10 Megabytes using a single HTTP POST * (multipart/form-data) request. An image can be uploaded by sending an image file * or passing an accessible to an API url. */ create(params, options) { const { account_id, ...body } = params; return this._client.post(`/accounts/${account_id}/images/v1`, multipartFormRequestOptions({ body, ...options }))._thenUnwrap((obj) => obj.result); } /** * List up to 100 images with one request. Use the optional parameters below to get * a specific range of images. */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(`/accounts/${account_id}/images/v1`, V1ListResponsesV4PagePagination, { query, ...options, }); } /** * Delete an image on Cloudflare Images. On success, all copies of the image are * deleted and purged from cache. */ delete(imageId, params, options) { const { account_id } = params; return this._client.delete(`/accounts/${account_id}/images/v1/${imageId}`, options)._thenUnwrap((obj) => obj.result); } /** * Update image access control. On access control change, all copies of the image * are purged from cache. */ edit(imageId, params, options) { const { account_id, ...body } = params; return this._client.patch(`/accounts/${account_id}/images/v1/${imageId}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetch details for a single image. */ get(imageId, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/images/v1/${imageId}`, options)._thenUnwrap((obj) => obj.result); } } export class V1ListResponsesV4PagePagination extends V4PagePagination { } (function (V1) { V1.V1ListResponsesV4PagePagination = V1API.V1ListResponsesV4PagePagination; V1.Keys = KeysAPI.Keys; V1.Stats = StatsAPI.Stats; V1.Variants = VariantsAPI.Variants; V1.Blobs = BlobsAPI.Blobs; })(V1 || (V1 = {})); //# sourceMappingURL=v1.mjs.map