06-Jul-2017
07:21
- last edited on
21-Nov-2022
22:03
by
JimmyPackets
Hi, I've build an iApp, and I would like to create/update services using iControl REST.
Creation is working fine:
↪ curl -sk -u admin:password -H "Content-Type: application/json" -X POST --data @iapp.json https://172.31.X.X/mgmt/tm/sys/application/service/ | jq .
{
"kind": "tm:sys:application:service:servicestate",
"name": "test",
"partition": "Common",
"subPath": "test.app",
"fullPath": "/Common/test.app/test",
"generation": 1120,
"selfLink": "https://localhost/mgmt/tm/sys/application/service/~Common~test.app~test?ver=13.0.0",
"deviceGroup": "none",
"inheritedDevicegroup": "false",
"inheritedTrafficGroup": "false",
"strictUpdates": "enabled",
"template": "/Common/mytemplate",
"templateReference": {
"link": "https://localhost/mgmt/tm/sys/application/template/~Common~mytemplate?ver=13.0.0"
},
"templateModified": "no",
"trafficGroup": "none",
"tables": [
{
"name": "hosts__ip_host",
"columnNames": [
"ip",
"host"
],
"rows": [ ..... ]
}
],
"variables": [
{
"name": "vip__vip",
"encrypted": "no",
"value": "2.2.2.2"
}
]
}
`
Update is not easy :
`↪ curl -sk -u admin:password -H "Content-Type: application/json" -X POST --data @iapp.json https://172.31.X.X/mgmt/tm/sys/application/service/
{"code":400,"message":"01020066:3: The requested application instance (/Common/test.app/test) already exists in partition Common.","errorStack":[],"apiError":3}
↪ curl -sk -u admin:password -H "Content-Type: application/json" -X PUT --data @iapp.json https://172.31.X.X/mgmt/tm/sys/application/service/
{"code":403,"message":"Operation is not supported on component /sys/application/service.","errorStack":[],"apiError":1}
Do you see where I'm wrong ?
Do you know how to use the "Reconfigure" action that I use to have in WebUI?
Thank you in advance,
Best regards,
- Sébastien B.
10-Jul-2017
17:35
- last edited on
05-Jun-2023
15:11
by
JimmyPackets
Use the
PATCH
method to modify the field(s).
Check the
selfLink
field in the output you got when you created the iApp. That's where the endpoint (URL) is. In your case, that's
"selfLink": "https://localhost/mgmt/tm/sys/application/service/~Common~test.app~test?ver=13.0.0",
For example,
Create an iApp (TestApp):
curl -sku admin: https:///mgmt/tm/sys/application/service \
-H "Content-Type: application/json" \
-X POST -d@iAppMakeDel.dat
The output says:
{
...
"fullPath":"/Common/TestApp.app/TestApp",
"selfLink":"https://localhost/mgmt/tm/sys/application/service/~Common~TestApp.app~TestApp?ver=11.6.1",
...
}
Get the iApp (equivalent to
tmsh list sys application service TestApp.app/TestApp
😞
curl -sku admin: \
https:///mgmt/tm/sys/application/service/~Common~TestApp.app~TestApp
Modify the Description field:
curl -D - -sku admin: \
https:///mgmt/tm/sys/application/service/~Common~TestApp.app~TestApp \
-X PATCH -H "Content-Type: application/json" \
-d '{"description":"Hello World"}'