Skip to content

Commit

Permalink
[8.15] [Automatic Import] Modify codegen to autogenerate openAPI spec…
Browse files Browse the repository at this point in the history
… code (#193243) (#193297)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Automatic Import] Modify codegen to autogenerate openAPI spec code
(#193243)](#193243)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Bharat
Pasupula","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-18T13:02:24Z","message":"[Automatic
Import] Modify codegen to autogenerate openAPI spec code (#193243)\n\n##
Summary\r\n\r\nhttps://github.com//pull/186085 introduced
OpenAPI spec\r\nfor Automatic Import APIs. Since there was
a\r\n[bug](#186221)
`x-codegen-enabled`\r\nwas set to `false`.\r\n\r\nThis PR modifies it to
`true` and `node scripts/generate_openapi`\r\ngenerated new API classes
for the spec.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"e4180d211a06513cf51328da090ea14315880201","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","backport:prev-major","Team:Security-Scalability","Feature:AutomaticImport"],"number":193243,"url":"https://github.com/elastic/kibana/pull/193243","mergeCommit":{"message":"[Automatic
Import] Modify codegen to autogenerate openAPI spec code (#193243)\n\n##
Summary\r\n\r\nhttps://github.com//pull/186085 introduced
OpenAPI spec\r\nfor Automatic Import APIs. Since there was
a\r\n[bug](#186221)
`x-codegen-enabled`\r\nwas set to `false`.\r\n\r\nThis PR modifies it to
`true` and `node scripts/generate_openapi`\r\ngenerated new API classes
for the spec.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"e4180d211a06513cf51328da090ea14315880201"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193243","number":193243,"mergeCommit":{"message":"[Automatic
Import] Modify codegen to autogenerate openAPI spec code (#193243)\n\n##
Summary\r\n\r\nhttps://github.com//pull/186085 introduced
OpenAPI spec\r\nfor Automatic Import APIs. Since there was
a\r\n[bug](#186221)
`x-codegen-enabled`\r\nwas set to `false`.\r\n\r\nThis PR modifies it to
`true` and `node scripts/generate_openapi`\r\ngenerated new API classes
for the spec.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"e4180d211a06513cf51328da090ea14315880201"}},{"url":"https://github.com/elastic/kibana/pull/193290","number":193290,"branch":"8.x","state":"OPEN"}]}]
BACKPORT-->
  • Loading branch information
bhapas authored Sep 18, 2024
1 parent d2c74d4 commit 82cee56
Show file tree
Hide file tree
Showing 32 changed files with 228 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Integration } from '../../common/api/model/common_attributes';
import { Integration } from '../../common';

export const testIntegration: Integration = {
name: 'integration',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SamplesFormatName } from '../../common/api/model/common_attributes';
import { SamplesFormatName } from '../../common';

export const ecsMappingExpectedResults = {
mapping: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SamplesFormatName } from '../../common/api/model/common_attributes';
import { SamplesFormatName } from '../../common';

export const kvState = {
lastExecutedChain: 'testchain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SamplesFormatName } from '../../common/api/model/common_attributes';
import { SamplesFormatName } from '../../common';

export const logFormatDetectionTestState = {
lastExecutedChain: 'testchain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof AnalyzeLogsRequestBody>;
export const AnalyzeLogsRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
* 2.0.
*/

import { z } from 'zod';
/*
* 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<typeof BuildIntegrationRequestBody>;
export const BuildIntegrationRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@
* 2.0.
*/

import { z } from 'zod';
/*
* 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<typeof CategorizationRequestBody>;
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<typeof CategorizationRequestBody>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
* 2.0.
*/

import { z } from 'zod';
/*
* 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<typeof CheckPipelineRequestBody>;
export const CheckPipelineRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof EcsMappingRequestBody>;
export const EcsMappingRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
* 2.0.
*/

import { z } from 'zod';
/*
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
version: "not applicable"
paths: {}
components:
x-codegen-enabled: false
x-codegen-enabled: true
schemas:
PackageName:
type: string
Expand Down
Loading

0 comments on commit 82cee56

Please sign in to comment.