App Volumes API

With the release of App Volumes 2.17 the App Volumes REST API is now supported for customers to do automation or build scripts.   The App Volumes Manager uses the API and there are several VMware Flings that use the App Volumes API.  In this exercise we will go over how to use several of the API calls to build your own automation.   VMware Flings are located here.

In this lab we will go though some examples in Postman, which is an easy to use GUI API interface.   There are some optional steps if you would like to compare the API with Postman to the App Volumes Manager.

What is a REST API?

How to talk to a REST API

Where to learn more about the App Volumes API

Go here to view the App Volumes API documentation

https://code.vmware.com/apis/561/app-volumes-rest

Launch Postman

Launch Postman from the main console.  Postman is an easy to use GUI based tool which can be used to communicate with REST API's

Postman

You should see Postman launched, similar to the screen above.

Create Collection and Initial Request in Postman

Requests are the individual calls we make to the API - we will store them in a Collection within Postman.

  1. Click New
  2. Click Collection to create a new Collection for your App Volumes API requests

Create a New Collection

  1. Enter App Volumes for the name of the collection
  2. Enter App Volumes API for the description
  3. Click the Create button to create the collection

Create a New Request

  1. Click New
  2. Click Request to create a new request to login to the App Volumes API

Update and Save Request

  1. Enter Login to App Volumes API as the request name
  2. Enter Login as the request description
  3. Select the App Volumes collection you created earlier
  4. Click Save to App Volumes to save the request

Login to App Volumes API

Use the click and drag or Send Text features to copy the data into Postman.

Make sure to select the { }  in the text for the body as well.  They are the opening and closing brackets for our JSON

Do the following to create the API request to login to App Volumes

  1. Select POST from the drop-down list
  2. Enter https://appvol-01.corp.local/cv_api/sessions as the target address for the request
  3. Click on Body
  4. Click the raw radio button
  5. Select JSON (application/json) from the drop-down list to select the text for the request
  6. Enter the following as the request body:

{
"username":"Administrator",
"password":"VMware1!",
"domain":"corp"
}
  1. Click the Send button to submit the request
  2. You will see that the request was successfully processed.  You will see the response as success: OK and the status code will be 200 OK
{
"success":"Ok"
}

 

Review Session Cookies

  1. Click on the Cookies tab to see the session cookies
  2. We see a _session_id cookie - this will be used to authenticate further API calls in this session until it times out or we end it.  

List AppStacks

We will now run the API to list all AppStacks and compare to the App Volumes Manager

Open App Volumes Manager (Optional)

Open Chrome, and Select AppVol-01 under the AppVolumes folder

  1. Enter Administrator
  2. Enter VMware1! for password
  3. Click Login

Review AppStacks

Click on the AppStacks tab to review the current AppStacks - minimize the browser.

Open a New Tab in Postman

Keep the tabs open so you can go back to them without re-doing the entire request

  1. Click on the + tab to create a new request

Get list of AppStacks

Use the click and drag or Send Text features to copy the data into Postman.

  1. Change the verb to GET
  2. Enter the following in the address bar:  https://appvol-01.corp.local/cv_api/appstacks
  3. Click Send
  4. Click on Body
  5. Make sure JSON is selected
  6. Review the data that is returned - notice each AppStack has an id number.  Note that the Multimedia AppStack has an id of 4.

Compare App Volumes Manager to Postman (Optional)

Compare the App Volumes Manager to the output from Postman.

Return Details of an AppStack

  1. Append 4 to the previous address so it should be https://appvol-01.corp.local/cv_api/appstacks/4
  2. Click Send
  3. Review the data returned from the API

List Applications in Multimedia AppStack

  1. Append applications to the previous address so it should be https://appvol-01.corp.local/cv_api/appstacks/4/applications
  2. Click Send
  3. Review the data returned from the API

Notice it shows the AppStack contains two applications-Gimp and VLC Media Player

View Assignments

We will now view current assignments for an AppStack.

