@@ -17,55 +17,100 @@ state:
1717 want_more: false
1818 user: "{{ api_id }} "
1919 password: "{{ api_key }} "
20+ redact:
21+ fields:
22+ - password
2023program: |
2124 (
2225 has(state.worklist) && size(state.worklist) > 0 ?
2326 state
2427 :
25- request("GET", ( state.url + "logs.index")).with({
28+ request("GET", (state.url + "logs.index")).with({
2629 "Header":{
2730 "Authorization": ["Basic "+string(base64(state.user+":"+state.password))],
2831 }
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) ?
4065 (
4166 request("GET",
4267 state.url+v.worklist[v.next].filename
4368 ).with({
4469 "Header":{
4570 "Authorization": ["Basic "+string(base64(state.user + ":" + state.password))],
4671 }
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)
56104 :
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+ )
69114 )
70115 :
71116 {
0 commit comments