Product Documentation

Handle Multiple NITRO Calls in a Single Request

Sep 01, 2016

You can use the "macroapi" API to create, update, and delete multiple resources simultaneously, and thereby minimize network traffic. For example, multiple load-balancing virtual servers can be added in a single API.

To account for the failure of some operations within the bulk operation, NITRO allows configuring one of the following behaviors.

  • EXIT: When the first error is encountered, execution stops. The commands that were executed before the error are committed.

  • ROLLBACK: When the first error is encountered, execution stops. The commands that were executed before the error are rolled back. Rollback is supported for add and bind commands only.

  • CONTINUE: All the commands in the request are executed even if some commands fail.

You must specify the behavior of the bulk operation in the request header, by using the X-NITRO-ONERROR parameter.

Advantages

  • Heterogeneous resources can be configured with a single API. For example, multiple load balancing virtual servers and multiple services can be created, and services can be bound to load balancing virtual servers in a single API.

Limitations

  • Only homogenous operation is supported in this API. For example, multiple load balancing virtual servers can be created but cannot be updated or deleted in the same API.
  • “rollback” is supported only on “add” and “bind” operations.

For example, to add multiple load balancing resources in a single request:

HTTP Method
          POST

URL
         http://<NSIP>/nitro/v1/config/macroapi

 

Request Headers 복사

Content-Type: application/json

Cookie: NITRO_AUTH_TOKEN=<tokenvalue>

X-NITRO-ONERROR: exit

Request Payload 복사

{
"lbvserver":[
                      {"name":"lbv1","servicetype":"http"},
                      {"name":"lbv2","servicetype":"http"}
          ],
"serviceGroup": [
                      { "servicegroupname": "sg1", "servicetype": "HTTP" },
                      { "servicegroupname": "sg2", "servicetype": "HTTP" }
],
"lbvserver_servicegroup_binding":[
                     { "name":"lbv1", "servicegroupname":"sg1" },
                     { "name":"lbv2", "servicegroupname":"sg2" }
]
}
 

  • Response:

HTTP Status Code on Success
         201 Created for the add operation and 200 OK for the update operation.

HTTP Status Code on Failure
         207 Multi Status with error details in the response payload. For more information, see Error Handling.

For deleting multiple resources using macroapi, use POST HTTP method with query parameter “action=remove” in the URI.