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.
data/docs/table.md ADDED
@@ -0,0 +1,320 @@
1
+ # Table API Methods
2
+
3
+ ## Table of Contents
4
+
5
+ | Method | Description |
6
+ |--------|-------------|
7
+ | [List Tables](#list-tables) | List all sys_db_object tables |
8
+ | [Query Records](#query-records) | Retrieve multiple records with filtering |
9
+ | [Get Record](#get-record) | Retrieve a single record by sys_id |
10
+ | [Create Record](#create-record) | Create a new record in a table |
11
+ | [Update Record](#update-record) | Replace all fields of a record (PUT) |
12
+ | [Patch Record](#patch-record) | Update specific fields of a record (PATCH) |
13
+ | [Delete Record](#delete-record) | Delete a record from a table |
14
+
15
+ ## List Tables
16
+
17
+ Lists all `sys_db_object` tables.
18
+
19
+ **Resource**: `servicenow://table/list_tables`
20
+
21
+ **Required Parameters**:
22
+ - `instance_id` (string): ServiceNow instance identifier used to build `https://#{instance_id}.service-now.com`
23
+
24
+ **Optional Parameters**:
25
+ - `query` (string): Query parameters e.g.: `active=true`
26
+ - `limit` (integer): Maximum number of records to return
27
+ - `offset` (integer): Starting record index for which to begin retrieving records. Use this value to paginate record retrieval.
28
+ - `fields` (string): Comma-separated list of fields to return in the response.
29
+
30
+ **Example**:
31
+
32
+ ```json
33
+ {
34
+ "Resource": "servicenow://table/list_tables",
35
+ "Parameters": {
36
+ "instance_id": "dev12345",
37
+ "query": "active=true",
38
+ "limit": 2
39
+ }
40
+ }
41
+ ```
42
+
43
+ **Response**:
44
+
45
+ ```json
46
+ {
47
+ "result": [
48
+ {
49
+ "name": "sn_mif_sync_data"
50
+ },
51
+ {
52
+ "name": "open_nlu_predict_log0000"
53
+ }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ ## Query Records
59
+
60
+ Retrieve multiple records from a specific table with optional filtering.
61
+
62
+ **Resource**: `servicenow://table/query_records`
63
+
64
+ **Required Parameters**:
65
+ - `instance_id` (string): ServiceNow instance identifier
66
+ - `table_name` (string): Name of the table to query (e.g., "incident", "cmdb_ci")
67
+
68
+ **Optional Parameters**:
69
+ - `query` (string): Encoded query string (e.g., "active=true^priority=1")
70
+ - `limit` (integer): Maximum number of records to return
71
+ - `offset` (integer): Starting record index for pagination
72
+ - `fields` (string): Comma-separated list of fields to return
73
+ - `display_value` (string): Return display values ("true", "false", or "all")
74
+ - `exclude_reference_link` (boolean): Exclude reference links from response
75
+
76
+ **Example**:
77
+
78
+ ```json
79
+ {
80
+ "Resource": "servicenow://table/query_records",
81
+ "Parameters": {
82
+ "instance_id": "dev12345",
83
+ "table_name": "incident",
84
+ "query": "active=true^priority=1",
85
+ "limit": 10,
86
+ "fields": "number,short_description,priority"
87
+ }
88
+ }
89
+ ```
90
+
91
+ **Response**:
92
+
93
+ ```json
94
+ {
95
+ "result": [
96
+ {
97
+ "number": "INC0001",
98
+ "short_description": "Network connectivity issue",
99
+ "priority": "1"
100
+ }
101
+ ]
102
+ }
103
+ ```
104
+
105
+ ## Get Record
106
+
107
+ Retrieve a single record by its sys_id.
108
+
109
+ **Resource**: `servicenow://table/get_record`
110
+
111
+ **Required Parameters**:
112
+ - `instance_id` (string): ServiceNow instance identifier
113
+ - `table_name` (string): Name of the table
114
+ - `sys_id` (string): Unique identifier of the record
115
+
116
+ **Optional Parameters**:
117
+ - `fields` (string): Comma-separated list of fields to return
118
+ - `display_value` (string): Return display values ("true", "false", or "all")
119
+ - `exclude_reference_link` (boolean): Exclude reference links from response
120
+
121
+ **Example**:
122
+
123
+ ```json
124
+ {
125
+ "Resource": "servicenow://table/get_record",
126
+ "Parameters": {
127
+ "instance_id": "dev12345",
128
+ "table_name": "incident",
129
+ "sys_id": "abc123def456",
130
+ "fields": "number,short_description,state"
131
+ }
132
+ }
133
+ ```
134
+
135
+ **Response**:
136
+
137
+ ```json
138
+ {
139
+ "result": {
140
+ "number": "INC0001",
141
+ "short_description": "Network connectivity issue",
142
+ "state": "2"
143
+ }
144
+ }
145
+ ```
146
+
147
+ ## Create Record
148
+
149
+ Create a new record in a table.
150
+
151
+ **Resource**: `servicenow://table/create_record`
152
+
153
+ **Required Parameters**:
154
+ - `instance_id` (string): ServiceNow instance identifier
155
+ - `table_name` (string): Name of the table
156
+ - `data` (object): Hash of field names and values for the new record
157
+
158
+ **Optional Parameters**:
159
+ - `display_value` (string): Return display values ("true", "false", or "all")
160
+ - `exclude_reference_link` (boolean): Exclude reference links from response
161
+ - `input_display_value` (boolean): Set field values using display values
162
+
163
+ **Example**:
164
+
165
+ ```json
166
+ {
167
+ "Resource": "servicenow://table/create_record",
168
+ "Parameters": {
169
+ "instance_id": "dev12345",
170
+ "table_name": "incident",
171
+ "data": {
172
+ "short_description": "New network issue",
173
+ "urgency": "2",
174
+ "impact": "2"
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ **Response**:
181
+
182
+ ```json
183
+ {
184
+ "result": {
185
+ "sys_id": "xyz789",
186
+ "number": "INC0010",
187
+ "short_description": "New network issue",
188
+ "urgency": "2",
189
+ "impact": "2"
190
+ }
191
+ }
192
+ ```
193
+
194
+ ## Update Record
195
+
196
+ Replace all fields of an existing record (PUT operation).
197
+
198
+ **Resource**: `servicenow://table/update_record`
199
+
200
+ **Required Parameters**:
201
+ - `instance_id` (string): ServiceNow instance identifier
202
+ - `table_name` (string): Name of the table
203
+ - `sys_id` (string): Unique identifier of the record
204
+ - `data` (object): Hash of field names and values (replaces entire record)
205
+
206
+ **Optional Parameters**:
207
+ - `display_value` (string): Return display values ("true", "false", or "all")
208
+ - `exclude_reference_link` (boolean): Exclude reference links from response
209
+ - `input_display_value` (boolean): Set field values using display values
210
+
211
+ **Example**:
212
+
213
+ ```json
214
+ {
215
+ "Resource": "servicenow://table/update_record",
216
+ "Parameters": {
217
+ "instance_id": "dev12345",
218
+ "table_name": "incident",
219
+ "sys_id": "abc123def456",
220
+ "data": {
221
+ "short_description": "Updated description",
222
+ "state": "3",
223
+ "priority": "2"
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ **Response**:
230
+
231
+ ```json
232
+ {
233
+ "result": {
234
+ "sys_id": "abc123def456",
235
+ "number": "INC0001",
236
+ "short_description": "Updated description",
237
+ "state": "3",
238
+ "priority": "2"
239
+ }
240
+ }
241
+ ```
242
+
243
+ ## Patch Record
244
+
245
+ Update specific fields of an existing record (PATCH operation).
246
+
247
+ **Resource**: `servicenow://table/patch_record`
248
+
249
+ **Required Parameters**:
250
+ - `instance_id` (string): ServiceNow instance identifier
251
+ - `table_name` (string): Name of the table
252
+ - `sys_id` (string): Unique identifier of the record
253
+ - `data` (object): Hash of field names and values to update
254
+
255
+ **Optional Parameters**:
256
+ - `display_value` (string): Return display values ("true", "false", or "all")
257
+ - `exclude_reference_link` (boolean): Exclude reference links from response
258
+ - `input_display_value` (boolean): Set field values using display values
259
+
260
+ **Example**:
261
+
262
+ ```json
263
+ {
264
+ "Resource": "servicenow://table/patch_record",
265
+ "Parameters": {
266
+ "instance_id": "dev12345",
267
+ "table_name": "incident",
268
+ "sys_id": "abc123def456",
269
+ "data": {
270
+ "state": "6"
271
+ }
272
+ }
273
+ }
274
+ ```
275
+
276
+ **Response**:
277
+
278
+ ```json
279
+ {
280
+ "result": {
281
+ "sys_id": "abc123def456",
282
+ "number": "INC0001",
283
+ "state": "6"
284
+ }
285
+ }
286
+ ```
287
+
288
+ ## Delete Record
289
+
290
+ Delete a record from a table.
291
+
292
+ **Resource**: `servicenow://table/delete_record`
293
+
294
+ **Required Parameters**:
295
+ - `instance_id` (string): ServiceNow instance identifier
296
+ - `table_name` (string): Name of the table
297
+ - `sys_id` (string): Unique identifier of the record to delete
298
+
299
+ **Example**:
300
+
301
+ ```json
302
+ {
303
+ "Resource": "servicenow://table/delete_record",
304
+ "Parameters": {
305
+ "instance_id": "dev12345",
306
+ "table_name": "incident",
307
+ "sys_id": "abc123def456"
308
+ }
309
+ }
310
+ ```
311
+
312
+ **Response**:
313
+
314
+ ```json
315
+ {
316
+ "result": {
317
+ "success": true
318
+ }
319
+ }
320
+ ```
data/examples/cmdb.asl ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "Comment": "ServiceNow CMDB API Examples - Demonstrates Configuration Item management and relationships",
3
+ "StartAt": "GetCIClasses",
4
+ "States": {
5
+ "GetCIClasses": {
6
+ "Type": "Task",
7
+ "Resource": "servicenow://cmdb/get_ci_classes",
8
+ "Credentials": {
9
+ "username.$": "$$.Credentials.username",
10
+ "password.$": "$$.Credentials.password"
11
+ },
12
+ "Parameters": {
13
+ "instance_id.$": "$.instance_id",
14
+ "limit": 5
15
+ },
16
+ "ResultPath": "$.ci_classes",
17
+ "Next": "QueryCIs"
18
+ },
19
+ "QueryCIs": {
20
+ "Type": "Task",
21
+ "Resource": "servicenow://cmdb/query_cis",
22
+ "Credentials": {
23
+ "username.$": "$$.Credentials.username",
24
+ "password.$": "$$.Credentials.password"
25
+ },
26
+ "Parameters": {
27
+ "instance_id.$": "$.instance_id",
28
+ "method": "GET",
29
+ "table": "cmdb_ci_server",
30
+ "limit": 1,
31
+ "fields": "sys_id,name,ip_address,os"
32
+ },
33
+ "ResultPath": "$.servers",
34
+ "Next": "CreateCI"
35
+ },
36
+ "CreateCI": {
37
+ "Type": "Task",
38
+ "Resource": "servicenow://cmdb/create_ci",
39
+ "Credentials": {
40
+ "username.$": "$$.Credentials.username",
41
+ "password.$": "$$.Credentials.password"
42
+ },
43
+ "Parameters": {
44
+ "instance_id.$": "$.instance_id",
45
+ "table": "cmdb_ci_server",
46
+ "name": "test-server-workflow",
47
+ "ip_address": "192.168.100.50",
48
+ "os": "Ubuntu 22.04",
49
+ "operational_status": "1"
50
+ },
51
+ "ResultPath": "$.new_ci",
52
+ "Next": "UpdateCI"
53
+ },
54
+ "UpdateCI": {
55
+ "Type": "Task",
56
+ "Resource": "servicenow://cmdb/update_ci",
57
+ "Credentials": {
58
+ "username.$": "$$.Credentials.username",
59
+ "password.$": "$$.Credentials.password"
60
+ },
61
+ "Parameters": {
62
+ "instance_id.$": "$.instance_id",
63
+ "sys_id.$": "$.new_ci.result.sys_id",
64
+ "table": "cmdb_ci_server",
65
+ "ip_address": "192.168.100.51",
66
+ "comments": "Updated by workflow"
67
+ },
68
+ "ResultPath": "$.updated_ci",
69
+ "Next": "DeleteCI"
70
+ },
71
+ "DeleteCI": {
72
+ "Type": "Task",
73
+ "Resource": "servicenow://cmdb/delete_ci",
74
+ "Credentials": {
75
+ "username.$": "$$.Credentials.username",
76
+ "password.$": "$$.Credentials.password"
77
+ },
78
+ "Parameters": {
79
+ "instance_id.$": "$.instance_id",
80
+ "sys_id.$": "$.new_ci.result.sys_id",
81
+ "table": "cmdb_ci_server"
82
+ },
83
+ "ResultPath": "$.delete_result",
84
+ "Next": "Success"
85
+ },
86
+ "Success": {
87
+ "Type": "Succeed"
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "Comment": "Example workflow to create a Server Configuration Item in ServiceNow CMDB",
3
+ "StartAt": "CreateServerCi",
4
+ "States": {
5
+ "CreateServerCi": {
6
+ "Type": "Task",
7
+ "Resource": "servicenow://cmdb/create_ci",
8
+ "Parameters": {
9
+ "instance_id.$": "$.instance_id",
10
+ "table.$": "$.table",
11
+ "attributes": {
12
+ "name.$": "$.name",
13
+ "sys_class_name.$": "$.table",
14
+ "owned_by": "System Administrator",
15
+ "discovery_source": "Manual via IRE"
16
+ },
17
+ "outbound_relations": [],
18
+ "inbound_relations": []
19
+ },
20
+ "Credentials": {
21
+ "username.$": "$$.Credentials.username",
22
+ "password.$": "$$.Credentials.password"
23
+ },
24
+ "ResultPath": "$.new_server",
25
+ "Next": "GetServerDetails"
26
+ },
27
+ "GetServerDetails": {
28
+ "Type": "Task",
29
+ "Resource": "servicenow://cmdb/get_ci",
30
+ "Parameters": {
31
+ "instance_id.$": "$.instance_id",
32
+ "table.$": "$.table",
33
+ "sys_id.$": "$.new_server.attributes.sys_id"
34
+ },
35
+ "Credentials": {
36
+ "username.$": "$$.Credentials.username",
37
+ "password.$": "$$.Credentials.password"
38
+ },
39
+ "ResultPath": "$.server_details",
40
+ "End": true
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "Comment": "Example create, resolve, and close a ServiceNow Incident",
3
+ "StartAt": "CreateIncident",
4
+ "States": {
5
+ "CreateIncident": {
6
+ "Type": "Task",
7
+ "Resource": "servicenow://incident/create_incident",
8
+ "Credentials": {
9
+ "username.$": "$$.Credentials.username",
10
+ "password.$": "$$.Credentials.password"
11
+ },
12
+ "Parameters": {
13
+ "instance_id.$": "$.instance_id",
14
+ "short_description": "Test incident created by workflow",
15
+ "urgency": "3",
16
+ "impact": "3"
17
+ },
18
+ "ResultPath": "$.incident",
19
+ "Next": "ResolveIncident"
20
+ },
21
+ "ResolveIncident": {
22
+ "Type": "Task",
23
+ "Resource": "servicenow://incident/resolve_incident",
24
+ "Parameters": {
25
+ "instance_id.$": "$.instance_id",
26
+ "sys_id.$": "$.incident.result.sys_id",
27
+ "close_notes": "Issue resolved by workflow",
28
+ "close_code": "Solution provided"
29
+ },
30
+ "ResultPath": "$.resolved_incident",
31
+ "Credentials": {
32
+ "username.$": "$$.Credentials.username",
33
+ "password.$": "$$.Credentials.password"
34
+ },
35
+ "Next": "CloseIncident"
36
+ },
37
+ "CloseIncident": {
38
+ "Type": "Task",
39
+ "Resource": "servicenow://incident/close_incident",
40
+ "Parameters": {
41
+ "instance_id.$": "$.instance_id",
42
+ "sys_id.$": "$.incident.result.sys_id",
43
+ "close_notes": "Incident closed by workflow",
44
+ "close_code": "Solution provided"
45
+ },
46
+ "Credentials": {
47
+ "username.$": "$$.Credentials.username",
48
+ "password.$": "$$.Credentials.password"
49
+ },
50
+ "End": true
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "Comment": "Example of OAuth flow (password or refresh_token grant) followed by authenticated API call",
3
+ "StartAt": "CheckGrantType",
4
+ "States": {
5
+ "CheckGrantType": {
6
+ "Type": "Choice",
7
+ "Choices": [
8
+ {
9
+ "Variable": "$.grant_type",
10
+ "StringEquals": "password",
11
+ "Next": "OauthTokenPassword"
12
+ },
13
+ {
14
+ "Variable": "$.grant_type",
15
+ "StringEquals": "refresh_token",
16
+ "Next": "OauthTokenRefresh"
17
+ }
18
+ ],
19
+ "Default": "OauthTokenPassword"
20
+ },
21
+ "OauthTokenPassword": {
22
+ "Type": "Task",
23
+ "Resource": "servicenow://oauth/token",
24
+ "Credentials": {
25
+ "client_secret.$": "$$.Credentials.client_secret",
26
+ "username.$": "$$.Credentials.username",
27
+ "password.$": "$$.Credentials.password"
28
+ },
29
+ "Parameters": {
30
+ "instance_id.$": "$.instance_id",
31
+ "client_id.$": "$.client_id",
32
+ "grant_type": "password"
33
+ },
34
+ "ResultPath": "$$.Credentials.oauth_token",
35
+ "Next": "GetCIClasses"
36
+ },
37
+ "OauthTokenRefresh": {
38
+ "Type": "Task",
39
+ "Resource": "servicenow://oauth/token",
40
+ "Credentials": {
41
+ "client_secret.$": "$$.Credentials.client_secret",
42
+ "refresh_token.$": "$$.Credentials.refresh_token"
43
+ },
44
+ "Parameters": {
45
+ "instance_id.$": "$.instance_id",
46
+ "client_id.$": "$.client_id",
47
+ "grant_type": "refresh_token",
48
+ "scope": "useraccount"
49
+ },
50
+ "ResultPath": "$$.Credentials.oauth_token",
51
+ "Next": "GetCIClasses"
52
+ },
53
+ "GetCIClasses": {
54
+ "Type": "Task",
55
+ "Resource": "servicenow://cmdb/get_ci_classes",
56
+ "Credentials": {
57
+ "access_token.$": "$$.Credentials.oauth_token.access_token"
58
+ },
59
+ "Parameters": {
60
+ "instance_id.$": "$.instance_id",
61
+ "limit": 5
62
+ },
63
+ "ResultPath": "$.ci_classes",
64
+ "End": true
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "Comment": "ServiceNow Service Catalog API Examples - Demonstrates catalog browsing and item ordering",
3
+ "StartAt": "GetCatalogs",
4
+ "States": {
5
+ "GetCatalogs": {
6
+ "Type": "Task",
7
+ "Resource": "servicenow://service_catalog/get_catalogs",
8
+ "Credentials": {
9
+ "username.$": "$$.Credentials.username",
10
+ "password.$": "$$.Credentials.password"
11
+ },
12
+ "Parameters": {
13
+ "instance_id.$": "$.instance_id",
14
+ "limit": 5
15
+ },
16
+ "ResultPath": "$.catalogs",
17
+ "Next": "GetCatalogItems"
18
+ },
19
+ "GetCatalogItems": {
20
+ "Type": "Task",
21
+ "Resource": "servicenow://service_catalog/get_items",
22
+ "Credentials": {
23
+ "username.$": "$$.Credentials.username",
24
+ "password.$": "$$.Credentials.password"
25
+ },
26
+ "Parameters": {
27
+ "instance_id.$": "$.instance_id",
28
+ "limit": 10
29
+ },
30
+ "ResultPath": "$.catalog_items",
31
+ "Next": "GetCatalogItem"
32
+ },
33
+ "GetCatalogItem": {
34
+ "Type": "Task",
35
+ "Resource": "servicenow://service_catalog/get_item",
36
+ "Credentials": {
37
+ "username.$": "$$.Credentials.username",
38
+ "password.$": "$$.Credentials.password"
39
+ },
40
+ "Parameters": {
41
+ "instance_id.$": "$.instance_id",
42
+ "item_id.$": "$.catalog_items.result[0].sys_id"
43
+ },
44
+ "ResultPath": "$.item_detail",
45
+ "Next": "SubmitCatalogItem"
46
+ },
47
+ "SubmitCatalogItem": {
48
+ "Type": "Task",
49
+ "Resource": "servicenow://service_catalog/submit_catalog_item",
50
+ "Credentials": {
51
+ "username.$": "$$.Credentials.username",
52
+ "password.$": "$$.Credentials.password"
53
+ },
54
+ "Parameters": {
55
+ "instance_id.$": "$.instance_id",
56
+ "item_sys_id.$": "$.catalog_items.result[0].sys_id",
57
+ "sysparm_quantity": "1"
58
+ },
59
+ "ResultPath": "$.order",
60
+ "Next": "GetRequest"
61
+ },
62
+ "GetRequest": {
63
+ "Type": "Task",
64
+ "Resource": "servicenow://service_catalog/get_request",
65
+ "Credentials": {
66
+ "username.$": "$$.Credentials.username",
67
+ "password.$": "$$.Credentials.password"
68
+ },
69
+ "Parameters": {
70
+ "instance_id.$": "$.instance_id",
71
+ "request_id.$": "$.order.result.request_id"
72
+ },
73
+ "ResultPath": "$.request_detail",
74
+ "End": true
75
+ }
76
+ }
77
+ }