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.
devicehub-teal/ereuse_devicehub/resources/device/views.py

33 lines
825 B
Python
Raw Normal View History

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):
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."""
device = Device.query.filter_by(id=id).one()
return self.schema.jsonify(device)
def find(self, args: dict):
"""Gets many devices."""
devices = Device.query.all()
return self.schema.jsonify(devices, many=True)