Citrix DaaS REST APIs

How to delete a policy set in Citrix DaaS

Use REST APIs to delete a policy set within your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) 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 delete a policy set

Delete a policy set from your site using any REST API tool

Learn from the following example to detach the policy set from a delivery group in your Citrix DaaS site using any REST API tool.

Request

PATCH https://api.cloud.com/cvad/manage/DeliveryGroups/{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

{
  "PolicySetGuid": "00000000-0000-0000-0000-000000000000"
}
<!--NeedCopy-->

Response

HTTP/1.1 204 NoContent
citrix-transactionid: b5847316...
content-Type: application/json; charset=utf-8
date: "Fri,03 Nov 2023 03:25:41 GMT"
<!--NeedCopy-->

Learn from the following example to delete a policy set in your Citrix DaaS site using any REST API tool.

Request

DELETE https://api.cloud.com/cvad/manage/gpo/policySets/{policySetGuid} 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
<!--NeedCopy-->

Response

HTTP/1.1 204 NoContent
citrix-transactionid: 0f1ee91f...
content-Type: application/json; charset=utf-8
date: "Fri,03 Nov 2023 06:07:11 GMT"
<!--NeedCopy-->

Delete a policy set from your site using PowerShell

Learn from the following example to delete a policy set within your Citrix DaaS site using PowerShell.


function DeletePolicySet {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $policySetGuid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken
    )
    $requestUri = [string]::Format("https://api.cloud.com/cvad/manage/gpo/policySets/{0}", $policySetGuid)
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }
    
    $response = Invoke-RestMethod -Uri $requestUri -Method DELETE -Headers $headers 
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$policySetName = "PS01"
$bearerToken = "ey1.."
$emptyGuid = [GUID]::Empty
$body = @"
{
    "PolicySetGuid": "$emptyGuid"
}
"@
$policySets = GetPolicySets $customerid $siteid $bearerToken 
$policySet = $policySets.Items | Where-Object Name -eq $policySetName

if ([string]::IsNullOrEmpty($policySet))
{
    Write-Output "Policy Set named ${policySetName} does not exist"
    return
}

if ($policySet.isAssigned)
{
    $deliveryGroups = GetDeliveryGroups $customerid $siteid $bearerToken 
    $deliveryGroups.Items | Where-Object PolicySetGuid -eq $policySet.policySetGuid | ForEach-Object {
        PatchDeliveryGroup $customerid $siteid $_.Id $bearerToken $body
    }
}

DeletePolicySet $customerid $siteid $policySet.policySetGuid $bearerToken 

<!--NeedCopy-->

Delete a policy set from your site using C# code

Learn from the following example to delete a policy set within your Citrix DaaS site using any C# code.

public static async Task<string> DeletePolicySet(
    string customerid,
    string siteid,
    string policySetGuid,
    string bearerToken)
{
    var requestUri = string.Format("https://api.cloud.com/cvad/manage/gpo/policySets/{0}", policySetGuid);
    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.Add("Authorization", $"CWSAuth Bearer={bearerToken}");

        var response = await client.DeleteAsync(requestUri);    

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

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

Delete a policy set from your site using Python

Learn from the following example to delete a policy set within your Citrix DaaS site using Python.

import json
import requests

def delete_policy_set(bearerToken, customerid, siteid, policySetGuid):
    request_uri = "https://api.cloud.com/cvad/manage/gpo/policySets/{0}".format(policySetGuid)
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }

    response = requests.delete(request_uri, headers = headers, verify = False)

    return response
<!--NeedCopy-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to delete a policy set in Citrix DaaS