From 6f020bdc9db53a54b43cd48585cd831eaff6b9db Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:43:39 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#1017) --- .stats.yml | 2 +- api.md | 13 ++-- src/resources/api-gateway/api-gateway.ts | 6 -- src/resources/api-gateway/index.ts | 1 - .../api-gateway/schema-validation.ts | 59 ------------------ src/resources/api-gateway/settings/index.ts | 4 +- .../api-gateway/settings/schema-validation.ts | 62 ++++++++++++++----- .../api-gateway/settings/settings.ts | 28 ++++++++- .../api-gateway/schema-validation.test.ts | 33 ---------- .../settings/schema-validation.test.ts | 21 +++++++ 10 files changed, 101 insertions(+), 128 deletions(-) delete mode 100644 src/resources/api-gateway/schema-validation.ts delete mode 100644 tests/api-resources/api-gateway/schema-validation.test.ts diff --git a/.stats.yml b/.stats.yml index db0943d3d7..9a6188f099 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1348 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36a9d717773ebb507fd0744af578aa64b697030857c602c77458156a911fcab9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-07c6e460b4a34d21b666d639912027e5225b6d5e98748056a269965b196157ec.yml diff --git a/api.md b/api.md index 56966b0abc..7a3ab0b0c3 100644 --- a/api.md +++ b/api.md @@ -2631,15 +2631,16 @@ Methods: ## Settings -### SchemaValidation - Types: -- Settings +- Settings + +### SchemaValidation Methods: - client.apiGateway.settings.schemaValidation.update({ ...params }) -> Settings +- client.apiGateway.settings.schemaValidation.edit({ ...params }) -> Settings - client.apiGateway.settings.schemaValidation.get({ ...params }) -> Settings ## UserSchemas @@ -2669,12 +2670,6 @@ Methods: - client.apiGateway.userSchemas.operations.list(schemaId, { ...params }) -> OperationListResponsesSinglePage -## SchemaValidation - -Methods: - -- client.apiGateway.schemaValidation.edit({ ...params }) -> Settings - # ManagedHeaders Types: diff --git a/src/resources/api-gateway/api-gateway.ts b/src/resources/api-gateway/api-gateway.ts index 0957813e97..ee844ca289 100644 --- a/src/resources/api-gateway/api-gateway.ts +++ b/src/resources/api-gateway/api-gateway.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../resource'; import * as ConfigurationsAPI from './configurations'; -import * as SchemaValidationAPI from './schema-validation'; import * as SchemasAPI from './schemas'; import * as DiscoveryAPI from './discovery/discovery'; import * as OperationsAPI from './operations/operations'; @@ -16,9 +15,6 @@ export class APIGateway extends APIResource { schemas: SchemasAPI.Schemas = new SchemasAPI.Schemas(this._client); settings: SettingsAPI.Settings = new SettingsAPI.Settings(this._client); userSchemas: UserSchemasAPI.UserSchemas = new UserSchemasAPI.UserSchemas(this._client); - schemaValidation: SchemaValidationAPI.SchemaValidation = new SchemaValidationAPI.SchemaValidation( - this._client, - ); } export namespace APIGateway { @@ -55,6 +51,4 @@ export namespace APIGateway { export import UserSchemaDeleteParams = UserSchemasAPI.UserSchemaDeleteParams; export import UserSchemaEditParams = UserSchemasAPI.UserSchemaEditParams; export import UserSchemaGetParams = UserSchemasAPI.UserSchemaGetParams; - export import SchemaValidation = SchemaValidationAPI.SchemaValidation; - export import SchemaValidationEditParams = SchemaValidationAPI.SchemaValidationEditParams; } diff --git a/src/resources/api-gateway/index.ts b/src/resources/api-gateway/index.ts index 80ea14c8e8..4f88ad0080 100644 --- a/src/resources/api-gateway/index.ts +++ b/src/resources/api-gateway/index.ts @@ -40,5 +40,4 @@ export { UserSchemas, } from './user-schemas/index'; export { SchemaListResponse, SchemaListParams, Schemas } from './schemas'; -export { SchemaValidationEditParams, SchemaValidation } from './schema-validation'; export { Settings } from './settings/index'; diff --git a/src/resources/api-gateway/schema-validation.ts b/src/resources/api-gateway/schema-validation.ts deleted file mode 100644 index cc8b8d52dd..0000000000 --- a/src/resources/api-gateway/schema-validation.ts +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import * as Core from '../../core'; -import { APIResource } from '../../resource'; -import * as SchemaValidationAPI from './schema-validation'; -import * as SettingsSchemaValidationAPI from './settings/schema-validation'; - -export class SchemaValidation extends APIResource { - /** - * Updates zone level schema validation settings on the zone - */ - edit( - params: SchemaValidationEditParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return this._client.patch(`/zones/${zone_id}/api_gateway/settings/schema_validation`, { - body, - ...options, - }); - } -} - -export interface SchemaValidationEditParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The default mitigation action used when there is no mitigation - * action defined on the operation Mitigation actions are as follows: - * - * - `log` - log request when request does not conform to schema - * - `block` - deny access to the site when request does not conform to schema - * - * A special value of of `none` will skip running schema validation entirely for - * the request when there is no mitigation action defined on the operation - * - * `null` will have no effect. - */ - validation_default_mitigation_action?: 'none' | 'log' | 'block' | null; - - /** - * Body param: When set, this overrides both zone level and operation level - * mitigation actions. - * - * - `none` will skip running schema validation entirely for the request - * - * To clear any override, use the special value `disable_override` - * - * `null` will have no effect. - */ - validation_override_mitigation_action?: 'none' | 'disable_override' | null; -} - -export namespace SchemaValidation { - export import SchemaValidationEditParams = SchemaValidationAPI.SchemaValidationEditParams; -} diff --git a/src/resources/api-gateway/settings/index.ts b/src/resources/api-gateway/settings/index.ts index dd78b487cc..d7a6691090 100644 --- a/src/resources/api-gateway/settings/index.ts +++ b/src/resources/api-gateway/settings/index.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Settings } from './settings'; export { - Settings, SchemaValidationUpdateParams, + SchemaValidationEditParams, SchemaValidationGetParams, SchemaValidation, } from './schema-validation'; +export { Settings } from './settings'; diff --git a/src/resources/api-gateway/settings/schema-validation.ts b/src/resources/api-gateway/settings/schema-validation.ts index ef00ebf503..4d06ce1f2b 100644 --- a/src/resources/api-gateway/settings/schema-validation.ts +++ b/src/resources/api-gateway/settings/schema-validation.ts @@ -3,29 +3,55 @@ import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import * as SchemaValidationAPI from './schema-validation'; +import * as SettingsAPI from './settings'; export class SchemaValidation extends APIResource { /** * Updates zone level schema validation settings on the zone */ - update(params: SchemaValidationUpdateParams, options?: Core.RequestOptions): Core.APIPromise { + update( + params: SchemaValidationUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { const { zone_id, ...body } = params; return this._client.put(`/zones/${zone_id}/api_gateway/settings/schema_validation`, { body, ...options }); } + /** + * Updates zone level schema validation settings on the zone + */ + edit( + params: SchemaValidationEditParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { zone_id, ...body } = params; + return this._client.patch(`/zones/${zone_id}/api_gateway/settings/schema_validation`, { + body, + ...options, + }); + } + /** * Retrieves zone level schema validation settings currently set on the zone */ - get(params: SchemaValidationGetParams, options?: Core.RequestOptions): Core.APIPromise { + get( + params: SchemaValidationGetParams, + options?: Core.RequestOptions, + ): Core.APIPromise { const { zone_id } = params; return this._client.get(`/zones/${zone_id}/api_gateway/settings/schema_validation`, options); } } -export interface Settings { +export interface SchemaValidationUpdateParams { /** - * The default mitigation action used when there is no mitigation action defined on - * the operation + * Path param: Identifier + */ + zone_id: string; + + /** + * Body param: The default mitigation action used when there is no mitigation + * action defined on the operation * * Mitigation actions are as follows: * @@ -35,18 +61,21 @@ export interface Settings { * A special value of of `none` will skip running schema validation entirely for * the request when there is no mitigation action defined on the operation */ - validation_default_mitigation_action?: 'none' | 'log' | 'block'; + validation_default_mitigation_action: 'none' | 'log' | 'block'; /** - * When set, this overrides both zone level and operation level mitigation actions. + * Body param: When set, this overrides both zone level and operation level + * mitigation actions. * * - `none` will skip running schema validation entirely for the request * - `null` indicates that no override is in place + * + * To clear any override, use the special value `disable_override` or `null` */ - validation_override_mitigation_action?: 'none' | null; + validation_override_mitigation_action?: 'none' | 'disable_override' | null; } -export interface SchemaValidationUpdateParams { +export interface SchemaValidationEditParams { /** * Path param: Identifier */ @@ -54,26 +83,27 @@ export interface SchemaValidationUpdateParams { /** * Body param: The default mitigation action used when there is no mitigation - * action defined on the operation - * - * Mitigation actions are as follows: + * action defined on the operation Mitigation actions are as follows: * * - `log` - log request when request does not conform to schema * - `block` - deny access to the site when request does not conform to schema * * A special value of of `none` will skip running schema validation entirely for * the request when there is no mitigation action defined on the operation + * + * `null` will have no effect. */ - validation_default_mitigation_action: 'none' | 'log' | 'block'; + validation_default_mitigation_action?: 'none' | 'log' | 'block' | null; /** * Body param: When set, this overrides both zone level and operation level * mitigation actions. * * - `none` will skip running schema validation entirely for the request - * - `null` indicates that no override is in place * - * To clear any override, use the special value `disable_override` or `null` + * To clear any override, use the special value `disable_override` + * + * `null` will have no effect. */ validation_override_mitigation_action?: 'none' | 'disable_override' | null; } @@ -86,7 +116,7 @@ export interface SchemaValidationGetParams { } export namespace SchemaValidation { - export import Settings = SchemaValidationAPI.Settings; export import SchemaValidationUpdateParams = SchemaValidationAPI.SchemaValidationUpdateParams; + export import SchemaValidationEditParams = SchemaValidationAPI.SchemaValidationEditParams; export import SchemaValidationGetParams = SchemaValidationAPI.SchemaValidationGetParams; } diff --git a/src/resources/api-gateway/settings/settings.ts b/src/resources/api-gateway/settings/settings.ts index ce174db515..46c01c9f25 100644 --- a/src/resources/api-gateway/settings/settings.ts +++ b/src/resources/api-gateway/settings/settings.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../resource'; +import * as SettingsAPI from './settings'; import * as SchemaValidationAPI from './schema-validation'; export class Settings extends APIResource { @@ -9,9 +10,34 @@ export class Settings extends APIResource { ); } +export interface Settings { + /** + * The default mitigation action used when there is no mitigation action defined on + * the operation + * + * Mitigation actions are as follows: + * + * - `log` - log request when request does not conform to schema + * - `block` - deny access to the site when request does not conform to schema + * + * A special value of of `none` will skip running schema validation entirely for + * the request when there is no mitigation action defined on the operation + */ + validation_default_mitigation_action?: 'none' | 'log' | 'block'; + + /** + * When set, this overrides both zone level and operation level mitigation actions. + * + * - `none` will skip running schema validation entirely for the request + * - `null` indicates that no override is in place + */ + validation_override_mitigation_action?: 'none' | null; +} + export namespace Settings { + export import Settings = SettingsAPI.Settings; export import SchemaValidation = SchemaValidationAPI.SchemaValidation; - export import Settings = SchemaValidationAPI.Settings; export import SchemaValidationUpdateParams = SchemaValidationAPI.SchemaValidationUpdateParams; + export import SchemaValidationEditParams = SchemaValidationAPI.SchemaValidationEditParams; export import SchemaValidationGetParams = SchemaValidationAPI.SchemaValidationGetParams; } diff --git a/tests/api-resources/api-gateway/schema-validation.test.ts b/tests/api-resources/api-gateway/schema-validation.test.ts deleted file mode 100644 index fd0ea78112..0000000000 --- a/tests/api-resources/api-gateway/schema-validation.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const cloudflare = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource schemaValidation', () => { - test('edit: only required params', async () => { - const responsePromise = cloudflare.apiGateway.schemaValidation.edit({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('edit: required and optional params', async () => { - const response = await cloudflare.apiGateway.schemaValidation.edit({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - validation_default_mitigation_action: 'block', - validation_override_mitigation_action: 'none', - }); - }); -}); diff --git a/tests/api-resources/api-gateway/settings/schema-validation.test.ts b/tests/api-resources/api-gateway/settings/schema-validation.test.ts index c57bcf2868..2f06ec1e95 100644 --- a/tests/api-resources/api-gateway/settings/schema-validation.test.ts +++ b/tests/api-resources/api-gateway/settings/schema-validation.test.ts @@ -32,6 +32,27 @@ describe('resource schemaValidation', () => { }); }); + test('edit: only required params', async () => { + const responsePromise = cloudflare.apiGateway.settings.schemaValidation.edit({ + zone_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('edit: required and optional params', async () => { + const response = await cloudflare.apiGateway.settings.schemaValidation.edit({ + zone_id: '023e105f4ecef8ad9ca31a8372d0c353', + validation_default_mitigation_action: 'block', + validation_override_mitigation_action: 'none', + }); + }); + test('get: only required params', async () => { const responsePromise = cloudflare.apiGateway.settings.schemaValidation.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353',