-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathautomation-CPTaskStatus.yml
48 lines (47 loc) · 1.55 KB
/
automation-CPTaskStatus.yml
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
args:
- default: true
description: Task UUIDs
name: taskIDs
required: true
comment: Shows status of a checkpoint task by task uuid.
commonfields:
id: CPTaskStatus
version: -1
dependson:
must:
- checkpoint
deprecated: true
name: CPTaskStatus
runonce: false
script: |
res = []
taskIds = demisto.get(demisto.args(), 'taskIDs')
if type(taskIds) in [str, unicode]:
taskIds = taskIds.split(',') if ',' in taskIds else [taskIds]
dArgs = {'command':'show-task'}
rows = []
for tid in taskIds:
dArgs["task-id"] = tid
resCmd = demisto.executeCommand('checkpoint', dArgs)
try:
for entry in resCmd:
if isError(entry):
res = resCmd
break
else:
tasks = demisto.get(entry, 'Contents.tasks')
if tasks:
rows += tasks
else:
res.append({"Type": entryTypes["error"], "ContentsFormat": formats["text"],
"Contents": "Could not extract result list from response: " + json.dumps(entry["Contents"])})
except Exception as ex:
res.append({"Type": entryTypes["error"], "ContentsFormat": formats["text"],
"Contents": "Error occurred while parsing output from command. Exception info:\n" + str(ex) + "\n\nInvalid output:\n" + str(resCmd)})
res.append({"Type": entryTypes["note"], "ContentsFormat": formats["table"], "Contents": rows})
demisto.results(res)
scripttarget: 0
system: true
tags:
- checkpoint
type: python