Card¶
Bases: Card_
| METHOD | DESCRIPTION |
|---|---|
__eq__ |
Check if two model instances are equal |
__getitem__ |
Get the value of an attribute |
__hash__ |
Generate a hash for the model instance so it can be used in mappings ( |
__iter__ |
Iterate over public, assigned model attribute names |
add_attachment |
Adds an attachment to the card |
add_comment |
Adds a comment to the card |
add_label |
Adds a label to the card |
add_member |
Adds a user to the card |
add_stopwatch |
Adds a stopwatch to the card if there is not one already |
add_task |
Adds a task to the card |
bind |
Bind routes to the model |
delete |
Deletes the card |
duplicate |
Duplicates the card |
editor |
Context manager for editing the model |
json |
Dump the model properties to a JSON string |
move |
Moves the card to a new list |
pickle |
Pickle the model, preserving as much of its state as possible |
refresh |
Refreshes the card data |
remove_attachment |
Removes an attachment from the card |
remove_comment |
Pass a comment from self.comments to remove it |
remove_label |
Removes a label from the card |
remove_member |
Removes a user from the card |
remove_stopwatch |
Removes the stopwatch from the card |
set_due_date |
Sets the due date of the card |
update |
Updates the card with new values |
| ATTRIBUTE | DESCRIPTION |
|---|---|
attachments |
All attachments on the card
TYPE:
|
board |
Board the card belongs to
TYPE:
|
comments |
All comments on the card
TYPE:
|
created_at |
Get the creation date of the model instance
TYPE:
|
creator |
User that created the card
TYPE:
|
deleted_at |
Get the deletion date of the model instance
TYPE:
|
due_date |
Due date of the card in datetime format
TYPE:
|
labels |
All labels on the card
TYPE:
|
link |
Get the link to the model instance
TYPE:
|
list |
List the card belongs to
TYPE:
|
members |
All users assigned to the card
TYPE:
|
routes |
Get the routes for the model instance
TYPE:
|
tasks |
All tasks on the card
TYPE:
|
unique_name |
Generate a unique name for the model instance using the last 5 characters of the id
TYPE:
|
updated_at |
Get the last update date of the model instance
TYPE:
|
attachments
property
¶
attachments: QueryableList[Attachment]
All attachments on the card
| RETURNS | DESCRIPTION |
|---|---|
QueryableList[Attachment]
|
Queryable List of all attachments on the card |
board
property
¶
board: Board
Board the card belongs to
| RETURNS | DESCRIPTION |
|---|---|
Board
|
Board instance
TYPE:
|
comments
property
¶
comments: QueryableList[Action]
All comments on the card
| RETURNS | DESCRIPTION |
|---|---|
QueryableList[Action]
|
Queryable List of all comments on the card |
created_at
property
¶
created_at: datetime | None
Get the creation date of the model instance
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
Optional[datetime]: The creation date of the model instance |
creator
property
¶
creator: User
User that created the card
| RETURNS | DESCRIPTION |
|---|---|
User
|
Creator of the card
TYPE:
|
deleted_at
property
¶
deleted_at: datetime | None
Get the deletion date of the model instance
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
Optional[datetime]: The deletion date of the model instance |
due_date
property
¶
due_date: datetime | None
Due date of the card in datetime format
Note
The dueDate attribute is stored as an ISO 8601 string, this property will return
the due date as a python datetime object
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
Due date of the card |
labels
property
¶
labels: QueryableList[Label]
All labels on the card
| RETURNS | DESCRIPTION |
|---|---|
QueryableList[Label]
|
Queryable List of all labels on the card |
link
property
¶
link: str | None
Get the link to the model instance
Note
Only Project, Board, and Card models have links.
All other models return None
| RETURNS | DESCRIPTION |
|---|---|
str
|
The link to the model instance
TYPE:
|
list
property
¶
list: List
List the card belongs to
| RETURNS | DESCRIPTION |
|---|---|
List
|
List instance
TYPE:
|
members
property
¶
members: QueryableList[User]
All users assigned to the card
| RETURNS | DESCRIPTION |
|---|---|
QueryableList[User]
|
Queryable List of all users assigned to the card |
routes
property
writable
¶
routes: Routes
Get the routes for the model instance
| RETURNS | DESCRIPTION |
|---|---|
Routes
|
The routes bound to the model instance
TYPE:
|
tasks
property
¶
tasks: QueryableList[Task]
All tasks on the card
| RETURNS | DESCRIPTION |
|---|---|
QueryableList[Task]
|
Queryable List of all tasks on the card |
unique_name
property
¶
unique_name: str
Generate a unique name for the model instance using the last 5 characters of the id and the name attribute
| RETURNS | DESCRIPTION |
|---|---|
str
|
The unique name for the model instance in the format {name}_{id[:-5]}
TYPE:
|
updated_at
property
¶
updated_at: datetime | None
Get the last update date of the model instance
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
Optional[datetime]: The last update date of the model instance |
__eq__
¶
Check if two model instances are equal
Note
Compares the hash and class of the model instances
Warning
Does not compare the attributes of the model instances, out of sync models with different attributes can still be equal, it's best to refresh the models before comparing.
| PARAMETER | DESCRIPTION |
|---|---|
|
The other model instance to compare
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the model instances are equal, False otherwise
TYPE:
|
Source code in src/plankapy/v1/models.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
__getitem__
¶
__getitem__(key) -> Any
Get the value of an attribute
Warning
This is an implementation detail that allows for the unpacking operations
in the rest of the codebase, all model attributes are still directly accessible
through __getattribute___
Note
Returns None if the attribute is Unset or starts with an underscore
Example
print(model['name'])
>>> "Model Name"
model.name = Unset
print(model['name'])
>>> None
Source code in src/plankapy/v1/models.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
__hash__
¶
__hash__() -> int
Generate a hash for the model instance so it can be used in mappings (dict, set)
Note
All Models are still mutable, but their ID value is unique
| RETURNS | DESCRIPTION |
|---|---|
int
|
The hash value of the model instance
TYPE:
|
Example
board_map = {
Board(name="Board 1"): board.,
Board(name="Board 2"): "Board 2"
}
>>> 1
Source code in src/plankapy/v1/models.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
__iter__
¶
__iter__()
Iterate over public, assigned model attribute names
Warning
This is used in conjunction with __getitem__ to unpack assigned values.
This allows model state to be passed as keyword arguments to functions
Example:
model = Model(name="Model Name", position=1, other=Unset)
def func(name=None, position=None):
return {"name": name, "position": position}
print(func(**model))
>>> {'name': 'Model Name', 'position': 1}
None values to be assigned during
a PATCH request to delete data
Note
Skips attributes that are Unset or start with an underscore
| RETURNS | DESCRIPTION |
|---|---|
Iterator
|
The iterator of the model attributes |
Example
# Skip Private attributes
print(list(model.__dict__))
>>> ['_privateattribute', 'name', 'position', 'id']
print(list(model))
>>> ['name', 'position', 'id'] # Skips _privateattribute
# Skip Unset attributes
print(model.___dict___)
>>> {'_privateattribute': 'Private', 'name': 'Model Name', 'position': Unset, 'id': 1}
items = dict(model.items())
print(items)
>>> {'name': 'Model Name', 'id': 1} # Skips position because it's Unset
Source code in src/plankapy/v1/models.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
add_attachment
¶
add_attachment(file_path: Path) -> Attachment
Adds an attachment to the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Attachment instance to add (can be a file path or url)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Attachment
|
New attachment instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 | |
add_comment
¶
Adds a comment to the card
Note
Comments can only be added by the authenticated user, all comments made
through plankapy will be attributed to the user in planka.me
| PARAMETER | DESCRIPTION |
|---|---|
|
Comment to add
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Action
|
New comment action instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | |
add_label
¶
add_label(label: Label) -> CardLabel
Adds a label to the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Label instance to add
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CardLabel
|
New card label instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 | |
add_member
¶
add_member(user: User) -> CardMembership
Adds a user to the card
| PARAMETER | DESCRIPTION |
|---|---|
|
User instance to add
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CardMembership
|
New card membership instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 | |
add_stopwatch
¶
add_stopwatch() -> Stopwatch
Adds a stopwatch to the card if there is not one already
Warning
The stopwatch stored in the Card instance dictionary is actually a dictionary
that is used to update the stopwatch on Planka. When you access the stopwatch
attribute with card.stopwatch, a Stopwatch instance is generated. This is
an implementation detail to keep the stopwatch interface separate from the Card
interface.
Example:
>>> card.add_stopwatch()
>>> card.stopwatch
Stopwatch(startedAt=None, total=0)
>>> card.__dict__['stopwatch']
{'startedAt': None, 'total': 0}
>>> card.stopwatch.start()
>>> card.stopwatch
Stopwatch(startedAt=datetime.datetime(2024, 9, 30, 0, 0, 0), total=0)
>>> card.__dict__['stopwatch']
{'startedAt': '2024-9-30T00:00:00Z', 'total': 0}
| RETURNS | DESCRIPTION |
|---|---|
Stopwatch
|
A stopwatch instance used to track time on the card
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 | |
add_task
¶
add_task(task: Task) -> Task
add_task(*args, **kwargs) -> Task
Adds a task to the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Name of the task (required)
TYPE:
|
|
Position of the task (default: 0)
TYPE:
|
|
Whether the task is completed (default: False)
TYPE:
|
|
Whether the task is deleted (default: False)
TYPE:
|
| ALTERNATE | DESCRIPTION |
|---|---|
|
Task instance to create
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Task
|
New task instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 | |
bind
¶
Bind routes to the model Args: routes (Routes): The routes to bind to the model instance
| RETURNS | DESCRIPTION |
|---|---|
Self
|
Self for chain operations |
Example
model = Model(**kwargs).bind(routes)
Source code in src/plankapy/v1/models.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
delete
¶
delete() -> Card
Deletes the card
Danger
This action is irreversible and cannot be undone
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The deleted card instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 | |
duplicate
¶
duplicate() -> Card
Duplicates the card
Note
Duplicating a card will always insert it one slot below the original card
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The duplicated card instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 | |
editor
¶
Context manager for editing the model
Example
print(model.name)
>>> "Old Name"
with model.editor() as m:
m.name = "New Name"
m.position = 1
print(model.name)
>>> "New Name"
Source code in src/plankapy/v1/models.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
json
¶
json() -> str
Dump the model properties to a JSON string
Note
Only properties defined in the {Model}_ dataclass are dumped.
All relationships and included items (e.g. board.cards) are lost.
If you wish to preserve these relationships, use the .pickle method
| RETURNS | DESCRIPTION |
|---|---|
str
|
(str) : A JSON string with the Model attributes |
Source code in src/plankapy/v1/models.py
132 133 134 135 136 137 138 139 140 141 142 143 | |
move
¶
move(list: List) -> Card
Moves the card to a new list
| PARAMETER | DESCRIPTION |
|---|---|
|
List instance to move the card to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The moved card instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 | |
pickle
¶
pickle() -> bytes
Pickle the model, preserving as much of its state as possible
Warning
This method currently works, and since the object data is updated by routes
You can use this to store a reference to a specific object. The data will be
maintained until operations that trigger a .refresh() call are made, e.g.
using the .editor() context.
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
(bytes) : Raw bytes generated by |
Source code in src/plankapy/v1/models.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
refresh
¶
refresh()
Refreshes the card data
Note
This method is used to update the card instance with the latest data from the server
Source code in src/plankapy/v1/interfaces.py
2240 2241 2242 2243 2244 2245 2246 2247 | |
remove_attachment
¶
remove_attachment(attachment: Attachment) -> Attachment | None
Removes an attachment from the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Attachment instance to remove
TYPE:
|
Note
This method will remove the attachment from the card, but the attachment itself will not be deleted
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The card instance with the attachment removed
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 | |
remove_comment
¶
remove_comment(comment_action: Action) -> Card
Pass a comment from self.comments to remove it
| PARAMETER | DESCRIPTION |
|---|---|
|
Comment instance to remove
TYPE:
|
Note
This method will remove the comment from the card, but the comment itself will not be deleted
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The card instance with the comment removed
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 | |
remove_label
¶
remove_label(label: Label) -> Card
Removes a label from the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Label instance to remove
TYPE:
|
Note
This method will remove the label from the card, but the label itself will not be deleted
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The card instance with the label removed
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 | |
remove_member
¶
remove_member(user: User) -> Card
Removes a user from the card
| PARAMETER | DESCRIPTION |
|---|---|
|
User instance to remove
TYPE:
|
Note
This method will remove the user from the card, but the user itself will not be deleted
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The card instance with the user removed
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 | |
remove_stopwatch
¶
remove_stopwatch() -> Stopwatch
Removes the stopwatch from the card
| RETURNS | DESCRIPTION |
|---|---|
Stopwatch
|
The stopwatch instance that was removed
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 | |
set_due_date
¶
set_due_date(due_date: datetime | None) -> Card
Sets the due date of the card
| PARAMETER | DESCRIPTION |
|---|---|
|
Due date of the card (None to remove)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Card
|
The card instance with the due date set
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 | |
update
¶
update() -> Card
update(card: Card) -> Card
update(name: str, position: int = 0, description: str = None, dueDate: datetime = None, isDueDateCompleted: bool = None, stopwatch: Stopwatch = None, boardId: int = None, listId: int = None, creatorUserId: int = None, coverAttachmentId: int = None, isSubscribed: bool = None) -> Card
update(*args, **kwargs) -> Card
Updates the card with new values
Tip
It's recommended to use a card.editor() context manager to update the card
Example: ```python
with card.editor(): ... card.name='New Name'
card Card(name='New Name', ...) ``
| PARAMETER | DESCRIPTION |
|---|---|
|
Name of the card (optional)
TYPE:
|
|
Position of the card (optional)
TYPE:
|
|
Description of the card (optional)
TYPE:
|
|
Due date of the card (optional)
TYPE:
|
|
Whether the due date is completed (optional)
TYPE:
|
|
Stopwatch of the card (optional)
TYPE:
|
|
Board id of the card (optional)
TYPE:
|
|
List id of the card (optional)
TYPE:
|
|
Creator user id of the card (optional)
TYPE:
|
|
Cover attachment id of the card (optional)
TYPE:
|
|
Whether the card is subscribed (optional)
TYPE:
|
| ALTERNATE | DESCRIPTION |
|---|---|
|
Card instance to update (required)
TYPE:
|
Note
If no arguments are provided, the card will update itself with the current values stored in its attributes
| RETURNS | DESCRIPTION |
|---|---|
Card
|
Updated card instance
TYPE:
|
Source code in src/plankapy/v1/interfaces.py
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 | |