Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dataclass to represent ContentItem owner #190

Merged
Merged
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
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
Loading