This article describes how to perform multiple operations on NetScaler appliance using single NITRO API call.
One of the most basic sets of API operations used frequently by administrators is one that creates a set of lbvservers, services, and service groups, and adds the necessary bindings. This and similar tasks used to require multiple NITRO API commands, because the NITRO API did not support bulk configuration. Customers needed an API that could reduce network traffic by optimizing the execution of multiple tasks.
NetScaler release 11.1 introduced an API resource called macroapi, with which you can configure heterogeneous resources with a single API command.
Add 2 lbvservers, 5 services, and 1 service group, add members to the service group, bind service(s) to the lbvserver(s) and bind the service group to lbvserver(s).
URL: http://<NSIP>/nitro/v1/config/macroapi HTTP Method: POST Request Headers Content-Type: application/json X-NITRO-ONERROR: exit Payload: { "lbvserver": [ {"name":"lbvserver1","servicetype":"http"}, {"name":"lbvserver2","servicetype":"http"} ], "service": [ {"name":"service1", "servername":"10.102.216.115", "port":"80", "servicetype":"http"}, {"name":"service2","servername":"10.102.216.108", "port":"80","servicetype":"http"}, {"name":"service3","servername":"10.102.216.109", "port":"80","servicetype":"http"}, {"name":"service4","servername":"10.102.216.54", "port":"80","servicetype":"http"}, {"name":"service5","servername":"10.102.216.175", "port":"80","servicetype":"http"} ], "lbvserver_service_binding": [ {"name":"lbvserver1", "servicename":"service1"}, {"name":"lbvserver1", "servicename":"service2"}, {"name":"lbvserver1", "servicename":"service3"}, {"name":"lbvserver2", "servicename":"service4"}, {"name":"lbvserver2", "servicename":"service5"} ], "serviceGroup": [ { "servicegroupname": "servicegroup1", "servicetype": "HTTP" } ], "servicegroup_servicegroupmember_binding": [ { "servername":"10.105.157.72","servicegroupname":"servicegroup1","port":"80"}, { "servername":"10.105.157.246","servicegroupname":"servicegroup1","port":"80"} ], "lbvserver_servicegroup_binding": [ { "name":"lbvserver1", "servicegroupname":"servicegroup1" } ] }
Update lbmethod for 2 lbvservers and timeout for servicegroup
URL: http://<NSIP>/nitro/v1/config/macroapi HTTP Method: PUT Request Headers Content-Type: application/json X-NITRO-ONERROR: exit Payload: { "lbvserver": [ {"name":"lbvserver1","lbmethod":"roundrobin"}, {"name":"lbvserver2","lbmethod":"roundrobin"} ], "serviceGroup": [ { "servicegroupname": "servicegroup1", "svrtimeout": "10" } ] }
Delete 2 lbvservers, 5 services and 1 servicegroup
URL: http://<NSIP>/nitro/v1/config/macroapi?action=remove HTTP Method: POST Request Headers Content-Type: application/json X-NITRO-ONERROR: exit Payload: { "lbvserver": [ {"name":"lbvserver1"}, {"name":"lbvserver2"} ], "service": [ {"name":"service1"}, {"name":"service2"}, {"name":"service3"}, {"name":"service4"}, {"name":"service5"} ], "serviceGroup": [ { "servicegroupname": "servicegroup1"} ] }
Citrix Documentation - Handle Multiple NITRO Calls in a Single Request