Basic single uuid object client.

This commit is contained in:
Michael Woods
2025-02-16 10:34:28 -05:00
parent 2942b7763c
commit 7a0fa2a0d6

View File

@@ -76,5 +76,24 @@ def post_file(client: Client, bbs_callsign: str, file_path: str, private=True, n
data = open(file_path, mode).read() data = open(file_path, mode).read()
return post_object(client, bbs_callsign, obj_name, data, private=private) return post_object(client, bbs_callsign, obj_name, data, private=private)
def get_object_by_uuid(): def get_object_by_uuid(client: Client, bbs_callsign: str, uuid: Union[str, bytes, UUID, int]):
# TODO get object uuid if type(uuid) is str:
uid = UUID(uuid)
elif type(uuid) is bytes:
uid = UUID(bytes=uuid)
elif type(uuid) is UUID:
uid = uuid
elif type(uuid) is int:
uid = UUID(int=uuid)
else:
raise ValueError("uuid must represent a UUID object")
req = Request.blank()
req.path = "object"
req.set_var('uuid', uid.bytes)
req.method = Request.Method.GET
response = client.send_receive_callsign(req, bbs_callsign)
if response.status_code != 200:
raise RuntimeError(f"Sending job failed: {response.status_code}: {response.payload}")
return ObjectWrapper(response.payload)