Skip to content

Deck

Warning

scooze decks are still under construction...

scooze.routers.deck

deck_root() -> DeckModel async

Get a random deck from the database.

Returns:

Type Description
DeckModel

A random deck from the database.

Raises:

Type Description
HTTPException

404 - No decks found in the database.

add_deck(deck_data: DeckModelData) -> DeckModel async

Add a deck to the database.

Parameters:

Name Type Description Default
deck_data DeckModelData

A dict conforming to DeckModelData's schema.

required

Returns:

Type Description
DeckModel

The created deck.

Raises:

Type Description
HTTPException

400 - Create failed, passes along the error message.

get_deck_by_id(deck_id: PydanticObjectId = Depends(_validate_deck_id)) -> DeckModel async

Get the deck with the given ID.

Parameters:

Name Type Description Default
deck_id PydanticObjectId

The ID of the deck to get

Depends(_validate_deck_id)

Returns:

Type Description
DeckModel

The requested deck.

Raises:

Type Description
HTTPException

404 - Deck wasn't found.

HTTPException

422 - Bad ID given.

update_deck(deck_req: DeckModel, deck_id: PydanticObjectId = Depends(_validate_deck_id)) -> DeckModel async

Update an existing deck with the given scooze ID and payload.

Fields will be updated according to the given payload. If a field is not present in the payload, it will not be updated.

Parameters:

Name Type Description Default
deck_id PydanticObjectId

The ID of the deck to update.

Depends(_validate_deck_id)
deck_req DeckModel

The fields to update.

required

Returns:

Type Description
DeckModel

The updated deck.

Raises:

Type Description
HTTPException

404 - Deck wasn't found, pre-update.

HTTPException

404 - Deck wasn't found, post-update.

HTTPException

422 - Bad ID given.

delete_deck_by_id(deck_id: PydanticObjectId = Depends(_validate_deck_id)) -> JSONResponse async

Delete an existing deck with the given scooze ID.

Parameters:

Name Type Description Default
deck_id PydanticObjectId

The ID of the deck to delete.

Depends(_validate_deck_id)

Returns:

Type Description
JSONResponse

A message that either the deck was deleted or not deleted.

Raises:

Type Description
HTTPException

400 - Deck wasn't deleted.

HTTPException

404 - Deck wasn't found.

HTTPException

422 - Bad ID given.

scooze.routers.decks

decks_root(limit: int = 3) -> list[DeckModel] async

Get random decks from the database.

Parameters:

Name Type Description Default
limit int

The maximum number of decks to get.

3

Returns:

Type Description
list[DeckModel]

Random decks from the database.

Raises:

Type Description
HTTPException

404 - No decks found in the database.

add_decks(decks: list[DeckModelData]) -> JSONResponse async

Add a list of decks to the database.

Parameters:

Name Type Description Default
decks list[DeckModelData]

A list of dicts conforming to DeckModelData's schema.

required

Returns:

Type Description
JSONResponse

A message stating how many decks were created.

Raises:

Type Description
HTTPException

400 - Create failed, passes along the error message.

get_decks_by(property_name: str, values: list[Any], paginated: bool = False, page: int = 1, page_size: int = 10) -> list[DeckModel] async

Get decks where the given property matches any of the given values.

Parameters:

Name Type Description Default
property_name str

The property to check against.

required
values list[Any]

Matching values of the given property.

required
paginated bool

Return paginated results if True, or all matches if False.

False
page int

The page to return matches from.

1
page_size int

The number of results per page.

10

Returns:

Type Description
list[DeckModel]

A list of decks matching the search criteria.

Raises:

Type Description
HTTPException

404 - Decks weren't found.

delete_decks_all() -> JSONResponse async

Deletes all decks in the database.

Returns:

Type Description
JSONResponse

A message that the decks were deleted.

Raises:

Type Description
HTTPException

400 - Decks weren't deleted.