This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-04-10 15:06:39 +00:00
|
|
|
from teal.resource import View
|
|
|
|
|
2018-09-07 10:38:02 +00:00
|
|
|
from ereuse_devicehub.resources.device.models import Device
|
|
|
|
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
class DeviceView(View):
|
2018-06-24 14:57:49 +00:00
|
|
|
|
|
|
|
def get(self, id):
|
|
|
|
"""
|
|
|
|
Devices view
|
|
|
|
---
|
|
|
|
description: Gets a device or multiple devices.
|
|
|
|
parameters:
|
|
|
|
- name: id
|
|
|
|
type: integer
|
|
|
|
in: path
|
|
|
|
description: The identifier of the device.
|
|
|
|
responses:
|
|
|
|
200:
|
|
|
|
description: The device or devices.
|
|
|
|
"""
|
|
|
|
return super().get(id)
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
def one(self, id: int):
|
2018-04-10 15:06:39 +00:00
|
|
|
"""Gets one device."""
|
2018-05-11 16:58:48 +00:00
|
|
|
device = Device.query.filter_by(id=id).one()
|
2018-05-13 13:13:12 +00:00
|
|
|
return self.schema.jsonify(device)
|
2018-05-11 16:58:48 +00:00
|
|
|
|
|
|
|
def find(self, args: dict):
|
2018-06-24 14:57:49 +00:00
|
|
|
"""Gets many devices."""
|
2018-09-11 20:51:13 +00:00
|
|
|
return self.schema.jsonify(Device.query, many=True)
|