Skip to content

Commit 6ade288

Browse files
committed
Add minimal api to list system accounts
1 parent dd8648b commit 6ade288

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

plexapi/server.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ def account(self):
182182
""" Returns the :class:`~plexapi.server.Account` object this server belongs to. """
183183
data = self.query(Account.key)
184184
return Account(self, data)
185+
186+
def systemAccounts(self):
187+
""" Returns the :class:`~plexapi.server.SystemAccounts` objects this server contains. """
188+
accounts = []
189+
for elem in self.query('/accounts'):
190+
accounts.append(SystemAccount(self, data=elem))
191+
return accounts
185192

186193
def myPlexAccount(self):
187194
""" Returns a :class:`~plexapi.myplex.MyPlexAccount` object using the same
@@ -507,3 +514,14 @@ def _loadData(self, data):
507514
self.subscriptionFeatures = utils.toList(data.attrib.get('subscriptionFeatures'))
508515
self.subscriptionActive = cast(bool, data.attrib.get('subscriptionActive'))
509516
self.subscriptionState = data.attrib.get('subscriptionState')
517+
518+
519+
class SystemAccount(PlexObject):
520+
""" Minimal api to list system accounts. """
521+
key = '/accounts'
522+
523+
def _loadData(self, data):
524+
self._data = data
525+
self.accountId = cast(int, data.attrib.get('id'))
526+
self.accountKey = data.attrib.get('key')
527+
self.name = data.attrib.get('name')

0 commit comments

Comments
 (0)