From 8e2e479cfd64d350739c84eade90abe87bf43831 Mon Sep 17 00:00:00 2001 From: Michael Beigelmacher Date: Thu, 2 May 2024 16:47:39 -0400 Subject: [PATCH] feat: add dataclass to represent ContentItem owner (#165) --- src/posit/connect/content.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/posit/connect/content.py b/src/posit/connect/content.py index 4213b426..9512c8da 100644 --- a/src/posit/connect/content.py +++ b/src/posit/connect/content.py @@ -15,6 +15,26 @@ from .resources import Resources, Resource +class ContentItemOwner(Resource): + """The owner of a piece of content.""" + + @property + def guid(self) -> str: + return self.get("guid") # type: ignore + + @property + def username(self) -> str: + return self.get("username") # type: ignore + + @property + def first_name(self) -> Optional[str]: + return self.get("first_name") # type: ignore + + @property + def last_name(self) -> Optional[str]: + return self.get("last_name") # type: ignore + + class ContentItem(Resource): """A piece of content.""" @@ -191,7 +211,7 @@ def owner_guid(self) -> str: return self.get("owner_guid") # type: ignore @property - def owner(self) -> str: + def owner(self) -> ContentItemOwner: return self.get("owner", {}) # type: ignore @property