Skip to content

Models

CLASS DESCRIPTION
Action_

Action Model

Archive_

Archive Model

Attachment_

Attachment Model

BoardMembership_

Board Membership Model

Board_

Board Model

CardLabel_

Card Label Model

CardMembership_

Card Membership Model

CardSubscription_

Card Subscription Model

Card_

Card Model

IdentityProviderUser_

Identity Provider User Model

Label_

Label Model

List_

List Model

Model

Implements common magic methods for all Models

Notification_

Notification Model

ProjectManager_

Project Manager Model

Project_

Project Model

QueryableList

A list of Queryable objects

Stopwatch

Stopwatch Model

Task_

Task Model

User_

User Model

Action_ dataclass

Action_(id: int | None = Unset, type: ActionType | None = Required, data: dict | None = Required, cardId: int | None = Required, userId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Action Model

ATTRIBUTE DESCRIPTION
id

The ID of the action

TYPE: int

type

The type of the action

TYPE: ActionType

data

The data of the action

TYPE: dict

cardId

The ID of the card the action is associated with

TYPE: int

userId

The ID of the user who created the action

TYPE: int

createdAt

The creation date of the action

TYPE: datetime

updatedAt

The last update date of the action

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Archive_ dataclass

Archive_(fromModel: str | None = Required, originalRecordId: int | None = Required, originalRecord: dict | None = Required)

Bases: Model

Archive Model

Warning

This model is currently unavailable in the Planka API

ATTRIBUTE DESCRIPTION
fromModel

The model the archive is from

TYPE: str

originalRecordId

The ID of the original record

TYPE: int

originalRecord

The original record

TYPE: dict

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Attachment_ dataclass

Attachment_(id: int | None = Unset, name: str | None = Required, dirname: Literal['public', 'private/attachments'] | None = Required, filename: str | None = Required, image: dict | None = Unset, url: str | None = Unset, coverUrl: str | None = Unset, cardId: int | None = Required, creatorUserId: int | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Attachment Model

ATTRIBUTE DESCRIPTION
id

The ID of the attachment

TYPE: int

name

The name of the attachment

TYPE: str

url

The URL of the attachment

TYPE: str

cardId

The ID of the card the attachment is associated with

TYPE: int

dirname

The directory name of the attachment

TYPE: str

filename

The filename of the attachment

TYPE: str

image

The image of the attachment in the format {'width': int, 'height': int}

TYPE: dict

url

The URL of the attachment

TYPE: str

coverUrl

The cover URL of the attachment

TYPE: str

cardId

The ID of the card the attachment is associated with

TYPE: int

creatorUserId

The ID of the user who created the attachment

TYPE: int

createdAt

The creation date of the attachment

TYPE: datetime

updatedAt

The last update date of the attachment

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

BoardMembership_ dataclass

BoardMembership_(id: int | None = Unset, role: BoardRole | None = Required, canComment: bool | None = Unset, boardId: int | None = Required, userId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Board Membership Model

ATTRIBUTE DESCRIPTION
id

The ID of the board membership

TYPE: int

role

The role of the board membership

TYPE: BoardRole

canComment

The comment permission of the board membership

TYPE: bool

boardId

The ID of the board the membership is associated with

TYPE: int

userId

The ID of the user the membership is associated with

TYPE: int

createdAt

The creation date of the board membership

TYPE: datetime

updatedAt

The last update date of the board membership

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Board_ dataclass

Board_(id: int | None = Unset, name: str | None = Required, position: int | None = Required, projectId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Board Model

ATTRIBUTE DESCRIPTION
id

The ID of the board

TYPE: int

name

The name of the board

TYPE: str

description

The description of the board

TYPE: str

isClosed

The closed status of the board

TYPE: bool

isStarred

The starred status of the board

TYPE: bool

createdAt

The creation date of the board

TYPE: datetime

updatedAt

The last update date of the board

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

CardLabel_ dataclass

CardLabel_(id: int | None = Unset, cardId: int | None = Required, labelId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Card Label Model

ATTRIBUTE DESCRIPTION
id

The ID of the card label

TYPE: int

cardId

The ID of the card the label is associated with

TYPE: int

labelId

The ID of the label the card is associated with

TYPE: int

createdAt

The creation date of the card label

TYPE: datetime

updatedAt

The last update date of the card label

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

CardMembership_ dataclass

CardMembership_(id: int | None = Unset, cardId: int | None = Required, userId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Card Membership Model

ATTRIBUTE DESCRIPTION
id

The ID of the card membership

TYPE: int

cardId

The ID of the card the membership is associated with

TYPE: int

userId

The ID of the user the membership is associated with

TYPE: int

createdAt

The creation date of the card membership

TYPE: datetime

updatedAt

The last update date of the card membership

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

CardSubscription_ dataclass

CardSubscription_(id: int | None = Unset, cardId: int | None = Required, userId: int | None = Required, isPermanent: bool | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Card Subscription Model

ATTRIBUTE DESCRIPTION
id

The ID of the card subscription

TYPE: int

cardId

The ID of the card the subscription is associated with

TYPE: int

userId

The ID of the user the subscription is associated with

TYPE: int

createdAt

The creation date of the card subscription

TYPE: datetime

updatedAt

The last update date of the card subscription

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Card_ dataclass

Card_(id: int | None = Unset, name: str | None = Required, position: int | None = Required, description: str | None = Unset, dueDate: str | None = Unset, isDueDateCompleted: bool | None = Unset, stopwatch: Stopwatch | None = Unset, boardId: int | None = Required, listId: int | None = Required, creatorUserId: int | None = Unset, coverAttachmentId: int | None = Unset, isSubscribed: bool | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Card Model

ATTRIBUTE DESCRIPTION
id

The ID of the card

TYPE: int

name

The name of the card

TYPE: str

position

The position of the card

TYPE: int

description

The description of the card

TYPE: str

dueDate

The due date of the card

TYPE: datetime

isDueDateCompleted

The due date completion status of the card

TYPE: bool

stopwatch

The stopwatch associated with the card

TYPE: _Stopwatch

boardId

The ID of the board the card is associated with

TYPE: int

listId

The ID of the list the card is associated with

TYPE: int

creatorUserId

The ID of the user who created the card

TYPE: int

coverAttachmentId

The ID of the cover attachment of the card

TYPE: int

isSubscribed

The current user's subscription status with the card

TYPE: bool

createdAt

The creation date of the card

TYPE: datetime

updatedAt

The last update date of the card

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

IdentityProviderUser_ dataclass

IdentityProviderUser_(id: int | None = Unset, issuer: str | None = Unset, sub: str | None = Unset, userId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Identity Provider User Model

ATTRIBUTE DESCRIPTION
id

The ID of the identity provider user

TYPE: int

issuer

The issuer of the identity provider user

TYPE: str

sub

The sub of the identity provider user

TYPE: str

userId

The ID of the user the identity provider user is associated with

TYPE: int

createdAt

The creation date of the identity provider user

TYPE: datetime

updatedAt

The last update date of the identity provider user

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Label_ dataclass

Label_(id: int | None = Unset, name: str | None = Required, position: int | None = Required, color: str | None = Required, boardId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Label Model

ATTRIBUTE DESCRIPTION
id

The ID of the label

TYPE: int

name

The name of the label

TYPE: str

position

The position of the label

TYPE: int

color

The color of the label

TYPE: str

boardId

The ID of the board the label is associated with

TYPE: int

createdAt

The creation date of the label

TYPE: datetime

updatedAt

The last update date of the label

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

List_ dataclass

List_(id: int | None = Unset, name: str | None = Required, position: int | None = Required, boardId: int | None = Required, color: str | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

List Model

ATTRIBUTE DESCRIPTION
id

The ID of the list

TYPE: int

name

The name of the list

TYPE: str

position

The position of the list

TYPE: int

boardId

The ID of the board the list is associated with

TYPE: int

color

The color of the list

TYPE: str

createdAt

The creation date of the list

TYPE: datetime

updatedAt

The last update date of the list

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Model

Bases: Mapping

Implements common magic methods for all Models

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

ATTRIBUTE DESCRIPTION
created_at

Get the creation date of the model instance

TYPE: datetime | None

deleted_at

Get the deletion date of the model instance

TYPE: datetime | None

link

Get the link to the model instance

TYPE: str | None

routes

Get the routes for the model instance

TYPE: Routes

unique_name

Generate a unique name for the model instance using the last 5 characters of the id

TYPE: str

updated_at

Get the last update date of the model instance

TYPE: datetime | None

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Notification_ dataclass

Notification_(id: int | None = Unset, isRead: bool = Required, userId: int | None = Required, actionId: int | None = Required, cardId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Notification Model

ATTRIBUTE DESCRIPTION
id

The ID of the notification

TYPE: int

isRead

The read status of the notification

TYPE: bool

userId

The ID of the user the notification is associated with

TYPE: int

actionId

The ID of the action the notification is associated with

TYPE: int

cardId

The ID of the card the notification is associated with

TYPE: int

createdAt

The creation date of the notification

TYPE: datetime

updatedAt

The last update date of the notification

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

ProjectManager_ dataclass

ProjectManager_(id: int | None = Unset, projectId: int | None = Required, userId: int | None = Required, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Project Manager Model

ATTRIBUTE DESCRIPTION
id

The ID of the project manager

TYPE: int

projectId

The ID of the project the manager is associated with

TYPE: int

userId

The ID of the user the manager is associated with

TYPE: int

createdAt

The creation date of the project manager

TYPE: datetime

updatedAt

The last update date of the project manager

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Project_ dataclass

Project_(id: int | None = Unset, name: str | None = Required, background: dict | None = Unset, backgroundImage: BackgroundImage | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Project Model

ATTRIBUTE DESCRIPTION
id

The ID of the project

TYPE: int

name

The name of the project

TYPE: str

background

The background of the project

TYPE: Background

backgroundImage

The background image of the project

TYPE: BackgroundImage

createdAt

The creation date of the project

TYPE: datetime

updatedAt

The last update date of the project

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

QueryableList

Bases: list[M], Generic[M]

A list of Queryable objects

This class is a subclass of the built-in list class that allows for querying the list of objects.

METHOD DESCRIPTION
filter_where

Filter the list of objects by keyword arguments

order_by

Order the list by a key

pop_where

Get the first object that matches the filter

select_where

Select objects from the list that match a function

take

Take the first n objects from the list

filter_where

filter_where(**kwargs) -> QueryableList[M] | None

Filter the list of objects by keyword arguments

PARAMETER DESCRIPTION

**kwargs

See Model for the available attributes

DEFAULT: {}

RETURNS DESCRIPTION
QueryableList[M] | None

QueryableList[M]: The objects that match the filter or None if no objects match

Example:

>>> users = QueryableList(project.users)
>>> users
[User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Bob')]

>>> users.filter_where(name='Bob')
[User(id=1, name='Bob'), User(id=3, name='Bob')]

Source code in src/plankapy/v1/models.py
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
def filter_where(self, **kwargs) -> QueryableList[M] | None:
    """Filter the list of objects by keyword arguments

    Args:
        **kwargs: See Model for the available attributes

    Returns:
        QueryableList[M]: The objects that match the filter or None if no objects match

    Example:
    ```python
    >>> users = QueryableList(project.users)
    >>> users
    [User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Bob')]

    >>> users.filter_where(name='Bob')
    [User(id=1, name='Bob'), User(id=3, name='Bob')]
    ```
    """
    return QueryableList(item for item in self if all(getattr(item, key) == value for key, value in kwargs.items())) or None

order_by

order_by(key: str, desc: bool = False) -> QueryableList[M]

Order the list by a key

PARAMETER DESCRIPTION

key

The key to order by

TYPE: str

desc

True to order in descending order, False otherwise

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
QueryableList[M]

QueryableList[M]: The list of objects ordered by the key

Example:

>>> users = QueryableList(project.users)
>>> users
[User(name='Bob'), User(name='Alice')]

>>> users = users.order_by('name')
>>> users
[User(name='Alice'), User(name='Bob')]

>>> users = users.order_by('name', desc=True)
>>> users
[User(name='Bob'), User(name='Alice')]

Source code in src/plankapy/v1/models.py
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
def order_by(self, key: str, desc: bool=False) -> QueryableList[M]:
    """Order the list by a key

    Args:
        key (str): The key to order by
        desc (bool): True to order in descending order, False otherwise

    Returns:
        QueryableList[M]: The list of objects ordered by the key

    Example:
    ```python
    >>> users = QueryableList(project.users)
    >>> users
    [User(name='Bob'), User(name='Alice')]

    >>> users = users.order_by('name')
    >>> users
    [User(name='Alice'), User(name='Bob')]

    >>> users = users.order_by('name', desc=True)
    >>> users
    [User(name='Bob'), User(name='Alice')]
    ```
    """
    return QueryableList(sorted(self, key=lambda x: getattr(x, key), reverse=desc))

pop_where

pop_where(**kwargs) -> M | None

Get the first object that matches the filter

PARAMETER DESCRIPTION

**kwargs

Keyword arguments to filter the list by

DEFAULT: {}

RETURNS DESCRIPTION
M

The first object that matches the filter

TYPE: M | None

Example:

>>> users = QueryableList(project.users)
>>> users
[User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Bob')]

>>> users.pop_where(name='Bob')
User(id=1, name='Bob')

>>> user = users.pop_where(name='Frank')
>>> user
None

Source code in src/plankapy/v1/models.py
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
def pop_where(self, **kwargs) -> M | None:
    """Get the first object that matches the filter

    Args:
        **kwargs: Keyword arguments to filter the list by

    Returns:
        M: The first object that matches the filter

    Example:
    ```python
    >>> users = QueryableList(project.users)
    >>> users
    [User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Bob')]

    >>> users.pop_where(name='Bob')
    User(id=1, name='Bob')

    >>> user = users.pop_where(name='Frank')
    >>> user
    None
    ```
    """
    vals = self.filter_where(**kwargs)
    return vals[0] if vals else None

select_where

select_where(predicate: Callable[[M], bool]) -> QueryableList[M]

Select objects from the list that match a function

PARAMETER DESCRIPTION

predicate

A function that takes an object and returns a boolean

TYPE: Callable[[M], bool]

RETURNS DESCRIPTION
QueryableList[M]

QueryableList[M]: The objects that match the function

Example:

>>> users = QueryableList(project.users)
>>> users
[User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Frank')]

>>> users = users.select_where(lambda x: x.name in ('Bob', 'Alice'))
>>> users
[User(id=1, name='Bob'), User(id=2, name='Alice')]

Source code in src/plankapy/v1/models.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
def select_where(self, predicate: Callable[[M], bool]) -> QueryableList[M]:
    """Select objects from the list that match a function

    Args:
        predicate: A function that takes an object and returns a boolean

    Returns:
        QueryableList[M]: The objects that match the function

    Example:
    ```python
    >>> users = QueryableList(project.users)
    >>> users
    [User(id=1, name='Bob'), User(id=2, name='Alice'), User(id=3, name='Frank')]

    >>> users = users.select_where(lambda x: x.name in ('Bob', 'Alice'))
    >>> users
    [User(id=1, name='Bob'), User(id=2, name='Alice')]
    ```
    """
    return QueryableList(item for item in self if predicate(item))

take

take(n: int) -> QueryableList[M]

Take the first n objects from the list

PARAMETER DESCRIPTION

n

The number of objects to take

TYPE: int

RETURNS DESCRIPTION
QueryableList[M]

QueryableList[M]: The first n objects in the list, if n is greater than the length of the list, the list is padded with None

Example:

>>> users = QueryableList(project.users)
>>> users.take(2)
[User(name='Alice'), User(name='Bob')]

>>> users.take(3)
[User(name='Alice'), User(name='Bob'), None]

Source code in src/plankapy/v1/models.py
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
def take(self, n: int) -> QueryableList[M]:
    """Take the first n objects from the list

    Args:
        n (int): The number of objects to take

    Returns:
        QueryableList[M]: The first n objects in the list, if n is greater than the length of the list, the list is padded with `None`

    Example:
    ```python
    >>> users = QueryableList(project.users)
    >>> users.take(2)
    [User(name='Alice'), User(name='Bob')]

    >>> users.take(3)
    [User(name='Alice'), User(name='Bob'), None]
    ```
    """
    if n > len(self):
        return self + [None] * (n - len(self))
    return self[:n]

Stopwatch dataclass

Stopwatch(_card: Card_ | None = Unset, startedAt: str | None = Unset, total: int | None = Unset)

Bases: Model

Stopwatch Model

Note

The stopwatch model is not a regular interface and instead is dynamically generated on Access through the Card .stopwatch attribute. There is an override that intercepts __getitem__ to return a Stopwatch.

All Stopwatch methods directly update the .stopwatch attribute of the linked Card instance.

ATTRIBUTE DESCRIPTION
startedAt

The start date of the stopwatch

TYPE: datetime

total

The total time of the stopwatch (in seconds)

TYPE: int

_card

The card the stopwatch is associated with (Managed by the Card class)

TYPE: 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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

set

Set an amount of time for the stopwatch

start

Starts the stopwatch

start_time

Returns the datetime the stopwatch was started

stop

Stops the stopwatch

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

set

set(hours: int = 0, minutes: int = 0, seconds: int = 0) -> None

Set an amount of time for the stopwatch

PARAMETER DESCRIPTION

hours

Hours to set

TYPE: int DEFAULT: 0

minutes

Minutes to set

TYPE: int DEFAULT: 0

seconds

Seconds to set

TYPE: int DEFAULT: 0

Source code in src/plankapy/v1/models.py
674
675
676
677
678
679
680
681
682
683
684
def set(self, hours: int=0, minutes: int=0, seconds: int=0) -> None:
    """Set an amount of time for the stopwatch

    Args:
        hours (int): Hours to set
        minutes (int): Minutes to set
        seconds (int): Seconds to set
    """
    self.total = (hours * 3600) + (minutes * 60) + seconds
    with self._card.editor():
        self._card.stopwatch = self

start

start() -> None

Starts the stopwatch

Source code in src/plankapy/v1/models.py
652
653
654
655
656
657
658
659
def start(self) -> None:
    """Starts the stopwatch"""
    self.refresh()
    if self.startedAt:
        return
    self.startedAt = datetime.now().isoformat()
    with self._card.editor():
        self._card.stopwatch = self

start_time

start_time() -> datetime

Returns the datetime the stopwatch was started

Source code in src/plankapy/v1/models.py
647
648
649
650
def start_time(self) -> datetime:
    """Returns the datetime the stopwatch was started"""
    self.refresh()
    return datetime.fromisoformat(self.startedAt) if self.startedAt else None

stop

stop() -> None

Stops the stopwatch

Source code in src/plankapy/v1/models.py
661
662
663
664
665
666
667
668
669
670
671
672
def stop(self) -> None:
    """Stops the stopwatch"""
    self.refresh()
    if not self.startedAt:
        return

    now = datetime.now()
    started = datetime.fromisoformat(self.startedAt)
    self.total += int(now.timestamp() - started.timestamp())
    self.startedAt = None
    with self._card.editor():
        self._card.stopwatch = self

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

Task_ dataclass

Task_(id: int | None = Unset, name: str | None = Required, position: int | None = Required, isCompleted: bool = Unset, cardId: int | None = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset)

Bases: Model

Task Model

ATTRIBUTE DESCRIPTION
id

The ID of the task

TYPE: int

name

The name of the task

TYPE: str

position

The position of the task

TYPE: int

isCompleted

The completion status of the task

TYPE: bool

cardId

The ID of the card the task is associated with

TYPE: int

createdAt

The creation date of the task

TYPE: datetime

updatedAt

The last update date of the task

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

User_ dataclass

User_(id: int | None = Unset, name: str | None = Required, username: str | None = Unset, email: str | None = Required, language: str | None = Unset, organization: str | None = Unset, phone: str | None = Unset, avatarUrl: str | None = Unset, isSso: bool | None = Unset, isAdmin: bool = Unset, isDeletionLocked: bool = Unset, isLocked: bool = Unset, isRoleLocked: bool = Unset, isUsernameLocked: bool = Unset, subscribeToOwnCards: bool = Unset, createdAt: str | None = Unset, updatedAt: str | None = Unset, deletedAt: str | None = Unset)

Bases: Model

User Model

ATTRIBUTE DESCRIPTION
id

The ID of the user

TYPE: int

name

The name of the user

TYPE: str

username

The username of the user

TYPE: str

email

The email of the user

TYPE: str

language

The language of the user

TYPE: str

organization

The organization of the user

TYPE: str

phone

The phone of the user

TYPE: str

avatarUrl

The avatar URL of the user

TYPE: str

isSso

The SSO status of the user

TYPE: bool

isAdmin

The admin status of the user

TYPE: bool

isDeletionLocked

The deletion lock status of the user

TYPE: bool

isLocked

The lock status of the user

TYPE: bool

isRoleLocked

The role lock status of the user

TYPE: bool

isUsernameLocked

The username lock status of the user

TYPE: bool

subscribeToOwnCards

The subscription status of the user

TYPE: bool

createdAt

The creation date of the user

TYPE: datetime

updatedAt

The last update date of the user

TYPE: datetime

deletedAt

The deletion date of the user

TYPE: datetime

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 (dict, set)

__iter__

Iterate over public, assigned model attribute names

bind

Bind routes to the model

delete

Delete the model instance

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

"Refresh the model instance

update

Update the model instance

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: 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: str | None

routes property writable

routes: Routes

Get the routes for the model instance

RETURNS DESCRIPTION
Routes

The routes bound to the model instance

TYPE: Routes

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: str

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__

__eq__(other: Model) -> bool

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

other

The other model instance to compare

TYPE: Model

RETURNS DESCRIPTION
bool

True if the model instances are equal, False otherwise

TYPE: bool

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
def __eq__(self, other: Model) -> bool:
    """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.

    Args:
        other (Model): The other model instance to compare

    Returns:
        bool: True if the model instances are equal, False otherwise
    """
    return isinstance(other, self.__class__) and hash(self) == hash(other)

__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
def __getitem__(self, 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:
        ```python
        print(model['name'])
        >>> "Model Name"

        model.name = Unset
        print(model['name'])
        >>> None
        ```
    """
    val = self.__dict__[key]
    return val if val is not Unset else None

__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: int

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
def __hash__(self) -> 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:
        int: The hash value of the model instance

    Example:
        ```python
        board_map = {
            Board(name="Board 1"): board.,
            Board(name="Board 2"): "Board 2"
        }
        >>> 1
        ```
    """
    if hasattr(self, 'id'):
        return int(self.id)

    # Default hash if no id (string of name and attributes)
    return hash(f"{self.__class__.__name__}{self.__dict__}")

__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}
Notice how only the assigned values are returned after unpacking and any Unset or private attributes are skipped, This allows 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
def __iter__(self):
    """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:
            ```python
            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}
            ```
        Notice how only the assigned values are returned after unpacking and any Unset or 
        private attributes are skipped, This allows `None` values to be assigned during
        a `PATCH` request to delete data 

    Note:
        Skips attributes that are `Unset` or start with an underscore

    Returns:
        Iterator: The iterator of the model attributes

    Example:
        ```python

        # 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
        ```
    """
    return iter(
        k for k, v in self.__dict__.items() 
        if v is not Unset 
        and not k.startswith("_")
    )

bind

bind(routes: Routes) -> Self

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
def bind(self, routes: Routes) -> Self:
    """Bind routes to the model
    Args:
        routes (Routes): The routes to bind to the model instance

    Returns:
        Self for chain operations

    Example:
        ```python
        model = Model(**kwargs).bind(routes)
        ```
    """
    self.routes = routes
    return self

delete

delete()

Delete the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
313
314
315
316
317
318
def delete(self): 
    """Delete the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

editor

editor() -> Generator[Self, None, None]

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
@contextmanager
def editor(self) -> Generator[Self, None, None]:
    """Context manager for editing the model

    Example:
        ```python
        print(model.name)
        >>> "Old Name"
        with model.editor() as m:
            m.name = "New Name"
            m.position = 1

        print(model.name)
        >>> "New Name"
        ```

    """
    try:
        self.refresh()
        _self = self.__dict__.copy() # Backup the model state
        yield self
    except Exception as e:
        self.__dict__ = _self # Restore the model state
        raise e
    finally:
        self.update()

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
def json(self) -> 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:
        (str) : A JSON string with the Model attributes
    """
    return json.dumps({k: self[k] for k in self})

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 pickle.dump

Source code in src/plankapy/v1/models.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def pickle(self) -> 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:
        (bytes) : Raw bytes generated by `pickle.dump`
    """
    out = io.BufferedWriter(raw=io.BytesIO())
    pickle.dump(self, out)
    return out.raw.read()

refresh

refresh()

"Refresh the model instance Note: Method is implemented in the child classes, but is not required

Source code in src/plankapy/v1/models.py
306
307
308
309
310
311
def refresh(self): 
    """"Refresh the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...

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
def update(self): 
    """Update the model instance
    Note:
        Method is implemented in the child classes, but is not required
    """
    ...