Wrap mistralclient code in api.py
All mistralclient specific code should be wrapped in api.py, see discusstion on: https://review.openstack.org/#/c/198056/1/mistraldashboard/executions/views.py Change-Id: Idcf94f523473bdb31c257ca2054942fe79ea54ba
This commit is contained in:
parent
c9375086d5
commit
3ea61da17f
@ -38,3 +38,36 @@ def mistralclient(request):
|
||||
),
|
||||
service_type=SERVICE_TYPE
|
||||
)
|
||||
|
||||
|
||||
def execution_create(request, **data):
|
||||
"""Creates new execution."""
|
||||
|
||||
return mistralclient(request).executions.create(**data)
|
||||
|
||||
|
||||
def execution_list(request):
|
||||
"""Returns all executions."""
|
||||
|
||||
return mistralclient(request).executions.list()
|
||||
|
||||
|
||||
def task_list(request, execution_id=None):
|
||||
"""Returns all tasks.
|
||||
|
||||
:param execution_id: Workflow execution ID associated with list of Tasks
|
||||
"""
|
||||
|
||||
return mistralclient(request).tasks.list(execution_id)
|
||||
|
||||
|
||||
def workflow_list(request):
|
||||
"""Returns all workflows."""
|
||||
|
||||
return mistralclient(request).workflows.list()
|
||||
|
||||
|
||||
def workbook_list(request):
|
||||
"""Returns all workbooks."""
|
||||
|
||||
return mistralclient(request).workbooks.list()
|
||||
|
@ -26,7 +26,7 @@ class IndexView(tables.DataTableView):
|
||||
template_name = 'mistral/executions/index.html'
|
||||
|
||||
def get_data(self):
|
||||
return api.mistralclient(self.request).executions.list()
|
||||
return api.execution_list(self.request)
|
||||
|
||||
|
||||
class TaskView(tables.DataTableView):
|
||||
@ -34,6 +34,4 @@ class TaskView(tables.DataTableView):
|
||||
template_name = 'mistral/executions/index.html'
|
||||
|
||||
def get_data(self):
|
||||
return api.mistralclient(self.request).tasks.list(
|
||||
self.kwargs['execution_id']
|
||||
)
|
||||
return api.task_list(self.kwargs['execution_id'])
|
||||
|
@ -25,4 +25,4 @@ class IndexView(tables.DataTableView):
|
||||
template_name = 'mistral/tasks/index.html'
|
||||
|
||||
def get_data(self):
|
||||
return api.mistralclient(self.request).tasks.list()
|
||||
return api.task_list(self.request)
|
||||
|
@ -25,4 +25,4 @@ class IndexView(tables.DataTableView):
|
||||
template_name = 'mistral/workbooks/index.html'
|
||||
|
||||
def get_data(self):
|
||||
return api.mistralclient(self.request).workbooks.list()
|
||||
return api.workbook_list(self.request)
|
||||
|
@ -44,7 +44,7 @@ class ExecuteForm(forms.SelfHandlingForm):
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
ex = api.mistralclient(request).executions.create(**data)
|
||||
ex = api.execution_create(request, **data)
|
||||
|
||||
msg = _('Execution has been created with id "%s".') % ex.id
|
||||
messages.success(request, msg)
|
||||
|
@ -29,7 +29,7 @@ class IndexView(tables.DataTableView):
|
||||
template_name = 'mistral/workflows/index.html'
|
||||
|
||||
def get_data(self):
|
||||
return api.mistralclient(self.request).workflows.list()
|
||||
return api.workflow_list(self.request)
|
||||
|
||||
|
||||
class ExecuteView(forms.ModalFormView):
|
||||
|
Loading…
x
Reference in New Issue
Block a user