Function: Add REST Operations to a REST Hosts

by Simon Sparks · 1 June 2025

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 REST Hosts

Function RESTOperationCreate

public RESTOperationCreate(objProperties: Properties, arrRESTHost: RESTHost[]): void {
    let arrKey: string[] = objProperties.keys;

    arrRESTHost.forEach((objRESTHost: RESTHost): void => {

        arrKey.forEach((strKey: string): void => {

            let arrKey: string[] = strKey.split('-');

            let strMethod: string = arrKey[0].toUpperCase();

            let strTemplateURL: string = objProperties.get(strKey);

            let objRESTOperation: RESTOperation = new RESTOperation(strKey);
            //@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.

You may also like