Page MenuHomeVyOS Platform

Comments via API
Open, WishlistPublicFEATURE REQUEST

Description

While the comments seem to work just file via CLI:

thomas@vyos02# comment firewall ipv4 name example2 "CLI Comment"
[edit]
thomas@vyos02# comment firewall ipv4 name example2 default-action "CLI Comment"
[edit]
thomas@vyos02# commit
[edit]
thomas@vyos02# show firewall ipv4 name |grep example2 -B1 -A5
 /* CLI Comment */
 name example2 {
     /* CLI Comment */
     default-action accept
 }

I am having some issues settings comments via the API

$ curl -k --location --request POST "https://$VYOS_HOST/configure" --form key="$VYOS_KEY" --form data='[{"op":"comment","path":["firewall","ipv4","name","example2","API Comment"]}]
'
{"success": false, "error": "Configuration path: [firewall ipv4 name example2 API Comment] is not valid\n\nComment failed\n", "data": null}

$ curl -k --location --request POST "https://$VYOS_HOST/configure" --form key="$VYOS_KEY" --form data='[{"op":"comment","path":["firewall","ipv4","name","example2","default-action","API Comment"]}]'
{"success": false, "error": "The specified config node does not exist\nComment failed\n", "data": null}

I am also not able to locate any way to retrieve config comments via the API at all.

$ curl -k --location --request POST "https://$VYOS_HOST/retrieve" --form key="$VYOS_KEY" --form data='{"op":"showConfig","path": ["firewall","ipv4","name","example2"]}'
{"success": true, "data": {"default-action": "accept"}, "error": null}

I was hoping to later support using the comments as a way for users to set notes on why configurations are needed, or ticket numbers, or as a key/value store in the same vain as AWS resource tags.

While I don't think modifying the showConfig should be modified and break the interface, maybe a dedicated comment operation would be good for symmetry with the (broken?) comment operation on the /configure endpoint?

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Improvement (missing useful functionality)

Event Timeline

Viacheslav triaged this task as Wishlist priority.Mar 25 2024, 9:55 AM

Comments can be set via the API with the following request format:

curl -k -X POST -Fkey=SOME_KEY -Fdata='{"op": "comment", "path": ["interfaces", "ethernet", "eth0"], "value": "some comment"}' https://192.168.122.244/configure

But for the moment, the rendering of the showConfig response does not include comments; I'll keep this as wishlist for now, and we can extend this sometime soon ...