Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

Logical Folders are containers for storing and organizing inventory objects, in this case virtual machines. As Just like the network resource, a Folder has a Managed Object Reference (moref) which is required for either virtual machine deployment (where a virtual machine will be placed upon creation) or updating virtual machine containing folder (movedmove).

The /v2/folder resource lists folders you are allowed to access in our environment. If by any chance you cannot see a folder and you add it to a new virtual machine creation request or a virtual machine change request, they will not be successfully processed. If you believe you need access to a specific folder, please let us know.


Panel

On this page:

Table of Contents
maxLevel2
outlinetrue


The following table shows a brief description and HTTP methods allowed to interact with logical folders.

ResourceURIDescriptionGETPOSTPUTPATCH
OPTIONS
Folder/folderLogical Folder Management resource. List permitted folders and their attributes(tick) (tick)
  
 (tick)
Note
titleOPTIONS HTTP method

Remember, you can also show what methods are allowed and method description, parameters, etc. by making an OPTIONS HTTP request to /v2/folder.

Code Block
languagebash
http OPTIONS "https://vss-api.eis.utoronto.ca:8001/v2/folder"
curl -X OPTIONS "https://vss-api.eis.utoronto.ca:8001/v2/folder" 

 

List

In order to list allowed Folders you should make a  GET request to the endpoint /v2/folder, passing your access token. As a result, you will get a reference URI /v2/folder/<moref> to get detailed information about that folder, human readable name and Managed Object Reference (moref).

NameTypeDescription
namestringFolder name.
parentstringParent folder name.
morefstringvCenter Managed Object Reference (moref)
_linksarrayList of URIs related to the resource.
full_pathstringvCenter full path to the folder

The following examples implements HTTPie and CURL to list all folders a user have access to:

Code Blockhttp -a $TK

Folder Object/folder/<moref>Get logical folder attributes.(tick) 


Folder Name/folder/<moref>/nameRename object.

(tick) 
Folder Children/folder/<moref>/childrenGet children folders if any.(tick) 


Folder Parent/folder/<moref>/parentGet or move folder to a different parent.(tick)
(tick) 
Folder VMs/folder/<moref>/vmList children virtual machines.(tick) 


Folder Permission/folder/<moref>/permissionList object permission.(tick) 



Note

TK stores the Cloud API Token generated as a result of the following POST request to the /auth/request-token resource:

Code Block
curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username>

For example, extracting the token with the jq command:

Code Block
TK=$(curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username> | jq -r '.token')



List

In order to list allowed Folders you should make a  GET request to the endpoint /v2/folder, passing your access token. As a result, you will get a reference URI /v2/folder/<moref> to get detailed information about that folder.


Code Block
http GET "https://vss-api.eis.utoronto.ca:8001/v2/folder" "Authorization: Bearer $TK"
curl -uH "Authorization: Bearer $TK" -X GET "https://vss-api.eis.utoronto.ca:8001/v2/folder"
Code Block
languagepy
title

The following examples implements HTTPie and CURL to list all folders a user have access to:


Code Block
languagepy
titleResponse Body
collapsetrue
{
    "_links": {
        "apiself": "https://vss-api.eis.utoronto.ca:8001/v2/",folder?per_page=3&filter=path,like,%25Testing%25"
    },
    "selfdata": "https://vss-api.eis.utoronto.ca:8001/v2/folder" [
        {
       },     "datacreated_on": [ "2019-07-17 Wed 15:18:59 EDT",
            {"has_children": false,
            "has_linksparent": {true,
                "selfmoref": "https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736v8923",
             }"name": "ut20170621092129",
            "full_pathparent": "VSS{
> Sandbox > jm > APIDemo",
            "moref": "group-v6736v7350",
                "name": "APIDemoTesting",
                "parent_moref": "jm"
        }group-v7349",
        {        "path": "VSS > Development > Testing"_links": {
,
                "selfvim_type": "https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6749vim.Folder"
            },
            "full_parent_moref": "group-v7350",
            "path": "VSS > SandboxDevelopment > jmTesting > DockerDatacenterut20170621092129",
            "morefupdated_on": "group-v67492019-07-17 Wed 15:18:59 EDT",
            "namevim_type": "DockerDatacentervim.Folder",
        },
    "parent": "jm"    {
      }     ],
    "meta": { "created_on": "2019-07-17 Wed 15:18:59 EDT",
            "counthas_children": 2true,
            "timehas_parent": "0.46083s"true,
            "usermoref": "jm"group-v7350",
           }
}

Filters

This resource has two main filters to narrow down the number of Networks shown in the result.

NameDescription
NameFolder name
morefvCenter Managed Object Reference (moref)

The following examples show how to make a GET request, which in both cases, the result would be the same because APIDemo moref contains number 6379.

