-
Notifications
You must be signed in to change notification settings - Fork 10
/
quicktest.js
59 lines (50 loc) · 1.44 KB
/
quicktest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const restaf = require("@sassoftware/restaf");
const restaflib = require("@sassoftware/restaflib");
let logonPayload = {
host : process.env.VIYA_SERVER,
token : getToken(),
tokenType: "bearer",
authType : "server",
};
let store = restaf.initStore(
{ casProxy: true,
options : {
proxyServer: null
}});
run()
.then((r) => console.log("done"))
.catch((err) => console.log(JSON.stringify(err, null, 4)));
async function run() {
let msg = await store.logon(logonPayload);
console.log(msg);
let { casManagement } = await store.addServices("casManagement");
let { session } = await restaflib.casSetup(store, null);
let p = {
action: "datastep.runCode",
data : {
single: "YES",
code : "data casuser.score; keep x1 x2;do i = 1 to 20; x1=i; x2=i*10;output;end;run; ",
},
};
let r = await store.runAction(session, p);
console.log('-----------------');
console.log(r.items().toJS());
console.log("-------------------------");
p = {
action: "builtins.echo",
data : {
code: "data casuser.score; x1=10;x2=20;x3=30; score1 = x1+x2+x3;run; ",
},
};
let r1 = await store.runAction(session, p);
console.log(r1.items().toJS());
return "done";
}
function getToken() {
let fs = require("fs");
let j = fs.readFileSync(process.env.SASTOKEN, "utf8");
let js = JSON.parse(j);
let token = js.Default["access-token"];
console.log("token", token);
return token;
}