Orchestrator Functions: vRA REST Requests

by Simon Sparks · 11 February 2026

To use this function add it to the class library file named OrchestratorPluginVRAService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: OrchestratorPluginVRAService.ts

Description: Orchestrator Function to Create and Execute a vRA REST Request

Public Function: VraRestGet

publicVraRestGet<T>(objVraHost:VraHost,strUri:string,objPropertiesHeaders:Properties):T{

returnthis.VraRestRequest<T>(objVraHost,strUri,"GET",objPropertiesHeaders);
}

Public Function: VraRestDelete

publicVraRestDelete<T>(objVraHost:VraHost,strUri:string,objPropertiesHeaders:Properties):T{

returnthis.VraRestRequest<T>(objVraHost,strUri,"DELETE",objPropertiesHeaders);
}

Public Function: VraRestPatch

publicVraRestPatch<T>(objVraHost:VraHost,strUri:string,objPropertiesHeaders:Properties,objPayload:any):T{

returnthis.VraRestRequest(objVraHost,strUri,"PATCH",objPropertiesHeaders,objPayload);
}

Public Function: VraRestPost

publicVraRestPost<T>(objVraHost:VraHost,strUri:string,objPropertiesHeaders:Properties,objPayload:any):T{

returnthis.VraRestRequest<T>(objVraHost,strUri,"POST",objPropertiesHeaders,objPayload);
}

Public Function: VraRestPut

publicVraRestPut<T>(objVraHost:VraHost,strUri:string,objPropertiesHeaders:Properties,objPayload:any):T{

returnthis.VraRestRequest<T>(objVraHost,strUri,"PUT",objPropertiesHeaders,objPayload);
}

Private Function: VraRestRequest

privateVraRestRequest<T>(objVraHost:VraHost,strUri:string,strMethod:"GET"|"DELETE"|"PATCH"|"POST"|"PUT",objPropertiesHeaders:Properties=newProperties(),objPayload:any=null):T{

letobjVraGenericRestClient:VraGenericRestClient=objVraHost.createRestClient();

letobjVraRestRequest:VraRestRequest=objVraGenericRestClient.createRequest(strMethod,strUri,objPayload);

objPropertiesHeaders.keys.forEach((strKey:string):void=>{
objVraRestRequest.setHeader(strKey,objPropertiesHeaders.get(strKey));
});

letobjVraRestResponse:VraRestResponse=objVraGenericRestClient.execute(objVraRestRequest);

this.objLogger.info("Status code:"+objVraRestResponse.statusCode);
this.objLogger.info("Status Message:"+objVraRestResponse.statusMessage);
this.objLogger.info("Content as string:"+objVraRestResponse.contentAsString);

letobjHeader:{ [key:string]:string}=objVraRestResponse.allHeaders;

letarrKey:string[]=Object.keys(objHeader);

arrKey.forEach((strKey:string):void=>{
this.objLogger.info(strKey.toString());
});

letobjReturn:T=JSON.parse(objVraRestResponse.contentAsString);

returnobjReturn;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like