File tree Expand file tree Collapse file tree 3 files changed +13
-15
lines changed
x-pack/plugins/ingest_manager Expand file tree Collapse file tree 3 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,16 @@ export type AgentType =
1414
1515export type AgentStatus = 'offline' | 'error' | 'online' | 'inactive' | 'warning' ;
1616
17- export interface AgentAction extends SavedObjectAttributes {
17+ export interface NewAgentAction {
1818 type : 'CONFIG_CHANGE' | 'DATA_DUMP' | 'RESUME' | 'PAUSE' ;
19- id : string ;
20- created_at : string ;
2119 data ?: string ;
2220 sent_at ?: string ;
2321}
2422
25- export type NewAgentAction = Pick < AgentAction , 'type' | 'data' | 'sent_at' > ;
23+ export interface AgentAction extends NewAgentAction , SavedObjectAttributes {
24+ id : string ;
25+ created_at : string ;
26+ }
2627
2728export interface AgentEvent {
2829 type : 'STATE' | 'ERROR' | 'ACTION_RESULT' | 'ACTION' ;
Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ import { httpServerMock } from '../../../../../../src/core/server/http/http_serv
1515import { ActionsService } from '../../services/agents' ;
1616import { AgentAction } from '../../../common/types/models' ;
1717import { postNewAgentActionHandlerBuilder } from './actions_handlers' ;
18- import { PostNewAgentActionResponse } from '../../../common/types/rest_spec' ;
18+ import {
19+ PostNewAgentActionRequest ,
20+ PostNewAgentActionResponse ,
21+ } from '../../../common/types/rest_spec' ;
1922
2023describe ( 'test actions handlers schema' , ( ) => {
2124 it ( 'validate that new agent actions schema is valid' , async ( ) => {
@@ -48,7 +51,7 @@ describe('test actions handlers', () => {
4851 } ) ;
4952
5053 it ( 'should succeed on valid new agent action' , async ( ) => {
51- const mockRequest = httpServerMock . createKibanaRequest ( {
54+ const mockRequest = httpServerMock . createKibanaRequest ( ( {
5255 body : {
5356 action : {
5457 type : 'CONFIG_CHANGE' ,
@@ -59,7 +62,7 @@ describe('test actions handlers', () => {
5962 params : {
6063 agentId : 'id' ,
6164 } ,
62- } ) ;
65+ } as unknown ) as PostNewAgentActionRequest ) ;
6366
6467 const agentAction = ( {
6568 type : 'CONFIG_CHANGE' ,
Original file line number Diff line number Diff line change @@ -31,18 +31,12 @@ export async function updateAgentActions(
3131}
3232
3333export function createAgentAction ( createdAt : Date , newAgentAction : NewAgentAction ) : AgentAction {
34- const agentAction : object = {
34+ const agentAction = {
3535 id : uuid . v4 ( ) ,
3636 created_at : createdAt . toISOString ( ) ,
3737 } ;
3838
39- Object . assign ( agentAction , ...keys ( newAgentAction ) . map ( key => ( { [ key ] : newAgentAction [ key ] } ) ) ) ;
40-
41- return agentAction as AgentAction ;
42- }
43-
44- function keys < O extends object > ( obj : O ) : Array < keyof O > {
45- return Object . keys ( obj ) as Array < keyof O > ;
39+ return Object . assign ( agentAction , newAgentAction ) as AgentAction ;
4640}
4741
4842export interface ActionsService {
You can’t perform that action at this time.
0 commit comments