Skip to content

Commit 0e5cf0a

Browse files
committed
dynamic settings work
1 parent a1bc3ff commit 0e5cf0a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

x-pack/legacy/plugins/uptime/server/rest_api/dynamic_settings/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { UMRestApiRouteFactory } from '..';
7+
import { schema } from '@kbn/config-schema';
88
import { UMServerLibs } from '../../lib/lib';
99
import { savedObjectsAdapter } from '../../lib/adapters';
10+
import { UMDynamicSettingsType } from '../../lib/sources';
11+
import { UMRestApiRouteFactory } from '..';
1012

1113
export const createGetDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
1214
method: 'GET',
@@ -24,16 +26,17 @@ export const createGetDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMSer
2426
},
2527
});
2628

27-
export const createSetDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
28-
method: 'PUT',
29+
export const createPostDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
30+
method: 'POST',
2931
path: '/api/uptime/dynamic_settings',
30-
validate: false,
32+
validate: schema.object({}, { allowUnknowns: true }),
3133
options: {
3234
tags: ['access:uptime'],
3335
},
3436
handler: async ({ savedObjectsClient }, _context, request, response): Promise<any> => {
35-
console.log("BODY IS", request.body);
36-
await savedObjectsAdapter.setUptimeSourceSettings(savedObjectsClient, JSON.parse(request.body));
37+
// @ts-ignore
38+
const newSettings: UMDynamicSettingsType = request.body;
39+
await savedObjectsAdapter.setUptimeSourceSettings(savedObjectsClient, newSettings);
3740

3841
return response.ok({
3942
body: {

x-pack/legacy/plugins/uptime/server/rest_api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { createGetAllRoute } from './pings';
88
import { createGetIndexPatternRoute } from './index_pattern';
9-
import { createGetDynamicSettingsRoute } from './dynamic_settings';
9+
import { createGetDynamicSettingsRoute, createPostDynamicSettingsRoute } from './dynamic_settings';
1010
import { createLogMonitorPageRoute, createLogOverviewPageRoute } from './telemetry';
1111
import { createGetSnapshotCount } from './snapshot';
1212
import { UMRestApiRouteFactory } from './types';
@@ -19,6 +19,7 @@ export const restApiRoutes: UMRestApiRouteFactory[] = [
1919
createGetAllRoute,
2020
createGetIndexPatternRoute,
2121
createGetDynamicSettingsRoute,
22+
createPostDynamicSettingsRoute,
2223
createGetMonitorDetailsRoute,
2324
createGetMonitorLocationsRoute,
2425
createGetSnapshotCount,

0 commit comments

Comments
 (0)