Generating thousands/millions of rows of Synthetic DPL data using Rest APIs
Below is the Service Suite script that can be used to generate synthetic data using Rest APIs, this would be useful when generating millions of data which might be difficult using the UI as UI will have its own limitations.
Start AIQ
Go to Service Suite
API editor
Open the below script
modify the quantity variable to 1000000 (or as desired)
Save and run
a file with 1000000 will be created.
Note: There are 2 parameters that might be required to change.
-
AIQ URL (Line 1) -
var $baseURL = "http://localhost:8080"; -
Creds (Line 12 and 13) - Username and password.
var $baseURL = "http://localhost:8080";
function getTimestamp() {
return (new Date()).getTime();
}
//
// LOGIN
//
function login($baseURL) {
var $loginForm = formData();
$loginForm.put("username", "appvance");
$loginForm.put("password", "appvance");
var $call = createPost($baseURL + "/AppvanceServer/rest/admin/logginForServices", $loginForm);
var $resp = process($call).getDataString();
if ($resp.indexOf("true") != -1) {
//
// GET JSESSIONID COOKIE
//
var $jsession = getCookieValue($baseURL, "JSESSIONID");
addGlobalHeader("cookie", "JSESSION = " + $jsession);
log("Login successful, JSESSION:" + $jsession)
return true;
} else {
return false;
}
}
var $resp = login($baseURL);
var quantity = 100000;
var fileName = "REPOSITORY/HOME/DPL.csv";
if ($resp === true) {
log("Is Logged");
var data = [["qty", "test"],["syn.random.number(10)","syn.random.number(100)"]];
var call = createPost($baseURL + "/AppvanceServer/rest/syntheticDPL/evaluate?lines="+quantity+"&locale=en_US", data);
var stringJson = process(call).getDataString();
var payload = JSON.parse(stringJson.replace(/\n|\r/g, "").trim());
var callSave = createPost($baseURL + '/AppvanceServer/rest/file/updateCSVFile?commitMessage=&path=' + fileName, payload);
var stringJsonSave = process(callSave).getDataString();
var response = JSON.parse(stringJsonSave);
log(fileName + " was saved: " + response.status);
}
//
// LOGOUT
//
var $resp = get($baseURL + "/AppvanceServer/rest/admin/logout");
log("logout: " + $resp.getDataString());
Last updated: June 02, 2023
If you have any feedback on this topic, please contact us at documentation@appvance.ai