cloudflare
Version:
The official TypeScript library for the Cloudflare API
59 lines • 2.55 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import * as ContentAPI from "./content.mjs";
import { BaseContent, Content } from "./content.mjs";
import * as RulesAPI from "./rules.mjs";
import { BaseRules, Rules, } from "./rules.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { multipartFormRequestOptions } from "../../internal/uploads.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseSnippets = /* @__PURE__ */ (() => {
class BaseSnippets extends APIResource {
/**
* Creates or updates a snippet belonging to the zone.
*/
update(snippetName, params, options) {
const { zone_id, ...body } = params;
return this._client.put(path `/zones/${zone_id}/snippets/${snippetName}`, multipartFormRequestOptions({ body, ...options }, this._client))._thenUnwrap((obj) => obj.result);
}
/**
* Fetches all snippets belonging to the zone.
*/
list(params, options) {
const { zone_id, ...query } = params;
return this._client.getAPIList(path `/zones/${zone_id}/snippets`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a snippet belonging to the zone. Returns a 4XX response if the zone or
* snippet no longer exists.
*/
delete(snippetName, params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/snippets/${snippetName}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Fetches a snippet belonging to the zone.
*/
get(snippetName, params, options) {
const { zone_id } = params;
return this._client.get(path `/zones/${zone_id}/snippets/${snippetName}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSnippets._key = Object.freeze(['snippets']);
return BaseSnippets;
})();
export var Snippets = /* @__PURE__ */ (() => {
class Snippets extends BaseSnippets {
constructor() {
super(...arguments);
this.content = new ContentAPI.Content(this._client);
this.rules = new RulesAPI.Rules(this._client);
}
}
Snippets.Content = Content;
Snippets.BaseContent = BaseContent;
Snippets.Rules = Rules;
Snippets.BaseRules = BaseRules;
return Snippets;
})();
//# sourceMappingURL=snippets.mjs.map