[Ingest Manager] expose method to get agent and list agents to other plugins (#70087)
This commit is contained in:
parent
f47b3e50c7
commit
6e9972e693
|
@ -54,7 +54,12 @@ import {
|
||||||
AgentService,
|
AgentService,
|
||||||
datasourceService,
|
datasourceService,
|
||||||
} from './services';
|
} from './services';
|
||||||
import { getAgentStatusById, authenticateAgentWithAccessToken } from './services/agents';
|
import {
|
||||||
|
getAgentStatusById,
|
||||||
|
authenticateAgentWithAccessToken,
|
||||||
|
listAgents,
|
||||||
|
getAgent,
|
||||||
|
} from './services/agents';
|
||||||
import { CloudSetup } from '../../cloud/server';
|
import { CloudSetup } from '../../cloud/server';
|
||||||
import { agentCheckinState } from './services/agents/checkin/state';
|
import { agentCheckinState } from './services/agents/checkin/state';
|
||||||
|
|
||||||
|
@ -236,7 +241,7 @@ export class IngestManagerPlugin
|
||||||
plugins: {
|
plugins: {
|
||||||
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
|
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
|
||||||
}
|
}
|
||||||
) {
|
): Promise<IngestManagerStartContract> {
|
||||||
await appContextService.start({
|
await appContextService.start({
|
||||||
encryptedSavedObjectsStart: plugins.encryptedSavedObjects,
|
encryptedSavedObjectsStart: plugins.encryptedSavedObjects,
|
||||||
encryptedSavedObjectsSetup: this.encryptedSavedObjectsSetup,
|
encryptedSavedObjectsSetup: this.encryptedSavedObjectsSetup,
|
||||||
|
@ -255,6 +260,8 @@ export class IngestManagerPlugin
|
||||||
return {
|
return {
|
||||||
esIndexPatternService: new ESIndexPatternSavedObjectService(),
|
esIndexPatternService: new ESIndexPatternSavedObjectService(),
|
||||||
agentService: {
|
agentService: {
|
||||||
|
getAgent,
|
||||||
|
listAgents,
|
||||||
getAgentStatusById,
|
getAgentStatusById,
|
||||||
authenticateAgentWithAccessToken,
|
authenticateAgentWithAccessToken,
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { SavedObjectsClientContract } from 'kibana/server';
|
import { SavedObjectsClientContract, KibanaRequest } from 'kibana/server';
|
||||||
import { AgentStatus } from '../types';
|
import { AgentStatus, Agent } from '../types';
|
||||||
import * as settingsService from './settings';
|
import * as settingsService from './settings';
|
||||||
export { ESIndexPatternSavedObjectService } from './es_index_pattern';
|
export { ESIndexPatternSavedObjectService } from './es_index_pattern';
|
||||||
|
|
||||||
|
@ -24,12 +24,38 @@ export interface ESIndexPatternService {
|
||||||
* A service that provides exported functions that return information about an Agent
|
* A service that provides exported functions that return information about an Agent
|
||||||
*/
|
*/
|
||||||
export interface AgentService {
|
export interface AgentService {
|
||||||
|
/**
|
||||||
|
* Get an Agent by id
|
||||||
|
*/
|
||||||
|
getAgent(soClient: SavedObjectsClientContract, agentId: string): Promise<Agent>;
|
||||||
|
/**
|
||||||
|
* Authenticate an agent with access toekn
|
||||||
|
*/
|
||||||
|
authenticateAgentWithAccessToken(
|
||||||
|
soClient: SavedObjectsClientContract,
|
||||||
|
request: KibanaRequest
|
||||||
|
): Promise<Agent>;
|
||||||
/**
|
/**
|
||||||
* Return the status by the Agent's id
|
* Return the status by the Agent's id
|
||||||
* @param soClient
|
|
||||||
* @param agentId
|
|
||||||
*/
|
*/
|
||||||
getAgentStatusById(soClient: SavedObjectsClientContract, agentId: string): Promise<AgentStatus>;
|
getAgentStatusById(soClient: SavedObjectsClientContract, agentId: string): Promise<AgentStatus>;
|
||||||
|
/**
|
||||||
|
* List agents
|
||||||
|
*/
|
||||||
|
listAgents(
|
||||||
|
soClient: SavedObjectsClientContract,
|
||||||
|
options: {
|
||||||
|
page: number;
|
||||||
|
perPage: number;
|
||||||
|
kuery?: string;
|
||||||
|
showInactive: boolean;
|
||||||
|
}
|
||||||
|
): Promise<{
|
||||||
|
agents: Agent[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
perPage: number;
|
||||||
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saved object services
|
// Saved object services
|
||||||
|
|
|
@ -35,6 +35,9 @@ export const createMockEndpointAppContextServiceStartContract = (): jest.Mocked<
|
||||||
export const createMockAgentService = (): jest.Mocked<AgentService> => {
|
export const createMockAgentService = (): jest.Mocked<AgentService> => {
|
||||||
return {
|
return {
|
||||||
getAgentStatusById: jest.fn(),
|
getAgentStatusById: jest.fn(),
|
||||||
|
authenticateAgentWithAccessToken: jest.fn(),
|
||||||
|
getAgent: jest.fn(),
|
||||||
|
listAgents: jest.fn(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue