summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Lundberg <lundberg@nordu.net>2014-03-26 17:53:06 +0100
committerJohan Lundberg <lundberg@nordu.net>2014-03-26 17:53:06 +0100
commitb31bdbb68fee48b31cb933181bd5a6a0c7477afe (patch)
tree1b68ce28c98d5b5f835afe1671ff81f73f44c53b
parent33702b48637d2cd50cb2d72a88b2f239c473f3c2 (diff)
Added utility functions to the api client
-rw-r--r--meetingtools/ac/api.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/meetingtools/ac/api.py b/meetingtools/ac/api.py
index 110c79d..5ffa151 100644
--- a/meetingtools/ac/api.py
+++ b/meetingtools/ac/api.py
@@ -259,4 +259,46 @@ class ACPClient():
def poll_user_counts(self, room):
(room.user_count, room.host_count) = self.user_counts(room.sco_id)
room.save()
- return (room.user_count, room.host_count) \ No newline at end of file
+ return (room.user_count, room.host_count)
+
+ def get_byte_count(self, sco_id):
+ sco_sizes = self.request('sco-sizes', {'filter-sco-id': sco_id}, False)
+ if sco_sizes.status_code() == 'ok':
+ byte_count = sco_sizes.et.xpath('.//sco[@byte-count]')
+ if byte_count:
+ try:
+ return int(byte_count[0].get('byte-count'))
+ except ValueError:
+ pass
+ return None
+
+ def get_sco_info(self, sco_id):
+ sco_info = self.request('sco-info', {'sco-id': sco_id}, False)
+ if sco_info.status_code() == 'ok':
+ info = sco_info.et.xpath('//sco')
+ if info:
+ return info[0]
+ return None
+
+ def get_permissions(self, acl_id, principal_id=None):
+ """
+ acl-id is an ID of a SCO, principal, or account.
+ """
+ principals = []
+ p = {'acl-id': acl_id}
+ if principal_id:
+ p['principal-id'] = principal_id
+ permissions = self.request('permissions-info', p, False)
+ if permissions.status_code() == 'ok':
+ for principal in permissions.et.xpath('//principal'):
+ if principal.get('permission-id') != '':
+ d = {
+ 'principal-id': principal.get('principal-id'),
+ 'permission-id': principal.get('permission-id'),
+ 'type': principal.get('type'),
+ 'login': principal.findtext('login')
+ }
+ principals.append(d)
+ return principals
+
+