HP OneView 1.05 User Guide

resource model. You can use the TaskResource resource model URI to list the current status of
the operation.
5.8 Task resource
When you make an asynchronous REST API operation, HTTP status 202 Accepted is returned
and the URI of a TaskResource resource model is returned in the Location header of the
response.
You can then perform a GET on the TaskResource model URI to poll for the status of the
asynchronous operation. The TaskResource model also contains the name and URI of the resource
that is affected by the task in the associatedResource attribute.
Creating an appliance backup example
1. Create an appliance backup.
/rest/backups
The URI of a TaskResource in the Location header is returned in the response.
2. Poll for status of the backup using the TaskResource URI returned in step 1.
/rest/tasks/{id}
3. When the task reaches the Completed state, use the associatedResource URI in the TaskResource to
download the backup file.
GET {associatedResource URI}
5.9 Error handling
If an error occurs during a REST API operation, a 4xx (client-side) or 5xx (appliance) error is
returned along with an error message (ErrorMessage resource model). The error message
contains a description and might contain recommended actions to correct the error.
A successful REST API POST operation returns the newly created resource (synchronous) or a
TaskResource URI in the Location header (asynchronous).
5.10 Concurrency control using etags
A client uses etags to verify the version of the resource model. This prevents the client from modifying
(PUT) a version of the resource model that is not current. For example, if a client performs a GET
on a server profile and receives an etag in the response header, modifies the server profile, and
then updates (PUT) the resource model, the etag in the PUT request header must match the resource
model etag. If the etags do not match, the client PUT request will not complete and a 412
PRECONDITION FAILED error is returned.
5.11 Querying resources and pagination using common REST API
parameters
Querying resources
You can use a set of common parameters to customize the results returned from a GET operation,
such as sorting or filtering. Each REST API specification lists the set of available common parameters.
Pagination when querying for a collection of resources
When you perform a GET operation to retrieve multiple resources (that is, a GET on a collection
URI, such as /rest/server-profiles), the resources are returned in a collection object that
includes an array of resources along with information about the set of resources returned. This
collection of resources may be automatically truncated into pages to improve performance when
74 Using the REST APIs and other programmatic interfaces