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.

ResourceURIDescriptionGETPOSTPUTPATCHOPTIONS
Content Library/contentlibMain content library resource(tick) 


(tick)
Content Libraries/contentlib/libraryAvailable Content Libraries(tick)


(tick)
Content Library Items/contentlib/itemsAvailable Content Library Items(tick)


(tick)

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:

TypeDescription
OVFvApp OVF appliance
ISOISO 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"
Response Body
{
    "_links": {
        "self": "https://vss-api.eis.utoronto.ca/v2/contentlib/item?filter=type,eq,ISO%3Bname,like,ubuntu-20%25"
    },
    "data": [
        {
            "content_version": "2",
            "created_on": "2021-04-12 Mon 09:48:24 EDT",
            "creation_time": "2021-04-12T13:46:40.266Z",
            "description": "",
            "id": "0921acc6-f049-49ba-bf72-36abf3dcd1a1",
            "last_modified_time": "2021-04-12T13:47:21.025Z",
            "library": {
                "id": "8632f1a0-4a5d-4a30-a629-4cbfdcce2e2e",
                "name": "VSS-Nix",
                "type": "LOCAL"
            },
            "library_id": "8632f1a0-4a5d-4a30-a629-4cbfdcce2e2e",
            "metadata_version": "1",
            "name": "ubuntu-20.10-live-server-amd64",
            "size": 1046083584,
            "type": "ISO",
            "updated_on": "2021-04-12 Mon 09:48:24 EDT",
            "urn": "urn:vapi:com.vmware.content.Library.Item:0921acc6-f049-49ba-bf72-36abf3dcd1a1",
            "version": "1"
        }
    ],
    "meta": {
        "count": 2,
        "filter": "type,eq,ISO;name,like,ubuntu-20%",
        "pages": {
            "first_url": "https://vss-api.eis.utoronto.ca/v2/contentlib/item?filter=type%2Ceq%2CISO%3Bname%2Clike%2Cubuntu-20%25&page=1&per_page=10&expand=True",
            "last_url": "https://vss-api.eis.utoronto.ca/v2/contentlib/item?filter=type%2Ceq%2CISO%3Bname%2Clike%2Cubuntu-20%25&page=1&per_page=10&expand=True",
            "next_url": null,
            "page": 1,
            "pages": 1,
            "per_page": 10,
            "prev_url": null,
            "total": 1
        },
        "time": "0.01401s",
        "user": "josem"
    }
}

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:

KeyDescription
first_urlContain the URLs to navigate through results.
last_url
prev_url
next_url
pageCurrent page
pagesTotal number of pages
per_pageResults per page. Maximum 250; Default 10.
totalTotal 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:

OperatorDescription
eqEquals
neNot equal
ltLower than
leLower equal
gtGreater than
geGreater equal
likeMatching pattern
inMatch 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"