To use this function add it to the class library file named OpsViewService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OpsViewService.ts
Description: Orchestrator Function to login to OpsView – Part 1
Function OpsViewLogon1
privateOpsViewLogon1(objRESTOperation:RESTOperation,strOpsViewServerName:string,strUsername:string,strPassword:string):void{
letobjJson:{ username:string, password:string}={
username:strUsername,
password:strPassword
};
letobjRESTRequest:RESTRequest=objRESTOperation.createRequest([],objJson);
objRESTRequest.contentType="application/json";
objRESTRequest.setHeader("Accept","application/json");
letobjRESTResponse:RESTResponse=objRESTRequest.execute();
letstrContentAsString:string=objRESTResponse.contentAsString;
letobjJSON:any=JSON.parse(strContentAsString);
if (objRESTResponse.statusCode==200){
this.objLogger.info("===== Successfully Logged into OpsView '"+strOpsViewServerName+"'");
letstrToken:string=objJSON.token;
}
else{
this.objLogger.info("===== Failed to Login to OpsView '"+strOpsViewServerName+"'");
letstrMessage:string=objJSON.message;
letstrDetail:string=objJSON.detailmessage;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
