diff --git a/mitel_ommclient2/client.py b/mitel_ommclient2/client.py index 7e54f12..a63417f 100644 --- a/mitel_ommclient2/client.py +++ b/mitel_ommclient2/client.py @@ -147,6 +147,20 @@ class OMMClient2: d = self.get_device(ppn) return self.detach_user_device(d.uid, ppn) + def find_devices(self, filter): + """ + Get all devices matching a filter + + :param filter: function taking one parameter which is a device, returns True to keep, False to discard + + Usage:: + + >>> c.find_devices(lambda d: d.relType == mitel_ommclient2.types.PPRelTypeType("Unbound")) + """ + + for d in self.get_devices(): + if filter(d): + yield d def get_account(self, id): """ diff --git a/mitel_ommclient2/types/__init__.py b/mitel_ommclient2/types/__init__.py index b57d445..ec456c9 100644 --- a/mitel_ommclient2/types/__init__.py +++ b/mitel_ommclient2/types/__init__.py @@ -72,6 +72,9 @@ class EnumType: def __repr__(self): return "{}({})".format(self.__class__.__name__, repr(self.value)) + def __eq__(self, other): + return isinstance(other, type(self)) and self.value == other.value + class CallForwardStateType(EnumType): VALUES = [