Service Types Overview

All service types are listed in the frame at the left of this page. Click a name to display the reference documentation for the service.

To quickly find any entry, start typing its name in the Quick Index.

Managing Service references

View API Helper library is wrapper over View APIs. This library makes life of View API PowerCLI developers easier by providing methods to create, update and delete View API objects.

For each ViewAPI service named Foo there is a corresponding FooService helper class. For example, Desktop View API Service has a corresponding DesktopService helper class. In powershell script, service object can be created as below.

$desktopService = New-Object VMware.Hv.DesktopService

In each helper class you can find all the View API service methods defined, which are wrappers over View API service methods. For example, DesktopService helper class has all the methods defined in Desktop View API service like Desktop_Create(), Desktop_Delete(), Desktop_AddMachinesToManualDesktop() etc. The advantage of having these wrapper methods over service methods defined in View API Service is that users do not have to pass ManagedObjectReference parameter and is taken care by helper class's wrapper method(as mentioned in Approach 2 below).

We can access the service methods in following different approaches.

Approach 1: Use ManagedObjectReference

Create a ManagedObjectReference and use the same in method invocations. Both the type and value of the ManagedObjectReference for a service will be the name of the service.

Example: Invoking ConnectionServer_List method in ConnectionServer service using ManagedObjectReference

$hvServer = Connect-HVServer -Server <Server> -User <UserName> -Password <Password> -Domain <Domain>
$Global:hvServices = $hvServer.ExtensionData

$mob = new-object VMware.Hv.ManagedObjectReference -property @{'type' = 'ConnectionServer'; 'value' = 'ConnectionServer'}
$hvServices.ConnectionServer_List($mob)

Approach 2: Use Service Handlers (Recommended approach)

This approach does not require a ManagedObjectReference, instead create an handle object for the required service type. Use this object in method invocations. In View API, every service method expects a parameter of ManagedObjectReference. Pass services object(as like in following example) in place of ManagedObjectReference.

Example: Invoking ConnectionServer_List method in ConnectionServer service using Service handlers

$hvServer = Connect-HVServer -Server <Server> -User <UserName> -Password <Password> -Domain <Domain>
$Global:hvServices = $hvServer.ExtensionData

$csService = new-object VMware.Hv.ConnectionServerService
$csService.ConnectionServer_List($hvServices)

Update Methods

If a service has an update method this allows the user to update only a subset of the properties of the object. This is represented as a set of name value pairs, with the name being the Property Name of the property to be updated along with the new value. These are presented as an array of MapEntry objects. The documentation for each update method will specify the base object these property names will be based on.

The View API Helper library provides functionality to wrap a data object and track changes made to that object. This will track all changes made through the Service object and will push the updates to the server when the update method of that object is called.

Additionally, the Service class will provide a convenience update function to update a single property. The simplest example of this would be enabling or disabling a resource.

To make the updates more easy, View API Helper library provides the following two methods to each Service class corresponding to View API service.

read()

It returns InfoHelper object (For example, DesktopInfoHelper) as output by accepting Entity Id (For example, DesktopId) as input.

update()

It updates the data in connection server by accepting updated InfoHelper object (For example, DesktopInfoHelper) as input.

Following are some of the examples for update methods.

Example: Updating Connection Server Information

Using MapEntry


$csList = $hvServices.ConnectionServer.ConnectionServer_List()
$csId = $csList[0].id
$update = new-object VMware.Hv.MapEntry
$update.key = "general.tags"
[String[]] $array = 'tag1', 'tag2'
$update.value = $array

$hvServices.ConnectionServer.ConnectionServer_Update($csId, $update)

Using View API Helper library (Recommended approach)

$csService = new-object VMware.Hv.ConnectionServerService
$csList = $csService.ConnectionServer_List($hvServices)
$csId = $csList[0].id
$csInfoHelper = $csService.read($hvServices, $csId)
$csDataHelper = $csInfoHelper.getGeneralHelper()
$tags = $csDataHelper.getTags()
$tags.Add("newTag")
$csDataHelper.setTags($tags)

$csService.update($hvServices, $csInfoHelper)

Example: Updating Desktop Information

Using MapEntry

# Fetch desktop id
$desktopName = 'Pool1'
$queyService = New-Object VMware.Hv.QueryServiceService
$desktopService = New-Object VMware.Hv.DesktopService
$defn = New-Object VMware.Hv.QueryDefinition
$defn.queryEntityType = 'DesktopSummaryView'
$defn.filter = New-Object VMware.Hv.QueryFilterEquals -property @{'memberName'='desktopSummaryData.name'; 'value' = $desktopName}
$queryResults = $queyService.QueryService_Query($hvServices, $defn)
$desktopId = $queryResults.results[0].id

# Update desktop properties
$update1 = New-Object VMware.Hv.MapEntry
$update1.key = 'base.displayName'
$update1.value = 'NewDisplayName'

$update2 = New-Object VMware.Hv.MapEntry
$update2.key = 'base.description'
$update2.value = 'New Desc for the desktop pool'

$updates = @()
$updates += $update1
$updates += $update2

$desktopService.Desktop_Update($hvServices, $desktopId, $updates)

Using View API Helper library (Recommended approach)

# Fetch desktop id
$desktopName = 'Pool1'
$queyService = New-Object VMware.Hv.QueryServiceService
$defn = New-Object VMware.Hv.QueryDefinition
$defn.queryEntityType = 'DesktopSummaryView'
$defn.filter = New-Object VMware.Hv.QueryFilterEquals -property @{'memberName'='desktopSummaryData.name'; 'value' = $desktopName}
$queryResults = $queyService.QueryService_Query($hvServices, $defn)
$desktopId = $queryResults.results[0].id

# Update desktop properties
$desktopService = New-Object VMware.Hv.DesktopService
$desktopInfoHelper = $desktopService.read($services, $DesktopId)
$desktopInfoHelper.getBase().setDisplayName("NewDisplayName")
$desktopService.update($hvServices, $desktopInfoHelper)
Back to Home