Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HttpSetup } from '@kbn/core/public';
import { TimeSeriesResult } from '@kbn/triggers-actions-ui-plugin/common';
import { IndexThresholdAlertParams } from './types';

const INDEX_THRESHOLD_DATA_API_ROOT = '/api/triggers_actions_ui/data';
const INDEX_THRESHOLD_DATA_API_ROOT = '/internal/triggers_actions_ui/data';

export interface GetThresholdAlertVisualizationDataParams {
model: IndexThresholdAlertParams;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/triggers_actions_ui/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
/* eslint-disable @kbn/eslint/no_export_all */

export * from './data';
export const BASE_TRIGGERS_ACTIONS_UI_API_PATH = '/api/triggers_actions_ui';
export const BASE_TRIGGERS_ACTIONS_UI_API_PATH = '/internal/triggers_actions_ui';
export * from './parse_interval';
export * from './experimental_features';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('triggersActionsUiConfig', () => {
expect(http.get.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"/api/triggers_actions_ui/_config",
"/internal/triggers_actions_ui/_config",
],
]
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Data API', () => {
http.post.mockResolvedValueOnce(mockFields);
const fields = await getESIndexFields({ indexes, http });

expect(http.post).toHaveBeenCalledWith('/api/triggers_actions_ui/data/_fields', {
expect(http.post).toHaveBeenCalledWith('/internal/triggers_actions_ui/data/_fields', {
body: `{"indexPatterns":${JSON.stringify(indexes)}}`,
});
expect(fields).toEqual(mockFields.fields);
Expand All @@ -50,7 +50,7 @@ describe('Data API', () => {
http.post.mockResolvedValueOnce(mockIndices);
const indices = await getMatchingIndices({ pattern, http });

expect(http.post).toHaveBeenCalledWith('/api/triggers_actions_ui/data/_indices', {
expect(http.post).toHaveBeenCalledWith('/internal/triggers_actions_ui/data/_indices', {
body: `{"pattern":"*${mockPattern}*"}`,
});
expect(indices).toEqual(mockIndices.indices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { HttpSetup } from '@kbn/core/public';
import { DataViewsContract, DataView } from '@kbn/data-views-plugin/public';

const DATA_API_ROOT = '/api/triggers_actions_ui/data';
const DATA_API_ROOT = '/internal/triggers_actions_ui/data';

const formatPattern = (pattern: string) => {
let formattedPattern = pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('triggersActionsUiHealth', () => {
expect(http.get.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"/api/triggers_actions_ui/_health",
"/internal/triggers_actions_ui/_health",
],
]
`);
Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/triggers_actions_ui/server/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The TriggersActionsUi plugin's Data Apis back the functionality needed by the In

The following endpoints are provided for this alert type:

- `POST /api/triggers_actions_ui/data/_indices`
- `POST /api/triggers_actions_ui/data/_fields`
- `POST /api/triggers_actions_ui/data/_time_series_query`
- `POST /internal/triggers_actions_ui/data/_indices`
- `POST /internal/triggers_actions_ui/data/_fields`
- `POST /internal/triggers_actions_ui/data/_time_series_query`

### `POST .../_indices`

Expand Down Expand Up @@ -79,7 +79,7 @@ provide a "preview" of the alert during creation/editing based on recent data,
and could be used to show a "simulation" of the the alert over an arbitrary
range of time.

The endpoint is `POST /api/triggers_actions_ui/data/_time_series_query`.
The endpoint is `POST /internal/triggers_actions_ui/data/_time_series_query`.
The request and response bodies are specifed in
[`lib/core_query_types.ts`][it-core-query]
and
Expand All @@ -93,7 +93,7 @@ for the last 10 seconds.
This example uses [now-iso][] to generate iso date strings.

```console
curl -k "https://elastic:changeme@localhost:5601/api/triggers_actions_ui/data/_time_series_query" \
curl -k "https://elastic:changeme@localhost:5601/internal/triggers_actions_ui/data/_time_series_query" \
-H "kbn-xsrf: foo" -H "content-type: application/json" -d "{
\"index\": \"es-hb-sim\",
\"timeField\": \"@timestamp\",
Expand Down Expand Up @@ -136,7 +136,7 @@ curl -k "https://elastic:changeme@localhost:5601/api/triggers_actions_ui/data/_
To get the current value of the calculated metric, you can leave off the date:

```
curl -k "https://elastic:changeme@localhost:5601/api/triggers_actions_ui/data/_time_series_query" \
curl -k "https://elastic:changeme@localhost:5601/internal/triggers_actions_ui/data/_time_series_query" \
-H "kbn-xsrf: foo" -H "content-type: application/json" -d '{
"index": "es-hb-sim",
"timeField": "@timestamp",
Expand Down Expand Up @@ -169,7 +169,7 @@ curl -k "https://elastic:changeme@localhost:5601/api/triggers_actions_ui/data/_
## service functions

A single service function is available that provides the functionality
of the http endpoint `POST /api/triggers_actions_ui/data/_time_series_query`,
of the http endpoint `POST /internal/triggers_actions_ui/data/_time_series_query`,
but as an API for Kibana plugins. The function is available as
`triggersActionsUi.data.timeSeriesQuery()` on the plugin's _Start_ contract

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ describe('createConfigRoute', () => {
it('registers the route', async () => {
const router = httpServiceMock.createRouter();
const logger = loggingSystemMock.create().get();
createConfigRoute(logger, router, `/api/triggers_actions_ui`, () => ({
createConfigRoute(logger, router, `/internal/triggers_actions_ui`, () => ({
isUsingSecurity: true,
minimumScheduleInterval: { value: '1m', enforce: false },
}));

const [config, handler] = router.get.mock.calls[0];
expect(config.path).toMatchInlineSnapshot(`"/api/triggers_actions_ui/_config"`);
expect(config.path).toMatchInlineSnapshot(`"/internal/triggers_actions_ui/_config"`);

const mockResponse = httpServerMock.createResponseFactory();
await handler({}, httpServerMock.createKibanaRequest(), mockResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Spaces } from '../../../../scenarios';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { ESTestIndexTool, ES_TEST_INDEX_NAME, getUrlPrefix } from '../../../../../common/lib';

const API_URI = 'api/triggers_actions_ui/data/_fields';
const API_URI = 'internal/triggers_actions_ui/data/_fields';

// eslint-disable-next-line import/no-default-export
export default function fieldsEndpointTests({ getService }: FtrProviderContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ESTestIndexTool, ES_TEST_INDEX_NAME, getUrlPrefix } from '../../../../.
import { createEsDocumentsWithGroups } from '../lib/create_test_data';
import { createDataStream, deleteDataStream } from '../lib/create_test_data';

const API_URI = 'api/triggers_actions_ui/data/_indices';
const API_URI = 'internal/triggers_actions_ui/data/_indices';

// eslint-disable-next-line import/no-default-export
export default function indicesEndpointTests({ getService }: FtrProviderContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { ESTestIndexTool, ES_TEST_INDEX_NAME, getUrlPrefix } from '../../../../.

import { createEsDocumentsWithGroups } from '../lib/create_test_data';

const INDEX_THRESHOLD_TIME_SERIES_QUERY_URL = 'api/triggers_actions_ui/data/_time_series_query';
const INDEX_THRESHOLD_TIME_SERIES_QUERY_URL =
'internal/triggers_actions_ui/data/_time_series_query';

const START_DATE_MM_DD_HH_MM_SS_MS = '01-01T00:00:00.000Z';
const START_DATE = `2020-${START_DATE_MM_DD_HH_MM_SS_MS}`;
Expand Down