ProjectManager¶
Bases: ProjectManager_
| 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 |
bind |
Bind routes to the model |
delete |
Deletes the project manager relationship |
editor |
Context manager for editing the model |
json |
Dump the model properties to a JSON string |
pickle |
Pickle the model, preserving as much of its state as possible |
refresh |
Refreshes the project manager data |
update |
Update the model instance |
| ATTRIBUTE | DESCRIPTION |
|---|---|
created_at |
Get the creation date of the model instance
TYPE:
|
deleted_at |
Get the deletion date of the model instance
TYPE:
|
link |
Get the link to the model instance
TYPE:
|
project |
Project the user is a manager of
TYPE:
|
routes |
Get the routes for the model instance
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:
|
user |
User that is a manager of the project
TYPE:
|
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 |
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 |
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:
|
project
property
¶
project: Project
Project the user is a manager of
| RETURNS | DESCRIPTION |
|---|---|
Project
|
Project instance
TYPE:
|
routes
property
writable
¶
routes: Routes
Get the routes for the model instance
| RETURNS | DESCRIPTION |
|---|---|
Routes
|
The routes bound to the model instance
TYPE:
|
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 |
user
property
¶
user: User
User that is a manager of the project
| RETURNS | DESCRIPTION |
|---|---|
User
|
User instance
TYPE:
|
__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 | |
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() -> tuple[User, Project]
Deletes the project manager relationship
Danger
This action is irreversible and cannot be undone
| RETURNS | DESCRIPTION |
|---|---|
tuple[User, Project]
|
tuple[User, Project]: The user and project that the user was manager of |
Source code in src/plankapy/v1/interfaces.py
2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 | |
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 | |
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() -> None
Refreshes the project manager data
Source code in src/plankapy/v1/interfaces.py
2600 2601 2602 2603 2604 | |
update
¶
update()
Update the model instance Note: Method is implemented in the child classes, but is not required
Source code in src/plankapy/v1/models.py
299 300 301 302 303 304 | |