-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathautomation-CherwellUpdateIncident.yml
117 lines (101 loc) · 4.06 KB
/
automation-CherwellUpdateIncident.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
args:
- description: Incident description.
name: description
- auto: PREDEFINED
description: Incident priority.
name: priority
predefined:
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
- description: Incident owner.
name: owned_by
- description: Service needed.
name: service
- description: Public ID or record ID.
name: id_value
required: true
- auto: PREDEFINED
description: Type of ID.
name: id_type
predefined:
- public_id
- record_id
required: true
comment: This script is an example script of how to update an incident in Cherwell.
The script wraps the update-business-object command of the cherwell integration.
When writing your own script to update a business object, follow the instructions
found in the configuration section of the script, but do not change the execution
section.
commonfields:
id: CherwellUpdateIncident
version: -1
dependson:
must:
- Cherwell|||cherwell-update-business-object
dockerimage: demisto/python3:3.7.2.214
name: CherwellUpdateIncident
outputs:
- contextPath: Cherwell.BusinessObjects.PublicId
description: Incident public ID
type: String
- contextPath: Cherwell.BusinessObjects.RecordId
description: Incident record ID
type: String
runonce: false
script: |2-
args = demisto.args()
# ####################################################################################
# ############################## CONFIGURATION PART ##################################
# ####################################################################################
"""
`BUSINESS_OBJECT_TYPE` is the name of business object you wish to create using this script.
In this case we set it to be 'incident' as this script is in charge of creating incidents.
"""
BUSINESS_OBJECT_TYPE = 'Incident'
"""
`FIELDS` contains all the fields you wish to include in your business object.
In order to update a field in a business object, you will need to have a corresponding argument in the script arguments
(found in the script settings). After you added the argument to the script arguments, you will need to add its value to
the `FIELDS` object by using `args.get('argument_name').
Make sure the key name is identical to the field name in the Cherwell system.
For example: we wished to update the requesting customer of some incident, thus, we added a customer_display_name
argument to this script, we pulled the value of the argument by using`args.get('customer_display_name')` and we set
the key name to be `CustomerDisplayName` - as it appears in the Cherwell system.
Expert tip: if you don't want to keep Demisto's arguments naming convention, (where variables are written in snake
case), you can name your arguments exactly as they appear in the Cherwell system, This will shorten the `FIELDS`
constant to be `FIELDS = args`
"""
FIELDS = {
'Description': args.get('description'),
'Priority': args.get('priority'),
'CustomerDisplayName': args.get('customer_display_name'),
'OwnedBy': args.get('owned_by'),
'Service': args.get('service')
}
# ####################################################################################
# ############################## EXECUTION PART ######################################
# ####################################################################################
def build_arguments():
arguments = {
'type': BUSINESS_OBJECT_TYPE,
'id_type': args.get('id_type'),
'id_value': args.get('id_value'),
# As `owned_by` and `service` arguments are not mandatory we make sure to remove them by using the createContext
# function with removeNull flag set to true.
# If all script arguments are mandatory, it would be sufficient to use `json: FIELDS` instead of
# `createContext(FIELDS, removeNull=True)`
'json': createContext(FIELDS, removeNull=True)
}
return arguments
result = demisto.executeCommand('cherwell-update-business-object', build_arguments())
demisto.results(result)
scripttarget: 0
subtype: python3
system: true
tags:
- Cherwell
type: python