forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automatic Import] Migrating to UX design and adding support for gene…
…rating auth (elastic#202587) ## Summary This PR adds authentication to the generated CEL programs, and overhauls the UI flow to be closer to the forthcoming UX design. ## Details This PR provides the following updates related to CEL generation: 1. Adds support for generating auth - basic, oauth2, digest and api tokens 2. Adds new tooling for working with the OpenAPI specs and support for reducing the spec to minimally required information to the LLM (new Kibana dep on [oas](https://www.npmjs.com/package/oas)) 3. Addresses various feedback around the generated CEL program (error handling, cursor, trimming the state.url, etc) 4. Migrates the CEL flow to be closer to the forthcoming design specified by UX, now within a flyout on the datastream step. 5. Removes the dependency on the CEL generation feature flag ## Current screenshots <details> <summary>Click me</summary> the datastream setup page: <img width="1724" alt="Screenshot 2024-12-13 at 4 33 28 PM" src="https://github.com/user-attachments/assets/2d35f448-c5c4-4891-92fc-393f83549213" /> the user selects the cel input and the button to configure shows up: <img width="1725" alt="Screenshot 2024-12-13 at 4 33 49 PM" src="https://github.com/user-attachments/assets/e55be532-5eaa-4a46-80f1-16dd82430fc4" /> upon clicking the button, the flyout opens: <img width="1722" alt="Screenshot 2024-12-13 at 4 34 02 PM" src="https://github.com/user-attachments/assets/269248cb-21e7-4ebf-86af-f031facb5822" /> the user can upload the spec file (a json or yaml openapi file): <img width="1722" alt="Screenshot 2024-12-13 at 4 34 30 PM" src="https://github.com/user-attachments/assets/5f996ff3-194a-416b-a1ae-ba0d5ef89a1a" /> the llm will suggest paths to use, or the user can select to enter manually and view all the GETs <img width="865" alt="Screenshot 2024-12-13 at 4 35 26 PM" src="https://github.com/user-attachments/assets/a0ad6d6f-5d82-442a-8f2c-235190b2078c" /> we will also suggest an auth method based on the spec, but allow the user to select otherwise if they want: <img width="1723" alt="Screenshot 2024-12-13 at 4 35 37 PM" src="https://github.com/user-attachments/assets/840b0201-cae2-4313-bf5d-d7b3ab2034ed" /> if they choose an auth the spec doesn't specify, we will warn but not block: <img width="1336" alt="Screenshot 2024-12-16 at 9 07 52 AM" src="https://github.com/user-attachments/assets/c2fb04b5-3d98-4c70-95b2-2fab259c0702" /> once path and auth are selected, they can save and continue (generate the cel config): <img width="1722" alt="Screenshot 2024-12-13 at 4 35 50 PM" src="https://github.com/user-attachments/assets/3e54a435-3ddf-4e64-81ab-49dc25420210" /> generating: <img width="1724" alt="Screenshot 2024-12-13 at 4 36 18 PM" src="https://github.com/user-attachments/assets/0772c016-078c-44cb-ad72-b096f7d635e2" /> all configured: <img width="1720" alt="Screenshot 2024-12-13 at 4 36 35 PM" src="https://github.com/user-attachments/assets/5f92979c-1f40-43e3-90f3-941c20c99cc7" /> </details> ## Sample results > **_Note:_** All these sample integrations are built with the teleport log samples. ### API key [eset.json](https://github.com/user-attachments/files/18151638/eset.json) [eset___api_key-1.0.0.zip](https://github.com/user-attachments/files/18151622/eset___api_key-1.0.0.zip) ### OAuth2 [bitwarden.json](https://github.com/user-attachments/files/18151635/bitwarden.json) [bitwarden___oauth-1.0.0.zip](https://github.com/user-attachments/files/18151618/bitwarden___oauth-1.0.0.zip) ### Basic [sumlogic-api.yaml.zip](https://github.com/user-attachments/files/18151650/sumlogic-api.yaml.zip) [sumologic___basic-1.0.0.zip](https://github.com/user-attachments/files/18151630/sumologic___basic-1.0.0.zip) Relates: - elastic#197651 - elastic#197653 --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Ilya Nikokoshev <[email protected]>
- Loading branch information
1 parent
baf79bc
commit 0585712
Showing
106 changed files
with
5,238 additions
and
1,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
x-pack/platform/plugins/shared/integration_assistant/__jest__/fixtures/api_analysis.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 { ApiAnalysisState } from '../../server/types'; | ||
|
||
export const apiAnalysisTestState: ApiAnalysisState = { | ||
dataStreamName: 'testDataStream', | ||
lastExecutedChain: 'testchain', | ||
results: { test: 'testResults' }, | ||
pathOptions: { '/path1': 'path1 description', '/path2': 'path2 description' }, | ||
suggestedPaths: ['/path1'], | ||
}; | ||
|
||
export const apiAnalysisPathSuggestionsMockedResponse = ['/path1', '/path2', '/path3', '/path4']; | ||
|
||
export const apiAnalysisExpectedResults = { | ||
suggestedPaths: ['/path1', '/path2', '/path3', '/path4'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...form/plugins/shared/integration_assistant/common/api/analyze_api/analyze_api_route.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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: Automatic Import Analyze API specifications API endpoint | ||
* version: 1 | ||
*/ | ||
|
||
import { z } from '@kbn/zod'; | ||
|
||
import { DataStreamTitle, Connector, LangSmithOptions } from '../model/common_attributes.gen'; | ||
import { PathOptions } from '../model/cel_input_attributes.gen'; | ||
import { AnalyzeApiAPIResponse } from '../model/response_schemas.gen'; | ||
|
||
export type AnalyzeApiRequestBody = z.infer<typeof AnalyzeApiRequestBody>; | ||
export const AnalyzeApiRequestBody = z.object({ | ||
dataStreamTitle: DataStreamTitle, | ||
pathOptions: PathOptions, | ||
connectorId: Connector, | ||
langSmithOptions: LangSmithOptions.optional(), | ||
}); | ||
export type AnalyzeApiRequestBodyInput = z.input<typeof AnalyzeApiRequestBody>; | ||
|
||
export type AnalyzeApiResponse = z.infer<typeof AnalyzeApiResponse>; | ||
export const AnalyzeApiResponse = AnalyzeApiAPIResponse; |
39 changes: 39 additions & 0 deletions
39
...plugins/shared/integration_assistant/common/api/analyze_api/analyze_api_route.schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Automatic Import Analyze API specifications API endpoint | ||
version: "1" | ||
paths: | ||
/internal/automatic_import/analyzeapi: | ||
post: | ||
summary: Analyzes API specifications. | ||
operationId: AnalyzeApi | ||
x-codegen-enabled: true | ||
description: Analyzes API specifications. | ||
tags: | ||
- Analyze API spec | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
required: | ||
- dataStreamTitle | ||
- pathOptions | ||
- connectorId | ||
properties: | ||
dataStreamTitle: | ||
$ref: "../model/common_attributes.schema.yaml#/components/schemas/DataStreamTitle" | ||
pathOptions: | ||
$ref: "../model/cel_input_attributes.schema.yaml#/components/schemas/PathOptions" | ||
connectorId: | ||
$ref: "../model/common_attributes.schema.yaml#/components/schemas/Connector" | ||
langSmithOptions: | ||
$ref: "../model/common_attributes.schema.yaml#/components/schemas/LangSmithOptions" | ||
responses: | ||
200: | ||
description: Indicates a successful call. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../model/response_schemas.schema.yaml#/components/schemas/AnalyzeApiAPIResponse" |
20 changes: 20 additions & 0 deletions
20
...orm/plugins/shared/integration_assistant/common/api/analyze_api/analyze_api_route.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { expectParseSuccess } from '@kbn/zod-helpers'; | ||
import { AnalyzeApiRequestBody } from './analyze_api_route.gen'; | ||
import { getAnalyzeApiRequestBody } from '../model/api_test.mock'; | ||
|
||
describe('Analyze API request schema', () => { | ||
test('full request validate', () => { | ||
const payload: AnalyzeApiRequestBody = getAnalyzeApiRequestBody(); | ||
|
||
const result = AnalyzeApiRequestBody.safeParse(payload); | ||
expectParseSuccess(result); | ||
expect(result.data).toEqual(payload); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.