Skip to content

Commit

Permalink
[Security solution] assistantKnowledgeBaseByDefault flag removed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Nov 12, 2024
1 parent 0ab841f commit 194de0d
Show file tree
Hide file tree
Showing 84 changed files with 255 additions and 3,170 deletions.
10 changes: 5 additions & 5 deletions api_docs/kbn_elastic_assistant_common.devdocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@
"\nInterface for features available to the elastic assistant"
],
"signature": [
"{ readonly assistantKnowledgeBaseByDefault: boolean; readonly assistantModelEvaluation: boolean; }"
"{ readonly assistantModelEvaluation: boolean; }"
],
"path": "x-pack/packages/kbn-elastic-assistant-common/impl/capabilities/index.ts",
"deprecated": false,
Expand Down Expand Up @@ -2772,7 +2772,7 @@
"label": "GetCapabilitiesResponse",
"description": [],
"signature": [
"{ assistantKnowledgeBaseByDefault: boolean; assistantModelEvaluation: boolean; }"
"{ assistantModelEvaluation: boolean; }"
],
"path": "x-pack/packages/kbn-elastic-assistant-common/impl/schemas/capabilities/get_capabilities_route.gen.ts",
"deprecated": false,
Expand Down Expand Up @@ -4767,7 +4767,7 @@
"\nDefault features available to the elastic assistant"
],
"signature": [
"{ readonly assistantKnowledgeBaseByDefault: true; readonly assistantModelEvaluation: false; }"
"{ readonly assistantModelEvaluation: false; }"
],
"path": "x-pack/packages/kbn-elastic-assistant-common/impl/capabilities/index.ts",
"deprecated": false,
Expand Down Expand Up @@ -5232,7 +5232,7 @@
"label": "GetCapabilitiesResponse",
"description": [],
"signature": [
"Zod.ZodObject<{ assistantKnowledgeBaseByDefault: Zod.ZodBoolean; assistantModelEvaluation: Zod.ZodBoolean; }, \"strip\", Zod.ZodTypeAny, { assistantKnowledgeBaseByDefault: boolean; assistantModelEvaluation: boolean; }, { assistantKnowledgeBaseByDefault: boolean; assistantModelEvaluation: boolean; }>"
"Zod.ZodObject<{ assistantModelEvaluation: Zod.ZodBoolean; }, \"strip\", Zod.ZodTypeAny, { assistantModelEvaluation: boolean; }, { assistantModelEvaluation: boolean; }>"
],
"path": "x-pack/packages/kbn-elastic-assistant-common/impl/schemas/capabilities/get_capabilities_route.gen.ts",
"deprecated": false,
Expand Down Expand Up @@ -6201,4 +6201,4 @@
}
]
}
}
}
14 changes: 7 additions & 7 deletions api_docs/security_solution.devdocs.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ export type AssistantFeatureKey = keyof AssistantFeatures;
* Default features available to the elastic assistant
*/
export const defaultAssistantFeatures = Object.freeze({
assistantKnowledgeBaseByDefault: true,
assistantModelEvaluation: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ import { z } from '@kbn/zod';

export type GetCapabilitiesResponse = z.infer<typeof GetCapabilitiesResponse>;
export const GetCapabilitiesResponse = z.object({
assistantKnowledgeBaseByDefault: z.boolean(),
assistantModelEvaluation: z.boolean(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ paths:
schema:
type: object
properties:
assistantKnowledgeBaseByDefault:
type: boolean
assistantModelEvaluation:
type: boolean
required:
- assistantKnowledgeBaseByDefault
- assistantModelEvaluation
'400':
description: Generic Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ export type CreateKnowledgeBaseRequestParamsInput = z.input<
export type CreateKnowledgeBaseResponse = z.infer<typeof CreateKnowledgeBaseResponse>;
export const CreateKnowledgeBaseResponse = KnowledgeBaseResponse;

export type DeleteKnowledgeBaseRequestParams = z.infer<typeof DeleteKnowledgeBaseRequestParams>;
export const DeleteKnowledgeBaseRequestParams = z.object({
/**
* The KnowledgeBase `resource` value.
*/
resource: z.string().optional(),
});
export type DeleteKnowledgeBaseRequestParamsInput = z.input<
typeof DeleteKnowledgeBaseRequestParams
>;

export type DeleteKnowledgeBaseResponse = z.infer<typeof DeleteKnowledgeBaseResponse>;
export const DeleteKnowledgeBaseResponse = KnowledgeBaseResponse;

export type ReadKnowledgeBaseRequestParams = z.infer<typeof ReadKnowledgeBaseRequestParams>;
export const ReadKnowledgeBaseRequestParams = z.object({
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,6 @@ paths:
type: string
message:
type: string
delete:
x-codegen-enabled: true
x-labels: [ess, serverless]
operationId: DeleteKnowledgeBase
description: Deletes KnowledgeBase with the `resource` field.
summary: Deletes a KnowledgeBase
tags:
- KnowledgeBase API
parameters:
- name: resource
in: path
description: The KnowledgeBase `resource` value.
schema:
type: string
responses:
200:
description: Indicates a successful call.
content:
application/json:
schema:
$ref: '#/components/schemas/KnowledgeBaseResponse'
400:
description: Generic Error
content:
application/json:
schema:
type: object
properties:
statusCode:
type: number
error:
type: string
message:
type: string

components:
schemas:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ paths:
/internal/elastic_assistant/knowledge_base/entries/_bulk_action:
post:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: PerformKnowledgeBaseEntryBulkAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ paths:
/internal/elastic_assistant/knowledge_base/entries:
post:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: CreateKnowledgeBaseEntry
Expand Down Expand Up @@ -37,7 +37,7 @@ paths:
/internal/elastic_assistant/knowledge_base/entries/{id}:
get:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: ReadKnowledgeBaseEntry
Expand Down Expand Up @@ -67,7 +67,7 @@ paths:
$ref: './common_attributes.schema.yaml#/components/schemas/KnowledgeBaseEntryErrorSchema'
put:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: UpdateKnowledgeBaseEntry
Expand Down Expand Up @@ -103,7 +103,7 @@ paths:
$ref: './common_attributes.schema.yaml#/components/schemas/KnowledgeBaseEntryErrorSchema'
delete:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: DeleteKnowledgeBaseEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ paths:
/internal/elastic_assistant/knowledge_base/entries/_find:
get:
x-codegen-enabled: true
# This API is still behind the `assistantKnowledgeBaseByDefault` feature flag
# Targeted to update to public by 8.18
x-internal: true
x-labels: [ess, serverless]
operationId: FindKnowledgeBaseEntries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

import { HttpSetup } from '@kbn/core-http-browser';

import {
deleteKnowledgeBase,
getKnowledgeBaseIndices,
getKnowledgeBaseStatus,
postKnowledgeBase,
} from './api';
import { getKnowledgeBaseIndices, getKnowledgeBaseStatus, postKnowledgeBase } from './api';

jest.mock('@kbn/core-http-browser');

Expand Down Expand Up @@ -78,29 +73,6 @@ describe('API tests', () => {
});
});

describe('deleteKnowledgeBase', () => {
it('calls the knowledge base API when correct resource path', async () => {
await deleteKnowledgeBase(knowledgeBaseArgs);

expect(mockHttp.fetch).toHaveBeenCalledWith(
'/internal/elastic_assistant/knowledge_base/a-resource',
{
method: 'DELETE',
signal: undefined,
version: '1',
}
);
});
it('returns error when error is an error', async () => {
const error = 'simulated error';
(mockHttp.fetch as jest.Mock).mockImplementation(() => {
throw new Error(error);
});

await expect(deleteKnowledgeBase(knowledgeBaseArgs)).resolves.toThrowError('simulated error');
});
});

describe('getKnowledgeBaseIndices', () => {
it('calls the knowledge base API when correct resource path', async () => {
await getKnowledgeBaseIndices({ http: mockHttp });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
API_VERSIONS,
CreateKnowledgeBaseRequestParams,
CreateKnowledgeBaseResponse,
DeleteKnowledgeBaseRequestParams,
DeleteKnowledgeBaseResponse,
ELASTIC_AI_ASSISTANT_KNOWLEDGE_BASE_INDICES_URL,
ELASTIC_AI_ASSISTANT_KNOWLEDGE_BASE_URL,
GetKnowledgeBaseIndicesResponse,
Expand Down Expand Up @@ -79,38 +77,6 @@ export const postKnowledgeBase = async ({
return response as CreateKnowledgeBaseResponse;
};

/**
* API call for deleting the Knowledge Base. Provide a resource to delete that specific resource.
*
* @param {Object} options - The options object.
* @param {HttpSetup} options.http - HttpSetup
* @param {string} [options.resource] - Resource to be deleted from the KB, otherwise delete the entire KB
* @param {AbortSignal} [options.signal] - AbortSignal
*
* @returns {Promise<DeleteKnowledgeBaseResponse | IHttpFetchError>}
*/
export const deleteKnowledgeBase = async ({
http,
resource,
signal,
}: DeleteKnowledgeBaseRequestParams & {
http: HttpSetup;
signal?: AbortSignal | undefined;
}): Promise<DeleteKnowledgeBaseResponse | IHttpFetchError> => {
try {
const path = ELASTIC_AI_ASSISTANT_KNOWLEDGE_BASE_URL.replace('{resource?}', resource || '');
const response = await http.fetch(path, {
method: 'DELETE',
signal,
version: API_VERSIONS.internal.v1,
});

return response as DeleteKnowledgeBaseResponse;
} catch (error) {
return error as IHttpFetchError;
}
};

/**
* API call for getting indices that have fields of `semantic_text` type.
*
Expand Down

This file was deleted.

Loading

0 comments on commit 194de0d

Please sign in to comment.