Skip to content

Commit

Permalink
feat: add dataclass to represent ContentItem owner (#165) (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooklynbagel committed May 28, 2024
1 parent 62ff359 commit b6eacc1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b6eacc1

Please sign in to comment.