Forum Discussion
Add new key into data group without updating entire list using the API
- Apr 22, 2020
Hello,
I workaround this with options parameter:
e.g.
?options=records add { key3 { data value3 } }
curl -ku "admin:admin" -X PATCH -H 'Content-type: application/json' -d '{ "name":"my_datagroup" }' https://localhost/mgmt/tm/ltm/data-group/internal/my_datagroup?options=records%20add%20%7b%20key3%20%7b%20data%20value3%20%7d%20%7d |jq .Best regards.
Hi,
You can find a generic explanation in user guide about options parameter.
"options:
Specifies the options to a query request. This parameter takes values that are compatible with the tmsh command-line options."
In this case, "PATCH" runs "modify" and "options" completes the tmsh command:
e.g.
modify ltm data-group internal my_datagroup records add { key3 { data value3 } }
So, to delete a record, change operation to "delete":
?options=records delete { key1 }
curl -ku "admin:admin" -X PATCH -H 'Content-type: application/json' -d '{ "name":"my_datagroup" }' https://localhost/mgmt/tm/ltm/data-group/internal/my_datagroup?options=records%20delete%20%7B%20key1%20%7D |jq .
Full docs:
https://clouddocs.f5.com/api/icontrol-rest/#
https://cdn.f5.com/websites/devcentral.f5.com/downloads/icontrol-rest-api-user-guide-14-1-0.pdf
Data-group docs:
https://clouddocs.f5.com/api/icontrol-rest/APIRef_tm_ltm_data-group.html
Regards
Hi ,
I just ran a test on versions 14.1.2.2 and 13.1.3.2 successfully.
Best regards.
[root@bigipdelta:Active:Standalone] config # tmsh list ltm data-group internal dg_devcentral
ltm data-group internal dg_devcentral {
records {
key1 {
data value1
}
key2 {
data value2
}
key3 {
data value3
}
key4 {
data value4
}
key5 {
data value5
}
}
type string
}
[root@bigipdelta:Active:Standalone] config # curl -k -su "admin" -X PATCH -H 'Content-type: application/json' -d '{ "name":"dg_devcentral" }' https://localhost/mgmt/tm/ltm/data-group/internal/dg_devcentral?options=records%20delete%20%7B%20key1%20%7D |jq .
Enter host password for user 'admin':
{
"kind": "tm:ltm:data-group:internal:internalstate",
"name": "dg_devcentral",
"fullPath": "dg_devcentral",
"generation": 499,
"selfLink": "https://localhost/mgmt/tm/ltm/data-group/internal/dg_devcentral?options=records+delete+%7B+key1+%7D&ver=14.1.2.2",
"type": "string",
"records": [
{
"name": "key2",
"data": "value2"
},
{
"name": "key3",
"data": "value3"
},
{
"name": "key4",
"data": "value4"
},
{
"name": "key5",
"data": "value5"
}
]
}
[root@bigipdelta:Active:Standalone] config # curl -k -su "admin" -X PATCH -H 'Content-type: application/json' -d '{ "name":"dg_devcentral" }' https://localhost/mgmt/tm/ltm/data-group/internal/dg_devcentral?options=records%20add%20%7b%20key1%20%7b%20data%20value1%20%7d%20%7d |jq .
Enter host password for user 'admin':
{
"kind": "tm:ltm:data-group:internal:internalstate",
"name": "dg_devcentral",
"fullPath": "dg_devcentral",
"generation": 500,
"selfLink": "https://localhost/mgmt/tm/ltm/data-group/internal/dg_devcentral?options=records+add+%7B+key1+%7B+data+value1+%7D+%7D&ver=14.1.2.2",
"type": "string",
"records": [
{
"name": "key1",
"data": "value1"
},
{
"name": "key2",
"data": "value2"
},
{
"name": "key3",
"data": "value3"
},
{
"name": "key4",
"data": "value4"
},
{
"name": "key5",
"data": "value5"
}
]
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com