Content Library
Introduction
Content libraries (CLibs) are container objects for VM and vApp (OVF) templates and other types of files, such as ISO images, text files, and so on across multiple vCenter Server instances in the same or remote locations which ensures consistency and compliance when deploying virtual machine workloads.
On this page:
The following table shows a brief description and HTTP methods allowed to interact with Content Libraries and Items available to users.
Resource | URI | Description | GET | POST | PUT | PATCH | OPTIONS |
---|---|---|---|---|---|---|---|
Content Library | /contentlib | Main content library resource | |||||
Content Libraries | /contentlib/library | Available Content Libraries | |||||
Content Library Items | /contentlib/items | Available Content Library Items |
TK stores the Cloud API Token generated as a result of the following POST request to the /auth/request-token resource:
curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username>
For example, extracting the token with the jq command:
TK=$(curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username> | jq -r '.token')
List available Content Library items
The content library hosts three types of items:
Type | Description |
---|---|
OVF | vApp OVF appliance |
ISO | ISO Images. |
VM | Virtual Machine Templates |
The following examples implements HTTPie and CURL to list available Ubuntu ISO images:
http GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?filter=type,eq,ISO" "Authorization: Bearer $TK" curl -H "Authorization: Bearer $TK" -X GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?filter=type,eq,ISO"
Expand
You can also expand given resources by adding the parameter to the query string expand=1 as follows:
http GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?expand=1" "Authorization: Bearer $TK" curl -H "Authorization: Bearer $TK" -X GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?expand=1"
Paging
All requests to the /contentlib/item URL are paginated. The response body includes a 'meta.pages' key with everything to navigate through the results, for instance:
Key | Description |
---|---|
first_url | Contain the URLs to navigate through results. |
last_url | |
prev_url | |
next_url | |
page | Current page |
pages | Total number of pages |
per_page | Results per page. Maximum 250; Default 10. |
total | Total number of results |
Results per page can be set by including the parameter in the URL query, so we can get the desired number of elements per page, for example:
http GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?per_page=250&expand=1" "Authorization: Bearer $TK" curl -X GET -H "Authorization: Bearer $TK" "https://vss-api.eis.utoronto.ca/v2/contentlib/item?per_page=250&expand=1"
Filtering
ISOs can be filtered by adding the filter argument to the query string in the following format:
filter=<field_name>,<operator>,<value>
Operators can be:
Operator | Description |
---|---|
eq | Equals |
ne | Not equal |
lt | Lower than |
le | Lower equal |
gt | Greater than |
ge | Greater equal |
like | Matching pattern |
in | Match value in many items separated by commas |
A resource can be filtered by as many attributes the request has, for instance /contentlib/item can be filtered by name, path, created_on, updated_on, etc. Thus, the following example will filter only CentOS images:
http GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?per_page=250&expand=1&filter=name,like,CentO%" "Authorization: Bearer $TK"
Sorting
Content Library Items can be sorted by adding the sort parameter in the URL query string in the following format:
sort=<field_name>,<asc|desc>
The following example shows how to filter by date (latest first):
http GET "https://vss-api.eis.utoronto.ca/v2/contentlib/item?per_page=250&expand=1&filter=name,like,CentO%&sort=name,desc" "Authorization: Bearer $TK" curl -X GET -H "Authorization: Bearer $TK" "https://vss-api.eis.utoronto.ca/v2/contentlib/item?per_page=250&expand=1&filter=name,like,CentO%&sort=name,desc"