1
# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
11
"DeviceStateSearchParams",
14
from zope.interface import Interface
15
from zope.schema import Datetime
17
from lazr.restful.declarations import (
18
export_as_webservice_entry,
20
export_factory_operation,
22
from lazr.restful.fields import (
26
from lazr.restful.frameworks.django import IDjangoLocation
28
from lpresults.registry.interfaces.search import (
33
from lpresults.hardware.interfaces.device import IDevice
34
from lpresults.hardware.interfaces.devicedriver import IHasDeviceDriver
37
class IDeviceState(IDjangoLocation, IDevice, IHasDeviceDriver):
38
"""A device state for a particular system unit."""
40
export_as_webservice_entry()
42
date_created = exported(
44
title=u"Date created",
47
description=u"Date on which this device state was created."))
50
class IDeviceStateSet(ISearchSet):
52
def add(system_unit, device):
53
"""Add a device state and return it."""
56
class IHasDeviceStates(Interface):
57
"""An entity which has a collection of device states."""
61
title=u"List of device states.",
62
value_type=Reference(schema=IDeviceState),
66
class IDeviceStateTarget(IHasDeviceStates):
67
"""An entity on which a device states can be added.
69
Examples include an ISystemUnit for now.
71
export_as_webservice_entry()
73
@export_factory_operation(
75
["bus_name", "category_name", "product_name", "vendor_name",
76
"product_id", "vendor_id", "subproduct_id", "subvendor_id",
77
"driver_name", "date_created"])
79
bus_name, category_name=None, product_name=None, vendor_name=None,
80
product_id=None, vendor_id=None, subproduct_id=None,
81
subvendor_id=None, driver_name=None, date_created=None):
82
"""Add a new device state on this target."""
85
class DeviceStateSearchParams(SearchParams):
86
"""Encapsulates search parameters for IDeviceStateSet.search()"""