@@ -17,55 +17,100 @@ state:
17
17
want_more: false
18
18
user: "{{ api_id }} "
19
19
password: "{{ api_key }} "
20
+ redact:
21
+ fields:
22
+ - password
20
23
program: |
21
24
(
22
25
has(state.worklist) && size(state.worklist) > 0 ?
23
26
state
24
27
:
25
- request("GET", ( state.url + "logs.index")).with({
28
+ request("GET", (state.url + "logs.index")).with({
26
29
"Header":{
27
30
"Authorization": ["Basic "+string(base64(state.user+":"+state.password))],
28
31
}
29
- }).do_request().as(resp, bytes(resp.Body).as(body, {
30
- "worklist": (
31
- has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
32
- ?
33
- string(body).split(state.cursor.log_file)[1].split("\n").filter(x,x!="").map(x,{"filename":x})
34
- :
35
- string(body).split("\n").map(x,{"filename":x})
36
- ),
37
- "next": 0,
38
- }))
39
- ).as(v, v.next < size(v.worklist) ?
32
+ }).do_request().as(resp, resp.StatusCode == 200 ?
33
+ bytes(resp.Body).as(body, {
34
+ "worklist": (
35
+ has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
36
+ ?
37
+ string(body).split(state.cursor.log_file)[1].split("\n").filter(x,x!="").map(x,{"filename":x})
38
+ :
39
+ string(body).split("\n").map(x,{"filename":x})
40
+ ),
41
+ "next": 0,
42
+ })
43
+ :
44
+ {
45
+ "events": {
46
+ "error": {
47
+ "code": string(resp.StatusCode),
48
+ "id": string(resp.Status),
49
+ "message": "GET " + state.url + "logs.index: " + "+(
50
+ size(resp.Body) != 0 ?
51
+ string(resp.Body)
52
+ :
53
+ string(resp.Status) + ' (' + string(resp.StatusCode) + ')'
54
+ ),
55
+ },
56
+ },
57
+ "want_more": false,
58
+ "user": state.user,
59
+ "password": state.password,
60
+ }
61
+ )
62
+ ).as(v, has(v.?events.error) ?
63
+ v
64
+ : v.next < size(v.worklist) ?
40
65
(
41
66
request("GET",
42
67
state.url+v.worklist[v.next].filename
43
68
).with({
44
69
"Header":{
45
70
"Authorization": ["Basic "+string(base64(state.user + ":" + state.password))],
46
71
}
47
- }).do_request().as(resp, bytes(resp.Body).as(body, {
48
- "events": (string(body)+"|==|").split("|==|")[1].split("\n").filter(x,x!="").map(x,{"message":x}),
49
- "cursor": {
50
- "log_file": (
51
- has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
52
- ?
53
- (
54
- (v.worklist[v.next].filename).split(".")[0] != (state.cursor.log_file).split(".")[0] ?
55
- v.worklist[v.next].filename
72
+ }).do_request().as(resp, resp.StatusCode == 200 ?
73
+ bytes(resp.Body).as(body, {
74
+ "events": (string(body)+"|==|").split("|==|")[1].split("\n").filter(x,x!="").map(x,{"message":x}),
75
+ "cursor": {
76
+ "log_file": (
77
+ has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
78
+ ?
79
+ (
80
+ (v.worklist[v.next].filename).split(".")[0] != (state.cursor.log_file).split(".")[0] ?
81
+ v.worklist[v.next].filename
82
+ :
83
+ state.cursor.log_file
84
+ )
85
+ :
86
+ v.worklist[v.next].filename
87
+ )
88
+ },
89
+ "worklist": (int(v.next)+1) < size(v.worklist) ? v.worklist : [],
90
+ "next": (int(v.next)+1) < size(v.worklist) ? (int(v.next)+1) : 0,
91
+ "want_more": (int(v.next)+1) < size(v.worklist),
92
+ "user": state.user,
93
+ "password": state.password,
94
+ })
95
+ :
96
+ {
97
+ "events": {
98
+ "error": {
99
+ "code": string(resp.StatusCode),
100
+ "id": string(resp.Status),
101
+ "message": "GET " + state.url+v.worklist[v.next].filename + ": " + "+(
102
+ size(resp.Body) != 0 ?
103
+ string(resp.Body)
56
104
:
57
- state.cursor.log_file
58
- )
59
- :
60
- v.worklist[v.next].filename
61
- )
62
- },
63
- "worklist": (int(v.next)+1) < size(v.worklist) ? v.worklist : [],
64
- "next": (int(v.next)+1) < size(v.worklist) ? (int(v.next)+1) : 0,
65
- "want_more": (int(v.next)+1) < size(v.worklist),
66
- "user": state.user,
67
- "password": state.password
68
- }))
105
+ string(resp.Status) + ' (' + string(resp.StatusCode) + ')'
106
+ ),
107
+ },
108
+ },
109
+ "want_more": false,
110
+ "user": state.user,
111
+ "password": state.password,
112
+ }
113
+ )
69
114
)
70
115
:
71
116
{
0 commit comments