Skip to content

custom_list_entry

Custom list Entry CRUD endpoints.

create_custom_list_entry(*, custom_list_id, entry, current_user)

Create a custom list entry.

Parameters:

Name Type Description Default
entry CustomListEntryModel

The custom list entry to create

required

Returns:

Type Description
CustomListEntryModel

The created custom list entry

Source code in mlte/backend/api/endpoints/custom_list_entry.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@router.post("/{custom_list_id}/entry")
def create_custom_list_entry(
    *,
    custom_list_id: CustomListName,
    entry: CustomListEntryModel,
    current_user: AuthorizedUser,
) -> CustomListEntryModel:
    """
    Create a custom list entry.
    :param entry: The custom list entry to create
    :return: The created custom list entry
    """
    with state_stores.custom_list_stores_session() as custom_list_store:
        try:
            return custom_list_store.custom_list_entry_mapper.create(
                entry, custom_list_id
            )
        except errors.ErrorNotFound as e:
            raise HTTPException(status_code=codes.NOT_FOUND, detail=f"{e}")
        except errors.ErrorAlreadyExists as e:
            raise HTTPException(
                status_code=codes.ALREADY_EXISTS, detail=f"Exists: {e}"
            )
        except Exception as e:
            raise_http_internal_error(e)

delete_custom_list_entry(*, custom_list_id, custom_list_entry_id, current_user)

Delete a custom list Entry.

Parameters:

Name Type Description Default
custom_list_entry_id str

The entry id to delete

required

Returns:

Type Description
CustomListEntryModel

The deleted entry

Source code in mlte/backend/api/endpoints/custom_list_entry.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@router.delete("/{custom_list_id}/entry/{custom_list_entry_id}")
def delete_custom_list_entry(
    *,
    custom_list_id: CustomListName,
    custom_list_entry_id: str,
    current_user: AuthorizedUser,
) -> CustomListEntryModel:
    """
    Delete a custom list Entry.
    :param custom_list_entry_id: The entry id to delete
    :return: The deleted entry
    """
    with state_stores.custom_list_stores_session() as custom_list_store:
        try:
            return custom_list_store.custom_list_entry_mapper.delete(
                custom_list_entry_id, custom_list_id
            )
        except errors.ErrorNotFound as e:
            raise HTTPException(
                status_code=codes.NOT_FOUND, detail=f"{e} not found."
            )
        except Exception as e:
            raise_http_internal_error(e)

edit_custom_list_entry(*, custom_list_id, entry, current_user)

Edit a custom list entry.

Parameters:

Name Type Description Default
entry CustomListEntryModel

The custom list entry to edit

required

Returns:

Type Description
CustomListEntryModel

The edited custom list entry

Source code in mlte/backend/api/endpoints/custom_list_entry.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@router.put("/{custom_list_id}/entry")
def edit_custom_list_entry(
    *,
    custom_list_id: CustomListName,
    entry: CustomListEntryModel,
    current_user: AuthorizedUser,
) -> CustomListEntryModel:
    """
    Edit a custom list entry.
    :param entry: The custom list entry to edit
    :return: The edited custom list entry
    """
    with state_stores.custom_list_stores_session() as custom_list_store:
        try:
            return custom_list_store.custom_list_entry_mapper.edit(
                entry, custom_list_id
            )
        except errors.ErrorNotFound as e:
            raise HTTPException(status_code=codes.NOT_FOUND, detail=f"{e}")
        except Exception as e:
            raise_http_internal_error(e)

list_custom_list_details(*, custom_list_id, current_user)

List MLTE custom list, with details for each entry in list.

Returns:

Type Description
List[CustomListEntryModel]

A collection of custom list entries with their details.

Source code in mlte/backend/api/endpoints/custom_list_entry.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@router.get("/{custom_list_id}")
def list_custom_list_details(
    *,
    custom_list_id: CustomListName,
    current_user: AuthorizedUser,
) -> List[CustomListEntryModel]:
    """
    List MLTE custom list, with details for each entry in list.
    :return: A collection of custom list entries with their details.
    """
    with state_stores.custom_list_stores_session() as custom_list_store:
        try:
            return custom_list_store.custom_list_entry_mapper.list_details(
                custom_list_id
            )
        except Exception as e:
            raise_http_internal_error(e)

list_custom_lists(*, current_user)

List MLTE custom lists.

Returns:

Type Description
List[str]

A collection of list names

Source code in mlte/backend/api/endpoints/custom_list_entry.py
70
71
72
73
74
75
76
77
78
79
@router.get("s")
def list_custom_lists(
    *,
    current_user: AuthorizedUser,
) -> List[str]:
    """
    List MLTE custom lists.
    :return: A collection of list names
    """
    return [list_name.value for list_name in CustomListName]

read_custom_list_entry(*, custom_list_id, custom_list_entry_id, current_user)

Read a custom list Entry.

Parameters:

Name Type Description Default
custom_list_entry_id str

The entry id to read

required

Returns:

Type Description
CustomListEntryModel

The read entry

Source code in mlte/backend/api/endpoints/custom_list_entry.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@router.get("/{custom_list_id}/entry/{custom_list_entry_id}")
def read_custom_list_entry(
    *,
    custom_list_id: CustomListName,
    custom_list_entry_id: str,
    current_user: AuthorizedUser,
) -> CustomListEntryModel:
    """
    Read a custom list Entry.
    :param custom_list_entry_id: The entry id to read
    :return: The read entry
    """
    with state_stores.custom_list_stores_session() as custom_list_store:
        try:
            return custom_list_store.custom_list_entry_mapper.read(
                custom_list_entry_id, custom_list_id
            )
        except errors.ErrorNotFound as e:
            raise HTTPException(
                status_code=codes.NOT_FOUND, detail=f"{e} not found."
            )
        except Exception as e:
            raise_http_internal_error(e)