File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
x-pack/legacy/plugins/uptime/server/rest_api Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 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 ' ;
88import { UMServerLibs } from '../../lib/lib' ;
99import { savedObjectsAdapter } from '../../lib/adapters' ;
10+ import { UMDynamicSettingsType } from '../../lib/sources' ;
11+ import { UMRestApiRouteFactory } from '..' ;
1012
1113export 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 : {
Original file line number Diff line number Diff line change 66
77import { createGetAllRoute } from './pings' ;
88import { createGetIndexPatternRoute } from './index_pattern' ;
9- import { createGetDynamicSettingsRoute } from './dynamic_settings' ;
9+ import { createGetDynamicSettingsRoute , createPostDynamicSettingsRoute } from './dynamic_settings' ;
1010import { createLogMonitorPageRoute , createLogOverviewPageRoute } from './telemetry' ;
1111import { createGetSnapshotCount } from './snapshot' ;
1212import { 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 ,
You can’t perform that action at this time.
0 commit comments