Merge "Modified Rest action for process 'input' property"

This commit is contained in:
Jenkins 2014-01-28 13:05:52 +00:00 committed by Gerrit Code Review
commit 3a9c3a499e
2 changed files with 15 additions and 3 deletions

View File

@ -53,9 +53,20 @@ def get_rest_action(task):
headers.update(action_dsl.get('headers', {}))
method = action_dsl['parameters'].get('method', "GET")
# input_yaql = task.get('input')
# TODO(nmakhotkin) extract input from context within the YAQL expression
task_input = {} # yaql_utils.evaluate(input_yaql, ctx)
task_data = {}
if method.upper() == "GET":
task_params.update(task_input)
elif method.upper() in ["POST", "PUT"]:
task_data.update(task_input)
return actions.RestAction(action_type, action_name, url,
params=task_params, method=method,
headers=headers)
headers=headers, data=task_data)
def get_mistral_rest_action(task):

View File

@ -41,19 +41,20 @@ class BaseAction(object):
class RestAction(BaseAction):
def __init__(self, action_type, action_name, url, params={},
method="GET", headers={}):
method="GET", headers={}, data={}):
super(RestAction, self).__init__(action_type, action_name)
self.url = url
self.params = params
self.method = method
self.headers = headers
self.data = data
def run(self):
LOG.info("Sending action HTTP request "
"[method=%s, url=%s, params=%s, headers=%s]" %
(self.method, self.url, self.params, self.headers))
resp = requests.request(self.method, self.url, params=self.params,
headers=self.headers)
headers=self.headers, data=self.data)
LOG.info("Received HTTP response:\n%s\n%s" %
(resp.status_code, resp.content))
# Return rather json than text, but response can contain text also.