VMware Horizon Cloud Service Next-Gen – The Automation Series – Chapter 9 – Unified Access Gateway

This blog post is part of the VMware Horizon Cloud Service Next-Gen – The Automation Series, a series of blog posts that describes the possibilities and use of the VMware Horizon Cloud Service Next-Gen APIs.

In this chapter we will add, get and delete Unified Access Gateway deployments. We will use PowerShell to execute the requests. Since Azure is the only provider type supported at the time of writing this chapter, that’s the one we currently focusing on.

The original VMware documentation for Unified Access Gateway operations can be found here.

Create

We will start by creating a Unified Access Gateway deployment. For this we will use the following information:

HTTP Method POST
URI https://cloud.vmwarehorizon.com/admin/v2/uag-deployments
Content-Type application/json Header
Authorization Bearer <Access token> Header
name Name for the UAG deployment Body
description Description for the UAG deployment Body
orgId Organization ID Body
fqdn The fully qualified domain name for the UAG deployment Body
type The type of UAG deployment, either internal or external Body
providerInstanceId
The provider instance used for deploying the UAGs Body
numberOfGateways
The number of UAGs to deploy Body
cluster The minumum and maximum number of UAGs to deploy Body
sslCertificate The SSL certificate used for the UAG deployment Body
infrastructure The required networks/subnets required for the UAG deployment Body

With this information we will now construct the lines of code in PowerShell to add the Unified Access Gateway configuration.

(1) We create the access token from the API token using the New-HCSAccessToken function we described in chapter 2. We put this value in the $AccessToken variable, which we will use in the following step.

(2) We then construct the $Header array, where we specify the expected Content-Type to be received by the URI, which is application/json. And we specify the type of authorization using the Bearer type with the access token from the variable $AccessToken.

(3) We execute the command to add the Unified Access Gateway configuration (3). Once executed, the output with what has been configured will be displayed.

Get

To retrieve the Unified Access Gateway configuration(s), we will use the following information:

HTTP Method GET
URI https://cloud.vmwarehorizon.com/admin/v2/uag-deployments
Content-Type application/json Header
Authorization Bearer <Access token> Header

With this information we will now construct the lines of code in PowerShell to retrieve the Unified Access Gateway configuration(s).

(1) We create the access token from the API token again using the New-HCSAccessToken function, and put this value in the $AccessToken variable, which we will use in the following step.

(2) We construct the $Header array, where we specify the expected Content-Type to be received by the URI, which is application/json. And we specify the type of authorization using the Bearer type with the access token from the variable $AccessToken.

(3) We execute the command to retrieve the Unified Access Gateway configuration(s).

(4) Once executed, the output with what has been configured will be displayed.

Delete

To delete a Unified Access Gateway configuration, we will use the following information:

HTTP Method DELETE
URI https://cloud.vmwarehorizon.com/admin/v2/uag-deployments
Content-Type application/json Header
Authorization Bearer <Access token> Header
id Id number for the Unified Access Gateway deployment URI

(1) We create the access token from the API token again using the New-HCSAccessToken function, and put this value in the $AccessToken variable, which we will use in the following step.

(2) We construct the $Header array, where we specify the expected Content-Type to be received by the URI, which is application/json. And we specify the type of authorization using the Bearer type with the access token from the variable $AccessToken.

(3) We execute the command to delete the Unified Access Gateway configuration.

(4) Once executed, the output with what has been deleted will be displayed.

PowerShell Functions Examples

The scripts below serve as examples. You may change the scripts to your own needs or standards, like error handling, securing password strings and things like that.

I hope this chapter was informative and that you enjoyed reading.

This concludes the automation series for now. In the future I will create standalone posts on different Horizon Cloud next-gen automation topics.

You may also like...