floe-servicenow 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop_local.yml +5 -0
- data/.whitesource +3 -0
- data/CHANGELOG.md +24 -0
- data/LICENSE.txt +202 -0
- data/README.md +185 -0
- data/Rakefile +12 -0
- data/docs/cmdb.md +343 -0
- data/docs/incident.md +270 -0
- data/docs/oauth.md +98 -0
- data/docs/service_catalog.md +423 -0
- data/docs/table.md +320 -0
- data/examples/cmdb.asl +90 -0
- data/examples/create_server_ci.asl +43 -0
- data/examples/incident.asl +53 -0
- data/examples/oauth.asl +67 -0
- data/examples/service_catalog.asl +77 -0
- data/examples/table.asl +138 -0
- data/exe/floe-servicenow +9 -0
- data/lib/floe/service_now.rb +1 -0
- data/lib/floe/servicenow/cmdb.rb +282 -0
- data/lib/floe/servicenow/incident.rb +128 -0
- data/lib/floe/servicenow/methods.rb +73 -0
- data/lib/floe/servicenow/oauth.rb +39 -0
- data/lib/floe/servicenow/runner.rb +73 -0
- data/lib/floe/servicenow/service_catalog.rb +446 -0
- data/lib/floe/servicenow/table.rb +217 -0
- data/lib/floe/servicenow/version.rb +7 -0
- data/lib/floe/servicenow.rb +35 -0
- metadata +130 -0
data/docs/cmdb.md
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
# CMDB API Methods
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
| Method | Description |
|
|
6
|
+
|--------|-------------|
|
|
7
|
+
| [Get Configuration Item](#get-configuration-item) | Retrieve a single CI by sys_id |
|
|
8
|
+
| [Query Configuration Items](#query-configuration-items) | Query multiple CIs with filtering |
|
|
9
|
+
| [Create Configuration Item](#create-configuration-item) | Create a new CI |
|
|
10
|
+
| [Update Configuration Item](#update-configuration-item) | Update an existing CI |
|
|
11
|
+
| [Delete Configuration Item](#delete-configuration-item) | Delete a CI |
|
|
12
|
+
| [Get CI Relationships](#get-ci-relationships) | Retrieve CI and its relationships |
|
|
13
|
+
| [Create CI Relationship](#create-ci-relationship) | Create a relationship between two CIs |
|
|
14
|
+
| [Get CI Classes](#get-ci-classes) | Retrieve available CMDB CI classes |
|
|
15
|
+
|
|
16
|
+
## Get Configuration Item
|
|
17
|
+
|
|
18
|
+
Retrieve a single Configuration Item (CI) by its sys_id.
|
|
19
|
+
|
|
20
|
+
**Resource**: `servicenow://cmdb/get_ci`
|
|
21
|
+
|
|
22
|
+
**Required Parameters**:
|
|
23
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
24
|
+
- `sys_id` (string): Unique identifier of the CI
|
|
25
|
+
|
|
26
|
+
**Optional Parameters**:
|
|
27
|
+
- `table` (string): CMDB table name (defaults to "cmdb_ci")
|
|
28
|
+
|
|
29
|
+
**Example**:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"Resource": "servicenow://cmdb/get_ci",
|
|
34
|
+
"Parameters": {
|
|
35
|
+
"instance_id": "dev12345",
|
|
36
|
+
"sys_id": "abc123def456",
|
|
37
|
+
"table": "cmdb_ci_server"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Response**:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"result": {
|
|
47
|
+
"sys_id": "abc123def456",
|
|
48
|
+
"name": "web-server-01",
|
|
49
|
+
"ip_address": "192.168.1.100"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Query Configuration Items
|
|
55
|
+
|
|
56
|
+
Query multiple Configuration Items with optional filtering.
|
|
57
|
+
|
|
58
|
+
**Resource**: `servicenow://cmdb/query_cis`
|
|
59
|
+
|
|
60
|
+
**Required Parameters**:
|
|
61
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
62
|
+
- `method` (string): HTTP method (typically "GET")
|
|
63
|
+
|
|
64
|
+
**Optional Parameters**:
|
|
65
|
+
- `table` (string): CMDB table name (defaults to "cmdb_ci")
|
|
66
|
+
- `query` (string): Encoded query string
|
|
67
|
+
- `limit` (integer): Maximum number of records to return
|
|
68
|
+
- `offset` (integer): Starting record index for pagination
|
|
69
|
+
- `fields` (string): Comma-separated list of fields to return
|
|
70
|
+
|
|
71
|
+
**Example**:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"Resource": "servicenow://cmdb/query_cis",
|
|
76
|
+
"Parameters": {
|
|
77
|
+
"instance_id": "dev12345",
|
|
78
|
+
"method": "GET",
|
|
79
|
+
"table": "cmdb_ci_server",
|
|
80
|
+
"query": "operational_status=1",
|
|
81
|
+
"limit": 10,
|
|
82
|
+
"fields": "name,ip_address,os"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Response**:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"result": [
|
|
92
|
+
{
|
|
93
|
+
"name": "web-server-01",
|
|
94
|
+
"ip_address": "192.168.1.100",
|
|
95
|
+
"os": "Linux"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Create Configuration Item
|
|
102
|
+
|
|
103
|
+
Create a new Configuration Item.
|
|
104
|
+
|
|
105
|
+
**Resource**: `servicenow://cmdb/create_ci`
|
|
106
|
+
|
|
107
|
+
**Required Parameters**:
|
|
108
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
109
|
+
|
|
110
|
+
**Optional Parameters**:
|
|
111
|
+
- `table` (string): CMDB table name (defaults to "cmdb_ci")
|
|
112
|
+
- Additional fields as key-value pairs for the CI
|
|
113
|
+
|
|
114
|
+
**Example**:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"Resource": "servicenow://cmdb/create_ci",
|
|
119
|
+
"Parameters": {
|
|
120
|
+
"instance_id": "dev12345",
|
|
121
|
+
"table": "cmdb_ci_server",
|
|
122
|
+
"name": "new-server-01",
|
|
123
|
+
"ip_address": "192.168.1.200",
|
|
124
|
+
"os": "Ubuntu 20.04"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Response**:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"result": {
|
|
134
|
+
"sys_id": "xyz789",
|
|
135
|
+
"name": "new-server-01",
|
|
136
|
+
"ip_address": "192.168.1.200",
|
|
137
|
+
"os": "Ubuntu 20.04"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Update Configuration Item
|
|
143
|
+
|
|
144
|
+
Update an existing Configuration Item.
|
|
145
|
+
|
|
146
|
+
**Resource**: `servicenow://cmdb/update_ci`
|
|
147
|
+
|
|
148
|
+
**Required Parameters**:
|
|
149
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
150
|
+
- `sys_id` (string): Unique identifier of the CI to update
|
|
151
|
+
|
|
152
|
+
**Optional Parameters**:
|
|
153
|
+
- `table` (string): CMDB table name (defaults to "cmdb_ci")
|
|
154
|
+
- Additional fields as key-value pairs to update
|
|
155
|
+
|
|
156
|
+
**Example**:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"Resource": "servicenow://cmdb/update_ci",
|
|
161
|
+
"Parameters": {
|
|
162
|
+
"instance_id": "dev12345",
|
|
163
|
+
"sys_id": "abc123def456",
|
|
164
|
+
"table": "cmdb_ci_server",
|
|
165
|
+
"ip_address": "192.168.1.150",
|
|
166
|
+
"operational_status": "1"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Response**:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"result": {
|
|
176
|
+
"sys_id": "abc123def456",
|
|
177
|
+
"name": "web-server-01",
|
|
178
|
+
"ip_address": "192.168.1.150",
|
|
179
|
+
"operational_status": "1"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Delete Configuration Item
|
|
185
|
+
|
|
186
|
+
Delete a Configuration Item.
|
|
187
|
+
|
|
188
|
+
**Resource**: `servicenow://cmdb/delete_ci`
|
|
189
|
+
|
|
190
|
+
**Required Parameters**:
|
|
191
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
192
|
+
- `sys_id` (string): Unique identifier of the CI to delete
|
|
193
|
+
|
|
194
|
+
**Optional Parameters**:
|
|
195
|
+
- `table` (string): CMDB table name (defaults to "cmdb_ci")
|
|
196
|
+
|
|
197
|
+
**Example**:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"Resource": "servicenow://cmdb/delete_ci",
|
|
202
|
+
"Parameters": {
|
|
203
|
+
"instance_id": "dev12345",
|
|
204
|
+
"sys_id": "abc123def456",
|
|
205
|
+
"table": "cmdb_ci_server"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Response**:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"result": {
|
|
215
|
+
"success": true
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Get CI Relationships
|
|
221
|
+
|
|
222
|
+
Retrieve a Configuration Item and its relationships.
|
|
223
|
+
|
|
224
|
+
**Resource**: `servicenow://cmdb/get_ci_relationships`
|
|
225
|
+
|
|
226
|
+
**Required Parameters**:
|
|
227
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
228
|
+
- `sys_id` (string): Unique identifier of the CI
|
|
229
|
+
|
|
230
|
+
**Example**:
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"Resource": "servicenow://cmdb/get_ci_relationships",
|
|
235
|
+
"Parameters": {
|
|
236
|
+
"instance_id": "dev12345",
|
|
237
|
+
"sys_id": "abc123def456"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Response**:
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"sys_id": "abc123def456",
|
|
247
|
+
"name": "web-server-01",
|
|
248
|
+
"relationships": [
|
|
249
|
+
{
|
|
250
|
+
"parent": "abc123def456",
|
|
251
|
+
"child": "xyz789",
|
|
252
|
+
"type": "Depends on::Used by"
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Create CI Relationship
|
|
259
|
+
|
|
260
|
+
Create a relationship between two Configuration Items.
|
|
261
|
+
|
|
262
|
+
**Resource**: `servicenow://cmdb/create_ci_relationship`
|
|
263
|
+
|
|
264
|
+
**Required Parameters**:
|
|
265
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
266
|
+
- `parent_sys_id` (string): sys_id of the parent CI
|
|
267
|
+
- `child_sys_id` (string): sys_id of the child CI
|
|
268
|
+
- `relationship_type` (string): Type of relationship (e.g., "Depends on::Used by")
|
|
269
|
+
|
|
270
|
+
**Optional Parameters**:
|
|
271
|
+
- `connection_strength` (string): Strength of the connection (defaults to "1")
|
|
272
|
+
|
|
273
|
+
**Example**:
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"Resource": "servicenow://cmdb/create_ci_relationship",
|
|
278
|
+
"Parameters": {
|
|
279
|
+
"instance_id": "dev12345",
|
|
280
|
+
"parent_sys_id": "abc123",
|
|
281
|
+
"child_sys_id": "xyz789",
|
|
282
|
+
"relationship_type": "Depends on::Used by",
|
|
283
|
+
"connection_strength": "2"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Response**:
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"result": {
|
|
293
|
+
"sys_id": "rel123",
|
|
294
|
+
"parent": "abc123",
|
|
295
|
+
"child": "xyz789",
|
|
296
|
+
"type": "Depends on::Used by",
|
|
297
|
+
"connection_strength": "2"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Get CI Classes
|
|
303
|
+
|
|
304
|
+
Retrieve available CMDB CI classes (types).
|
|
305
|
+
|
|
306
|
+
**Resource**: `servicenow://cmdb/get_ci_classes`
|
|
307
|
+
|
|
308
|
+
**Required Parameters**:
|
|
309
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
310
|
+
|
|
311
|
+
**Optional Parameters**:
|
|
312
|
+
- `limit` (integer): Maximum number of classes to return
|
|
313
|
+
|
|
314
|
+
**Example**:
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"Resource": "servicenow://cmdb/get_ci_classes",
|
|
319
|
+
"Parameters": {
|
|
320
|
+
"instance_id": "dev12345",
|
|
321
|
+
"limit": 5
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Response**:
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"result": [
|
|
331
|
+
{
|
|
332
|
+
"name": "cmdb_ci_server",
|
|
333
|
+
"label": "Server",
|
|
334
|
+
"super_class": "cmdb_ci_computer"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "cmdb_ci_computer",
|
|
338
|
+
"label": "Computer",
|
|
339
|
+
"super_class": "cmdb_ci_hardware"
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
```
|
data/docs/incident.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Incident API Methods
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
| Method | Description |
|
|
6
|
+
|--------|-------------|
|
|
7
|
+
| [Create Incident](#create-incident) | Create a new incident |
|
|
8
|
+
| [Get Incident](#get-incident) | Retrieve a single incident by sys_id |
|
|
9
|
+
| [Update Incident](#update-incident) | Update an existing incident |
|
|
10
|
+
| [Resolve Incident](#resolve-incident) | Resolve an incident (state 6) |
|
|
11
|
+
| [Close Incident](#close-incident) | Close an incident (state 7) |
|
|
12
|
+
| [Query Incidents](#query-incidents) | Query multiple incidents with filtering |
|
|
13
|
+
|
|
14
|
+
## Create Incident
|
|
15
|
+
|
|
16
|
+
Create a new incident in ServiceNow.
|
|
17
|
+
|
|
18
|
+
**Resource**: `servicenow://incident/create_incident`
|
|
19
|
+
|
|
20
|
+
**Required Parameters**:
|
|
21
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
22
|
+
- `short_description` (string): Brief description of the incident
|
|
23
|
+
|
|
24
|
+
**Optional Parameters**:
|
|
25
|
+
- `urgency` (string): Urgency level (1=High, 2=Medium, 3=Low)
|
|
26
|
+
- `impact` (string): Impact level (1=High, 2=Medium, 3=Low)
|
|
27
|
+
- `priority` (string): Priority (calculated from urgency and impact)
|
|
28
|
+
- `assignment_group` (string): sys_id of the assignment group
|
|
29
|
+
- `assigned_to` (string): sys_id of the assigned user
|
|
30
|
+
- `caller_id` (string): sys_id of the caller
|
|
31
|
+
- `category` (string): Incident category
|
|
32
|
+
- `subcategory` (string): Incident subcategory
|
|
33
|
+
- Additional incident fields as key-value pairs
|
|
34
|
+
|
|
35
|
+
**Example**:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"Resource": "servicenow://incident/create_incident",
|
|
40
|
+
"Parameters": {
|
|
41
|
+
"instance_id": "dev12345",
|
|
42
|
+
"short_description": "Network connectivity issue",
|
|
43
|
+
"urgency": "2",
|
|
44
|
+
"impact": "2",
|
|
45
|
+
"category": "Network"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Response**:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"result": {
|
|
55
|
+
"sys_id": "abc123",
|
|
56
|
+
"number": "INC0010001",
|
|
57
|
+
"short_description": "Network connectivity issue",
|
|
58
|
+
"urgency": "2",
|
|
59
|
+
"impact": "2",
|
|
60
|
+
"state": "1"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Get Incident
|
|
66
|
+
|
|
67
|
+
Retrieve a single incident by its sys_id.
|
|
68
|
+
|
|
69
|
+
**Resource**: `servicenow://incident/get_incident`
|
|
70
|
+
|
|
71
|
+
**Required Parameters**:
|
|
72
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
73
|
+
- `sys_id` (string): Unique identifier of the incident
|
|
74
|
+
|
|
75
|
+
**Example**:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"Resource": "servicenow://incident/get_incident",
|
|
80
|
+
"Parameters": {
|
|
81
|
+
"instance_id": "dev12345",
|
|
82
|
+
"sys_id": "abc123def456"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Response**:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"result": {
|
|
92
|
+
"sys_id": "abc123def456",
|
|
93
|
+
"number": "INC0010001",
|
|
94
|
+
"short_description": "Network connectivity issue",
|
|
95
|
+
"state": "2",
|
|
96
|
+
"priority": "3"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Update Incident
|
|
102
|
+
|
|
103
|
+
Update an existing incident.
|
|
104
|
+
|
|
105
|
+
**Resource**: `servicenow://incident/update_incident`
|
|
106
|
+
|
|
107
|
+
**Required Parameters**:
|
|
108
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
109
|
+
- `sys_id` (string): Unique identifier of the incident
|
|
110
|
+
|
|
111
|
+
**Optional Parameters**:
|
|
112
|
+
- Any incident field as key-value pairs to update
|
|
113
|
+
|
|
114
|
+
**Example**:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"Resource": "servicenow://incident/update_incident",
|
|
119
|
+
"Parameters": {
|
|
120
|
+
"instance_id": "dev12345",
|
|
121
|
+
"sys_id": "abc123def456",
|
|
122
|
+
"state": "2",
|
|
123
|
+
"work_notes": "Investigating the issue"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Response**:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"result": {
|
|
133
|
+
"sys_id": "abc123def456",
|
|
134
|
+
"number": "INC0010001",
|
|
135
|
+
"state": "2",
|
|
136
|
+
"work_notes": "Investigating the issue"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Resolve Incident
|
|
142
|
+
|
|
143
|
+
Resolve an incident (sets state to 6 - Resolved).
|
|
144
|
+
|
|
145
|
+
**Resource**: `servicenow://incident/resolve_incident`
|
|
146
|
+
|
|
147
|
+
**Required Parameters**:
|
|
148
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
149
|
+
- `sys_id` (string): Unique identifier of the incident
|
|
150
|
+
|
|
151
|
+
**Optional Parameters**:
|
|
152
|
+
- `close_notes` (string): Resolution notes
|
|
153
|
+
- `close_code` (string): Resolution code
|
|
154
|
+
- Any other incident fields to update
|
|
155
|
+
|
|
156
|
+
**Example**:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"Resource": "servicenow://incident/resolve_incident",
|
|
161
|
+
"Parameters": {
|
|
162
|
+
"instance_id": "dev12345",
|
|
163
|
+
"sys_id": "abc123def456",
|
|
164
|
+
"close_notes": "Issue resolved by restarting the service",
|
|
165
|
+
"close_code": "Solved (Permanently)"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Response**:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"result": {
|
|
175
|
+
"sys_id": "abc123def456",
|
|
176
|
+
"number": "INC0010001",
|
|
177
|
+
"state": "6",
|
|
178
|
+
"close_notes": "Issue resolved by restarting the service"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Close Incident
|
|
184
|
+
|
|
185
|
+
Close an incident (sets state to 7 - Closed).
|
|
186
|
+
|
|
187
|
+
**Resource**: `servicenow://incident/close_incident`
|
|
188
|
+
|
|
189
|
+
**Required Parameters**:
|
|
190
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
191
|
+
- `sys_id` (string): Unique identifier of the incident
|
|
192
|
+
|
|
193
|
+
**Optional Parameters**:
|
|
194
|
+
- `close_notes` (string): Closure notes
|
|
195
|
+
- `close_code` (string): Closure code
|
|
196
|
+
- Any other incident fields to update
|
|
197
|
+
|
|
198
|
+
**Example**:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"Resource": "servicenow://incident/close_incident",
|
|
203
|
+
"Parameters": {
|
|
204
|
+
"instance_id": "dev12345",
|
|
205
|
+
"sys_id": "abc123def456",
|
|
206
|
+
"close_notes": "Incident closed after verification",
|
|
207
|
+
"close_code": "Closed/Resolved by Caller"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Response**:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"result": {
|
|
217
|
+
"sys_id": "abc123def456",
|
|
218
|
+
"number": "INC0010001",
|
|
219
|
+
"state": "7",
|
|
220
|
+
"close_notes": "Incident closed after verification"
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Query Incidents
|
|
226
|
+
|
|
227
|
+
Query multiple incidents with optional filtering.
|
|
228
|
+
|
|
229
|
+
**Resource**: `servicenow://incident/query_incidents`
|
|
230
|
+
|
|
231
|
+
**Required Parameters**:
|
|
232
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
233
|
+
|
|
234
|
+
**Optional Parameters**:
|
|
235
|
+
- `query` (string): Encoded query string (e.g., "active=true^priority=1")
|
|
236
|
+
- `limit` (integer): Maximum number of records to return
|
|
237
|
+
- `offset` (integer): Starting record index for pagination
|
|
238
|
+
- `fields` (string): Comma-separated list of fields to return
|
|
239
|
+
|
|
240
|
+
**Example**:
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"Resource": "servicenow://incident/query_incidents",
|
|
245
|
+
"Parameters": {
|
|
246
|
+
"instance_id": "dev12345",
|
|
247
|
+
"query": "active=true^priority=1",
|
|
248
|
+
"limit": 1,
|
|
249
|
+
"fields": "number,short_description,state,priority"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Response**:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"result": [
|
|
259
|
+
{
|
|
260
|
+
"result": {
|
|
261
|
+
"sys_id": "abc123def456",
|
|
262
|
+
"number": "INC0010001",
|
|
263
|
+
"short_description": "Network connectivity issue",
|
|
264
|
+
"state": "2",
|
|
265
|
+
"priority": "3"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
```
|
data/docs/oauth.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# OAuth API Methods
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
| Method | Description |
|
|
6
|
+
|--------|-------------|
|
|
7
|
+
| [Get OAuth Token](#get-oauth-token) | Obtain OAuth access tokens using password or refresh_token grant types |
|
|
8
|
+
|
|
9
|
+
## Get OAuth Token
|
|
10
|
+
|
|
11
|
+
Obtain an OAuth access token using various grant types.
|
|
12
|
+
|
|
13
|
+
**Resource**: `servicenow://oauth/token`
|
|
14
|
+
|
|
15
|
+
**Required Parameters**:
|
|
16
|
+
- `instance_id` (string): ServiceNow instance identifier
|
|
17
|
+
- `grant_type` (string): OAuth grant type ("password" or "refresh_token")
|
|
18
|
+
- `client_id` (string): OAuth client ID
|
|
19
|
+
|
|
20
|
+
**Required Credentials** (varies by grant type):
|
|
21
|
+
|
|
22
|
+
**Password Grant**:
|
|
23
|
+
- `client_secret` (string): OAuth client secret
|
|
24
|
+
- `username` (string): ServiceNow username
|
|
25
|
+
- `password` (string): ServiceNow password
|
|
26
|
+
|
|
27
|
+
**Refresh Token Grant**:
|
|
28
|
+
- `client_secret` (string): OAuth client secret
|
|
29
|
+
- `refresh_token` (string): Valid refresh token
|
|
30
|
+
|
|
31
|
+
**Example - Password Grant**:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"Resource": "servicenow://oauth/token",
|
|
36
|
+
"Credentials": {
|
|
37
|
+
"client_secret.$": "$$.Credentials.client_secret",
|
|
38
|
+
"username.$": "$$.Credentials.username",
|
|
39
|
+
"password.$": "$$.Credentials.password"
|
|
40
|
+
},
|
|
41
|
+
"Parameters": {
|
|
42
|
+
"instance_id": "dev12345",
|
|
43
|
+
"client_id": "your-client-id",
|
|
44
|
+
"grant_type": "password"
|
|
45
|
+
},
|
|
46
|
+
"ResultPath": "$$.Credentials.oauth_token"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Example - Refresh Token Grant**:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"Resource": "servicenow://oauth/token",
|
|
55
|
+
"Credentials": {
|
|
56
|
+
"client_secret.$": "$$.Credentials.client_secret",
|
|
57
|
+
"refresh_token.$": "$$.Credentials.refresh_token"
|
|
58
|
+
},
|
|
59
|
+
"Parameters": {
|
|
60
|
+
"instance_id": "dev12345",
|
|
61
|
+
"client_id": "your-client-id",
|
|
62
|
+
"grant_type": "refresh_token"
|
|
63
|
+
},
|
|
64
|
+
"ResultPath": "$$.Credentials.oauth_token"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Response**:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
73
|
+
"refresh_token": "refresh_token_value",
|
|
74
|
+
"scope": "useraccount",
|
|
75
|
+
"token_type": "Bearer",
|
|
76
|
+
"expires_in": 3600
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Using the Access Token**:
|
|
81
|
+
|
|
82
|
+
After obtaining an access token, use it in subsequent API calls:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"Resource": "servicenow://cmdb/get_ci_classes",
|
|
87
|
+
"Credentials": {
|
|
88
|
+
"access_token.$": "$$.Credentials.oauth_token.access_token"
|
|
89
|
+
},
|
|
90
|
+
"Parameters": {
|
|
91
|
+
"instance_id": "dev12345",
|
|
92
|
+
"limit": 5
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Complete Workflow Example**:
|
|
98
|
+
- `examples/oauth.asl` - Combined OAuth flow supporting both password and refresh_token grant types with authenticated API call
|