-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathautomation-CherwellCreateIncident.yml
108 lines (92 loc) · 3.74 KB
/
automation-CherwellCreateIncident.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
args:
- description: Incident description.
name: description
required: true
- auto: PREDEFINED
description: Incident priority.
name: priority
predefined:
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
required: true
- description: Incident owner.
name: owned_by
- description: Service needed.
name: service
- description: Requesting customer name.
name: customer_display_name
required: true
comment: This script is an example script of how to create an incident in Cherwell.
The script wraps the create business object command in the cherwell integration.
When writing your own script to create a business object, follow the instructions
in the configuration part, but do not change the execution section.
commonfields:
id: CherwellCreateIncident
version: -1
dependson:
must:
- Cherwell|||cherwell-create-business-object
dockerimage: demisto/python3:3.7.2.214
name: CherwellCreateIncident
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 add a field to a business object you will need to have a corresponding argument in the script arguments.
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 is identical to the field name in the Cherwell system.
For example: we wished to create an incident with a requesting customer field in it, 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, 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,
# 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 arguments are mandatory it would be sufficient to use `json: FIELDS`
'json': createContext(FIELDS, removeNull=True)
}
return arguments
result = demisto.executeCommand('cherwell-create-business-object', build_arguments())
demisto.results(result)
scripttarget: 0
subtype: python3
system: true
tags:
- Cherwell
type: python