Citrix Virtual Apps and Desktops REST APIs

How to update a hypervisor in Citrix Virtual Apps and Desktops

Use REST APIs to update a hypervisor within your Citrix Virtual Apps and Desktops site.

Follow the prerequisites and examples to get started with this API.

You can make API requests using the PowerShell code, C# code, Python, or any tool that supports invoking the REST API.

Prerequisites to update a hypervisor in Citrix Virtual Apps and Desktops

Update a hypervisor in your site using any REST API tool

Learn from the following example to update a hypervisor within your Citrix Virtual Apps and Desktops site using any REST API tool.

Request

PATCH https://[DdcServerAddress]/cvad/manage/hypervisors/{nameOrId} HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
Citrix-InstanceId: 22ded57c-0306-47e4-b6e8-fed6252759e1

{
    "Name": "CVAD_APIs_CONN",
    "InMaintenanceMode": false,
    "MaxAbsoluteActiveActions": 100,
    "MaxAbsoluteNewActionsPerMinute": 1000,
    "MaxPowerActionsPercentageOfMachines": 100,
    "ConnectionOptions": "Connection options",
    "ConnectionType": "AzureRM"
}
<!--NeedCopy-->

Response

HTTP/1.1 200 OK
citrix-transactionid: 26b3eeb5-4087-49b4-b4a6-bd5fa724b184
content-Length: 1051
content-Type: application/json; charset=utf-8
date: "Mon, 28 Sep 2020 03:48:35 GMT"

{
    "ApplicationId": "aa8f1fd6...",
    "SubscriptionId": "7bb42f40...",
    "ActiveDirectoryId": "94367291...",
    "Environment": "AzureCloud",
    "ManagementEndpoint": "https://management.azure.com/",
    "AuthenticationAuthority": "https://login.microsoftonline.com/",
    "StorageSuffix": "core.windows.net",
    "Capabilities": [
        "AdditionalDiskIndexRemapping",
        "BatchProvisioningPreflightCheck",
        "CreateVmWithNetworkDisconnected",
        "ExtraSpinUptime",
        "PageFileRedirected",
        "PerformsPowerManagementViaHypervisorInterface",
        "PowerOff",
        "PowerOn",
        "ReportsExplicitStorageRequirements",
        "ReportsLocalizedStrings",
        "ReportsPowerStates",
        "Reset",
        "Restart",
        "Shutdown",
        "SupportsMachineCatalogAbortNotify",
        "SupportsMachineCatalogCreationDeletionNotify",
        "SupportsProvisioning",
        "SupportsWriteBackCache"
    ],
    "ConfigurationObjectCapabilities": [
        {
            "ResourceType": "Vm",
            "TypeCapabilities": [
                "CpuCount",
                "MemoryMB",
                "MinMemoryMB",
                "HardDiskSizeGB",
                "NetworkMappings"
            ]
        },
        {
            "ResourceType": "Snapshot",
            "TypeCapabilities": [
                "CpuCount",
                "MemoryMB",
                "MinMemoryMB",
                "HardDiskSizeGB",
                "NetworkMappings"
            ]
        }
    ],
    "PluginRevision": "e5bba22e...",
    "MaxAbsoluteActiveActions": 100,
    "MaxAbsoluteNewActionsPerMinute": 1000,
    "MaxPowerActionsPercentageOfMachines": 100,
    "ConnectionOptions": "Connection options",
    "SupportsLocalStorageCaching": false,
    "SupportsPvsVms": true,
    "ConnectionType": "AzureRM",
    "Addresses": [
        "https://management.azure.com/"
    ],
    "InMaintenanceMode": false,
    "PluginId": "AzureRmFactory",
    "Scopes": [
        {
            "Id": "00000000...",
            "Uid": null,
            "Name": "All",
            "Description": null,
            "IsBuiltIn": true,
            "IsAllScope": true,
            "IsTenantScope": false,
            "TenantId": null,
            "TenantName": null
        }
    ],
    "Tenants": null,
    "UsesCloudInfrastructure": false,
    "Zone": {
        "Id": "41e85452...",
        "Uid": 5,
        "Name": "My Resource Location"
    },
    "Id": "e07c3501...",
    "Name": "CVAD_APIs_CONN",
    "XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN"
}
<!--NeedCopy-->

Update a hypervisor in your site using PowerShell

Learn from the following example to update a hypervisor within your Citrix Virtual Apps and Desktops site using any PowerShell code.

function PatchHypervisor {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $nameOrId,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken,
        [Parameter(Mandatory=$true)]
        [string] $body
    )
    $requestUri = [string]::Format("https://[DdcServerAddress]/cvad/manage/hypervisors/{0}", $nameOrId)
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }

    $response = Invoke-RestMethod -Uri $requestUri -Method PATCH -Headers $headers -Body $body 
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$nameOrId = "56f1cbf3-1cc6-40cd-9c82-c95633ba88bb"
$bearerToken = "ey1.."
$body = @"
{
    "Name": "CVAD_APIs_CONN",
    "InMaintenanceMode": false,
    "MaxAbsoluteActiveActions": 100,
    "MaxAbsoluteNewActionsPerMinute": 1000,
    "MaxPowerActionsPercentageOfMachines": 100,
    "ConnectionOptions": "Connection options",
    "ConnectionType": "AzureRM"
}
"@
$response = PatchHypervisor $customerid $siteid $nameOrId $bearerToken $body
<!--NeedCopy-->

Update a hypervisor in your site using C# code

Learn from the following example to update a hypervisor within your Citrix Virtual Apps and Desktops site using C# code.

public static async Task<string> PatchHypervisor(
    string customerid,
    string siteid,
    string nameOrId,
    string bearerToken,
    EditHypervisorConnectionRequestModel model)
{
    var requestUri = string.Format("https://[DdcServerAddress]/cvad/manage/hypervisors/{0}", nameOrId);
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
        client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerid);
        client.DefaultRequestHeaders.Add("Citrix-InstanceId", siteid);
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);

        var jsonBody = JsonConvert.SerializeObject(model, new JsonSerializerSettings
        {
            Converters = new JsonConverter[] { new StringEnumConverter() }
        });

        var response = await client.PatchAsync(requestUri, new StringContent(jsonBody, Encoding.UTF8, "application/json"));

        if (response != null)
        {
            var content = await response.Content.ReadAsStringAsync();
            return content;
        }

        return null;
    }
}
<!--NeedCopy-->

Update a hypervisor in your site using Python

Learn from the following example to update a hypervisor within your Citrix Virtual Apps and Desktops site using Python.

import requests 

def patch_hypervisor(bearerToken, customerid, siteid, nameOrId):
    request_uri = "https://[DdcServerAddress]/cvad/manage/hypervisors/{0}".format(nameOrId)
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }
    payload = json.dumps({
        "Name": "CVAD_APIs_CONN",
        "InMaintenanceMode": false,
        "MaxAbsoluteActiveActions": 100,
        "MaxAbsoluteNewActionsPerMinute": 1000,
        "MaxPowerActionsPercentageOfMachines": 100,
        "ConnectionOptions": "Connection options",
        "ConnectionType": "AzureRM"
    })

    response = requests.patch(request_uri, headers = headers, verify = False, data = payload)

    return response.json()
<!--NeedCopy-->
Resources
Citrix Virtual Apps and Desktops REST APIs OpenAPI Specification
Copy Download
How to update a hypervisor in Citrix Virtual Apps and Desktops