diff --git a/api.md b/api.md index 9973ea31d4..742f82a3fd 100644 --- a/api.md +++ b/api.md @@ -2365,7 +2365,7 @@ Types: Methods: -- client.apiGateway.operations.create([ ...body ]) -> OperationCreateResponse +- client.apiGateway.operations.create([ ...operations ]) -> OperationCreateResponse - client.apiGateway.operations.list({ ...params }) -> OperationListResponsesV4PagePaginationArray - client.apiGateway.operations.delete(operationId, { ...params }) -> OperationDeleteResponse - client.apiGateway.operations.bulkDelete({ ...params }) -> OperationBulkDeleteResponse diff --git a/src/resources/api-gateway/operations/operations.ts b/src/resources/api-gateway/operations/operations.ts index 478b00afcf..e9664d5006 100644 --- a/src/resources/api-gateway/operations/operations.ts +++ b/src/resources/api-gateway/operations/operations.ts @@ -31,10 +31,10 @@ export class Operations extends APIResource { params: OperationCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { - const { zone_id, body } = params; + const { zone_id, operations } = params; return ( this._client.post(`/zones/${zone_id}/api_gateway/operations`, { - body: body, + body: operations, ...options, }) as Core.APIPromise<{ result: OperationCreateResponse }> )._thenUnwrap((obj) => obj.result); @@ -123,259 +123,288 @@ export interface APIShield { * 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 type OperationCreateResponse = Array; - export namespace APIShieldOperationFeatureThresholds { - export interface Thresholds { - /** - * The total number of auth-ids seen across this calculation. - */ - auth_id_tokens?: number; +export namespace OperationCreateResponse { + export interface OperationCreateResponseItem { + /** + * 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; - /** - * The number of data points used for the threshold suggestion calculation. - */ - data_points?: number; + /** + * RFC3986-compliant host. + */ + host: string; - last_updated?: string; + last_updated: string; - /** - * The p50 quantile of requests (in period_seconds). - */ - p50?: number; + /** + * The HTTP method used to access the endpoint. + */ + method: 'GET' | 'POST' | 'HEAD' | 'OPTIONS' | 'PUT' | 'DELETE' | 'CONNECT' | 'PATCH' | 'TRACE'; - /** - * The p90 quantile of requests (in period_seconds). - */ - p90?: number; + /** + * UUID + */ + operation_id: string; + + features?: + | OperationCreateResponseItem.APIShieldOperationFeatureThresholds + | OperationCreateResponseItem.APIShieldOperationFeatureParameterSchemas + | OperationCreateResponseItem.APIShieldOperationFeatureAPIRouting + | OperationCreateResponseItem.APIShieldOperationFeatureConfidenceIntervals + | OperationCreateResponseItem.APIShieldOperationFeatureSchemaInfo; + } - /** - * The p99 quantile of requests (in period_seconds). - */ - p99?: number; + export namespace OperationCreateResponseItem { + export interface APIShieldOperationFeatureThresholds { + thresholds?: APIShieldOperationFeatureThresholds.Thresholds; + } - /** - * The period over which this threshold is suggested. - */ - period_seconds?: number; + export namespace APIShieldOperationFeatureThresholds { + export interface Thresholds { + /** + * The total number of auth-ids seen across this calculation. + */ + auth_id_tokens?: number; - /** - * The estimated number of requests covered by these calculations. - */ - requests?: number; + /** + * The number of data points used for the threshold suggestion calculation. + */ + data_points?: number; - /** - * The suggested threshold in requests done by the same auth_id or period_seconds. - */ - suggested_threshold?: number; - } - } + last_updated?: string; - export interface APIShieldOperationFeatureParameterSchemas { - parameter_schemas: APIShieldOperationFeatureParameterSchemas.ParameterSchemas; - } + /** + * The p50 quantile of requests (in period_seconds). + */ + p50?: number; - export namespace APIShieldOperationFeatureParameterSchemas { - export interface ParameterSchemas { - last_updated?: string; + /** + * The p90 quantile of requests (in period_seconds). + */ + p90?: number; - /** - * An operation schema object containing a response. - */ - parameter_schemas?: ParameterSchemas.ParameterSchemas; - } + /** + * The p99 quantile of requests (in period_seconds). + */ + p99?: number; - export namespace ParameterSchemas { - /** - * An operation schema object containing a response. - */ - export interface ParameterSchemas { /** - * An array containing the learned parameter schemas. + * The period over which this threshold is suggested. */ - parameters?: Array; + period_seconds?: number; /** - * An empty response object. This field is required to yield a valid operation - * schema. + * The estimated number of requests covered by these calculations. */ - responses?: unknown | null; + requests?: number; + + /** + * The suggested threshold in requests done by the same auth_id or period_seconds. + */ + suggested_threshold?: number; } } - } - export interface APIShieldOperationFeatureAPIRouting { - /** - * API Routing settings on endpoint. - */ - api_routing?: APIShieldOperationFeatureAPIRouting.APIRouting; - } + export interface APIShieldOperationFeatureParameterSchemas { + parameter_schemas: APIShieldOperationFeatureParameterSchemas.ParameterSchemas; + } - export namespace APIShieldOperationFeatureAPIRouting { - /** - * API Routing settings on endpoint. - */ - export interface APIRouting { - last_updated?: string; + export namespace APIShieldOperationFeatureParameterSchemas { + export interface ParameterSchemas { + last_updated?: string; - /** - * Target route. - */ - route?: string; - } - } + /** + * An operation schema object containing a response. + */ + parameter_schemas?: ParameterSchemas.ParameterSchemas; + } - export interface APIShieldOperationFeatureConfidenceIntervals { - confidence_intervals?: APIShieldOperationFeatureConfidenceIntervals.ConfidenceIntervals; - } + export namespace ParameterSchemas { + /** + * An operation schema object containing a response. + */ + export interface ParameterSchemas { + /** + * An array containing the learned parameter schemas. + */ + parameters?: Array; - export namespace APIShieldOperationFeatureConfidenceIntervals { - export interface ConfidenceIntervals { - last_updated?: string; + /** + * An empty response object. This field is required to yield a valid operation + * schema. + */ + responses?: unknown | null; + } + } + } - suggested_threshold?: ConfidenceIntervals.SuggestedThreshold; + export interface APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + api_routing?: APIShieldOperationFeatureAPIRouting.APIRouting; } - export namespace ConfidenceIntervals { - export interface SuggestedThreshold { - confidence_intervals?: SuggestedThreshold.ConfidenceIntervals; + export namespace APIShieldOperationFeatureAPIRouting { + /** + * API Routing settings on endpoint. + */ + export interface APIRouting { + last_updated?: string; /** - * Suggested threshold. + * Target route. */ - mean?: number; + route?: string; } + } - export namespace SuggestedThreshold { - export interface ConfidenceIntervals { - /** - * Upper and lower bound for percentile estimate - */ - p90?: ConfidenceIntervals.P90; + export interface APIShieldOperationFeatureConfidenceIntervals { + confidence_intervals?: APIShieldOperationFeatureConfidenceIntervals.ConfidenceIntervals; + } - /** - * Upper and lower bound for percentile estimate - */ - p95?: ConfidenceIntervals.P95; + export namespace APIShieldOperationFeatureConfidenceIntervals { + export interface ConfidenceIntervals { + last_updated?: string; + + suggested_threshold?: ConfidenceIntervals.SuggestedThreshold; + } + + export namespace ConfidenceIntervals { + export interface SuggestedThreshold { + confidence_intervals?: SuggestedThreshold.ConfidenceIntervals; /** - * Upper and lower bound for percentile estimate + * Suggested threshold. */ - p99?: ConfidenceIntervals.P99; + mean?: number; } - export namespace ConfidenceIntervals { - /** - * Upper and lower bound for percentile estimate - */ - export interface P90 { + export namespace SuggestedThreshold { + export interface ConfidenceIntervals { /** - * Lower bound for percentile estimate + * Upper and lower bound for percentile estimate */ - lower?: number; + p90?: ConfidenceIntervals.P90; /** - * Upper bound for percentile estimate + * Upper and lower bound for percentile estimate */ - upper?: number; - } + p95?: ConfidenceIntervals.P95; - /** - * Upper and lower bound for percentile estimate - */ - export interface P95 { /** - * Lower bound for percentile estimate + * Upper and lower bound for percentile estimate */ - lower?: number; + p99?: ConfidenceIntervals.P99; + } + export namespace ConfidenceIntervals { /** - * Upper bound for percentile estimate + * Upper and lower bound for percentile estimate */ - upper?: number; - } + 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 P99 { /** - * Lower bound for percentile estimate + * Upper and lower bound for percentile estimate */ - lower?: number; + export interface P95 { + /** + * Lower bound for percentile estimate + */ + lower?: number; + + /** + * Upper bound for percentile estimate + */ + upper?: number; + } /** - * Upper bound for percentile estimate + * Upper and lower bound for percentile estimate */ - upper?: number; + 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 interface APIShieldOperationFeatureSchemaInfo { + schema_info?: APIShieldOperationFeatureSchemaInfo.SchemaInfo; } - export namespace SchemaInfo { - /** - * Schema active on endpoint. - */ - export interface ActiveSchema { + export namespace APIShieldOperationFeatureSchemaInfo { + export interface SchemaInfo { /** - * UUID + * Schema active on endpoint. */ - id?: string; + active_schema?: SchemaInfo.ActiveSchema; - created_at?: string; + /** + * True if a Cloudflare-provided learned schema is available for this endpoint. + */ + learned_available?: boolean; /** - * True if schema is Cloudflare-provided. + * Action taken on requests failing validation. */ - is_learned?: boolean; + mitigation_action?: 'none' | 'log' | 'block' | null; + } + export namespace SchemaInfo { /** - * Schema file name. + * Schema active on endpoint. */ - name?: string; + 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 @@ -959,11 +988,11 @@ export interface OperationCreateParams { /** * Body param: */ - body: Array; + operations: Array; } export namespace OperationCreateParams { - export interface Body { + export interface Operation { /** * 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 diff --git a/src/resources/api-gateway/user-schemas/operations.ts b/src/resources/api-gateway/user-schemas/operations.ts index 2908edd28d..7f6ddd5f8e 100644 --- a/src/resources/api-gateway/user-schemas/operations.ts +++ b/src/resources/api-gateway/user-schemas/operations.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../../resource'; import * as Core from '../../../core'; -import * as OperationsAPI from '../operations/operations'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; export class Operations extends APIResource { @@ -26,9 +25,287 @@ export class Operations extends APIResource { export class OperationListResponsesV4PagePaginationArray extends V4PagePaginationArray {} -export type OperationListResponse = OperationsAPI.APIShield | OperationListResponse.APIShieldBasicOperation; +export type OperationListResponse = + | OperationListResponse.APIShieldOperation + | OperationListResponse.APIShieldBasicOperation; export namespace OperationListResponse { + export interface APIShieldOperation { + /** + * 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?: + | APIShieldOperation.APIShieldOperationFeatureThresholds + | APIShieldOperation.APIShieldOperationFeatureParameterSchemas + | APIShieldOperation.APIShieldOperationFeatureAPIRouting + | APIShieldOperation.APIShieldOperationFeatureConfidenceIntervals + | APIShieldOperation.APIShieldOperationFeatureSchemaInfo; + } + + export namespace APIShieldOperation { + 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 interface APIShieldBasicOperation { /** * The endpoint which can contain path parameter templates in curly braces, each diff --git a/tests/api-resources/api-gateway/operations/operations.test.ts b/tests/api-resources/api-gateway/operations/operations.test.ts index f194b4b068..3b1843a2d7 100644 --- a/tests/api-resources/api-gateway/operations/operations.test.ts +++ b/tests/api-resources/api-gateway/operations/operations.test.ts @@ -13,7 +13,7 @@ describe('resource operations', () => { test('create: only required params', async () => { const responsePromise = client.apiGateway.operations.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - body: [{ endpoint: '/api/v1/users/{var1}', host: 'www.example.com', method: 'GET' }], + operations: [{ endpoint: '/api/v1/users/{var1}', host: 'www.example.com', method: 'GET' }], }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -27,7 +27,7 @@ describe('resource operations', () => { test('create: required and optional params', async () => { const response = await client.apiGateway.operations.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - body: [{ endpoint: '/api/v1/users/{var1}', host: 'www.example.com', method: 'GET' }], + operations: [{ endpoint: '/api/v1/users/{var1}', host: 'www.example.com', method: 'GET' }], }); });