Add yaml and json parsing functions
Sometimes you'll get a string back from some action (like swift get_object) and it will be in either a yaml or json format. These functions will allow you to parse those into a useful object. Change-Id: I375219f4b019319e1b3d756dca512f7f90cd097f
This commit is contained in:
parent
f6b6f1d20b
commit
6bd96d70b1
@ -17,6 +17,7 @@ from functools import partial
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from stevedore import extension
|
||||
import yaml
|
||||
import yaql
|
||||
|
||||
from mistral.db.v2 import api as db_api
|
||||
@ -271,3 +272,11 @@ def global_(context, var_name):
|
||||
wf_ex = db_api.get_workflow_execution(context['__execution']['id'])
|
||||
|
||||
return wf_ex.context.get(var_name)
|
||||
|
||||
|
||||
def json_parse_(context, data):
|
||||
return jsonutils.loads(data)
|
||||
|
||||
|
||||
def yaml_parse_(context, data):
|
||||
return yaml.safe_load(data)
|
||||
|
5
releasenotes/notes/yaml-json-parse-53217627a647dc1d.yaml
Normal file
5
releasenotes/notes/yaml-json-parse-53217627a647dc1d.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add yaml_parse and json_parse expression functions. Each accepts a string
|
||||
and will parse as either json or yaml, and return an object.
|
@ -83,6 +83,8 @@ mistral.expression.functions =
|
||||
execution = mistral.utils.expression_utils:execution_
|
||||
env = mistral.utils.expression_utils:env_
|
||||
uuid = mistral.utils.expression_utils:uuid_
|
||||
json_parse = mistral.utils.expression_utils:json_parse_
|
||||
yaml_parse = mistral.utils.expression_utils:yaml_parse_
|
||||
|
||||
mistral.expression.evaluators =
|
||||
yaql = mistral.expressions.yaql_expression:InlineYAQLEvaluator
|
||||
|
Loading…
Reference in New Issue
Block a user