Este contenido no está disponible en el idioma seleccionado.
7.2. Collections
7.2.1. Listing All Resources in a Collection Copiar enlaceEnlace copiado en el portapapeles!
GET
request on the collection URI obtained from the entry point.
7.2.2. Listing Extended Resource Sub-Collections Copiar enlaceEnlace copiado en el portapapeles!
Accept
header includes the detail
parameter.
GET /api/collection HTTP/1.1 Accept: application/xml; detail=subcollection
GET /api/collection HTTP/1.1
Accept: application/xml; detail=subcollection
detail
parameters:
GET /api/collection HTTP/1.1 Accept: application/xml; detail=subcollection1; detail=subcollection2
GET /api/collection HTTP/1.1
Accept: application/xml; detail=subcollection1; detail=subcollection2
detail
parameter that separates the sub-collection with the +
operator:
GET /api/collection HTTP/1.1 Accept: application/xml; detail=subcollection1+subcollection2+subcollection3
GET /api/collection HTTP/1.1
Accept: application/xml; detail=subcollection1+subcollection2+subcollection3
Collection | Extended Sub-Collection Support |
---|---|
hosts | statistics |
bricks | statistics |
step | statistics |
Example 7.1. An request for extended statistics in the servers collection
GET /api/hosts HTTP/1.1 Accept: application/xml; detail=statistics
GET /api/hosts HTTP/1.1
Accept: application/xml; detail=statistics
7.2.3. Searching Collections with Queries Copiar enlaceEnlace copiado en el portapapeles!
GET
request on a "collection/search"
link results in a search query of that collection. The API only returns resources within the collection that satisfy the search query constraints.
7.2.3.1. Query Syntax Copiar enlaceEnlace copiado en el portapapeles!
query
with a GET
request:
GET /api/collection?search={query} HTTP/1.1 Accept: application/xml
GET /api/collection?search={query} HTTP/1.1
Accept: application/xml
query
template value refers to the search query the API directs to the collection
. This query
uses the same format as Red Hat Storage Console search query language:
(criteria) [sortby (element) asc|desc]
sortby
clause is optional and only needed when ordering results.
Collection | Criteria | Result |
---|---|---|
volumes | type=REPLICATE | Displays a list of all replicate volumes |
events | severity>normal sortby time | Displays the list of all events with severity higher than normal and sorted by the time element values. |
events | severity>normal sortby time desc | Displays the list of all events with severity higher than normal and sorted by the time element values in descending order. |
query
template to be URL-encoded to translate reserved characters, such as operators and spaces.
Example 7.2. URL-encoded search query
GET /api/events?search=severity%3Derror HTTP/1.1 Accept: application/xml
GET /api/events?search=severity%3Derror HTTP/1.1
Accept: application/xml
Important
7.2.3.2. Wildcards Copiar enlaceEnlace copiado en el portapapeles!
Example 7.3. Wildcard search query for name=server*
GET /api/hosts?search=name%3Dserver* HTTP/1.1 Accept: application/xml
GET /api/hosts?search=name%3Dserver* HTTP/1.1
Accept: application/xml
server
, such as server-1
, server-2
, or server-data
.
Example 7.4. Wildcard search query for name=s*1
GET /api/hosts?search=name%3D*1 HTTP/1.1 Accept: application/xml
GET /api/hosts?search=name%3D*1 HTTP/1.1
Accept: application/xml
s
and ending with 1
, such as server1
or server-1
.
7.2.3.3. Pagination Copiar enlaceEnlace copiado en el portapapeles!
page
command.
Example 7.5. Paginating resources
GET /api/collection?search=page%201 HTTP/1.1 Accept: application/xml
GET /api/collection?search=page%201 HTTP/1.1
Accept: application/xml
page
value to view the next page of results.
GET /api/collection?search=page%202 HTTP/1.1 Accept: application/xml
GET /api/collection?search=page%202 HTTP/1.1
Accept: application/xml
page
command also in conjunction with other commands in a search query. For example:
GET /api/collection?search=sortby%20element%20asc%20page%202 HTTP/1.1 Accept: application/xml
GET /api/collection?search=sortby%20element%20asc%20page%202 HTTP/1.1
Accept: application/xml
7.2.4. Creating a Resource in a Collection Copiar enlaceEnlace copiado en el portapapeles!
POST
request to the collection URI containing a representation of the new resource.
POST
request requires a Content-Type: application/xml
header. This informs the API of the XML representation in the body content as part of the request.
fault
representation indicating the missing elements.
Location
header in the response gives the URI of the queried resource. The response body contains either a complete representation, partial representation or no representation of the resource. It is recommended that clients rely only on fetching the representation via the URI in the response header.