-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathserviceNowDemo.ur
70 lines (58 loc) · 1.72 KB
/
serviceNowDemo.ur
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
60
61
62
63
64
65
66
67
68
69
70
(* For this demo, it's necessary to create serviceNowSecrets.ur,
* defining [instance], [client_id], and [client_secret]. *)
structure A = ServiceNow.ThreeLegged(struct
open ServiceNowSecrets
val https = False
val onCompletion = return <xml>Done.</xml>
val scopes = ServiceNow.Scope.empty
end)
structure S = ServiceNow.Make(A)
fun table_ name =
{Columns = cs, DisplayColumn = disp} <- S.Tables.columns name;
return <xml><body>
<h1>Columns</h1>
{case disp of
None => <xml></xml>
| Some disp => <xml><p>Display column is: <b>{[disp]}</b>.</p></xml>}
<table>
<tr><th>Name</th> <th>Type</th></tr>
{List.mapX (fn c => <xml>
<tr><td>{[c.Nam]}</td> <td>{[c.Typ]}</td></tr>
</xml>) cs}
</table>
</body></xml>
val main =
toko <- A.token;
case toko of
None => return <xml><body><a link={A.authorize}>Log into ServiceNow</a></body></xml>
| Some _ =>
is <- S.Incidents.list;
ts <- S.Tables.list;
return <xml><body>
<h1>Incidents</h1>
<table>
<tr><th>Description</th></tr>
{List.mapX (fn i => <xml>
<tr><td>{[i.Description]}</td></tr>
</xml>) is}
</table>
<h1>Tables</h1>
<table>
<tr><th>Name</th></tr>
{List.mapX (fn t => <xml>
<tr><td><a link={table_ t.Nam}>{[t.Nam]}</a></td></tr>
</xml>) ts}
</table>
</body></xml>
val incidents =
is <- S.Table.list {Description = "description",
Severity = "severity"} "incident";
return <xml><body>
<table>
<tr><th>Description</th> <th>Severity</th></tr>
{List.mapX (fn {Description = d : option string,
Severity = s : option int} => <xml>
<tr><td>{[d]}</td> <td>{[s]}</td></tr>
</xml>) is}
</table>
</body></xml>