
from mistralclient.api import base


class Task(base.Resource):
    resource_name = 'Task'


class TaskManager(base.ResourceManager):
    resource_class = Task

    def update(self, id, state):
        self._ensure_not_empty(id=id, state=state)

        data = {
            'state': state
        }

        return self._update('/tasks/%s' % id, data)

    def list(self):
        return self._list('/tasks', response_key='tasks')

    def get(self, id):
        self._ensure_not_empty(id=id)

        return self._get('/tasks/%s' % id)


from mistralclient.api import base


class Task(base.Resource):
    resource_name = 'Task'


class TaskManager(base.ResourceManager):
    resource_class = Task

    def update(self, id, state):
        self._ensure_not_empty(id=id, state=state)

        data = {
            'state': state
        }

        return self._update('/tasks/%s' % id, data)

    def list(self, execution_id=None):
        url = '/tasks'

        if execution_id:
            url = '/executions/%s/tasks' % execution_id

        return self._list(url, response_key='tasks')

    def get(self, id):
        self._ensure_not_empty(id=id)

        return self._get('/tasks/%s' % id)

Support naive filtering in python API
Support naive filtering in python API

Change-Id: I10caecf68c73e7c722a9ab93a718b80c588d4d0e

  
  from mistralclient.api import base
  
  
  class Task(base.Resource):
      resource_name = 'Task'
  
  
  class TaskManager(base.ResourceManager):
      resource_class = Task
  
      def update(self, id, state):
          self._ensure_not_empty(id=id, state=state)
  
          data = {
              'state': state
          }
  
          return self._update('/tasks/%s' % id, data)
  
-     def list(self):
+     def list(self, execution_id=None):
+         url = '/tasks'
+ 
+         if execution_id:
+             url = '/executions/%s/tasks' % execution_id
+ 
-         return self._list('/tasks', response_key='tasks')
+         return self._list(url, response_key='tasks')
  
      def get(self, id):
          self._ensure_not_empty(id=id)
  
          return self._get('/tasks/%s' % id)
  
Support naive filtering in python API
## Code Before:

from mistralclient.api import base


class Task(base.Resource):
    resource_name = 'Task'


class TaskManager(base.ResourceManager):
    resource_class = Task

    def update(self, id, state):
        self._ensure_not_empty(id=id, state=state)

        data = {
            'state': state
        }

        return self._update('/tasks/%s' % id, data)

    def list(self):
        return self._list('/tasks', response_key='tasks')

    def get(self, id):
        self._ensure_not_empty(id=id)

        return self._get('/tasks/%s' % id)

## Instruction:
Support naive filtering in python API
## Code After:

from mistralclient.api import base


class Task(base.Resource):
    resource_name = 'Task'


class TaskManager(base.ResourceManager):
    resource_class = Task

    def update(self, id, state):
        self._ensure_not_empty(id=id, state=state)

        data = {
            'state': state
        }

        return self._update('/tasks/%s' % id, data)

    def list(self, execution_id=None):
        url = '/tasks'

        if execution_id:
            url = '/executions/%s/tasks' % execution_id

        return self._list(url, response_key='tasks')

    def get(self, id):
        self._ensure_not_empty(id=id)

        return self._get('/tasks/%s' % id)
