Add method to filter devices
This commit is contained in:
		| @@ -147,6 +147,20 @@ class OMMClient2: | |||||||
|         d = self.get_device(ppn) |         d = self.get_device(ppn) | ||||||
|         return self.detach_user_device(d.uid, 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): |     def get_account(self, id): | ||||||
|         """ |         """ | ||||||
|   | |||||||
| @@ -72,6 +72,9 @@ class EnumType: | |||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|         return "{}({})".format(self.__class__.__name__, repr(self.value)) |         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): | class CallForwardStateType(EnumType): | ||||||
|     VALUES = [ |     VALUES = [ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user