Dismiss a vRA XaaS deployment

New introduced in vRA 7.5 there is single view for requests and deployments. This feature brings a lot of advantages. Now there is a possiblity to switch from the request to the deployed machine. This works fine for IaaS Blueprints which deploying components or machines. On a failed request you are even able to to resubmit or cancel/dismiss the request which is nice!

For XaaS Blueprints the request will be shown on the same level as IaaS machine requests. Even on a successful request it remains in this overview. The user needs to dismiss the request in order to have a nice view on all assigned managed components/machines.

This new feature “dismiss” was new introduced in vRA 7.5. This function is not yet updated in vRO plugin for type vCACCAFE:CatalogItemRequest. So dismissing a request is only possible to dismiss via vRA Catalog Service REST API. In this post I will show you how to achieve an automated dismissing of XaaS request in a simple way.

This is useful for XaaS deployments which should not remain in list of deployments or should be cleaned up after a defined amount of days (e.g. with a scheduled WF execution). Many times a IaaS deplyoment is wrapped with a XaaS deployment, to have the request interactive with user interactions or update data for the request form. Thus the IaaS request will also show up in vRA tab deployments and will hold the deployed components. Thereby the XaaS request is no longer needed.

 * @param cafeHost:vCACCAFE:VCACHost
 * @param request:vCACCAFE:CatalogItemRequest
 * @retrun null
 * Will dismiss a request which is listed in vRA UI > Deployments
 * created by raphaelgassmann on 30.03.19

var endpoint = 'com.vmware.csp.core.cafe.catalog.api';  
var restClient = cafeHost.createRestClient(endpoint);  

var requestId = request.id;
//set the url for the REST call to be the consumer service and include the request id as the value to retrieve results for  
var catalogServiceRequestUrl = "consumer/requests/" + requestId + "/dismiss";  
//make the REST call and retrieve the state in string format  
var attachment = new MimeAttachment() ;
attachment.content = "{'requestId'='"+request.id+"'}";
var catalogServiceRequest = restClient.postFile(catalogServiceRequestUrl, attachment);  

if (catalogServiceRequest.getStatus()=="204"){
    System.log("Request: "+request.id+" sucessfully dismissed.");
    throw "Error during dismissing requestId: "+request.id+"!";