Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shellhub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Increment versions here according to SemVer
__version__ = "0.1.0"
__version__ = "0.2.0"

from .models.device import ShellHubDevice, ShellHubDeviceInfo
from .models.base import ShellHub
Expand Down
6 changes: 6 additions & 0 deletions shellhub/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ def refresh(self) -> None:
except requests.exceptions.HTTPError as e:
raise ShellHubApiError(e)

@property
def sshid(self) -> Optional[str]:
if self.acceptable:
return None
return f"{self.namespace}.{self.name}@{self._api._endpoint}"

def __repr__(self) -> str:
return (
f"ShellHubDevice(name={self.name}, online={self.online}, namespace={self.namespace}, status={self.status})"
Expand Down
9 changes: 9 additions & 0 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,12 @@ def test_accept_device(self, shellhub_device, requests_mock):
shellhub_device.accept()

assert not shellhub_device.acceptable


class TestDeviceSSHID:
def test_get_sshid(self, shellhub_device, shellhub):
assert shellhub_device.sshid == f"{shellhub_device.namespace}.{shellhub_device.name}@{shellhub._endpoint}"

def test_acceptable_device_sshid(self, shellhub_device, shellhub):
shellhub_device.acceptable = True
assert shellhub_device.sshid is None