diff --git a/src/conductor/client/automator/task_runner.py b/src/conductor/client/automator/task_runner.py index 28f7ca84..eb470ce3 100644 --- a/src/conductor/client/automator/task_runner.py +++ b/src/conductor/client/automator/task_runner.py @@ -166,7 +166,7 @@ def __update_task(self, task_result: TaskResult): task_id=task_result.task_id, workflow_instance_id=task_result.workflow_instance_id, task_definition_name=task_definition_name, - response=str(response) + response=response ) ) return response diff --git a/src/conductor/client/http/api/task_resource_api.py b/src/conductor/client/http/api/task_resource_api.py index f1101408..033b6561 100644 --- a/src/conductor/client/http/api/task_resource_api.py +++ b/src/conductor/client/http/api/task_resource_api.py @@ -6,6 +6,7 @@ import six from conductor.client.http.api_client import ApiClient +from conductor.client.http.models.task_result_status import TaskResultStatus class TaskResourceApi(object): @@ -1467,3 +1468,124 @@ def update_task_with_http_info(self, body, **kwargs): # noqa: E501 _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + + def update_task_by_ref_name(self, output: dict, workflow_id: str, task_ref_name: str, status: TaskResultStatus, **kwargs): # noqa: E501 + """Update a task By Ref Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_task(output, workflow_id, task_ref_name, status, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) output: (required) + :param str workflow_id: (required) + :param str task_ref_name: (required) + :param str status: (required) + :return: str + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.update_task_by_ref_name_with_http_info(output, workflow_id, task_ref_name, status, **kwargs) # noqa: E501 + else: + (data) = self.update_task_by_ref_name_with_http_info(output, workflow_id, task_ref_name, status, **kwargs) # noqa: E501 + return data + + def update_task_by_ref_name_with_http_info(self, body, workflow_id, task_ref_name, status, **kwargs): # noqa: E501 + """Update a task By Ref Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_task_with_http_info(body, workflow_id, task_ref_name, status, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) body: (required) + :param str workflow_id: (required) + :param str task_ref_name: (required) + :param str status: (required) + :return: str + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'workflow_id', 'task_ref_name', 'status'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method update_task" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `update_task`") # noqa: E501 + # verify the required parameter 'workflow_id' is set + if ('workflow_id' not in params or + params['workflow_id'] is None): + raise ValueError("Missing the required parameter `workflow_id` when calling `update_task`") # noqa: E501 + # verify the required parameter 'task_ref_name' is set + if ('task_ref_name' not in params or + params['task_ref_name'] is None): + raise ValueError("Missing the required parameter `task_ref_name` when calling `update_task`") # noqa: E501 + # verify the required parameter 'status' is set + if ('status' not in params or + params['status'] is None): + raise ValueError("Missing the required parameter `status` when calling `update_task`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'workflow_id' in params: + path_params['workflowId'] = params['workflow_id'] # noqa: E501 + if 'task_ref_name' in params: + path_params['taskRefName'] = params['task_ref_name'] # noqa: E501 + if 'status' in params: + path_params['status'] = params['status'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['text/plain']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + '/api/tasks/{workflowId}/{taskRefName}/{status}', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='str', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/src/conductor/client/http/api_client.py b/src/conductor/client/http/api_client.py index 4416980c..3a4c6a12 100644 --- a/src/conductor/client/http/api_client.py +++ b/src/conductor/client/http/api_client.py @@ -521,12 +521,17 @@ def __deserialize_primitive(self, data, klass): :return: int, long, float, str, bool. """ try: + if klass == str and type(data) == bytes: + return self.__deserialize_bytes_to_str(data) return klass(data) except UnicodeEncodeError: return six.text_type(data) except TypeError: return data + def __deserialize_bytes_to_str(self, data): + return data.decode('utf-8') + def __deserialize_object(self, value): """Return a original value.