Open a New Tab in Postman

Keep the tabs open so you can go back to them without re-doing the entire request

Click the + button to open a new tab in Postman

Return Assignments

We will now return the assignments for the Multimedia AppStack.

  1. Set the verb to Get
  2. Enter https://appvol-01.corp.local/cv_api/appstacks/4/assignments as the address
  3. Click Send
  4. Notice that the retured data is empty - there are no assignments

Compare App Volumes Manager to Postman (Optional)

Open the App Volumes Manager you minimized earlier.

  1. Click on the Multimedia AppStack to expand details
  2. Notice there are zero assignments
  3. Remember Postman also had no assignments

Add Assignment

We will now add an assignment for user2mod2 for the Multimedia AppStack.

Open a new tab in Postman

Click the + button to open a new tab in Postman

Add assignment for User2Mod2

Postman may try to add extra characters at the end of the JSON when you click and drag - }]} Make sure the JSON you are going to POST is the same as the image above.

  1. Select POST as the verb
  2. Enter https://appvol-01.corp.local/cv_api/assignments as the target API endpoint
  3. Select Body
  4. Select Raw
  5. Make sure the body type is set to JSON (application/json)
  6. Type the following for the body (you can drag/drop or copy/paste from the manual)
{
"id":"4",
"action_type":"assign",
"assignments":
[{
"entity_type":"user",
"path":"CN=User2 Mod2,CN=Users,DC=corp,DC=local"
}],
"rtime":"false"
}
  1. Click Send
  2. Review the response - notice it successfully added one user as an assignment to this AppStack.

Verify Assignment was added

We will now list assignments for AppStack number 4 (Multimedia)

  1. Enter Get as the verb
  2. Enter https://appvol-01.corp.local/cv_api/appstacks/4/assignments as the API endpoint
  3. Click Send
  4. Review the response - notice that User2Mod2 is now assigned to the Multimedia AppStack.

Compare App Volumes Manager to Postman (Optional)

Open the App Volumes Manager you minimized earlier.

  1. Click the AppStacks tab
  2. Expand the Multimedia AppStack
  3. Notice there is now 1 Assignment, click on it to see more details
  4. Notice that user CORP\user2mod2 is now assigned to this AppStack
  5. We can see in the App Volumes Manager that user2mod2 was added, just as in Postman.

Remove Assignment

We will now remove the Assignment for user2mod2 from the Multimedia AppStack

Open a new tab in Postman

Click the + button to open a new tab in Postman.

Unassign User2Mod2

  1. Select POST as the verb
  2. Enter https://appvol-01.corp.local/cv_api/assignments as the target API endpoint
  3. Select Body
  4. Select Raw
  5. Make sure the body type is set to JSON (application/json)
  6. Type the following for the body (you can drag/drop or copy/paste from the manual)
{
"id":"4",
"action_type":"unassign",
"assignments":
[{
"entity_type":"user",
"path":"CN=User2 Mod2,CN=Users,DC=corp,DC=local"
}],
"rtime":"false"
}
  1. Click Send
  2. Review the response - notice that 1 user was unassigned from the AppStack

 

List Assignments for AppStack

We will once again list the Assignment for the Multimedia AppStack to verify that user2mod2 was removed

  1. Select GET as the verb - clear out the address bar if it contains data.
  2. Enter https://appvol-01.corp.local/cv_api/appstacks/4/assignments as the API endpoint
  3. Click Send
  4. Review the response - notice it is empty

Destroy session

We will now destroy the authenticated session we established to the App Volumes API

Open a new tab in Postman

Click the + button to add a new tab in Postman

Run API call to logout of existing session

  1. Select DELETE as the verb
  2. Enter https://appvol-01.corp.local/cv_api/sessions as the target API endpoint
  3. Click Send
  4. Verify that the session was destroyed

This is the conclusion of this exercise - we learned how to use the App Volumes REST API for automation or building your own scripts.

0 Comments

Add your comment

E-Mail me when someone replies to this comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.