vCO Workflow Script to Invoke the Notification Registration REST API of vFabric Application Director v5.2

The following script invokes the notification registration REST API of vFabric Application Director v5.2

 

 

var strPublicKey;
	strPublicKey = {"clientPublicKey":"TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF2OE12M01pWFJOeEltRm50bG1kMVFraTBmUkVjZjFBc1VWOTVmd1V0OE5IOEtlK2hpMlRxYkxVOGhoSEQ2dFAwZlRFaFNzN3lCaGEwMzE0OFM2V3Jza0FoenFEM1NXN0hhQnBXMDFEcGc1b0IvZUlmVlUybm1GWTdzNkQzREo5czIwWWNqQ2N5UCtvalhHR1JZZmZzcU5Eak8wM280L1lYV3E2bjhhZDVoZkxtdmVBcFJzNFRHaWw4anduN0V1SDdicnRTYjVmTXlQSHBtZVlRcCtjbHFQTG1LT0MwUzBFTy9maG9TSG1WYWZoUzIzY3Y1MjFiOFNrZVU4V1ZIWEk4bjBGd1BaVUpHRytQS3hGQWNmLzh3Wk9WN1hIS0loaWlWKysvQ0I3OWpDLytKMUNkK3lSdDRFcjI1UW5DRitQbkxrMTMvMGJkOTV2ZFBPWU5aTmhHdXdJREFRQUI="};

var objRESTOperation;
	objRESTOperation = new RESTOperation("RESTOperation");
	objRESTOperation.defaultContentType = "application/json";
	objRESTOperation.method = "POST";
	objRESTOperation.urlTemplate = "/darwin/api/1.0/notifications/register";
	objRESTOperation.host = objRESTHost;

var objRESTRequest;
	objRESTRequest = objRESTOperation.createRequest([], strPublicKey);
	objRESTRequest.contentType = "application/json";
	objRESTRequest.setHeader("Accept","application/json");
	objRESTRequest.setHeader("Authorization", "Basic " + strPassWordDefault);

var objRESTResponse;
	objRESTResponse = objRESTRequest.execute();

var strContentAsString;
	strContentAsString = objRESTResponse.contentAsString;

System.log("Status Code: " + objRESTResponse.statusCode);
System.log("Content As String: " + objRESTResponse.contentAsString);

if ( objRESTResponse.statusCode == 200 )
{
	var objJSON;
		objJSON = JSON.parse(strContentAsString);

	var strErrors;
		strErrors = objJSON.errors;

	var strAmqpUsername;
		strAmqpUsername = objJSON.amqpUsername;

	System.log("strAmqpUsername = " + strAmqpUsername);

	var strAmqpPassword;
		strAmqpPassword = objJSON.amqpPassword;

	System.log("strAmqpPassword = " + strAmqpPassword);

	var strAmqpQueuename;
		strAmqpQueuename = objJSON.amqpQueuename;

	System.log("strAmqpQueuename = " + strAmqpQueuename);

	var strAmqpHostname;
		strAmqpHostname = objJSON.amqpHostname;

	System.log("strAmqpHostname = " + strAmqpHostname);

	var strClientCert;
		strClientCert = objJSON.clientCert;

	System.log("strClientCert = " + strClientCert);

	var strRootCert;
		strRootCert = objJSON.rootCert;

	System.log("strRootCert = " + strRootCert);
}

Leave a Reply