From 72020d71553f30988fb546f5baf6699bb9f28809 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:07:38 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#1141) --- .stats.yml | 2 +- api.md | 14 +- src/resources/api-gateway/api-gateway.ts | 6 +- src/resources/api-gateway/configurations.ts | 23 +- .../api-gateway/discovery/discovery.ts | 10 +- src/resources/api-gateway/discovery/index.ts | 2 +- .../api-gateway/discovery/operations.ts | 21 +- src/resources/api-gateway/index.ts | 8 +- src/resources/api-gateway/operations/index.ts | 4 +- .../api-gateway/operations/operations.ts | 656 ++++++++++++++++-- .../api-gateway/user-schemas/index.ts | 4 +- .../api-gateway/user-schemas/operations.ts | 22 +- .../api-gateway/user-schemas/user-schemas.ts | 35 +- .../api-gateway/configurations.test.ts | 1 + .../api-gateway/discovery/operations.test.ts | 8 +- .../api-gateway/operations/operations.test.ts | 2 +- .../user-schemas/operations.test.ts | 4 +- .../user-schemas/user-schemas.test.ts | 4 +- 18 files changed, 681 insertions(+), 145 deletions(-) diff --git a/.stats.yml b/.stats.yml index 10fd2e7e73..a7c4ebd6ec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1256 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-74d68374448e03b29a39bb6cdf6c39cdeaaaa691dd9c38f46a26a1d562c8ee37.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b116e60da4a69a05bc8823c2397e4a33d111c82a6b458ea4f480d0ba52ea8de0.yml diff --git a/api.md b/api.md index 13d9542e3f..3ae4322470 100644 --- a/api.md +++ b/api.md @@ -2086,7 +2086,7 @@ Types: Methods: -- client.apiGateway.discovery.operations.list({ ...params }) -> DiscoveryOperationsSinglePage +- client.apiGateway.discovery.operations.list({ ...params }) -> DiscoveryOperationsV4PagePaginationArray - client.apiGateway.discovery.operations.edit(operationId, { ...params }) -> OperationEditResponse ## Operations @@ -2095,14 +2095,16 @@ Types: - APIShield - OperationCreateResponse +- OperationListResponse - OperationDeleteResponse +- OperationGetResponse Methods: -- client.apiGateway.operations.create([ ...body ]) -> OperationCreateResponse | null -- client.apiGateway.operations.list({ ...params }) -> APIShieldsSinglePage +- client.apiGateway.operations.create([ ...body ]) -> OperationCreateResponse +- client.apiGateway.operations.list({ ...params }) -> OperationListResponsesV4PagePaginationArray - client.apiGateway.operations.delete(operationId, { ...params }) -> OperationDeleteResponse -- client.apiGateway.operations.get(operationId, { ...params }) -> APIShield +- client.apiGateway.operations.get(operationId, { ...params }) -> OperationGetResponse ### SchemaValidation @@ -2154,7 +2156,7 @@ Types: Methods: - client.apiGateway.userSchemas.create({ ...params }) -> SchemaUpload -- client.apiGateway.userSchemas.list({ ...params }) -> PublicSchemasSinglePage +- client.apiGateway.userSchemas.list({ ...params }) -> PublicSchemasV4PagePaginationArray - client.apiGateway.userSchemas.delete(schemaId, { ...params }) -> UserSchemaDeleteResponse - client.apiGateway.userSchemas.edit(schemaId, { ...params }) -> PublicSchema - client.apiGateway.userSchemas.get(schemaId, { ...params }) -> PublicSchema @@ -2167,7 +2169,7 @@ Types: Methods: -- client.apiGateway.userSchemas.operations.list(schemaId, { ...params }) -> OperationListResponsesSinglePage +- client.apiGateway.userSchemas.operations.list(schemaId, { ...params }) -> OperationListResponsesV4PagePaginationArray # ManagedHeaders diff --git a/src/resources/api-gateway/api-gateway.ts b/src/resources/api-gateway/api-gateway.ts index ee844ca289..4f13f5a1a1 100644 --- a/src/resources/api-gateway/api-gateway.ts +++ b/src/resources/api-gateway/api-gateway.ts @@ -30,8 +30,10 @@ export namespace APIGateway { export import Operations = OperationsAPI.Operations; export import APIShield = OperationsAPI.APIShield; export import OperationCreateResponse = OperationsAPI.OperationCreateResponse; + export import OperationListResponse = OperationsAPI.OperationListResponse; export import OperationDeleteResponse = OperationsAPI.OperationDeleteResponse; - export import APIShieldsSinglePage = OperationsAPI.APIShieldsSinglePage; + export import OperationGetResponse = OperationsAPI.OperationGetResponse; + export import OperationListResponsesV4PagePaginationArray = OperationsAPI.OperationListResponsesV4PagePaginationArray; export import OperationCreateParams = OperationsAPI.OperationCreateParams; export import OperationListParams = OperationsAPI.OperationListParams; export import OperationDeleteParams = OperationsAPI.OperationDeleteParams; @@ -45,7 +47,7 @@ export namespace APIGateway { export import PublicSchema = UserSchemasAPI.PublicSchema; export import SchemaUpload = UserSchemasAPI.SchemaUpload; export import UserSchemaDeleteResponse = UserSchemasAPI.UserSchemaDeleteResponse; - export import PublicSchemasSinglePage = UserSchemasAPI.PublicSchemasSinglePage; + export import PublicSchemasV4PagePaginationArray = UserSchemasAPI.PublicSchemasV4PagePaginationArray; export import UserSchemaCreateParams = UserSchemasAPI.UserSchemaCreateParams; export import UserSchemaListParams = UserSchemasAPI.UserSchemaListParams; export import UserSchemaDeleteParams = UserSchemasAPI.UserSchemaDeleteParams; diff --git a/src/resources/api-gateway/configurations.ts b/src/resources/api-gateway/configurations.ts index fd72218bc5..4fc5d930f6 100644 --- a/src/resources/api-gateway/configurations.ts +++ b/src/resources/api-gateway/configurations.ts @@ -3,6 +3,7 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; import * as ConfigurationsAPI from './configurations'; +import * as UserSchemasAPI from './user-schemas/user-schemas'; export class Configurations extends APIResource { /** @@ -13,12 +14,7 @@ export class Configurations extends APIResource { options?: Core.RequestOptions, ): Core.APIPromise { const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/api_gateway/configuration`, { - body, - ...options, - }) as Core.APIPromise<{ result: ConfigurationUpdateResponse }> - )._thenUnwrap((obj) => obj.result); + return this._client.put(`/zones/${zone_id}/api_gateway/configuration`, { body, ...options }); } /** @@ -36,7 +32,7 @@ export class Configurations extends APIResource { } export interface Configuration { - auth_id_characteristics?: Array< + auth_id_characteristics: Array< Configuration.APIShieldAuthIDCharacteristic | Configuration.APIShieldAuthIDCharacteristicJwtClaim >; } @@ -79,7 +75,16 @@ export namespace Configuration { } } -export type ConfigurationUpdateResponse = unknown | string | null; +export interface ConfigurationUpdateResponse { + errors: UserSchemasAPI.Message; + + messages: UserSchemasAPI.Message; + + /** + * Whether the API call was successful + */ + success: true; +} export interface ConfigurationUpdateParams { /** @@ -90,7 +95,7 @@ export interface ConfigurationUpdateParams { /** * Body param: */ - auth_id_characteristics?: Array< + auth_id_characteristics: Array< | ConfigurationUpdateParams.APIShieldAuthIDCharacteristic | ConfigurationUpdateParams.APIShieldAuthIDCharacteristicJwtClaim >; diff --git a/src/resources/api-gateway/discovery/discovery.ts b/src/resources/api-gateway/discovery/discovery.ts index ac15c13368..192f1b7682 100644 --- a/src/resources/api-gateway/discovery/discovery.ts +++ b/src/resources/api-gateway/discovery/discovery.ts @@ -4,7 +4,7 @@ import { APIResource } from '../../../resource'; import * as Core from '../../../core'; import * as DiscoveryAPI from './discovery'; import * as OperationsAPI from './operations'; -import { SinglePage } from '../../../pagination'; +import { V4PagePaginationArray } from '../../../pagination'; export class Discovery extends APIResource { operations: OperationsAPI.Operations = new OperationsAPI.Operations(this._client); @@ -23,11 +23,11 @@ export class Discovery extends APIResource { } } -export class DiscoveryOperationsSinglePage extends SinglePage {} +export class DiscoveryOperationsV4PagePaginationArray extends V4PagePaginationArray {} export interface DiscoveryOperation { /** - * UUID identifier + * UUID */ id: string; @@ -91,9 +91,9 @@ export namespace DiscoveryOperation { } export interface DiscoveryGetResponse { - schemas?: Array; + schemas: Array; - timestamp?: string; + timestamp: string; } export interface DiscoveryGetParams { diff --git a/src/resources/api-gateway/discovery/index.ts b/src/resources/api-gateway/discovery/index.ts index d9a28a8a0f..613cea3e21 100644 --- a/src/resources/api-gateway/discovery/index.ts +++ b/src/resources/api-gateway/discovery/index.ts @@ -4,7 +4,7 @@ export { DiscoveryOperation, DiscoveryGetResponse, DiscoveryGetParams, - DiscoveryOperationsSinglePage, + DiscoveryOperationsV4PagePaginationArray, Discovery, } from './discovery'; export { OperationEditResponse, OperationListParams, OperationEditParams, Operations } from './operations'; diff --git a/src/resources/api-gateway/discovery/operations.ts b/src/resources/api-gateway/discovery/operations.ts index d74cf40812..eceff512c3 100644 --- a/src/resources/api-gateway/discovery/operations.ts +++ b/src/resources/api-gateway/discovery/operations.ts @@ -4,7 +4,8 @@ import { APIResource } from '../../../resource'; import * as Core from '../../../core'; import * as OperationsAPI from './operations'; import * as DiscoveryAPI from './discovery'; -import { DiscoveryOperationsSinglePage } from './discovery'; +import { DiscoveryOperationsV4PagePaginationArray } from './discovery'; +import { type V4PagePaginationArrayParams } from '../../../pagination'; export class Operations extends APIResource { /** @@ -13,11 +14,11 @@ export class Operations extends APIResource { list( params: OperationListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id, ...query } = params; return this._client.getAPIList( `/zones/${zone_id}/api_gateway/discovery/operations`, - DiscoveryOperationsSinglePage, + DiscoveryOperationsV4PagePaginationArray, { query, ...options }, ); } @@ -51,7 +52,7 @@ export interface OperationEditResponse { state?: 'review' | 'saved' | 'ignored'; } -export interface OperationListParams { +export interface OperationListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier */ @@ -98,16 +99,6 @@ export interface OperationListParams { */ origin?: 'ML' | 'SessionIdentifier'; - /** - * Query param: Page number of paginated results. - */ - page?: unknown; - - /** - * Query param: Maximum number of results per page. - */ - per_page?: unknown; - /** * Query param: Filter results to only include discovery results in a particular * state. States are as follows @@ -142,4 +133,4 @@ export namespace Operations { export import OperationEditParams = OperationsAPI.OperationEditParams; } -export { DiscoveryOperationsSinglePage }; +export { DiscoveryOperationsV4PagePaginationArray }; diff --git a/src/resources/api-gateway/index.ts b/src/resources/api-gateway/index.ts index 4f88ad0080..1d7cb1a5d1 100644 --- a/src/resources/api-gateway/index.ts +++ b/src/resources/api-gateway/index.ts @@ -4,12 +4,14 @@ export { APIGateway } from './api-gateway'; export { APIShield, OperationCreateResponse, + OperationListResponse, OperationDeleteResponse, + OperationGetResponse, OperationCreateParams, OperationListParams, OperationDeleteParams, OperationGetParams, - APIShieldsSinglePage, + OperationListResponsesV4PagePaginationArray, Operations, } from './operations/index'; export { @@ -23,7 +25,7 @@ export { DiscoveryOperation, DiscoveryGetResponse, DiscoveryGetParams, - DiscoveryOperationsSinglePage, + DiscoveryOperationsV4PagePaginationArray, Discovery, } from './discovery/index'; export { @@ -36,7 +38,7 @@ export { UserSchemaDeleteParams, UserSchemaEditParams, UserSchemaGetParams, - PublicSchemasSinglePage, + PublicSchemasV4PagePaginationArray, UserSchemas, } from './user-schemas/index'; export { SchemaListResponse, SchemaListParams, Schemas } from './schemas'; diff --git a/src/resources/api-gateway/operations/index.ts b/src/resources/api-gateway/operations/index.ts index b1d264f242..97da31c431 100644 --- a/src/resources/api-gateway/operations/index.ts +++ b/src/resources/api-gateway/operations/index.ts @@ -3,12 +3,14 @@ export { APIShield, OperationCreateResponse, + OperationListResponse, OperationDeleteResponse, + OperationGetResponse, OperationCreateParams, OperationListParams, OperationDeleteParams, OperationGetParams, - APIShieldsSinglePage, + OperationListResponsesV4PagePaginationArray, Operations, } from './operations'; export { diff --git a/src/resources/api-gateway/operations/operations.ts b/src/resources/api-gateway/operations/operations.ts index dfaa3d4626..393fb265a8 100644 --- a/src/resources/api-gateway/operations/operations.ts +++ b/src/resources/api-gateway/operations/operations.ts @@ -4,7 +4,8 @@ import { APIResource } from '../../../resource'; import * as Core from '../../../core'; import * as OperationsAPI from './operations'; import * as SchemaValidationAPI from './schema-validation'; -import { SinglePage } from '../../../pagination'; +import * as UserSchemasAPI from '../user-schemas/user-schemas'; +import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; export class Operations extends APIResource { schemaValidation: SchemaValidationAPI.SchemaValidation = new SchemaValidationAPI.SchemaValidation( @@ -21,13 +22,13 @@ export class Operations extends APIResource { create( params: OperationCreateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { const { zone_id, body } = params; return ( this._client.post(`/zones/${zone_id}/api_gateway/operations`, { body: body, ...options, - }) as Core.APIPromise<{ result: OperationCreateResponse | null }> + }) as Core.APIPromise<{ result: OperationCreateResponse }> )._thenUnwrap((obj) => obj.result); } @@ -37,12 +38,13 @@ export class Operations extends APIResource { list( params: OperationListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/api_gateway/operations`, APIShieldsSinglePage, { - query, - ...options, - }); + return this._client.getAPIList( + `/zones/${zone_id}/api_gateway/operations`, + OperationListResponsesV4PagePaginationArray, + { query, ...options }, + ); } /** @@ -54,35 +56,595 @@ export class Operations extends APIResource { options?: Core.RequestOptions, ): Core.APIPromise { const { zone_id } = params; + return this._client.delete(`/zones/${zone_id}/api_gateway/operations/${operationId}`, options); + } + + /** + * Retrieve information about an operation + */ + get( + operationId: string, + params: OperationGetParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { zone_id, ...query } = params; return ( - this._client.delete( - `/zones/${zone_id}/api_gateway/operations/${operationId}`, - options, - ) as Core.APIPromise<{ result: OperationDeleteResponse }> + this._client.get(`/zones/${zone_id}/api_gateway/operations/${operationId}`, { + query, + ...options, + }) as Core.APIPromise<{ result: OperationGetResponse }> )._thenUnwrap((obj) => obj.result); } +} + +export class OperationListResponsesV4PagePaginationArray extends V4PagePaginationArray {} + +export interface APIShield { + /** + * The endpoint which can contain path parameter templates in curly braces, each + * will be replaced from left to right with {varN}, starting with {var1}, during + * insertion. This will further be Cloudflare-normalized upon insertion. See: + * https://developers.cloudflare.com/rules/normalization/how-it-works/. + */ + endpoint: string; + + /** + * RFC3986-compliant host. + */ + host: string; + + last_updated: string; + + /** + * The HTTP method used to access the endpoint. + */ + method: 'GET' | 'POST' | 'HEAD' | 'OPTIONS' | 'PUT' | 'DELETE' | 'CONNECT' | 'PATCH' | 'TRACE'; + + /** + * UUID + */ + operation_id: string; + + features?: + | APIShield.APIShieldOperationFeatureThresholds + | APIShield.APIShieldOperationFeatureParameterSchemas + | APIShield.APIShieldOperationFeatureAPIRouting + | APIShield.APIShieldOperationFeatureConfidenceIntervals + | APIShield.APIShieldOperationFeatureSchemaInfo; +} + +export namespace APIShield { + export interface APIShieldOperationFeatureThresholds { + thresholds?: APIShieldOperationFeatureThresholds.Thresholds; + } + + export namespace APIShieldOperationFeatureThresholds { + export interface Thresholds { + /** + * The total number of auth-ids seen across this calculation. + */ + auth_id_tokens?: number; + + /** + * The number of data points used for the threshold suggestion calculation. + */ + data_points?: number; + + last_updated?: string; + + /** + * The p50 quantile of requests (in period_seconds). + */ + p50?: number; + + /** + * The p90 quantile of requests (in period_seconds). + */ + p90?: number; + + /** + * The p99 quantile of requests (in period_seconds). + */ + p99?: number; + + /** + * The period over which this threshold is suggested. + */ + period_seconds?: number; + + /** + * The estimated number of requests covered by these calculations. + */ + requests?: number; + + /** + * The suggested threshold in requests done by the same auth_id or period_seconds. + */ + suggested_threshold?: number; + } + } + + export interface APIShieldOperationFeatureParameterSchemas { + parameter_schemas: APIShieldOperationFeatureParameterSchemas.ParameterSchemas; + } + + export namespace APIShieldOperationFeatureParameterSchemas { + export interface ParameterSchemas { + last_updated?: string; + + /** + * An operation schema object containing a response. + */ + parameter_schemas?: ParameterSchemas.ParameterSchemas; + } + + export namespace ParameterSchemas { + /** + * An operation schema object containing a response. + */ + export interface ParameterSchemas { + /** + * An array containing the learned parameter schemas. + */ + parameters?: Array; + + /** + * An empty response object. This field is required to yield a valid operation + * schema. + */ + responses?: unknown | null; + } + } + } + + export interface APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + api_routing?: APIShieldOperationFeatureAPIRouting.APIRouting; + } + + export namespace APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + export interface APIRouting { + last_updated?: string; + + /** + * Target route. + */ + route?: string; + } + } + + export interface APIShieldOperationFeatureConfidenceIntervals { + confidence_intervals?: APIShieldOperationFeatureConfidenceIntervals.ConfidenceIntervals; + } + + export namespace APIShieldOperationFeatureConfidenceIntervals { + export interface ConfidenceIntervals { + last_updated?: string; + + suggested_threshold?: ConfidenceIntervals.SuggestedThreshold; + } + + export namespace ConfidenceIntervals { + export interface SuggestedThreshold { + confidence_intervals?: SuggestedThreshold.ConfidenceIntervals; + + /** + * Suggested threshold. + */ + mean?: number; + } + + export namespace SuggestedThreshold { + export interface ConfidenceIntervals { + /** + * Upper and lower bound for percentile estimate + */ + p90?: ConfidenceIntervals.P90; + + /** + * Upper and lower bound for percentile estimate + */ + p95?: ConfidenceIntervals.P95; + + /** + * Upper and lower bound for percentile estimate + */ + p99?: ConfidenceIntervals.P99; + } + + export namespace ConfidenceIntervals { + /** + * Upper and lower bound for percentile estimate + */ + export interface P90 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + + /** + * Upper and lower bound for percentile estimate + */ + export interface P95 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + + /** + * Upper and lower bound for percentile estimate + */ + export interface P99 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + } + } + } + } + + export interface APIShieldOperationFeatureSchemaInfo { + schema_info?: APIShieldOperationFeatureSchemaInfo.SchemaInfo; + } + + export namespace APIShieldOperationFeatureSchemaInfo { + export interface SchemaInfo { + /** + * Schema active on endpoint. + */ + active_schema?: SchemaInfo.ActiveSchema; + + /** + * True if a Cloudflare-provided learned schema is available for this endpoint. + */ + learned_available?: boolean; + + /** + * Action taken on requests failing validation. + */ + mitigation_action?: 'none' | 'log' | 'block' | null; + } + + export namespace SchemaInfo { + /** + * Schema active on endpoint. + */ + export interface ActiveSchema { + /** + * UUID + */ + id?: string; + + created_at?: string; + + /** + * True if schema is Cloudflare-provided. + */ + is_learned?: boolean; + + /** + * Schema file name. + */ + name?: string; + } + } + } +} + +export type OperationCreateResponse = Array; + +export interface OperationListResponse { + /** + * The endpoint which can contain path parameter templates in curly braces, each + * will be replaced from left to right with {varN}, starting with {var1}, during + * insertion. This will further be Cloudflare-normalized upon insertion. See: + * https://developers.cloudflare.com/rules/normalization/how-it-works/. + */ + endpoint: string; + + /** + * RFC3986-compliant host. + */ + host: string; + + last_updated: string; + + /** + * The HTTP method used to access the endpoint. + */ + method: 'GET' | 'POST' | 'HEAD' | 'OPTIONS' | 'PUT' | 'DELETE' | 'CONNECT' | 'PATCH' | 'TRACE'; + + /** + * UUID + */ + operation_id: string; + + features?: + | OperationListResponse.APIShieldOperationFeatureThresholds + | OperationListResponse.APIShieldOperationFeatureParameterSchemas + | OperationListResponse.APIShieldOperationFeatureAPIRouting + | OperationListResponse.APIShieldOperationFeatureConfidenceIntervals + | OperationListResponse.APIShieldOperationFeatureSchemaInfo; +} + +export namespace OperationListResponse { + export interface APIShieldOperationFeatureThresholds { + thresholds?: APIShieldOperationFeatureThresholds.Thresholds; + } + + export namespace APIShieldOperationFeatureThresholds { + export interface Thresholds { + /** + * The total number of auth-ids seen across this calculation. + */ + auth_id_tokens?: number; + + /** + * The number of data points used for the threshold suggestion calculation. + */ + data_points?: number; + + last_updated?: string; + + /** + * The p50 quantile of requests (in period_seconds). + */ + p50?: number; + + /** + * The p90 quantile of requests (in period_seconds). + */ + p90?: number; + + /** + * The p99 quantile of requests (in period_seconds). + */ + p99?: number; + + /** + * The period over which this threshold is suggested. + */ + period_seconds?: number; + + /** + * The estimated number of requests covered by these calculations. + */ + requests?: number; + + /** + * The suggested threshold in requests done by the same auth_id or period_seconds. + */ + suggested_threshold?: number; + } + } - /** - * Retrieve information about an operation - */ - get( - operationId: string, - params: OperationGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...query } = params; - return ( - this._client.get(`/zones/${zone_id}/api_gateway/operations/${operationId}`, { - query, - ...options, - }) as Core.APIPromise<{ result: APIShield }> - )._thenUnwrap((obj) => obj.result); + export interface APIShieldOperationFeatureParameterSchemas { + parameter_schemas: APIShieldOperationFeatureParameterSchemas.ParameterSchemas; + } + + export namespace APIShieldOperationFeatureParameterSchemas { + export interface ParameterSchemas { + last_updated?: string; + + /** + * An operation schema object containing a response. + */ + parameter_schemas?: ParameterSchemas.ParameterSchemas; + } + + export namespace ParameterSchemas { + /** + * An operation schema object containing a response. + */ + export interface ParameterSchemas { + /** + * An array containing the learned parameter schemas. + */ + parameters?: Array; + + /** + * An empty response object. This field is required to yield a valid operation + * schema. + */ + responses?: unknown | null; + } + } + } + + export interface APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + api_routing?: APIShieldOperationFeatureAPIRouting.APIRouting; + } + + export namespace APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + export interface APIRouting { + last_updated?: string; + + /** + * Target route. + */ + route?: string; + } + } + + export interface APIShieldOperationFeatureConfidenceIntervals { + confidence_intervals?: APIShieldOperationFeatureConfidenceIntervals.ConfidenceIntervals; + } + + export namespace APIShieldOperationFeatureConfidenceIntervals { + export interface ConfidenceIntervals { + last_updated?: string; + + suggested_threshold?: ConfidenceIntervals.SuggestedThreshold; + } + + export namespace ConfidenceIntervals { + export interface SuggestedThreshold { + confidence_intervals?: SuggestedThreshold.ConfidenceIntervals; + + /** + * Suggested threshold. + */ + mean?: number; + } + + export namespace SuggestedThreshold { + export interface ConfidenceIntervals { + /** + * Upper and lower bound for percentile estimate + */ + p90?: ConfidenceIntervals.P90; + + /** + * Upper and lower bound for percentile estimate + */ + p95?: ConfidenceIntervals.P95; + + /** + * Upper and lower bound for percentile estimate + */ + p99?: ConfidenceIntervals.P99; + } + + export namespace ConfidenceIntervals { + /** + * Upper and lower bound for percentile estimate + */ + export interface P90 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + + /** + * Upper and lower bound for percentile estimate + */ + export interface P95 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + + /** + * Upper and lower bound for percentile estimate + */ + export interface P99 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } + } + } + } + } + + export interface APIShieldOperationFeatureSchemaInfo { + schema_info?: APIShieldOperationFeatureSchemaInfo.SchemaInfo; + } + + export namespace APIShieldOperationFeatureSchemaInfo { + export interface SchemaInfo { + /** + * Schema active on endpoint. + */ + active_schema?: SchemaInfo.ActiveSchema; + + /** + * True if a Cloudflare-provided learned schema is available for this endpoint. + */ + learned_available?: boolean; + + /** + * Action taken on requests failing validation. + */ + mitigation_action?: 'none' | 'log' | 'block' | null; + } + + export namespace SchemaInfo { + /** + * Schema active on endpoint. + */ + export interface ActiveSchema { + /** + * UUID + */ + id?: string; + + created_at?: string; + + /** + * True if schema is Cloudflare-provided. + */ + is_learned?: boolean; + + /** + * Schema file name. + */ + name?: string; + } + } } } -export class APIShieldsSinglePage extends SinglePage {} +export interface OperationDeleteResponse { + errors: UserSchemasAPI.Message; -export interface APIShield { + messages: UserSchemasAPI.Message; + + /** + * Whether the API call was successful + */ + success: true; +} + +export interface OperationGetResponse { /** * The endpoint which can contain path parameter templates in curly braces, each * will be replaced from left to right with {varN}, starting with {var1}, during @@ -104,19 +666,19 @@ export interface APIShield { method: 'GET' | 'POST' | 'HEAD' | 'OPTIONS' | 'PUT' | 'DELETE' | 'CONNECT' | 'PATCH' | 'TRACE'; /** - * UUID identifier + * UUID */ operation_id: string; features?: - | APIShield.APIShieldOperationFeatureThresholds - | APIShield.APIShieldOperationFeatureParameterSchemas - | APIShield.APIShieldOperationFeatureAPIRouting - | APIShield.APIShieldOperationFeatureConfidenceIntervals - | APIShield.APIShieldOperationFeatureSchemaInfo; + | OperationGetResponse.APIShieldOperationFeatureThresholds + | OperationGetResponse.APIShieldOperationFeatureParameterSchemas + | OperationGetResponse.APIShieldOperationFeatureAPIRouting + | OperationGetResponse.APIShieldOperationFeatureConfidenceIntervals + | OperationGetResponse.APIShieldOperationFeatureSchemaInfo; } -export namespace APIShield { +export namespace OperationGetResponse { export interface APIShieldOperationFeatureThresholds { thresholds?: APIShieldOperationFeatureThresholds.Thresholds; } @@ -338,7 +900,7 @@ export namespace APIShield { */ export interface ActiveSchema { /** - * UUID identifier + * UUID */ id?: string; @@ -358,10 +920,6 @@ export namespace APIShield { } } -export type OperationCreateResponse = Array; - -export type OperationDeleteResponse = unknown | string | null; - export interface OperationCreateParams { /** * Path param: Identifier @@ -396,7 +954,7 @@ export namespace OperationCreateParams { } } -export interface OperationListParams { +export interface OperationListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier */ @@ -434,16 +992,6 @@ export interface OperationListParams { * available for ordering as well, e.g., `thresholds.suggested_threshold`. */ order?: 'method' | 'host' | 'endpoint' | 'thresholds.$key'; - - /** - * Query param: Page number of paginated results. - */ - page?: unknown; - - /** - * Query param: Number of results to return per page - */ - per_page?: number; } export interface OperationDeleteParams { @@ -470,8 +1018,10 @@ export interface OperationGetParams { export namespace Operations { export import APIShield = OperationsAPI.APIShield; export import OperationCreateResponse = OperationsAPI.OperationCreateResponse; + export import OperationListResponse = OperationsAPI.OperationListResponse; export import OperationDeleteResponse = OperationsAPI.OperationDeleteResponse; - export import APIShieldsSinglePage = OperationsAPI.APIShieldsSinglePage; + export import OperationGetResponse = OperationsAPI.OperationGetResponse; + export import OperationListResponsesV4PagePaginationArray = OperationsAPI.OperationListResponsesV4PagePaginationArray; export import OperationCreateParams = OperationsAPI.OperationCreateParams; export import OperationListParams = OperationsAPI.OperationListParams; export import OperationDeleteParams = OperationsAPI.OperationDeleteParams; diff --git a/src/resources/api-gateway/user-schemas/index.ts b/src/resources/api-gateway/user-schemas/index.ts index 65baad7b56..2d22f3ec5e 100644 --- a/src/resources/api-gateway/user-schemas/index.ts +++ b/src/resources/api-gateway/user-schemas/index.ts @@ -10,12 +10,12 @@ export { UserSchemaDeleteParams, UserSchemaEditParams, UserSchemaGetParams, - PublicSchemasSinglePage, + PublicSchemasV4PagePaginationArray, UserSchemas, } from './user-schemas'; export { OperationListResponse, OperationListParams, - OperationListResponsesSinglePage, + OperationListResponsesV4PagePaginationArray, Operations, } from './operations'; diff --git a/src/resources/api-gateway/user-schemas/operations.ts b/src/resources/api-gateway/user-schemas/operations.ts index 339e4a653a..58fd6ad7a5 100644 --- a/src/resources/api-gateway/user-schemas/operations.ts +++ b/src/resources/api-gateway/user-schemas/operations.ts @@ -4,7 +4,7 @@ import { APIResource } from '../../../resource'; import * as Core from '../../../core'; import * as UserSchemasOperationsAPI from './operations'; import * as OperationsAPI from '../operations/operations'; -import { SinglePage } from '../../../pagination'; +import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; export class Operations extends APIResource { /** @@ -15,17 +15,17 @@ export class Operations extends APIResource { schemaId: string, params: OperationListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id, ...query } = params; return this._client.getAPIList( `/zones/${zone_id}/api_gateway/user_schemas/${schemaId}/operations`, - OperationListResponsesSinglePage, + OperationListResponsesV4PagePaginationArray, { query, ...options }, ); } } -export class OperationListResponsesSinglePage extends SinglePage {} +export class OperationListResponsesV4PagePaginationArray extends V4PagePaginationArray {} export type OperationListResponse = OperationsAPI.APIShield | OperationListResponse.APIShieldBasicOperation; @@ -51,7 +51,7 @@ export namespace OperationListResponse { } } -export interface OperationListParams { +export interface OperationListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier */ @@ -86,20 +86,10 @@ export interface OperationListParams { * from the schema that already exist in API Shield Endpoint Management. */ operation_status?: 'new' | 'existing'; - - /** - * Query param: Page number of paginated results. - */ - page?: unknown; - - /** - * Query param: Maximum number of results per page. - */ - per_page?: unknown; } export namespace Operations { export import OperationListResponse = UserSchemasOperationsAPI.OperationListResponse; - export import OperationListResponsesSinglePage = UserSchemasOperationsAPI.OperationListResponsesSinglePage; + export import OperationListResponsesV4PagePaginationArray = UserSchemasOperationsAPI.OperationListResponsesV4PagePaginationArray; export import OperationListParams = UserSchemasOperationsAPI.OperationListParams; } diff --git a/src/resources/api-gateway/user-schemas/user-schemas.ts b/src/resources/api-gateway/user-schemas/user-schemas.ts index f15c5ca78a..98ca4eea83 100644 --- a/src/resources/api-gateway/user-schemas/user-schemas.ts +++ b/src/resources/api-gateway/user-schemas/user-schemas.ts @@ -5,7 +5,7 @@ import * as Core from '../../../core'; import * as UserSchemasAPI from './user-schemas'; import * as Shared from '../../shared'; import * as OperationsAPI from './operations'; -import { SinglePage } from '../../../pagination'; +import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; export class UserSchemas extends APIResource { operations: OperationsAPI.Operations = new OperationsAPI.Operations(this._client); @@ -29,12 +29,13 @@ export class UserSchemas extends APIResource { list( params: UserSchemaListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/api_gateway/user_schemas`, PublicSchemasSinglePage, { - query, - ...options, - }); + return this._client.getAPIList( + `/zones/${zone_id}/api_gateway/user_schemas`, + PublicSchemasV4PagePaginationArray, + { query, ...options }, + ); } /** @@ -89,7 +90,7 @@ export class UserSchemas extends APIResource { } } -export class PublicSchemasSinglePage extends SinglePage {} +export class PublicSchemasV4PagePaginationArray extends V4PagePaginationArray {} export type Message = Array; @@ -107,7 +108,7 @@ export interface PublicSchema { name: string; /** - * UUID identifier + * UUID */ schema_id: string; @@ -159,7 +160,7 @@ export namespace SchemaUpload { } } -export type UserSchemaDeleteResponse = unknown | string | null; +export type UserSchemaDeleteResponse = unknown | string; export interface UserSchemaCreateParams { /** @@ -188,7 +189,7 @@ export interface UserSchemaCreateParams { validation_enabled?: 'true' | 'false'; } -export interface UserSchemaListParams { +export interface UserSchemaListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier */ @@ -199,16 +200,6 @@ export interface UserSchemaListParams { */ omit_source?: boolean; - /** - * Query param: Page number of paginated results. - */ - page?: unknown; - - /** - * Query param: Maximum number of results per page. - */ - per_page?: unknown; - /** * Query param: Flag whether schema is enabled for validation. */ @@ -251,7 +242,7 @@ export namespace UserSchemas { export import PublicSchema = UserSchemasAPI.PublicSchema; export import SchemaUpload = UserSchemasAPI.SchemaUpload; export import UserSchemaDeleteResponse = UserSchemasAPI.UserSchemaDeleteResponse; - export import PublicSchemasSinglePage = UserSchemasAPI.PublicSchemasSinglePage; + export import PublicSchemasV4PagePaginationArray = UserSchemasAPI.PublicSchemasV4PagePaginationArray; export import UserSchemaCreateParams = UserSchemasAPI.UserSchemaCreateParams; export import UserSchemaListParams = UserSchemasAPI.UserSchemaListParams; export import UserSchemaDeleteParams = UserSchemasAPI.UserSchemaDeleteParams; @@ -259,6 +250,6 @@ export namespace UserSchemas { export import UserSchemaGetParams = UserSchemasAPI.UserSchemaGetParams; export import Operations = OperationsAPI.Operations; export import OperationListResponse = OperationsAPI.OperationListResponse; - export import OperationListResponsesSinglePage = OperationsAPI.OperationListResponsesSinglePage; + export import OperationListResponsesV4PagePaginationArray = OperationsAPI.OperationListResponsesV4PagePaginationArray; export import OperationListParams = OperationsAPI.OperationListParams; } diff --git a/tests/api-resources/api-gateway/configurations.test.ts b/tests/api-resources/api-gateway/configurations.test.ts index 6db1de3a07..9cdd49f095 100644 --- a/tests/api-resources/api-gateway/configurations.test.ts +++ b/tests/api-resources/api-gateway/configurations.test.ts @@ -13,6 +13,7 @@ describe('resource configurations', () => { test('update: only required params', async () => { const responsePromise = cloudflare.apiGateway.configurations.update({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', + auth_id_characteristics: [{ name: 'authorization', type: 'header' }], }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); diff --git a/tests/api-resources/api-gateway/discovery/operations.test.ts b/tests/api-resources/api-gateway/discovery/operations.test.ts index e2d982e54b..e746c613e2 100644 --- a/tests/api-resources/api-gateway/discovery/operations.test.ts +++ b/tests/api-resources/api-gateway/discovery/operations.test.ts @@ -33,15 +33,15 @@ describe('resource operations', () => { method: ['GET'], order: 'method', origin: 'ML', - page: {}, - per_page: {}, + page: 1, + per_page: 5, state: 'review', }); }); test('edit: only required params', async () => { const responsePromise = cloudflare.apiGateway.discovery.operations.edit( - '0d9bf70c-92e1-4bb3-9411-34a3bcc59003', + 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); const rawResponse = await responsePromise.asResponse(); @@ -55,7 +55,7 @@ describe('resource operations', () => { test('edit: required and optional params', async () => { const response = await cloudflare.apiGateway.discovery.operations.edit( - '0d9bf70c-92e1-4bb3-9411-34a3bcc59003', + 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', state: 'review' }, ); }); diff --git a/tests/api-resources/api-gateway/operations/operations.test.ts b/tests/api-resources/api-gateway/operations/operations.test.ts index 1e56dff57d..3aeecfe58f 100644 --- a/tests/api-resources/api-gateway/operations/operations.test.ts +++ b/tests/api-resources/api-gateway/operations/operations.test.ts @@ -61,7 +61,7 @@ describe('resource operations', () => { host: ['api.cloudflare.com'], method: ['GET'], order: 'method', - page: {}, + page: 1, per_page: 5, }); }); diff --git a/tests/api-resources/api-gateway/user-schemas/operations.test.ts b/tests/api-resources/api-gateway/user-schemas/operations.test.ts index c0bd4403fb..e6dab481df 100644 --- a/tests/api-resources/api-gateway/user-schemas/operations.test.ts +++ b/tests/api-resources/api-gateway/user-schemas/operations.test.ts @@ -34,8 +34,8 @@ describe('resource operations', () => { host: ['api.cloudflare.com'], method: ['GET'], operation_status: 'new', - page: {}, - per_page: {}, + page: 1, + per_page: 5, }, ); }); diff --git a/tests/api-resources/api-gateway/user-schemas/user-schemas.test.ts b/tests/api-resources/api-gateway/user-schemas/user-schemas.test.ts index 55f16e3dec..da9f18265e 100644 --- a/tests/api-resources/api-gateway/user-schemas/user-schemas.test.ts +++ b/tests/api-resources/api-gateway/user-schemas/user-schemas.test.ts @@ -52,8 +52,8 @@ describe('resource userSchemas', () => { const response = await cloudflare.apiGateway.userSchemas.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', omit_source: true, - page: {}, - per_page: {}, + page: 1, + per_page: 5, validation_enabled: true, }); });