UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

117 lines • 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Schemas = exports.BaseSchemas = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseSchemas = /* @__PURE__ */ (() => { class BaseSchemas extends resource_1.APIResource { /** * Uploads an OpenAPI schema that defines expected request formats for API * operations. * * @example * ```ts * const publicSchema = * await client.schemaValidation.schemas.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * kind: 'openapi_v3', * name: 'petstore schema', * source: '<schema file contents>', * validation_enabled: true, * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post((0, path_1.path) `/zones/${zone_id}/schema_validation/schemas`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists all OpenAPI schemas uploaded to API Security. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const publicSchema of client.schemaValidation.schemas.list( * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { zone_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/schema_validation/schemas`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Permanently removes an uploaded OpenAPI schema from API Security. Operations * using this schema will lose their validation rules. * * @example * ```ts * const schema = await client.schemaValidation.schemas.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(schemaID, params, options) { const { zone_id } = params; return this._client.delete((0, path_1.path) `/zones/${zone_id}/schema_validation/schemas/${schemaID}`, options)._thenUnwrap((obj) => obj.result); } /** * Enables or disables validation for an uploaded OpenAPI schema without changing * the schema document. * * @example * ```ts * const publicSchema = * await client.schemaValidation.schemas.edit( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(schemaID, params, options) { const { zone_id, ...body } = params; return this._client.patch((0, path_1.path) `/zones/${zone_id}/schema_validation/schemas/${schemaID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Gets the contents and metadata of a specific OpenAPI schema uploaded to API * Security. * * @example * ```ts * const publicSchema = * await client.schemaValidation.schemas.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(schemaID, params, options) { const { zone_id, ...query } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/schema_validation/schemas/${schemaID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseSchemas._key = Object.freeze([ 'schemaValidation', 'schemas', ]); return BaseSchemas; })(); exports.BaseSchemas = BaseSchemas; class Schemas extends BaseSchemas { } exports.Schemas = Schemas; //# sourceMappingURL=schemas.js.map