* [Connectors][API] Updated connectors with enabledAfterImport flag * fixed functional tests * added new field to connectors API docs * added update unit test * fixed test * renamed enableAfterImport to isMissingSecrets * removed onExport * revert the logic of true/false for isMissingSecrets * fixed test * fixed tests * added unit test * fixed docs * fixed import text and button labels * fixed import text * fixed text
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
/*
|
|
* 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 { IRouter } from 'kibana/server';
|
|
import { ILicenseState } from '../lib';
|
|
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
|
|
import { ActionsRequestHandlerContext, FindActionResult } from '../types';
|
|
import { verifyAccessAndContext } from './verify_access_and_context';
|
|
|
|
const rewriteBodyRes: RewriteResponseCase<FindActionResult[]> = (results) => {
|
|
return results.map(
|
|
({ actionTypeId, isPreconfigured, referencedByCount, isMissingSecrets, ...res }) => ({
|
|
...res,
|
|
connector_type_id: actionTypeId,
|
|
is_preconfigured: isPreconfigured,
|
|
referenced_by_count: referencedByCount,
|
|
is_missing_secrets: isMissingSecrets,
|
|
})
|
|
);
|
|
};
|
|
|
|
export const getAllActionRoute = (
|
|
router: IRouter<ActionsRequestHandlerContext>,
|
|
licenseState: ILicenseState
|
|
) => {
|
|
router.get(
|
|
{
|
|
path: `${BASE_ACTION_API_PATH}/connectors`,
|
|
validate: {},
|
|
},
|
|
router.handleLegacyErrors(
|
|
verifyAccessAndContext(licenseState, async function (context, req, res) {
|
|
const actionsClient = context.actions.getActionsClient();
|
|
const result = await actionsClient.getAll();
|
|
return res.ok({
|
|
body: rewriteBodyRes(result),
|
|
});
|
|
})
|
|
)
|
|
);
|
|
};
|