To use this function add it to the class library file named OrchestratorService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorService.ts
Description: Orchestrator Function to add REST Operations to a REST Host
Function RESTOperationCreate2
publicRESTOperationCreate2(objProperties:Properties,objRESTHost:RESTHost):void{
letarrPropertiesKey:string[]=objProperties.keys;
letarrRESTOperationName:string[]=objRESTHost.getOperations();
arrRESTOperationName.forEach((strRESTOperationName:string):void=>{
arrPropertiesKey.forEach((strPropertiesKey:string):void=>{
letobjRESTOperation: RESTOperation=objRESTHost.getOperation(strRESTOperationName);
//@ts-ignore
if (strPropertiesKey===objRESTOperation.name){
objProperties.remove(strPropertiesKey);
}
});
});
arrPropertiesKey=objProperties.keys;
arrPropertiesKey.forEach((strPropertiesKey:string):void=>{
letarrKey:string[]=strPropertiesKey.split('_');
letstrMethod:string=arrKey[0];
letstrName:string=arrKey[1];
letstrTemplateURL=objProperties.get(strPropertiesKey);
letobjRESTOperation: RESTOperation=newRESTOperation(strName);
//@ts-ignore
objRESTOperation.method=strMethod;
//@ts-ignore
objRESTOperation.urlTemplate=strTemplateURL;
//@ts-ignore
objRESTOperation.defaultContentType="application/json";
objRESTOperation=objRESTHost.addOperation(objRESTOperation);
RESTHostManager.updateHost(objRESTHost);
});
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
