Skip to content

Commit

Permalink
only register cel endpoint if ff enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kgeller committed Oct 9, 2024
1 parent 131e2d7 commit 39455ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion x-pack/plugins/integration_assistant/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import type {
IntegrationAssistantPluginStart,
IntegrationAssistantPluginStartDependencies,
} from './types';
import { parseExperimentalConfigValue } from '../common/experimental_features';
import { IntegrationAssistantConfigType } from './config';

export type IntegrationAssistantRouteHandlerContext = CustomRequestHandlerContext<{
integrationAssistant: {
Expand All @@ -36,11 +38,13 @@ export class IntegrationAssistantPlugin
implements Plugin<IntegrationAssistantPluginSetup, IntegrationAssistantPluginStart>
{
private readonly logger: Logger;
private readonly config: IntegrationAssistantConfigType;
private isAvailable: boolean;
private hasLicense: boolean;

constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
this.config = initializerContext.config.get();
this.isAvailable = true;
this.hasLicense = false;
}
Expand All @@ -59,9 +63,11 @@ export class IntegrationAssistantPlugin
logger: this.logger,
}));
const router = core.http.createRouter<IntegrationAssistantRouteHandlerContext>();
const experimentalFeatures = parseExperimentalConfigValue(this.config.enableExperimental ?? []);

this.logger.debug('integrationAssistant api: Setup');

registerRoutes(router);
registerRoutes(router, experimentalFeatures);

return {
setIsAvailable: (isAvailable: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ import { registerPipelineRoutes } from './pipeline_routes';
import type { IntegrationAssistantRouteHandlerContext } from '../plugin';
import { registerAnalyzeLogsRoutes } from './analyze_logs_routes';
import { registerCelInputRoutes } from './cel_routes';
import { ExperimentalFeatures } from '../../common/experimental_features';

export function registerRoutes(router: IRouter<IntegrationAssistantRouteHandlerContext>) {
export function registerRoutes(
router: IRouter<IntegrationAssistantRouteHandlerContext>,
experimentalFeatures: ExperimentalFeatures
) {
registerAnalyzeLogsRoutes(router);
registerEcsRoutes(router);
registerIntegrationBuilderRoutes(router);
registerCategorizationRoutes(router);
registerRelatedRoutes(router);
registerCelInputRoutes(router);
registerPipelineRoutes(router);

if (experimentalFeatures.generateCel) {
registerCelInputRoutes(router);
}
}

0 comments on commit 39455ec

Please sign in to comment.