UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

112 lines • 4.15 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseSchemas = /* @__PURE__ */ (() => { class BaseSchemas extends 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(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(path `/zones/${zone_id}/schema_validation/schemas`, (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(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(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(path `/zones/${zone_id}/schema_validation/schemas/${schemaID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseSchemas._key = Object.freeze([ 'schemaValidation', 'schemas', ]); return BaseSchemas; })(); export class Schemas extends BaseSchemas { } //# sourceMappingURL=schemas.mjs.map