From bf3ab1d6509254d0e60bb3dfa6189814a9bc2cb2 Mon Sep 17 00:00:00 2001 From: Bharat Pasupula <123897612+bhapas@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:02:24 +0200 Subject: [PATCH] [Automatic Import] Modify codegen to autogenerate openAPI spec code (#193243) ## Summary https://github.com/elastic/kibana/pull/186085 introduced OpenAPI spec for Automatic Import APIs. Since there was a [bug](https://github.com/elastic/kibana/pull/186221) `x-codegen-enabled` was set to `false`. This PR modifies it to `true` and `node scripts/generate_openapi` generated new API classes for the spec. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit e4180d211a06513cf51328da090ea14315880201) --- .../__jest__/fixtures/build_integration.ts | 2 +- .../__jest__/fixtures/categorization.ts | 2 +- .../__jest__/fixtures/ecs_mapping.ts | 2 +- .../__jest__/fixtures/kv.ts | 2 +- .../__jest__/fixtures/log_type_detection.ts | 2 +- .../__jest__/fixtures/related.ts | 2 +- ...ogs_route.ts => analyze_logs_route.gen.ts} | 8 +- .../analyze_logs_route.schema.yaml | 2 +- .../analyze_logs/analyze_logs_route.test.ts | 2 +- ...ntegration.ts => build_integration.gen.ts} | 11 +- .../build_integration.schema.yaml | 2 +- ...n_route.ts => categorization_route.gen.ts} | 23 ++-- .../categorization_route.schema.yaml | 2 +- .../categorization_route.test.ts | 2 +- ...heck_pipeline.ts => check_pipeline.gen.ts} | 13 ++- .../check_pipeline/check_pipeline.schema.yaml | 2 +- .../ecs/{ecs_route.ts => ecs_route.gen.ts} | 8 +- .../common/api/ecs/ecs_route.schema.yaml | 2 +- .../common/api/ecs/ecs_route.test.ts | 2 +- .../common/api/model/api_test.mock.ts | 12 +- ...attributes.ts => common_attributes.gen.ts} | 11 +- .../api/model/common_attributes.schema.yaml | 2 +- .../api/model/processor_attributes.gen.ts | 109 ++++++++++++++++++ .../model/processor_attributes.schema.yaml | 2 +- .../common/api/model/processor_attributes.ts | 52 --------- ...nse_schemas.ts => response_schemas.gen.ts} | 6 +- .../api/model/response_schemas.schema.yaml | 2 +- ...{related_route.ts => related_route.gen.ts} | 23 ++-- .../api/related/related_route.schema.yaml | 2 +- .../common/api/related/related_route.test.ts | 2 +- .../integration_assistant/common/index.ts | 21 ++-- .../public/common/lib/lang_smith.ts | 2 +- .../server/graphs/ecs/pipeline.ts | 3 +- 33 files changed, 223 insertions(+), 117 deletions(-) rename x-pack/plugins/integration_assistant/common/api/analyze_logs/{analyze_logs_route.ts => analyze_logs_route.gen.ts} (95%) rename x-pack/plugins/integration_assistant/common/api/build_integration/{build_integration.ts => build_integration.gen.ts} (64%) rename x-pack/plugins/integration_assistant/common/api/categorization/{categorization_route.ts => categorization_route.gen.ts} (78%) rename x-pack/plugins/integration_assistant/common/api/check_pipeline/{check_pipeline.ts => check_pipeline.gen.ts} (70%) rename x-pack/plugins/integration_assistant/common/api/ecs/{ecs_route.ts => ecs_route.gen.ts} (91%) rename x-pack/plugins/integration_assistant/common/api/model/{common_attributes.ts => common_attributes.gen.ts} (94%) create mode 100644 x-pack/plugins/integration_assistant/common/api/model/processor_attributes.gen.ts delete mode 100644 x-pack/plugins/integration_assistant/common/api/model/processor_attributes.ts rename x-pack/plugins/integration_assistant/common/api/model/{response_schemas.ts => response_schemas.gen.ts} (91%) rename x-pack/plugins/integration_assistant/common/api/related/{related_route.ts => related_route.gen.ts} (73%) diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/build_integration.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/build_integration.ts index 3161f06f8a6ae..81f2231bcb05d 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/build_integration.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/build_integration.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Integration } from '../../common/api/model/common_attributes'; +import { Integration } from '../../common'; export const testIntegration: Integration = { name: 'integration', diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/categorization.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/categorization.ts index 5f68dfc4668ec..80366e7bd6f93 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/categorization.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/categorization.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SamplesFormatName } from '../../common/api/model/common_attributes'; +import { SamplesFormatName } from '../../common'; import type { Pipeline } from '../../common'; export const categorizationInitialPipeline: Pipeline = { diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/ecs_mapping.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/ecs_mapping.ts index eba49baaa8595..67e6c7d8f6a5e 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/ecs_mapping.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/ecs_mapping.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SamplesFormatName } from '../../common/api/model/common_attributes'; +import { SamplesFormatName } from '../../common'; export const ecsMappingExpectedResults = { mapping: { diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/kv.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/kv.ts index 587d8987c0960..49c8d2e16809b 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/kv.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/kv.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SamplesFormatName } from '../../common/api/model/common_attributes'; +import { SamplesFormatName } from '../../common'; export const kvState = { lastExecutedChain: 'testchain', diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/log_type_detection.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/log_type_detection.ts index 31d7208eb4d87..b3c1e4c05ebd9 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/log_type_detection.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/log_type_detection.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SamplesFormatName } from '../../common/api/model/common_attributes'; +import { SamplesFormatName } from '../../common'; export const logFormatDetectionTestState = { lastExecutedChain: 'testchain', diff --git a/x-pack/plugins/integration_assistant/__jest__/fixtures/related.ts b/x-pack/plugins/integration_assistant/__jest__/fixtures/related.ts index 9d0915735d52a..d96d845ae43b6 100644 --- a/x-pack/plugins/integration_assistant/__jest__/fixtures/related.ts +++ b/x-pack/plugins/integration_assistant/__jest__/fixtures/related.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SamplesFormatName } from '../../common/api/model/common_attributes'; +import { SamplesFormatName } from '../../common'; import type { Pipeline } from '../../common'; export const relatedInitialPipeline: Pipeline = { diff --git a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.ts b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.gen.ts similarity index 95% rename from x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.ts rename to x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.gen.ts index 597c44fde54a5..a224bb3cbe241 100644 --- a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.ts +++ b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.gen.ts @@ -17,13 +17,13 @@ import { z } from '@kbn/zod'; import { + PackageName, + DataStreamName, LogSamples, Connector, LangSmithOptions, - DataStreamName, - PackageName, -} from '../model/common_attributes'; -import { AnalyzeLogsAPIResponse } from '../model/response_schemas'; +} from '../model/common_attributes.gen'; +import { AnalyzeLogsAPIResponse } from '../model/response_schemas.gen'; export type AnalyzeLogsRequestBody = z.infer; export const AnalyzeLogsRequestBody = z.object({ diff --git a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml index 23050bc6a50fc..165a2cff91a06 100644 --- a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Analyzes log samples and processes them. operationId: AnalyzeLogs - x-codegen-enabled: false + x-codegen-enabled: true description: Analyzes log samples and processes them tags: - Analyze Logs API diff --git a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.test.ts b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.test.ts index 08595c1ce1911..30848ca8945cf 100644 --- a/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.test.ts +++ b/x-pack/plugins/integration_assistant/common/api/analyze_logs/analyze_logs_route.test.ts @@ -6,7 +6,7 @@ */ import { expectParseSuccess } from '@kbn/zod-helpers'; -import { AnalyzeLogsRequestBody } from './analyze_logs_route'; +import { AnalyzeLogsRequestBody } from './analyze_logs_route.gen'; import { getAnalyzeLogsRequestBody } from '../model/api_test.mock'; describe('Analyze Logs request schema', () => { diff --git a/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.ts b/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.gen.ts similarity index 64% rename from x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.ts rename to x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.gen.ts index ce9c919c0d43d..46db1066ffdff 100644 --- a/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.ts +++ b/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.gen.ts @@ -5,9 +5,18 @@ * 2.0. */ +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Integration Assistatnt Build Integrarion API endpoint + * version: 1 + */ + import { z } from '@kbn/zod'; -import { Integration } from '../model/common_attributes'; +import { Integration } from '../model/common_attributes.gen'; export type BuildIntegrationRequestBody = z.infer; export const BuildIntegrationRequestBody = z.object({ diff --git a/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.schema.yaml b/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.schema.yaml index 798ead34114a6..7a5a994cff4df 100644 --- a/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/build_integration/build_integration.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Builds Integration with the given input samples operationId: BuildIntegration - x-codegen-enabled: false + x-codegen-enabled: true description: Build Integration for the given input samples tags: - Build Integration API diff --git a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.ts b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.gen.ts similarity index 78% rename from x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.ts rename to x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.gen.ts index c78aa745671e9..0b2492e41ac12 100644 --- a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.ts +++ b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.gen.ts @@ -5,27 +5,36 @@ * 2.0. */ +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Integration Assistatnt Categorization API endpoint + * version: 1 + */ + import { z } from '@kbn/zod'; import { - Connector, - DataStreamName, - LangSmithOptions, PackageName, - Pipeline, + DataStreamName, RawSamples, + Pipeline, + Connector, SamplesFormat, -} from '../model/common_attributes'; -import { CategorizationAPIResponse } from '../model/response_schemas'; + LangSmithOptions, +} from '../model/common_attributes.gen'; +import { CategorizationAPIResponse } from '../model/response_schemas.gen'; export type CategorizationRequestBody = z.infer; export const CategorizationRequestBody = z.object({ packageName: PackageName, dataStreamName: DataStreamName, rawSamples: RawSamples, - samplesFormat: SamplesFormat, currentPipeline: Pipeline, connectorId: Connector, + samplesFormat: SamplesFormat, langSmithOptions: LangSmithOptions.optional(), }); export type CategorizationRequestBodyInput = z.input; diff --git a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.schema.yaml b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.schema.yaml index e548f4d816776..4a8a28abf3a7e 100644 --- a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Builds Categorization processors based on the samples operationId: Categorization - x-codegen-enabled: false + x-codegen-enabled: true description: Perform Categorization for the given ecs mappings. tags: - Categorization API diff --git a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.test.ts b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.test.ts index f7ef31f5fdb99..fc7f6f9736d36 100644 --- a/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.test.ts +++ b/x-pack/plugins/integration_assistant/common/api/categorization/categorization_route.test.ts @@ -6,7 +6,7 @@ */ import { expectParseSuccess } from '@kbn/zod-helpers'; -import { CategorizationRequestBody } from './categorization_route'; +import { CategorizationRequestBody } from './categorization_route.gen'; import { getCategorizationRequestMock } from '../model/api_test.mock'; describe('Categorization request schema', () => { diff --git a/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.ts b/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.gen.ts similarity index 70% rename from x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.ts rename to x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.gen.ts index e2a9255490f5e..18888108396f4 100644 --- a/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.ts +++ b/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.gen.ts @@ -5,10 +5,19 @@ * 2.0. */ +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Integration Assistatnt Check Pipeline API endpoint + * version: 1 + */ + import { z } from '@kbn/zod'; -import { Pipeline, RawSamples } from '../model/common_attributes'; -import { CheckPipelineAPIResponse } from '../model/response_schemas'; +import { RawSamples, Pipeline } from '../model/common_attributes.gen'; +import { CheckPipelineAPIResponse } from '../model/response_schemas.gen'; export type CheckPipelineRequestBody = z.infer; export const CheckPipelineRequestBody = z.object({ diff --git a/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml b/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml index 22785fc40bbf2..b7f20616007ea 100644 --- a/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Checks if the pipeline is valid for the given samples operationId: CheckPipeline - x-codegen-enabled: false + x-codegen-enabled: true description: Check latest pipeline against the input samples. tags: - Check Pipeline API diff --git a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.ts b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.gen.ts similarity index 91% rename from x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.ts rename to x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.gen.ts index 58143ec7177d7..867f792405cbd 100644 --- a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.ts +++ b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.gen.ts @@ -20,13 +20,13 @@ import { PackageName, DataStreamName, RawSamples, + SamplesFormat, Mapping, Connector, LangSmithOptions, - SamplesFormat, -} from '../model/common_attributes'; -import { ESProcessorItem } from '../model/processor_attributes'; -import { EcsMappingAPIResponse } from '../model/response_schemas'; +} from '../model/common_attributes.gen'; +import { ESProcessorItem } from '../model/processor_attributes.gen'; +import { EcsMappingAPIResponse } from '../model/response_schemas.gen'; export type EcsMappingRequestBody = z.infer; export const EcsMappingRequestBody = z.object({ diff --git a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.schema.yaml b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.schema.yaml index 7026fc6d86f96..6bc125a74f52a 100644 --- a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Builds ECS Mapping based on the input samples operationId: EcsMapping - x-codegen-enabled: false + x-codegen-enabled: true description: Perform ECS mapping for the given input JSON samples tags: - ECS Mapping API diff --git a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.test.ts b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.test.ts index 770c3ff96f675..de4820633b825 100644 --- a/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.test.ts +++ b/x-pack/plugins/integration_assistant/common/api/ecs/ecs_route.test.ts @@ -6,7 +6,7 @@ */ import { expectParseSuccess } from '@kbn/zod-helpers'; -import { EcsMappingRequestBody } from './ecs_route'; +import { EcsMappingRequestBody } from './ecs_route.gen'; import { getEcsMappingRequestMock } from '../model/api_test.mock'; describe('Ecs Mapping request schema', () => { diff --git a/x-pack/plugins/integration_assistant/common/api/model/api_test.mock.ts b/x-pack/plugins/integration_assistant/common/api/model/api_test.mock.ts index 34ce49ae5b776..de29624cbb21a 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/api_test.mock.ts +++ b/x-pack/plugins/integration_assistant/common/api/model/api_test.mock.ts @@ -5,12 +5,12 @@ * 2.0. */ -import type { AnalyzeLogsRequestBody } from '../analyze_logs/analyze_logs_route'; -import type { BuildIntegrationRequestBody } from '../build_integration/build_integration'; -import type { CategorizationRequestBody } from '../categorization/categorization_route'; -import type { EcsMappingRequestBody } from '../ecs/ecs_route'; -import type { RelatedRequestBody } from '../related/related_route'; -import type { DataStream, Integration, Pipeline } from './common_attributes'; +import type { AnalyzeLogsRequestBody } from '../analyze_logs/analyze_logs_route.gen'; +import type { BuildIntegrationRequestBody } from '../build_integration/build_integration.gen'; +import type { CategorizationRequestBody } from '../categorization/categorization_route.gen'; +import type { EcsMappingRequestBody } from '../ecs/ecs_route.gen'; +import type { RelatedRequestBody } from '../related/related_route.gen'; +import type { DataStream, Integration, Pipeline } from './common_attributes.gen'; const rawSamples = ['{"test1": "test1"}']; diff --git a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.gen.ts similarity index 94% rename from x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts rename to x-pack/plugins/integration_assistant/common/api/model/common_attributes.gen.ts index 964aa9386a87f..59fe7d461698f 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts +++ b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.gen.ts @@ -5,9 +5,18 @@ * 2.0. */ +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Common Rule Attributes + * version: not applicable + */ + import { z } from '@kbn/zod'; -import { ESProcessorItem } from './processor_attributes'; +import { ESProcessorItem } from './processor_attributes.gen'; /** * Package name for the integration to be built. diff --git a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml index 4c4810b22f9be..0af01834970c7 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml @@ -4,7 +4,7 @@ info: version: "not applicable" paths: {} components: - x-codegen-enabled: false + x-codegen-enabled: true schemas: PackageName: type: string diff --git a/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.gen.ts b/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.gen.ts new file mode 100644 index 0000000000000..5916bcac4d839 --- /dev/null +++ b/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.gen.ts @@ -0,0 +1,109 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Common Rule Attributes + * version: not applicable + */ + +import type { ZodTypeDef } from '@kbn/zod'; +import { z } from '@kbn/zod'; + +/** + * Processor options for the Elasticsearch processor. + */ +export interface ESProcessorOptions { + /** + * An array of items to execute if the processor fails. + */ + on_failure?: ESProcessorItem[]; + /** + * If true, the processor continues to the next processor if the current processor fails. + */ + ignore_failure?: boolean; + /** + * If true, the processor continues to the next processor if the field is missing. + */ + ignore_missing?: boolean; + /** + * Conditionally execute the processor. + */ + if?: string; + /** + * A tag to assign to the document after processing. + */ + tag?: string; + [key: string]: unknown; +} +export interface ESProcessorOptionsInput { + /** + * An array of items to execute if the processor fails. + */ + on_failure?: ESProcessorItemInput[]; + /** + * If true, the processor continues to the next processor if the current processor fails. + */ + ignore_failure?: boolean; + /** + * If true, the processor continues to the next processor if the field is missing. + */ + ignore_missing?: boolean; + /** + * Conditionally execute the processor. + */ + if?: string; + /** + * A tag to assign to the document after processing. + */ + tag?: string; + [key: string]: unknown; +} +export const ESProcessorOptions: z.ZodType< + ESProcessorOptions, + ZodTypeDef, + ESProcessorOptionsInput +> = z + .object({ + /** + * An array of items to execute if the processor fails. + */ + on_failure: z.array(z.lazy(() => ESProcessorItem)).optional(), + /** + * If true, the processor continues to the next processor if the current processor fails. + */ + ignore_failure: z.boolean().optional(), + /** + * If true, the processor continues to the next processor if the field is missing. + */ + ignore_missing: z.boolean().optional(), + /** + * Conditionally execute the processor. + */ + if: z.string().optional(), + /** + * A tag to assign to the document after processing. + */ + tag: z.string().optional(), + }) + .catchall(z.unknown()); + +/** + * Processor item for the Elasticsearch processor. + */ +export interface ESProcessorItem { + [key: string]: ESProcessorOptions; +} +export interface ESProcessorItemInput { + [key: string]: ESProcessorOptionsInput; +} +export const ESProcessorItem: z.ZodType = z + .object({}) + .catchall(z.lazy(() => ESProcessorOptions)); diff --git a/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.schema.yaml b/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.schema.yaml index a0c930361737a..837ff5525df88 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.schema.yaml @@ -4,7 +4,7 @@ info: version: "not applicable" paths: {} components: - x-codegen-enabled: false + x-codegen-enabled: true schemas: ESProcessorItem: type: object diff --git a/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.ts b/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.ts deleted file mode 100644 index 4bbebb6b4686c..0000000000000 --- a/x-pack/plugins/integration_assistant/common/api/model/processor_attributes.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { z } from '@kbn/zod'; - -/** - * Processor item for the Elasticsearch processor. - */ -export type ESProcessorItem = Record; -export const ESProcessorItem: z.ZodType = z - .object({}) - .catchall(z.lazy(() => ESProcessorOptions)); - -/** - * Processor options for the Elasticsearch processor. - */ -export interface ESProcessorOptions { - on_failure?: ESProcessorItem[]; - ignore_failure?: boolean; - ignore_missing?: boolean; - if?: string; - tag?: string; - [key: string]: unknown; -} -export const ESProcessorOptions = z - .object({ - /** - * An array of items to execute if the processor fails. - */ - on_failure: z.array(ESProcessorItem).optional(), - /** - * If true, the processor continues to the next processor if the current processor fails. - */ - ignore_failure: z.boolean().optional(), - /** - * If true, the processor continues to the next processor if the field is missing. - */ - ignore_missing: z.boolean().optional(), - /** - * Conditionally execute the processor. - */ - if: z.string().optional(), - /** - * A tag to assign to the document after processing. - */ - tag: z.string().optional(), - }) - .catchall(z.unknown()); diff --git a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.gen.ts similarity index 91% rename from x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts rename to x-pack/plugins/integration_assistant/common/api/model/response_schemas.gen.ts index c496aa8493723..acb4954c21b90 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts +++ b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.gen.ts @@ -16,8 +16,8 @@ import { z } from '@kbn/zod'; -import { Docs, Mapping, Pipeline, SamplesFormat } from './common_attributes'; -import { ESProcessorItem } from './processor_attributes'; +import { Mapping, Pipeline, Docs, SamplesFormat } from './common_attributes.gen'; +import { ESProcessorItem } from './processor_attributes.gen'; export type EcsMappingAPIResponse = z.infer; export const EcsMappingAPIResponse = z.object({ @@ -52,9 +52,9 @@ export const CheckPipelineAPIResponse = z.object({ export type AnalyzeLogsAPIResponse = z.infer; export const AnalyzeLogsAPIResponse = z.object({ + additionalProcessors: z.array(ESProcessorItem).optional(), results: z.object({ samplesFormat: SamplesFormat, parsedSamples: z.array(z.string()), }), - additionalProcessors: z.array(ESProcessorItem).optional(), }); diff --git a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml index 72f853822b09e..c504ad8b17d16 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml @@ -4,7 +4,7 @@ info: version: "not applicable" paths: {} components: - x-codegen-enabled: false + x-codegen-enabled: true schemas: EcsMappingAPIResponse: type: object diff --git a/x-pack/plugins/integration_assistant/common/api/related/related_route.ts b/x-pack/plugins/integration_assistant/common/api/related/related_route.gen.ts similarity index 73% rename from x-pack/plugins/integration_assistant/common/api/related/related_route.ts rename to x-pack/plugins/integration_assistant/common/api/related/related_route.gen.ts index 14796dc5350ba..eceb01679a442 100644 --- a/x-pack/plugins/integration_assistant/common/api/related/related_route.ts +++ b/x-pack/plugins/integration_assistant/common/api/related/related_route.gen.ts @@ -5,27 +5,36 @@ * 2.0. */ +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Integration Assistatnt Related API endpoint + * version: 1 + */ + import { z } from '@kbn/zod'; import { - Connector, - DataStreamName, - LangSmithOptions, PackageName, - Pipeline, + DataStreamName, RawSamples, + Pipeline, + Connector, SamplesFormat, -} from '../model/common_attributes'; -import { RelatedAPIResponse } from '../model/response_schemas'; + LangSmithOptions, +} from '../model/common_attributes.gen'; +import { RelatedAPIResponse } from '../model/response_schemas.gen'; export type RelatedRequestBody = z.infer; export const RelatedRequestBody = z.object({ packageName: PackageName, dataStreamName: DataStreamName, rawSamples: RawSamples, - samplesFormat: SamplesFormat, currentPipeline: Pipeline, connectorId: Connector, + samplesFormat: SamplesFormat, langSmithOptions: LangSmithOptions.optional(), }); export type RelatedRequestBodyInput = z.input; diff --git a/x-pack/plugins/integration_assistant/common/api/related/related_route.schema.yaml b/x-pack/plugins/integration_assistant/common/api/related/related_route.schema.yaml index 71fee7e616709..9ca2f6ab7bae0 100644 --- a/x-pack/plugins/integration_assistant/common/api/related/related_route.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/related/related_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: summary: Builds related.* fields for integration with the given input samples operationId: Related - x-codegen-enabled: false + x-codegen-enabled: true description: Add Related mappings for the given samples. tags: - Related API diff --git a/x-pack/plugins/integration_assistant/common/api/related/related_route.test.ts b/x-pack/plugins/integration_assistant/common/api/related/related_route.test.ts index 8f69c13303056..fd6a81a61a1ad 100644 --- a/x-pack/plugins/integration_assistant/common/api/related/related_route.test.ts +++ b/x-pack/plugins/integration_assistant/common/api/related/related_route.test.ts @@ -6,7 +6,7 @@ */ import { expectParseSuccess } from '@kbn/zod-helpers'; -import { RelatedRequestBody } from './related_route'; +import { RelatedRequestBody } from './related_route.gen'; import { getRelatedRequestMock } from '../model/api_test.mock'; describe('Related request schema', () => { diff --git a/x-pack/plugins/integration_assistant/common/index.ts b/x-pack/plugins/integration_assistant/common/index.ts index 5310fa67c8cac..21ee814655e10 100644 --- a/x-pack/plugins/integration_assistant/common/index.ts +++ b/x-pack/plugins/integration_assistant/common/index.ts @@ -4,18 +4,21 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -export { BuildIntegrationRequestBody } from './api/build_integration/build_integration'; +export { BuildIntegrationRequestBody } from './api/build_integration/build_integration.gen'; export { CategorizationRequestBody, CategorizationResponse, -} from './api/categorization/categorization_route'; +} from './api/categorization/categorization_route.gen'; export { CheckPipelineRequestBody, CheckPipelineResponse, -} from './api/check_pipeline/check_pipeline'; -export { EcsMappingRequestBody, EcsMappingResponse } from './api/ecs/ecs_route'; -export { RelatedRequestBody, RelatedResponse } from './api/related/related_route'; -export { AnalyzeLogsRequestBody, AnalyzeLogsResponse } from './api/analyze_logs/analyze_logs_route'; +} from './api/check_pipeline/check_pipeline.gen'; +export { EcsMappingRequestBody, EcsMappingResponse } from './api/ecs/ecs_route.gen'; +export { RelatedRequestBody, RelatedResponse } from './api/related/related_route.gen'; +export { + AnalyzeLogsRequestBody, + AnalyzeLogsResponse, +} from './api/analyze_logs/analyze_logs_route.gen'; export type { DataStream, @@ -24,8 +27,10 @@ export type { Pipeline, Docs, SamplesFormat, -} from './api/model/common_attributes'; -export type { ESProcessorItem } from './api/model/processor_attributes'; + LangSmithOptions, +} from './api/model/common_attributes.gen'; +export { SamplesFormatName } from './api/model/common_attributes.gen'; +export type { ESProcessorItem } from './api/model/processor_attributes.gen'; export { CATEGORIZATION_GRAPH_PATH, diff --git a/x-pack/plugins/integration_assistant/public/common/lib/lang_smith.ts b/x-pack/plugins/integration_assistant/public/common/lib/lang_smith.ts index 7234870439930..a8c4f258e20da 100644 --- a/x-pack/plugins/integration_assistant/public/common/lib/lang_smith.ts +++ b/x-pack/plugins/integration_assistant/public/common/lib/lang_smith.ts @@ -11,7 +11,7 @@ import { } from '@kbn/elastic-assistant/impl/assistant_context/constants'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import type { TraceOptions } from '@kbn/elastic-assistant/impl/assistant/types'; -import type { LangSmithOptions } from '../../../common/api/model/common_attributes'; +import type { LangSmithOptions } from '../../../common'; const sessionStorage = new Storage(window.sessionStorage); diff --git a/x-pack/plugins/integration_assistant/server/graphs/ecs/pipeline.ts b/x-pack/plugins/integration_assistant/server/graphs/ecs/pipeline.ts index 242f6955700e8..e2d91c094d520 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/ecs/pipeline.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/ecs/pipeline.ts @@ -8,10 +8,9 @@ import { safeLoad } from 'js-yaml'; import { Environment, FileSystemLoader } from 'nunjucks'; import { join as joinPath } from 'path'; -import { Pipeline } from '../../../common/api/model/common_attributes'; +import { Pipeline, ESProcessorItem } from '../../../common'; import type { EcsMappingState } from '../../types'; import { ECS_TYPES } from './constants'; -import { ESProcessorItem } from '../../../common/api/model/processor_attributes'; import { deepCopy } from '../../util/util'; interface IngestPipeline {