Add GraphQL type and resolver for agent activity events
What does this MR do and why?
Adds GraphQL type & resolver for activity events related to an Agent. These will be used by the frontend to create an activity stream.
Screenshots or screen recordings
GraphQL query:
{
project(fullPath: "path/to/agent-config") {
clusterAgent(name:"my-agent") {
name
activityEvents {
nodes {
kind
level
recordedAt
agentToken {
name
}
user {
name
}
}
}
}
}
}
Response:
{
"data": {
"project": {
"clusterAgent": {
"name": "my-agent",
"activityEvents": {
"nodes": [
{
"kind": "token_created",
"level": "info",
"recordedAt": "2021-11-24T00:36:38Z",
"agentToken": {
"name": "new token"
},
"user": {
"name": "Administrator"
}
}
]
}
}
}
}
}
How to set up and validate locally
- Create an Agent record:
Clusters::Agent.create!(project: <project>, name: 'example-agent')
- Create an Agent token:
Clusters::AgentTokens::CreateService.new(container: <project>, current_user: <user>, params: { agent_id: <agent-id>, name: 'example-token' }).execute
- From the GraphQL explorer, execute the above query.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #340364 (closed)
Edited by Tiger Watson