-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix commands manager arguments parsing #245
Conversation
… integers and texts
Tested, it works with:
|
The API raises an error when the field
The rest of scenarios were successful
(apart from the already tested scenarios on the comment #245 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested objects scenario failing, details on comment #245 (comment)
Last commit implements the parsing of nested objects within {
"commands": [
{
"source": "Users/Services",
"user": "Management API",
"target": {
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0",
"type": "agent"
},
"action": {
"name": "set-group",
"version": "5.0.0",
"args": {
"groups": [
"group_1",
"group_2",
"group_3"
],
"type": {"1": "group_1"}
}
},
"timeout": 100
}
]
} returns {
"_index": ".commands",
"_documents": [
{
"_id": "DHJEmJQBLxruv0ftQq7p"
}
],
"result": "OK"
} and the document is correctly indexed: {
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": ".commands",
"_id": "BnJBmJQBLxruv0ft8q7f",
"_score": 1,
"_source": {
"agent": {
"groups": [
"groups000"
]
},
"command": {
"source": "Users/Services",
"user": "Management API",
"target": {
"type": "agent",
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0"
},
"action": {
"name": "set-group",
"args": {
"type": {
"1": "group_1"
},
"groups": [
"group_1",
"group_2",
"group_3"
]
},
"version": "5.0.0"
},
"timeout": 100,
"status": "pending",
"order_id": "BXJBmJQBLxruv0ft8q7e",
"request_id": "BHJBmJQBLxruv0ft8q7e"
},
"@timestamp": "2025-01-24T12:20:46Z",
"delivery_timestamp": "2025-01-24T12:22:26Z"
}
}
]
}
} The command above is not a valid command, but for now we want to accept anything within Valid commands are also accepted: set-group {
"commands": [
{
"source": "Users/Services",
"user": "Management API",
"target": {
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0",
"type": "agent"
},
"action": {
"name": "set-group",
"version": "5.0.0",
"args": {
"groups": [
"group_1",
"group_2",
"group_3"
]
}
},
"timeout": 100
}
]
} fetch-config {
"commands": [
{
"source": "Users/Services",
"user": "Management API",
"target": {
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0",
"type": "agent"
},
"action": {
"name": "set-group",
"version": "5.0.0",
"args": {}
},
"timeout": 100
}
]
} |
The API handles correctly the nested args, even with multiple layers of nesting Request {
"commands": [
{
"source": "Users/Services",
"user": "Management API",
"target": {
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0",
"type": "agent"
},
"action": {
"name": "set-group",
"version": "5.0.0",
"args": {
"nested1": {
"1": "test",
"nested2": {
"2": "test"
}
}
}
},
"timeout": 100
}
]
} Response {
"_index": ".commands",
"_documents": [
{
"_id": "hJpWmJQBk1YoO7gM2krJ"
}
],
"result": "OK"
} Document indexed on the cluster % curl http://127.0.0.1:9200/.commands/_search
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": ".commands",
"_id": "hJpWmJQBk1YoO7gM2krJ",
"_score": 1.0,
"_source": {
"agent": {
"groups": [
"groups000"
]
},
"command": {
"source": "Users/Services",
"user": "Management API",
"target": {
"type": "agent",
"id": "0a96a0ab-5bef-415c-bb3c-ea3e294215a0"
},
"action": {
"name": "set-group",
"args": {
"nested1": {
"1": "test",
"nested2": {
"2": "test"
}
}
},
"version": "5.0.0"
},
"timeout": 100,
"status": "pending",
"order_id": "g5pWmJQBk1YoO7gM2krH",
"request_id": "gppWmJQBk1YoO7gM2krH"
},
"@timestamp": "2025-01-24T12:43:36Z",
"delivery_timestamp": "2025-01-24T12:45:16Z"
}
}
]
}
} |
Description
Change the parsing of
command.acttion.args
so it can receive nested objects.Issues Resolved
244