diff --git a/plexapi/server.py b/plexapi/server.py index 69d5f89a..ebb7157f 100644 --- a/plexapi/server.py +++ b/plexapi/server.py @@ -189,6 +189,11 @@ class PlexServer(PlexObject): data = self.query(Settings.key) return Settings(self, data) + def identity(self): + """ Returns the Plex server identity. """ + data = self.query('/identity') + return Identity(self, data) + def account(self): """ Returns the :class:`~plexapi.server.Account` object this server belongs to. """ data = self.query(Account.key) @@ -1273,3 +1278,22 @@ class ButlerTask(PlexObject): self.name = data.attrib.get('name') self.scheduleRandomized = utils.cast(bool, data.attrib.get('scheduleRandomized')) self.title = data.attrib.get('title') + + +class Identity(PlexObject): + """ Represents a server identity. + + Attributes: + claimed (bool): True or False if the server is claimed. + machineIdentifier (str): The Plex server machine identifier. + version (str): The Plex server version. + """ + + def __repr__(self): + return f"<{self.__class__.__name__}:{self.machineIdentifier}>" + + def _loadData(self, data): + self._data = data + self.claimed = utils.cast(bool, data.attrib.get('claimed')) + self.machineIdentifier = data.attrib.get('machineIdentifier') + self.version = data.attrib.get('version') diff --git a/tests/test_server.py b/tests/test_server.py index e1bcf9ff..4c277814 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -566,3 +566,8 @@ def test_server_agents(plex): setting = next((s for s in settings if s.id == 'country'), None) assert setting assert setting.enumValues is not None + + +def test_server_identity(plex): + identity = plex.identity() + assert identity.machineIdentifier == plex.machineIdentifier