Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-197482
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 15, 2024
2 parents f5142ee + 7a4bb76 commit 3ff594c
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 31 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const sharedOas = {
tags: ['versioned'],
},
},
'/foo/{id}/{path*}': {
'/foo/{id}/{path}': {
get: {
description: 'route description',
operationId: 'get-foo-id-path',
Expand Down
14 changes: 7 additions & 7 deletions packages/kbn-router-to-openapispec/src/generate_oas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ describe('generateOpenApiDocument', () => {
}
);
// router paths
expect(result.paths['/1-1/{id}/{path*}']!.get!.tags).toEqual(['1', '2']);
expect(result.paths['/1-2/{id}/{path*}']!.get!.tags).toEqual(['1']);
expect(result.paths['/2-1/{id}/{path*}']!.get!.tags).toEqual([]);
expect(result.paths['/1-1/{id}/{path}']!.get!.tags).toEqual(['1', '2']);
expect(result.paths['/1-2/{id}/{path}']!.get!.tags).toEqual(['1']);
expect(result.paths['/2-1/{id}/{path}']!.get!.tags).toEqual([]);
// versioned router paths
expect(result.paths['/v1-1']!.get!.tags).toEqual(['v1']);
expect(result.paths['/v1-2']!.get!.tags).toEqual(['v2', 'v3']);
Expand Down Expand Up @@ -392,17 +392,17 @@ describe('generateOpenApiDocument', () => {
);

// router paths
expect(result.paths['/1-1/{id}/{path*}']!.get).toMatchObject({
expect(result.paths['/1-1/{id}/{path}']!.get).toMatchObject({
'x-state': 'Technical Preview',
});
expect(result.paths['/1-2/{id}/{path*}']!.get).toMatchObject({
expect(result.paths['/1-2/{id}/{path}']!.get).toMatchObject({
'x-state': 'Beta',
});

expect(result.paths['/1-3/{id}/{path*}']!.get).not.toMatchObject({
expect(result.paths['/1-3/{id}/{path}']!.get).not.toMatchObject({
'x-state': expect.any(String),
});
expect(result.paths['/2-1/{id}/{path*}']!.get).not.toMatchObject({
expect(result.paths['/2-1/{id}/{path}']!.get).not.toMatchObject({
'x-state': expect.any(String),
});

Expand Down
7 changes: 5 additions & 2 deletions packages/kbn-router-to-openapispec/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
getPathParameters,
createOpIdGenerator,
GetOpId,
assignToPaths,
extractTags,
} from './util';
import { assignToPaths, extractTags } from './util';

describe('extractTags', () => {
test.each([
Expand Down Expand Up @@ -115,9 +116,11 @@ describe('assignToPaths', () => {
const paths = {};
assignToPaths(paths, '/foo', {});
assignToPaths(paths, '/bar/{id?}', {});
assignToPaths(paths, '/bar/file/{path*}', {});
expect(paths).toEqual({
'/foo': {},
'/bar/{id}': {},
'/bar/file/{path}': {},
});
});
});
Expand Down Expand Up @@ -320,7 +323,7 @@ describe('createOpIdGenerator', () => {
{
input: {
method: 'get',
path: '/api/my/resource/{path*}',
path: '/api/my/resource/{path}',
},
output: 'get-my-resource-path',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-router-to-openapispec/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const assignToPaths = (
path: string,
pathObject: OpenAPIV3.PathItemObject
): void => {
const pathName = path.replace('?', '');
const pathName = path.replace(/[\?\*]/, '');
paths[pathName] = { ...paths[pathName], ...pathObject };
};

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/embeddable_enhanced/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export class EmbeddableEnhancedPlugin
);
const api: DynamicActionStorageApi = {
dynamicActionsState$,
setDynamicActions: (newState) => {
dynamicActionsState$.next(newState);
setDynamicActions: (enhancements) => {
dynamicActionsState$.next(getDynamicActionsState(enhancements));
},
};
const storage = new DynamicActionStorage(uuid, getTitle, api);
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/kubernetes_security/server/routes/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const registerAggregateRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/kubernetes_security/server/routes/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export const registerCountRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const registerMultiTermsAggregateRoute = (router: IRouter, logger: Logger
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { schema, type TypeOf } from '@kbn/config-schema';

export const config = schema.object({
enabled: schema.boolean({ defaultValue: true }),
modelId: schema.maybe(schema.string()), // TODO: Remove
scope: schema.maybe(schema.oneOf([schema.literal('observability'), schema.literal('search')])),
enableKnowledgeBase: schema.boolean({ defaultValue: true }),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ export class ObservabilityAIAssistantPlugin

// Using once to make sure the same model ID is used during service init and Knowledge base setup
const getSearchConnectorModelId = once(async () => {
// TODO: Remove this once the modelId is removed from the config
const configModelId = this.config.modelId;
if (configModelId) {
return configModelId;
}
const defaultModelId = '.elser_model_2';
const [_, pluginsStart] = await core.getStartServices();
// Wait for the license to be available so the ML plugin's guards pass once we ask for ELSER stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { Logger } from '@kbn/logging';
import moment from 'moment';

export const AI_ASSISTANT_KB_INFERENCE_ID = 'ai_assistant_kb_inference';
export const AI_ASSISTANT_KB_INFERENCE_ID = 'obs_ai_assistant_kb_inference';

export async function createInferenceEndpoint({
esClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export const registerAlertStatusRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/session_view/server/routes/alerts_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const registerAlertsRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export const registerGetTotalIOBytesRoute = (router: IRouter, logger: Logger) =>
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/session_view/server/routes/io_events_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export const registerIOEventsRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const registerProcessEventsRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { mapValues } from 'lodash';
import path from 'path';
import { createTestConfig, CreateTestConfig } from '../common/config';
import { SUPPORTED_TRAINED_MODELS } from '../../functional/services/ml/api';

export const observabilityAIAssistantDebugLogger = {
name: 'plugins.observabilityAIAssistant',
Expand All @@ -31,7 +30,6 @@ export const observabilityAIAssistantFtrConfigs = {
__dirname,
'../../../../test/analytics/plugins/analytics_ftr_helpers'
),
'xpack.observabilityAIAssistant.modelId': SUPPORTED_TRAINED_MODELS.TINY_ELSER.name, // TODO: Remove
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
.expect(200);

expect(res.body.service_settings.model_id).to.be('pt_tiny_elser');
expect(res.body.inference_id).to.be('ai_assistant_kb_inference');
expect(res.body.inference_id).to.be('obs_ai_assistant_kb_inference');

await deleteKnowledgeBaseModel(ml);
await deleteInferenceEndpoint({ es });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
expect(res.body.ready).to.be(false);
expect(res.body.enabled).to.be(true);
expect(res.body.errorMessage).to.include.string(
'Inference endpoint not found [ai_assistant_kb_inference]'
'Inference endpoint not found [obs_ai_assistant_kb_inference]'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { SUPPORTED_TRAINED_MODELS } from '@kbn/test-suites-xpack/functional/services/ml/api';
import { createTestConfig } from '../../../config.base';
import { ObservabilityAIAssistantServices } from './common/ftr_provider_context';
import { services as inheritedServices } from '../../../services';
Expand All @@ -28,7 +27,4 @@ export default createTestConfig({
// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/observability/config/elasticsearch.yml
esServerArgs: ['xpack.ml.dfa.enabled=false'],
kbnServerArgs: [
`--xpack.observabilityAIAssistant.modelId=${SUPPORTED_TRAINED_MODELS.TINY_ELSER.name}`, // TODO: Remove
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
.expect(200);

expect(res.body.service_settings.model_id).to.be('pt_tiny_elser');
expect(res.body.inference_id).to.be('ai_assistant_kb_inference');
expect(res.body.inference_id).to.be('obs_ai_assistant_kb_inference');

await deleteKnowledgeBaseModel(ml);
await deleteInferenceEndpoint({ es });
Expand Down

0 comments on commit 3ff594c

Please sign in to comment.