Skip to content

Commit e83b3d7

Browse files
committed
Refactor attachment classes
1 parent 6d66f8f commit e83b3d7

7 files changed

+15
-29
lines changed

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## 0.3.9
3+
## 0.4.0
44
- Add support for upload attachment and get attachment metadata
55

66
## 0.3.8

actions/get_attachment.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,5 @@
22

33

44
class GetAttachmentAction(BaseAction):
5-
def run(self, table, sys_id):
6-
s = self.client
7-
api_path = "/attachment/{}".format(sys_id)
8-
r = s.resource(api_path=api_path)
9-
records = r.get(query={})
10-
output = []
11-
for record in records.all():
12-
output.append(record)
13-
return output
5+
def run(self, sys_id):
6+
return self.get_attachments(sys_id)

actions/get_attachment.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ description: "Gets metadata for an attachment"
55
enabled: true
66
entry_point: "get_attachment.py"
77
parameters:
8-
table:
9-
type: "string"
10-
description: "Table to take action on"
11-
required: true
128
sys_id:
139
type: "string"
1410
description: "Sys-id of attachment to retrieve"

actions/get_attachments.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,5 @@
22

33

44
class GetAttachmentsAction(BaseAction):
5-
def run(self, table):
6-
s = self.client
7-
r = s.resource(api_path="/attachment")
8-
records = r.get(query={})
9-
output = []
10-
for record in records.all():
11-
output.append(record)
12-
return output
5+
def run(self):
6+
return self.get_attachments()

actions/get_attachments.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
22
name: "get_attachments"
33
runner_type: "python-script"
4-
description: "Gets meta-data for all attachments for specified table"
4+
description: "Gets meta-data for all attachments"
55
enabled: true
66
entry_point: "get_attachments.py"
7-
parameters:
8-
table:
9-
type: "string"
10-
description: "Table to take action on"
11-
required: true

actions/lib/actions.py

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ def _get_client(self):
1818
client.parameters.add_custom(self.config['custom_params'])
1919

2020
return client
21+
22+
def get_attachments(self, sys_id=None):
23+
api_path="/attachment"
24+
if sys_id:
25+
api_path+="/{}".format(sys_id)
26+
r = self.client.resource(api_path=api_path)
27+
records = r.get(query={})
28+
return [r for r in records.all()]

pack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: ServiceNow Integration Pack
55
keywords:
66
- servicenow
77
- incident management
8-
version: 0.3.9
8+
version: 0.4.0
99
python_versions:
1010
- "2"
1111
- "3"

0 commit comments

Comments
 (0)