Function: AVI Health Monitor Create

by Simon Sparks · 11 March 2026

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

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

Filename: PluginAVIService.ts

Description: Orchestrator Function to Create an AVI Health Monitor.

Private Function: AviHealthMonitorCreate

public AviHealthMonitorCreate(objAviWorkflowRuntime: AviWorkflowRuntime, strTenant: string = "admin", arrHttpResponseCode: string[], blnIsFederated: boolean, intSuccessfulCheck: number, intFailedCheck: number, intTimeout: number, intSendInterval: number, intMonitorPort: number, strHealthMonitorUUID: string, strHealthMonitorName: string, strHealthMonitorDescription: string, strHealthMonitorType: "HEALTH_MONITOR_EXTERNAL" | "HEALTH_MONITOR_UDP" | "HEALTH_MONITOR_DNS" | "HEALTH_MONITOR_HTTP" | "HEALTH_MONITOR_HTTPS" | "HEALTH_MONITOR_TCP", strCommandCode: string, strUdpRequest: string, strDnsQueryName: string, strTcpRequest: string, strTcpResponse: string, strMaintenanceCode: string, blnTcpHalfOpen: boolean): AviWorkflowRuntime {

    let objAviHealthMonitor: AviHealthMonitor = this.AviHealthMonitorBuild(strTenant, strHealthMonitorName, strHealthMonitorType, strHealthMonitorDescription, strHealthMonitorUUID, blnIsFederated, intMonitorPort, intTimeout, intSendInterval, intSuccessfulCheck, intFailedCheck);

    if (strHealthMonitorType === "HEALTH_MONITOR_EXTERNAL") {
        let objAviHealthMonitorExternal: AviHealthMonitorExternal = new AviHealthMonitorExternal();
        objAviHealthMonitorExternal.setCommandCode(strCommandCode);
        objAviHealthMonitor.setExternalMonitor(objAviHealthMonitorExternal);
    } else if (strHealthMonitorType === "HEALTH_MONITOR_UDP") {
        let objAviHealthMonitorUdp: AviHealthMonitorUdp = new AviHealthMonitorUdp();
        objAviHealthMonitorUdp.setUdpRequest(strUdpRequest);
        objAviHealthMonitor.setUdpMonitor(objAviHealthMonitorUdp);
    } else if (strHealthMonitorType === "HEALTH_MONITOR_DNS") {
        let objAviHealthMonitorDNS: AviHealthMonitorDNS = new AviHealthMonitorDNS();
        objAviHealthMonitorDNS.setQueryName(strDnsQueryName);
        objAviHealthMonitor.setDnsMonitor(objAviHealthMonitorDNS);
    } else if (strHealthMonitorType === "HEALTH_MONITOR_HTTP") {
        let objAviHealthMonitorHttp: AviHealthMonitorHttp = new AviHealthMonitorHttp();

        arrHttpResponseCode.forEach((strHttpResponseCode: string): void => {
            let strCode: string = `HTTP_${strHttpResponseCode}`;

            objAviHealthMonitorHttp.addHttpResponseCodeItem(strCode);
        });

        objAviHealthMonitor.setHttpMonitor(objAviHealthMonitorHttp);
    } else if (strHealthMonitorType === "HEALTH_MONITOR_HTTPS") {
        let objAviHealthMonitorSSLAttributes: AviHealthMonitorSSLAttributes = new AviHealthMonitorSSLAttributes();
        objAviHealthMonitorSSLAttributes.setSslProfileRef("/api/sslprofile?name=System-Standard");
        objAviHealthMonitorSSLAttributes.setSslKeyAndCertificateRef("/api/sslkeyandcertificate?name=System-Default-Cert");
        let objAviHealthMonitorHttp: AviHealthMonitorHttp = new AviHealthMonitorHttp();

        arrHttpResponseCode.forEach((strHttpResponseCode: string): void => {

            let strCode: string = `HTTP_${strHttpResponseCode}`;

            objAviHealthMonitorHttp.addHttpResponseCodeItem(strCode);
        });

        objAviHealthMonitorHttp.setSslAttributes(objAviHealthMonitorSSLAttributes);
        objAviHealthMonitor.setHttpsMonitor(objAviHealthMonitorHttp);
    } else if (strHealthMonitorType === "HEALTH_MONITOR_TCP") {
        let objAviHealthMonitorTcp: AviHealthMonitorTcp = new AviHealthMonitorTcp();
        objAviHealthMonitorTcp.setTcpRequest(strTcpRequest);
        objAviHealthMonitorTcp.setTcpResponse(strTcpResponse);
        objAviHealthMonitorTcp.setTcpHalfOpen(blnTcpHalfOpen);

        if (blnTcpHalfOpen === true) {
            objAviHealthMonitorTcp.setMaintenanceResponse(strMaintenanceCode);
        }

        objAviHealthMonitor.setTcpMonitor(objAviHealthMonitorTcp);
    }

    let objAviVroClient: AviVroClient = objAviWorkflowRuntime.getAviVroClient();
    objAviVroClient.addObject(objAviHealthMonitor, objAviWorkflowRuntime.getWorkflowId(), strTenant);

    return objAviWorkflowRuntime;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like