Skip to content

Commit

Permalink
[Security AI Assistant] Marked assistant APIs as internal (#183965)
Browse files Browse the repository at this point in the history
Temporary moved Security AI Assistant APIs to internal.
  • Loading branch information
YulNaumenko authored May 21, 2024
1 parent 5a939b0 commit bae84d4
Show file tree
Hide file tree
Showing 38 changed files with 89 additions and 86 deletions.
6 changes: 3 additions & 3 deletions x-pack/packages/kbn-elastic-assistant-common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ export const ELASTIC_AI_ASSISTANT_INTERNAL_API_VERSION = '1';
export const ELASTIC_AI_ASSISTANT_URL = '/api/elastic_assistant';
export const ELASTIC_AI_ASSISTANT_INTERNAL_URL = '/internal/elastic_assistant';

export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL = `${ELASTIC_AI_ASSISTANT_URL}/current_user/conversations`;
export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL = `${ELASTIC_AI_ASSISTANT_INTERNAL_URL}/current_user/conversations`;
export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID = `${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL}/{id}`;
export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID_MESSAGES = `${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID}/messages`;

export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION = `${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL}/_bulk_action`;
export const ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_FIND = `${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL}/_find`;

export const ELASTIC_AI_ASSISTANT_PROMPTS_URL = `${ELASTIC_AI_ASSISTANT_URL}/prompts`;
export const ELASTIC_AI_ASSISTANT_PROMPTS_URL = `${ELASTIC_AI_ASSISTANT_INTERNAL_URL}/prompts`;
export const ELASTIC_AI_ASSISTANT_PROMPTS_URL_BULK_ACTION = `${ELASTIC_AI_ASSISTANT_PROMPTS_URL}/_bulk_action`;
export const ELASTIC_AI_ASSISTANT_PROMPTS_URL_FIND = `${ELASTIC_AI_ASSISTANT_PROMPTS_URL}/_find`;

export const ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL = `${ELASTIC_AI_ASSISTANT_URL}/anonymization_fields`;
export const ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL = `${ELASTIC_AI_ASSISTANT_INTERNAL_URL}/anonymization_fields`;
export const ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION = `${ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL}/_bulk_action`;
export const ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_FIND = `${ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL}/_find`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { z } from 'zod';
*
* info:
* title: Bulk Actions API endpoint
* version: 2023-10-31
* version: 1
*/

import { NonEmptyString } from '../common_attributes.gen';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Bulk Actions API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/anonymization_fields/_bulk_action:
/internal/elastic_assistant/anonymization_fields/_bulk_action:
post:
operationId: PerformBulkAction
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ArrayFromString } from '@kbn/zod-helpers';
*
* info:
* title: Find AnonymizationFields API endpoint
* version: 2023-10-31
* version: 1
*/

import { AnonymizationFieldResponse } from './bulk_crud_anonymization_fields_route.gen';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Find AnonymizationFields API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/anonymization_fields/_find:
/internal/elastic_assistant/anonymization_fields/_find:
get:
operationId: FindAnonymizationFields
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { z } from 'zod';
*
* info:
* title: Bulk Actions API endpoint
* version: 2023-10-31
* version: 1
*/

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Bulk Actions API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/conversations/_bulk_action:
/internal/elastic_assistant/conversations/_bulk_action:
post:
operationId: PerformBulkAction
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { z } from 'zod';
*
* info:
* title: Create Conversation API endpoint
* version: 2023-10-31
* version: 1
*/

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Create Conversation API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/conversations:
/internal/elastic_assistant/conversations:
post:
operationId: CreateConversation
x-codegen-enabled: true
Expand Down Expand Up @@ -38,7 +38,7 @@ paths:
message:
type: string

/api/elastic_assistant/conversations/{id}:
/internal/elastic_assistant/conversations/{id}:
get:
operationId: ReadConversation
x-codegen-enabled: true
Expand Down Expand Up @@ -148,7 +148,7 @@ paths:
message:
type: string

/api/elastic_assistant/conversations/{id}/messages:
/internal/elastic_assistant/conversations/{id}/messages:
post:
operationId: AppendConversationMessage
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ArrayFromString } from '@kbn/zod-helpers';
*
* info:
* title: Find Conversations API endpoint
* version: 2023-10-31
* version: 1
*/

import { ConversationResponse } from './common_attributes.gen';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Find Conversations API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/conversations/_find:
/internal/elastic_assistant/conversations/_find:
get:
operationId: FindConversations
x-codegen-enabled: true
Expand Down Expand Up @@ -91,7 +91,7 @@ paths:
message:
type: string

/api/elastic_assistant/conversations/current_user/_find:
/internal/elastic_assistant/conversations/current_user/_find:
get:
operationId: FindCurrentUserConversations
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { z } from 'zod';
*
* info:
* title: Bulk Actions API endpoint
* version: 2023-10-31
* version: 1
*/

import { NonEmptyString, User } from '../common_attributes.gen';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Bulk Actions API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/prompts/_bulk_action:
/internal/elastic_assistant/prompts/_bulk_action:
post:
operationId: PerformBulkAction
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ArrayFromString } from '@kbn/zod-helpers';
*
* info:
* title: Find Prompts API endpoint
* version: 2023-10-31
* version: 1
*/

