Last active
April 14, 2020 13:29
-
-
Save daBONDi/991e63d32ac3e138b2a4385ff4973217 to your computer and use it in GitHub Desktop.
st2 output test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: 5e95b45d9bdf2a01660647c2 | |
status: failed | |
parameters: None | |
result: | |
error: "u'{"values": [{"test1": "test1", "test2": 1, "datestr": "2020-04-14T13:02:21.824846"}]}' is not of type 'object' | |
Failed validating 'type' in schema: | |
{'additionalProperties': False, | |
'properties': {u'values': {u'items': {u'datestr': {u'type': u'string'}, | |
u'test1': {u'type': u'string'}, | |
u'test2': {u'type': u'number'}}, | |
u'type': u'array'}}, | |
'type': 'object'} | |
On instance: | |
u'{"values": [{"test1": "test1", "test2": 1, "datestr": "2020-04-14T13:02:21.824846"}]}'" | |
message: Error validating output. See error output for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from st2common.runners.base_action import Action | |
from lib.SmbHelper import SmbShareCleaner | |
from datetime import datetime | |
import json | |
class DateTimeEncoder(json.JSONEncoder): | |
def default(self, o): | |
if isinstance(o, datetime): | |
return o.isoformat() | |
return json.JSONEncoder.default(self, o) | |
class cleanup(Action): | |
def run(self): | |
output={ | |
'values': [ | |
{ | |
'test1': 'test1', | |
'test2': 1, | |
'datestr': datetime.utcnow() | |
} | |
] | |
} | |
json_object = json.dumps(output, cls=DateTimeEncoder) | |
return (True, json_object) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
runner_type: python-script | |
entry_point: test.py | |
name: test | |
pack: smbutils | |
output_schema: | |
values: | |
type: array | |
items: | |
test1: | |
type: string | |
test2: | |
type: number | |
datestr: | |
type: string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment