Reducing the number of calls
Good integration design typically involves writing integration points so that the number of calls between services is as small as possible. Cloud API includes multiple features that let caller applications execute multiple requests in a single call. This topic discusses these features in detail.
Features that execute multiple requests at once
Cloud API has several features that let caller applications execute multiple requests in a single call: composite requests, request inclusion, and batch requests.
Composite requests are requests which consist of multiple sibling subrequests, with no parent request. Each subrequest is executed transactionally in the order it appears. If a given subrequest that attempts to commit data fails, the entire composite request fails. Information can be passed from one subrequest to another.
For details about composite requests, see Composite requests.
Request inclusion is a technique for POSTs and PATCHes in which the call consists of the following:
- A single parent request that creates or modifies a resource
- One or more child requests that create or modify resources related to the parent resource
If either the parent request or any child request fails, the entire request fails.
For details about request inclusion, see Request inclusion.
Batch requests are requests which consist of multiple sibling subrequests, with no parent request. Each subrequest is executed non-transactionally in the order it appears. If a given subrequest fails, other subrequests in the batch might still be attempted. Also, there is no mechanism for passing information from one subrequest to another. Each subrequest is essentially independent from the others.
For details about batch requests, see Batch requests.
Comparing features that execute multiple requests
|Feature||Composite requests||Request inclusion||Batch requests|
|Sibling subrequests (with no parent request)||A parent request with one or more child requests||Sibling subrequests (with no parent request)|
|The endpoint to call||The Composite API's
||The endpoint that creates or modifies the parent object (though not all endpoints support request inclusion)||The relevant API's
|Behavior when one subrequest that attempts to commit data fails||The entire request fails||The entire request fails||Other subrequests may still be attempted|
|Passing information between subrequests||Through the use of variables||Through the use of refids||Not possible|
|Allows GET subrequests?||Yes||No||Yes|
|Allows DELETE subrequests?||Yes||No||Yes|
|Allows business action POST subrequests (such as
|Allows the creation or modification of two unrelated objects?||Yes||No||Yes|
Determining which feature to use
There is no simple algorithm for determining the appropriate feature to use. In some situations, it may be possible to use multiple features, but it is easier to write the code using one particular feature.
At a high level, composite requests are typically the most robust option. If there is a choice of which feature to use, it may be best or easiest to use composite requests.
The following guidelines may also help you determine the best feature to use:
- Use composite requests or request inclusion if:
- All subrequests must succeed or fail as a unit.
- Information must be passed from one subrequest to another.
- The subrequests must use endpoints from different APIs.
- Use composite requests or batch requests if:
- At least some of the subrequests are GETs, DELETEs, or business action POSTs
There also may be some situations where a given technique is required. For example, unverified policies can only be created through composite requests.