Code Block
http -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/folder?name=API"
http -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/folder?moref=6736"
Code Block
languagepy
titleResponse Body
collapsetrue
{
    "_links": { "name": "Testing",
            "parent": {
                "moref": "group-v7349",
                "apiname": "https://vss-api.eis.utoronto.ca:8001/v2/",Development",
                "selfparent_moref": "https://vss-api.eis.utoronto.ca:8001/v2/folder"group-v305",
           },     "datapath": ["VSS > Development",
      {             "vim_linkstype": { "vim.Folder"
            },
            "selfparent_moref": "https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736"
            }group-v7349",
            "full_path": "VSS > SandboxDevelopment > jm > APIDemoTesting",
            "morefupdated_on": "group-v6736",
            "name": "APIDemo2019-07-17 Wed 15:18:59 EDT",
            "parentvim_type": "jmvim.Folder"
        },
      ],  {
  "meta": {         "countcreated_on": 1, "2019-07-17 Wed 15:18:59 EDT",
         "time": "0.46083s",   "has_children": true,
            "has_parent": true,
            "usermoref": "jm"group-v8900",
            }
}

List specific folder info

Some of the attributes will have an object value. Such is the case of items in attribute vms.

NameTypeDescription
vmsarrayArray of Virtual Machines in folder.
vmCountintegerNumber of virtual machines in folder

The following example, requests information about a particular Folder using the base resource /v2/folder and appending the moref to get the URI /v2/folder/group-v6736:

Code Block
http -a $TK GET https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736
curl -u $TK -X GET https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736

HTTP response body would look something like:

Code Block
languagepy
titleResponse Body
collapsetrue
{
    "_links": {"name": "ut20170135153548",
            "parent": {
                "foldermoref": "https://vss-api.eis.utoronto.ca:8001/v2/folder",group-v7350",
                "selfname": "https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736"Testing",
    },     "data": {         "name"parent_moref": "APIDemogroup-v7349",
 
      "parent": "jm",         "path": "VSS > SandboxDevelopment > jm > APIDemoTesting",
        "vmCount": 2,
        "vmsvim_type": ["vim.Folder"
            {
   },
            "parent_linksmoref": {
       "group-v7350",
            "hrefpath": "https://vss-api.eis.utoronto.ca:8001/v2/vm/501269e6-2c49-ecda-fdc0-862693465325"
     VSS > Development > Testing > ut20170135153548",
          },       "updated_on": "2019-07-17 Wed 15:18:59 EDT",
            "namevim_type": "1605T-loving_wilsonvim.Folder"
            },
    ],
    "meta": {
 {       "count": 3,
        "_linkspages": {
               "first_url": "https://vss-api.eis.utoronto.ca/v2/folder?per_page=100&page=1&expand=True",
            "hreflast_url": "https://vss-api.eis.utoronto.ca:8001/v2/vm/50124dc2-aba4-5c57-130c-da207557e5bd"
                },
                "name": "1605T-sick_stallman"
            }
        ]
    },
    "meta": {
        "count": 5,
        "time": "0.42114s",
        "user": "jm"
    }
}.eis.utoronto.ca/v2/folder?per_page=100&page=1&expand=True",
            "next_url": null,
            "page": 1,
            "pages": 1,
            "per_page": 100,
            "prev_url": null,
            "total": 3
        },
        "time": "0.11766s",
        "user": "jm"
    }
}

Paging

All requests to the /folder 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:

Code Block
http GET "https://vss-api.eis.utoronto.ca/v2/folder?per_page=1" "Authorization: Bearer $TK"
curl -H "Authorization: Bearer $TK" -X GET "https://vss-api.eis.utoronto.ca/v2/folder?per_page=1"

Filtering

Folders can be filtered by adding the filter argument to the query string in the following format:

Code Block
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 /folder can be filtered by moref, path, created_on, name, etc. Thus, the following example will filter only by name=Prod

Code Block
http GET "https://vss-api.eis.utoronto.ca/v2/folder?per_page=10&expand=1&filter=name,like,%Prod%" "Authorization: Bearer $TK"

Sorting

The resource provides also attribute sorting by adding the sort parameter in the URL query string in the following format:

Code Block
sort=<field_name>,<asc|desc>

The following example shows how to filter by label:

Code Block
http GET "https://vss-api.eis.utoronto.ca/v2/folder?per_page=10&expand=1&filter=name,like,%Prod%&sort=label,desc" "Authorization: Bearer $TK"

curl -X GET -H "Authorization: Bearer $TK" "https://vss-api.eis.utoronto.ca/v2/network?per_page=10&expand=1&filter=name,like,%VL%&sort=label,desc" 

Create

To create a new folder you just need to submit a request to /v2/folder/<moref> and provide the name of the new folder as a parameter. So, the folder <moref> will be parent of the new folder. For this example we will create a subfolder in APIDemo > APISubFolder, so request will be crafted as follows:

