Lot of work and it works
This commit is contained in:
parent
089de6685e
commit
f1d9aaf340
|
@ -45,9 +45,25 @@ class Node(HSAPICall):
|
|||
response = self.call('get')
|
||||
return v1ListNodesResponse(**response.json())
|
||||
|
||||
def get(self, nodeId: str) -> v1NodeResponse:
|
||||
response = self.call('get', call_path=nodeId)
|
||||
return v1NodeResponse(**response.json())
|
||||
def get(self, nodeId: str) -> v1Node:
|
||||
# There is a bug in headscale API
|
||||
# retrieving a specific node does not return the tags
|
||||
# so we get the full list of nodes and extract the node with the
|
||||
# ID we want
|
||||
# response = self.call('get', call_path=nodeId)
|
||||
nodelist = self.list()
|
||||
node = [n for n in nodelist.nodes if n.id == nodeId]
|
||||
if node:
|
||||
return node[0] # type: ignore
|
||||
else:
|
||||
return v1Node()
|
||||
|
||||
def byUser(self, username: str) -> v1ListNodesResponse:
|
||||
nodelist = self.list()
|
||||
|
||||
byUser = [n for n in nodelist.nodes if n.user.name == username]
|
||||
|
||||
return v1ListNodesResponse(nodes=byUser)
|
||||
|
||||
def delete(self, nodeId: str) -> None:
|
||||
self.call('delete', call_path=nodeId)
|
||||
|
|
|
@ -327,4 +327,4 @@ zstd = ["zstandard (>=0.18.0)"]
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "d6cbad8cd64ba63c62d1f3ab2dde75682d6a42c5b40808fd35615bccdf5fdd07"
|
||||
content-hash = "28f675747b0ee9850925befb61509ac513e0acc429d7efc1abe2a0fea6d8f97d"
|
||||
|
|
|
@ -13,6 +13,9 @@ pydantic = "^2.7.4"
|
|||
pydantic-settings = "^2.3.4"
|
||||
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
python-dotenv = "^1.0.1"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
|
Loading…
Reference in New Issue