Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Add view agents button to activity flyout #152555

Merged
merged 20 commits into from
Mar 13, 2023
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
58 changes: 58 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,54 @@
"basicAuth": []
}
]
},
"post": {
"summary": "List agents by action ids",
"tags": [
"Agents"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/agent_get_by_actions"
}
}
}
},
"400": {
"$ref": "#/components/responses/error"
}
},
"operationId": "get-agents-by-actions",
"parameters": [
{
"$ref": "#/components/parameters/kbn_xsrf"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"actionIds": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"policy_id"
]
}
}
}
}
}
},
"/agents/bulk_upgrade": {
Expand Down Expand Up @@ -6137,6 +6185,16 @@
"perPage"
]
},
"agent_get_by_actions": {
"title": "Agents get by action ids",
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
},
"bulk_upgrade_agents": {
"title": "Bulk upgrade agents",
"type": "object",
Expand Down
36 changes: 36 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,35 @@ paths:
type: boolean
security:
- basicAuth: []
post:
summary: List agents by action ids
tags:
- Agents
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agent_get_by_actions'
'400':
$ref: '#/components/responses/error'
operationId: get-agents-by-actions
parameters:
- $ref: '#/components/parameters/kbn_xsrf'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
actionIds:
type: array
items:
type: string
required:
- policy_id
/agents/bulk_upgrade:
post:
summary: Bulk upgrade agents
Expand Down Expand Up @@ -3890,6 +3919,13 @@ components:
- total
- page
- perPage
agent_get_by_actions:
title: Agents get by action ids
type: array
items:
type: array
items:
type: string
bulk_upgrade_agents:
title: Bulk upgrade agents
type: object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: Agents get by action ids
type: array
items:
type: array
items:
type: string
29 changes: 29 additions & 0 deletions x-pack/plugins/fleet/common/openapi/paths/agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,32 @@ get:
type: boolean
security:
- basicAuth: []
post:
summary: List agents by action ids
tags:
- Agents
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: ../components/schemas/agent_get_by_actions.yaml
'400':
$ref: ../components/responses/error.yaml
operationId: get-agents-by-actions
parameters:
- $ref: ../components/headers/kbn_xsrf.yaml
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
actionIds:
type: array
items:
type: string
required:
- policy_id
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/services/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export const agentRouteService = {
'{fileName}',
fileName
),
getAgentsByActionsPath: () => AGENT_API_ROUTES.LIST_PATTERN,
};

export const outputRoutesService = {
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/fleet/common/types/rest_spec/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,13 @@ export interface GetActionStatusResponse {
export interface GetAvailableVersionsResponse {
items: string[];
}

export interface PostRetrieveAgentsByActionsRequest {
body: {
actionIds: string[];
};
}

export interface PostRetrieveAgentsByActionsResponse {
items: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ describe('AgentActivityFlyout', () => {
const mockOnClose = jest.fn();
const mockOnAbortSuccess = jest.fn();
const mockAbortUpgrade = jest.fn();
const mockSetSearch = jest.fn();
const mockSetSelectedStatus = jest.fn();

beforeEach(() => {
mockOnClose.mockReset();
mockOnAbortSuccess.mockReset();
mockAbortUpgrade.mockReset();
mockUseActionStatus.mockReset();
mockSetSearch.mockReset();
mockSetSelectedStatus.mockReset();
mockUseGetAgentPolicies.mockReturnValue({
data: {
items: [
Expand Down Expand Up @@ -60,6 +64,8 @@ describe('AgentActivityFlyout', () => {
onClose={mockOnClose}
onAbortSuccess={mockOnAbortSuccess}
refreshAgentActivity={false}
setSearch={mockSetSearch}
setSelectedStatus={mockSetSelectedStatus}
/>
</IntlProvider>
);
Expand Down
Loading