To use this function add it to the class library file named InfobloxService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: InfobloxService.ts
Description: Orchestrator Function to create a CName record in Infoblox
Function InfobloxCreateCNameRecord
public InfobloxCreateCNameRecord(objRESTHost: RESTHost, strARecord: string, strCName: string): void {
let strJson: string = '{"canonical":"' + strCName + '","name":"' + strARecord + '"}';
try {
let objRESTRequest: RESTRequest = objRESTHost.createRequest("POST", "/wapi/v1.1/record:cname", strJson);
objRESTRequest.contentType = "application/json";
objRESTRequest.setHeader("Accept", "application/json");
let objRESTResponse: RESTResponse = objRESTRequest.execute();
let intStatusCode: number = objRESTResponse.statusCode;
let objJSON:any = JSON.parse(objRESTResponse.contentAsString);
if (intStatusCode === 201) {
this.objLogger.info("Successfully Added a CName Record for : '" + strCName + "' pointing to '" + strARecord + "' into InfoBlox.");
}
else {
let strError:string = objJSON.Error;
let strCode: string = objJSON.code;
let strText: string = objJSON.text;
this.objLogger.info("HTTP Error: " + intStatusCode + ", " + strText);
}
}
catch (objException) {
this.objLogger.info("objException = " + objException);
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
