Beispiel #1
0
 def _format_task(self, task, schema):
     task_view = {}
     attributes = ['type', 'status', 'input', 'result', 'owner', 'message']
     for key in attributes:
         task_view[key] = getattr(task, key)
     task_view['id'] = task.task_id
     task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view['created_at'] = timeutils.isotime(task.created_at)
     task_view['updated_at'] = timeutils.isotime(task.updated_at)
     task_view['self'] = '/v2/tasks/%s' % task.task_id
     task_view['schema'] = '/v2/schemas/task'
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #2
0
 def _format_task_stub(self, schema, task):
     task_view = {}
     task_view['id'] = task.task_id
     task_view['type'] = task.type
     task_view['status'] = task.status
     task_view['owner'] = task.owner
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view['created_at'] = timeutils.isotime(task.created_at)
     task_view['updated_at'] = timeutils.isotime(task.updated_at)
     task_view['self'] = self._get_task_location(task)
     task_view['schema'] = '/v2/schemas/task'
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #3
0
 def _format_task_stub(self, schema, task):
     task_view = {}
     task_view['id'] = task.task_id
     task_view['type'] = task.type
     task_view['status'] = task.status
     task_view['owner'] = task.owner
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view['created_at'] = timeutils.isotime(task.created_at)
     task_view['updated_at'] = timeutils.isotime(task.updated_at)
     task_view['self'] = self._get_task_location(task)
     task_view['schema'] = '/v2/schemas/task'
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #4
0
 def _format_task_stub(self, schema, task):
     task_view = {
         'id': task.task_id,
         'type': task.type,
         'status': task.status,
         'owner': task.owner,
         'created_at': timeutils.isotime(task.created_at),
         'updated_at': timeutils.isotime(task.updated_at),
         'self': self._get_task_location(task),
         'schema': '/v2/schemas/task'
     }
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #5
0
 def _format_task_stub(self, schema, task):
     task_view = {
         'id': task.task_id,
         'type': task.type,
         'status': task.status,
         'owner': task.owner,
         'created_at': timeutils.isotime(task.created_at),
         'updated_at': timeutils.isotime(task.updated_at),
         'self': self._get_task_location(task),
         'schema': '/v2/schemas/task'
     }
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #6
0
 def _format_task(self, schema, task, task_details=None):
     task_view = {}
     task_attributes = ['type', 'status', 'owner']
     task_details_attributes = ['input', 'result', 'message']
     for key in task_attributes:
         task_view[key] = getattr(task, key)
     if task_details:
         for key in task_details_attributes:
             task_view[key] = getattr(task_details, key)
     task_view['id'] = task.task_id
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view['created_at'] = timeutils.isotime(task.created_at)
     task_view['updated_at'] = timeutils.isotime(task.updated_at)
     task_view['self'] = self._get_task_location(task)
     task_view['schema'] = '/v2/schemas/task'
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #7
0
 def _format_task(self, schema, task, task_details=None):
     task_view = {}
     task_attributes = ['type', 'status', 'owner']
     task_details_attributes = ['input', 'result', 'message']
     for key in task_attributes:
         task_view[key] = getattr(task, key)
     if task_details:
         for key in task_details_attributes:
             task_view[key] = getattr(task_details, key)
     task_view['id'] = task.task_id
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view['created_at'] = timeutils.isotime(task.created_at)
     task_view['updated_at'] = timeutils.isotime(task.updated_at)
     task_view['self'] = self._get_task_location(task)
     task_view['schema'] = '/v2/schemas/task'
     task_view = schema.filter(task_view)  # domain
     return task_view
Beispiel #8
0
 def _format_task(self, schema, task):
     task_view = {
         'id': task.task_id,
         'input': task.task_input,
         'type': task.type,
         'status': task.status,
         'owner': task.owner,
         'message': task.message,
         'result': task.result,
         'created_at': timeutils.isotime(task.created_at),
         'updated_at': timeutils.isotime(task.updated_at),
         'self': self._get_task_location(task),
         'schema': '/v2/schemas/task'
     }
     if task.image_id:
         task_view['image_id'] = task.image_id
     if task.request_id:
         task_view['request_id'] = task.request_id
     if task.user_id:
         task_view['user_id'] = task.user_id
     if task.expires_at:
         task_view['expires_at'] = timeutils.isotime(task.expires_at)
     task_view = schema.filter(task_view)  # domain
     return task_view