Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
7.3. Collections
7.3.1. Collections Link kopierenLink in die Zwischenablage kopiert!
hosts collection which contains all virtualization hosts in the environment. An example of a sub-collection is the host.nics collection which contains resources for all network interface cards attached to a host resource.
7.3.2. Listing All Resources in a Collection Link kopierenLink in die Zwischenablage kopiert!
GET request on the collection URI obtained from the entry point.
Accept HTTP header to define the MIME type for the response format.
GET /ovirt-engine/api/[collection] HTTP/1.1 Accept: [MIME type]
GET /ovirt-engine/api/[collection] HTTP/1.1
Accept: [MIME type]
7.3.3. Listing Extended Resource Sub-Collections Link kopierenLink in die Zwischenablage kopiert!
Accept header includes the detail parameter.
GET /ovirt-engine/api/collection HTTP/1.1 Accept: application/xml; detail=subcollection
GET /ovirt-engine/api/collection HTTP/1.1
Accept: application/xml; detail=subcollection
detail parameters:
GET /ovirt-engine/api/collection HTTP/1.1 Accept: application/xml; detail=subcollection1; detail=subcollection2
GET /ovirt-engine/api/collection HTTP/1.1
Accept: application/xml; detail=subcollection1; detail=subcollection2
detail parameter that separates the sub-collection with the + operator:
GET /ovirt-engine/api/collection HTTP/1.1 Accept: application/xml; detail=subcollection1+subcollection2+subcollection3
GET /ovirt-engine/api/collection HTTP/1.1
Accept: application/xml; detail=subcollection1+subcollection2+subcollection3
| Collection | Extended Sub-Collection Support |
|---|---|
hosts | statistics |
vms | statistics, nics, disks |
Example 7.1. A request for extended statistics, NICs and disks sub-collections in the vms collection
GET /ovirt-engine/api/vms HTTP/1.1 Accept: application/xml; detail=statistics+nics+disks
GET /ovirt-engine/api/vms HTTP/1.1
Accept: application/xml; detail=statistics+nics+disks
7.3.4. Searching Collections with Queries Link kopierenLink in die Zwischenablage kopiert!
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.3.5. Maximum Results Parameter Link kopierenLink in die Zwischenablage kopiert!
max URL parameter to limit the list of results. An API search query without specifying the max parameter will return all values. Specifying the max parameter is recommended to prevent API search queries from slowing UI performance.
7.3.6. Case Sensitivity Link kopierenLink in die Zwischenablage kopiert!
Example 7.2. Case insensitive search query
GET /ovirt-engine/api/collection;case-sensitive=false?search={query} HTTP/1.1
Accept: application/xml
GET /ovirt-engine/api/collection;case-sensitive=false?search={query} HTTP/1.1
Accept: application/xml
7.3.7. Query Syntax Link kopierenLink in die Zwischenablage kopiert!
query with a GET request:
GET /ovirt-engine/api/collection?search={query} HTTP/1.1
Accept: application/xml
GET /ovirt-engine/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 Virtualization Query Language:
(criteria) [sortby (element) asc|desc]
sortby clause is optional and only needed when ordering results.
| Collection | Criteria | Result |
|---|---|---|
hosts | vms.status=up | Displays a list of all hosts running virtual machines that are up. |
vms | domain=qa.company.com | Displays a list of all virtual machines running on the specified domain. |
vms | users.name=mary | Displays a list of all virtual machines belonging to users with the user name mary. |
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.3. URL-encoded search query
GET /ovirt-engine/api/vms?search=name%3Dvm1 HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/vms?search=name%3Dvm1 HTTP/1.1
Accept: application/xml
7.3.8. Wildcards Link kopierenLink in die Zwischenablage kopiert!
Example 7.4. Wildcard search query for name=vm*
GET /ovirt-engine/api/vms?search=name%3Dvm* HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/vms?search=name%3Dvm* HTTP/1.1
Accept: application/xml
vm, such as vm1, vm2, vma or vm-webserver.
Example 7.5. Wildcard search query for name=v*1
GET /ovirt-engine/api/vms?search=name%3Dv*1 HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/vms?search=name%3Dv*1 HTTP/1.1
Accept: application/xml
v and ending with 1, such as vm1, vr1 or virtualmachine1.
7.3.9. Pagination Link kopierenLink in die Zwischenablage kopiert!
page command.
Example 7.6. Paginating resources
GET /ovirt-engine/api/collection?search=page%201 HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/collection?search=page%201 HTTP/1.1
Accept: application/xml
page value to view the next page of results:
GET /ovirt-engine/api/collection?search=page%202 HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/collection?search=page%202 HTTP/1.1
Accept: application/xml
page command in conjunction with other commands in a search query. For example:
GET /ovirt-engine/api/collection?search=sortby%20element%20asc%20page%202 HTTP/1.1 Accept: application/xml
GET /ovirt-engine/api/collection?search=sortby%20element%20asc%20page%202 HTTP/1.1
Accept: application/xml
Important
7.3.10. Creating a Resource in a Collection Link kopierenLink in die Zwischenablage kopiert!
POST request to the collection URI containing a representation of the new resource.
POST request requires a Content-Type header. This informs the API of the representation MIME type in the body content as part of the request.
Accept HTTP header to define the MIME type for the response format.
POST /ovirt-engine/api/[collection] HTTP/1.1 Accept: [MIME type] Content-Type: [MIME type] [body]
POST /ovirt-engine/api/[collection] HTTP/1.1
Accept: [MIME type]
Content-Type: [MIME type]
[body]
7.3.11. Asynchronous Requests Link kopierenLink in die Zwischenablage kopiert!
POST requests unless the user overrides them with an Expect: 201-created header.
202 Accepted status. The initial document structure for a 202 Accepted resource also contains a creation_status element and link for creation status updates. For example:
GET request to the creation_status link provides a creation status update:
Expect: 201-created header: