Skip to content

Instantly share code, notes, and snippets.

@daBONDi
Last active April 14, 2020 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daBONDi/991e63d32ac3e138b2a4385ff4973217 to your computer and use it in GitHub Desktop.
Save daBONDi/991e63d32ac3e138b2a4385ff4973217 to your computer and use it in GitHub Desktop.
st2 output test
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.
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)
---
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