Command Objects
Some TIBCO Cloud™ Integration API resources support command operations. These commands execute actions other than CRUD operations on the resource. See the documentation for the specific methods supported by each resource. While the commands are implemented as POST operations, there are different types of commands, each with different behavior: asynchronous, synchronous with results, and synchronous without results.
Command Type |
HTTP Verb |
HTTP Response On Success |
Notes |
---|---|---|---|
Asynchronous |
POST |
202 ACCEPTED |
Used for commands that may take some time to return their results. To return the result of the command, use a corresponding GET method with the ID returned in the command model from the POST method. See the Asynchronous example. |
Synchronous with results |
POST |
200 OK |
Used for commands that return their results quickly. The POST returns a model with the result of the command. See the Synchronous With Results example. |
Synchronous without results |
POST |
204 NO CONTENT |
Used for commands that do not return results. See the Synchronous Without Results example. |
POST Examples
Asynchronous
The following asynchronous command pushes a new app to the cloud:
POST /v1/subscriptions/{subscriptionLocator}/apps
curl -X POST "https://api.cloud.tibco.com/tci/v1/subscriptions/0/apps?appName=ASBTestNewApp1&instanceCount=0&retainAppProps=true" -H "accept: application/json" -H "Authorization: Bearer <your-oauth-token>" -H "Content-Type: multipart/form-data" -F "artifact=@flogo.json;type=application/json" -F "manifest.json=@manifest.json;type=application/json"
Returns a 202 code indicating that the request was accepted, but not that the request was completed:
{ "appId": "ctpzbxd3ixndbmceudmkjfmpj42negn4", "status": "success", "message": "App push request accepted successfully" }
Then, when you use the appId returned from the above model with the GET /v1/subscriptions/{subscriptionLocator}/apps/{appId}/status
method:
curl -X GET "https://api.cloud.tibco.com/tci/v1/subscriptions/0/apps/ctpzbxd3ixndbmceudmkjfmpj42negn4/status" -H "accept: application/json" -H "Authorization: Bearer <your-oauth-token>"
The status of the app is returned. In this case, the status is stopped because the app was pushed with 0 instances, however we know that the push to the cloud was successful because the message indicates that the process is completed.
{
"status": "stopped",
"message": "Application ctpzbxd3ixndbmceudmkjfmpj42negn4 process is completed.",
"details": "Application ctpzbxd3ixndbmceudmkjfmpj42negn4 was unlocked, i.e., the orchestration process was successfully completed.",
"instanceStatus": {}
}
Synchronous With Results
The following POST method that copies an app from one organization to another:
curl -X POST "https://api.cloud.tibco.com/tci/v1/subscriptions/0/apps/ctpzbxd3ixndbmceudmkjfmpj42negn4/copy?appName=ASBCopyApp1" -H "accept: application/json" -H "Authorization: Bearer <your-oauth-token>" -d ""
Immediately returns the results of the command:
{ "appId": "czqmh6dqrqmisg4rvap5yrn4xvuy2drf", }
Synchronous Without Results
The following POST method that changes an app owner from one user to another:
curl -X POST "https://api.cloud.tibco.com/tci/v1/subscriptions/0/apps/ctpzbxd3ixndbmceudmkjfmpj42negn4/owner?email=tbailey%40tibco.com" -H "accept: application/json" -H "Authorization: Bearer <your-oauth-token>" -d ""
Immediately returns the proper HTTP Response code or 200 OK with the following message:
{ "message": "The owner of app 'ASBPushAppAPI' was changed successfully" }