Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jun 19, 2024
1 parent e0cc0ec commit 6f020bd
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 4 additions & 9 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2631,15 +2631,16 @@ Methods:

## Settings

### SchemaValidation

Types:

- <code><a href="./src/resources/api-gateway/settings/schema-validation.ts">Settings</a></code>
- <code><a href="./src/resources/api-gateway/settings/settings.ts">Settings</a></code>

### SchemaValidation

Methods:

- <code title="put /zones/{zone_id}/api_gateway/settings/schema_validation">client.apiGateway.settings.schemaValidation.<a href="./src/resources/api-gateway/settings/schema-validation.ts">update</a>({ ...params }) -> Settings</code>
- <code title="patch /zones/{zone_id}/api_gateway/settings/schema_validation">client.apiGateway.settings.schemaValidation.<a href="./src/resources/api-gateway/settings/schema-validation.ts">edit</a>({ ...params }) -> Settings</code>
- <code title="get /zones/{zone_id}/api_gateway/settings/schema_validation">client.apiGateway.settings.schemaValidation.<a href="./src/resources/api-gateway/settings/schema-validation.ts">get</a>({ ...params }) -> Settings</code>

## UserSchemas
Expand Down Expand Up @@ -2669,12 +2670,6 @@ Methods:

- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations">client.apiGateway.userSchemas.operations.<a href="./src/resources/api-gateway/user-schemas/operations.ts">list</a>(schemaId, { ...params }) -> OperationListResponsesSinglePage</code>

## SchemaValidation

Methods:

- <code title="patch /zones/{zone_id}/api_gateway/settings/schema_validation">client.apiGateway.schemaValidation.<a href="./src/resources/api-gateway/schema-validation.ts">edit</a>({ ...params }) -> Settings</code>

# ManagedHeaders

Types:
Expand Down
6 changes: 0 additions & 6 deletions src/resources/api-gateway/api-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion src/resources/api-gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
59 changes: 0 additions & 59 deletions src/resources/api-gateway/schema-validation.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/resources/api-gateway/settings/index.ts
Original file line number Diff line number Diff line change
@@ -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';
62 changes: 46 additions & 16 deletions src/resources/api-gateway/settings/schema-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Settings> {
update(
params: SchemaValidationUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<SettingsAPI.Settings> {
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<SettingsAPI.Settings> {
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<Settings> {
get(
params: SchemaValidationGetParams,
options?: Core.RequestOptions,
): Core.APIPromise<SettingsAPI.Settings> {
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:
*
Expand All @@ -35,45 +61,49 @@ 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
*/
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:
* 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;
}
Expand All @@ -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;
}
28 changes: 27 additions & 1 deletion src/resources/api-gateway/settings/settings.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
}
33 changes: 0 additions & 33 deletions tests/api-resources/api-gateway/schema-validation.test.ts

This file was deleted.

21 changes: 21 additions & 0 deletions tests/api-resources/api-gateway/settings/schema-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 6f020bd

Please sign in to comment.