Forum Discussion
youssef1
Jun 14, 2018Cumulonimbus
here the documentation you need:
https://devcentral.f5.com/d/icontrol-rest-user-guide-version-131-246
Here, you can folow this lab, it will show you how to use API rest (you can download Postman_collection with request already built for vs, pool, ... creation)
http://clouddocs.f5.com/training/community/programmability/html/class1/module1/lab2.html
Below, an example with curl:
1.1.1.1 is you management IP
- 1 authentication, retrieve token
This token will be re-use on the next steps...
curl -k -X POST -H "Content-Type: application/json" -d '{"username":"restapiuser","password":"restapiuser","loginProviderName": "tmos"}' https://1.1.1.1/mgmt/shared/authn/login
In response you should retrieve a token ...":{"token":"2MBZTX4RV2QKQDXWDRGG4XAETU"....
You have to reuse this token in order to access to F5
- 2 monitor creation
curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-monitor-api","send":"GET / HTTP/1.1\r\nHost: mymonitor.mydomain.com\r\nConnection: Close\r\n\r\n","recv":""}' https://1.1.1.1/mgmt/tm/ltm/monitor/http
- 3 pool creation
curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-pool-api","monitor":"/Common/my-monitor-api"}' https://1.1.1.1/mgmt/tm/ltm/pool
- 4 http profile creation
curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-http-profile-api","insertXforwarderFor":"enabled","serverAgentName":"spirit"}' https://1.1.1.1/mgmt/tm/ltm/profile/http
5 - vs creation
curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-vs-api","destination":"1.2.3.4:80","ipProtocol":"tcp","pool":"/Common/my-pool-api","sourceAddressTranslation":{"type":"automap"},"profiles": [{"name":"/Common/tcp", "context":"clientside" },{"name":"/Common/tcp-wan-optimized", "context":"serverside" },"/Common/my-http-profile-api"]}' https://1.1.1.1/mgmt/tm/ltm/virtual