Code Block
http -a $TK POST https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736 name=APISubFolder
curl -u $TKv6736 "Authorization: Bearer $TK" name=APISubFolder
curl -H "Content-Type: application/json" -H "Authorization: Bearer $TK" -X POST https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6736 -d '{"name": "APISubFolder"}'
Response


Code Block
titleRespoonse Headers
HTTP/1.1 202 ACCEPTED
Allow: POST, HEAD, OPTIONS, GET
Connection: keep-alive
Content-Length: 400
Content-Type: application/json
Date: Wed, 11 May 2016 17:19:15 GMT
Location: https://vss-api.eis.utoronto.ca/v2/request/task/fff43ba4-40c1-40df-bf5b-02f5424e091a
Server: nginx
X-RateLimit-Limit: 3000
X-RateLimit-Remaining: 2997
X-RateLimit-Reset: 1462989600


Code Block
languagepy
titleResponse Body
collapsetrue
{
    "data": {
        "_links": {
            "request": "https://vss-api.eis.utoronto.ca:8001/v2/request/folder/2",
            "task": "https://vss-api.eis.utoronto.ca:8001/v2/request/task/fff43ba4-40c1-40df-bf5b-02f5424e091a"
        },
        "message": "VM Folder creation request has been accepted for processing",
        "name": "Accepted",
        "state": "Submitted",
        "status": 202
    },
    "meta": {
        "time": "0.07877s",
        "user": "jm"
    }
}

Listing folder

Listing folders with the API word in them, would show the folder has been successfully created:

Code Block
languagepy
titleResponse Body
collapsetrue
{ "_links": { "api": "https://vss-api.eis.utoronto.ca:8001/v2/", "self": "

Update

Renaming or moving folders between your folder tree is possible by making a PUT request to the URI folder in question sending both the attribute and value you wish to update. Currently, we support name and parent as supported attributes. 

AttributeDescription
namefolder new name
parentmanaged object reference of new parent folder

The following request illustrates how to update a folder's name (group-v6736) to NewAPIFolder:

Code Block
http PUT https://vss-api.eis.utoronto.ca:8001/v2/folder"
    },
    "data": [
        {
            "_links": {
                "self": "/group-v6736 "Authorization: Bearer $TK" attribute="name" value="NewAPIFolder" 
curl -H "Content-Type: application/json" -H "Authorization: Bearer $TK" -X PUT https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v6899"
            },
            "full_path": "VSS > Sandbox > jm > APIDemo > APISubFolder",
            "moref": "group-v6899",
            "name": "APISubFolder",
       -v6736 -d '{"attribute": "name", "value": "NewAPIFolder"}'

HTTP response  would look something like:

Code Block
titleRespoonse Headers
HTTP/1.1 202 ACCEPTED
Allow: HEAD, GET, PUT, POST, OPTIONS
Connection: keep-alive
Content-Length: 437
Content-Type: application/json
Date: Mon, 27 Jun 2016 14:38:32 GMT
Location: https://vss-api.eis.utoronto.ca/v2/request/task/d7eec47d-fd14-4958-a5ff-bfb93a191a01
Server: nginx
X-RateLimit-Limit: 3000
X-RateLimit-Remaining: 2996
X-RateLimit-Reset: 1467039600


Code Block
languagepy
titleResponse Body
collapsetrue
{
    "parentdata": "APIDemo"{
        },
        "_links": {
            "_linksrequest": {
   "https://vss-api.eis.utoronto.ca/v2/request/folder/3",
            "selftask": "https://vss-api.eis.utoronto.ca:8001/v2/request/folder/group-v6736"
  task/d7eec47d-fd14-4958-a5ff-bfb93a191a01"
        },
        "message": "VM Folder change request has been accepted for processing",
         },
   "name": "Accepted",
        "full_pathstate": "Submitted"VSS,
> Sandbox > jm > APIDemo",   "status": 202
    },
    "morefmeta": "group-v6736",
 {
          "nametime": "APIDemo0.39327s",
            "parentuser": "jm"
 
    }
 }
    ],
    "meta": {
        "count": 2,
        "time": "0.55448s",
        "user": "jm"
    }
}}


Tip

If you wish to update any parent folder, just select the new parent moref and include it in the PUT request attribute's value, i.e.

Code Block
http PUT https://vss-api.eis.utoronto.ca/v2/folder/group-v6736 "Authorization: Bearer $TK" attribute="parent" value="group-v1234"
curl -H "Content-Type: application/json" -H "Authorization: Bearer $TK" -X PUT https://vss-api.eis.utoronto.ca/v2/folder/group-v6736 -d '{"attribute": "parent", "value": "group-v1234""}'

Where group-v1234 would be new parent of group-v6736