import { PromptResponse } from './bulk_crud_prompts_route.gen';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openapi: 3.0.0
info:
title: Find Prompts API endpoint
version: '2023-10-31'
version: '1'
paths:
/api/elastic_assistant/prompts/_find:
/internal/elastic_assistant/prompts/_find:
get:
operationId: FindPrompts
x-codegen-enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('bulkUpdateAnonymizationFields', () => {
ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
create: [],
update: [],
Expand All @@ -71,7 +71,7 @@ describe('bulkUpdateAnonymizationFields', () => {
ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
create: [anonymizationField1, anonymizationField2],
update: [],
Expand All @@ -93,7 +93,7 @@ describe('bulkUpdateAnonymizationFields', () => {
ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
update: [anonymizationField1, anonymizationField2],
delete: { ids: [] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const bulkUpdateAnonymizationFields = async (
ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify(anonymizationFieldsActions),
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React from 'react';
import { useFetchAnonymizationFields } from './use_fetch_anonymization_fields';
import { HttpSetup } from '@kbn/core-http-browser';
import { useAssistantContext } from '../../../assistant_context';
import { defaultAssistantFeatures } from '@kbn/elastic-assistant-common';
import { API_VERSIONS, defaultAssistantFeatures } from '@kbn/elastic-assistant-common';

const http = {
fetch: jest.fn().mockResolvedValue(defaultAssistantFeatures),
Expand Down Expand Up @@ -44,15 +44,18 @@ describe('useFetchAnonymizationFields', () => {
await act(async () => {
const { waitForNextUpdate } = renderHook(() => useFetchAnonymizationFields());
await waitForNextUpdate();
expect(http.fetch).toHaveBeenCalledWith('/api/elastic_assistant/anonymization_fields/_find', {
method: 'GET',
query: {
page: 1,
per_page: 1000,
},
version: '2023-10-31',
signal: undefined,
});
expect(http.fetch).toHaveBeenCalledWith(
'/internal/elastic_assistant/anonymization_fields/_find',
{
method: 'GET',
query: {
page: 1,
per_page: 1000,
},
version: API_VERSIONS.internal.v1,
signal: undefined,
}
);

expect(http.fetch).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const CACHING_KEYS = [
ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_FIND,
QUERY.page,
QUERY.per_page,
API_VERSIONS.public.v1,
API_VERSIONS.internal.v1,
];

export const useFetchAnonymizationFields = (payload?: UseFetchAnonymizationFieldsParams) => {
Expand All @@ -50,7 +50,7 @@ export const useFetchAnonymizationFields = (payload?: UseFetchAnonymizationField
async () =>
http.fetch(ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_FIND, {
method: 'GET',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
query: QUERY,
signal: payload?.signal,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('bulkUpdateConversations', () => {
ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
update: [],
create: [],
Expand All @@ -89,7 +89,7 @@ describe('bulkUpdateConversations', () => {
ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
update: [],
create: [conversation1, conversation2],
Expand All @@ -114,7 +114,7 @@ describe('bulkUpdateConversations', () => {
ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
update: [conversation1, conversation2],
delete: { ids: [] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const bulkUpdateConversations = async (
ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION,
{
method: 'POST',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
body: JSON.stringify({
update: conversationsToUpdate,
create: conversationsToCreate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ describe('conversations api', () => {
await waitForNextUpdate();

expect(deleteProps.http.fetch).toHaveBeenCalledWith(
'/api/elastic_assistant/current_user/conversations/test',
'/internal/elastic_assistant/current_user/conversations/test',
{
method: 'DELETE',
signal: undefined,
version: '2023-10-31',
version: '1',
}
);
expect(toasts.addError).not.toHaveBeenCalled();
Expand All @@ -62,11 +62,11 @@ describe('conversations api', () => {
await waitForNextUpdate();

expect(getProps.http.fetch).toHaveBeenCalledWith(
'/api/elastic_assistant/current_user/conversations/test',
'/internal/elastic_assistant/current_user/conversations/test',
{
method: 'GET',
signal: undefined,
version: '2023-10-31',
version: '1',
}
);
expect(toasts.addError).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const getConversationById = async ({
try {
const response = await http.fetch(`${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL}/${id}`, {
method: 'GET',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
signal,
});

Expand Down Expand Up @@ -84,7 +84,7 @@ export const getUserConversations = async ({
ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_FIND,
{
method: 'GET',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
signal,
}
);
Expand Down Expand Up @@ -125,7 +125,7 @@ export const createConversation = async ({
try {
const response = await http.post(ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL, {
body: JSON.stringify(conversation),
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
signal,
});

Expand Down Expand Up @@ -168,7 +168,7 @@ export const deleteConversation = async ({
try {
const response = await http.fetch(`${ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL}/${id}`, {
method: 'DELETE',
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
signal,
});

Expand Down Expand Up @@ -237,7 +237,7 @@ export const updateConversation = async ({
headers: {
'Content-Type': 'application/json',
},
version: API_VERSIONS.public.v1,
version: API_VERSIONS.internal.v1,
signal,
}
);
Expand Down
Loading

0 comments on commit bae84d4

Please sign in to comment.