Skip to content

Commit dfdcd4c

Browse files
committed
Devices: Added method to get device's SSHID
1 parent e671b7d commit dfdcd4c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

shellhub/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Increment versions here according to SemVer
2-
__version__ = "0.1.0"
2+
__version__ = "0.2.0"
33

44
from .models.device import ShellHubDevice, ShellHubDeviceInfo
55
from .models.base import ShellHub

shellhub/models/device.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def refresh(self) -> None:
135135
except requests.exceptions.HTTPError as e:
136136
raise ShellHubApiError(e)
137137

138+
@property
139+
def sshid(self) -> str:
140+
return f"{self.namespace}.{self.name}@{self._api._endpoint}"
141+
138142
def __repr__(self) -> str:
139143
return (
140144
f"ShellHubDevice(name={self.name}, online={self.online}, namespace={self.namespace}, status={self.status})"

tests/test_devices.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,8 @@ def test_accept_device(self, shellhub_device, requests_mock):
260260
shellhub_device.accept()
261261

262262
assert not shellhub_device.acceptable
263+
264+
265+
class TestDeviceSSHID:
266+
def test_get_sshid(self, shellhub_device, shellhub):
267+
assert shellhub_device.sshid == f"{shellhub_device.namespace}.{shellhub_device.name}@{shellhub._endpoint}"

0 commit comments

Comments
 (0)