11from enum import Enum
2- from typing import Any , List , Optional , Union
2+ from typing import Any , Dict , List , Optional , Union
33import uuid
44
55from .calls import make_request
@@ -28,6 +28,21 @@ class SearchOrder(Enum):
2828 DESCENDING = "desc"
2929
3030
31+ class TagsAction (Enum ):
32+ """
33+ tags_action query parameter for PUT /{journal_id}/entries/{entry_id} requests.
34+ See Spire API implementation of that endpoint for more details:
35+ https://github.com/bugout-dev/spire/blob/cc748d45d0aa7e3350105810449ff4c14fa64ec9/spire/journal/api.py#L1249
36+
37+ Corresponds to EntryUpdateTagActions enum in Spire:
38+ https://github.com/bugout-dev/spire/blob/cc748d45d0aa7e3350105810449ff4c14fa64ec9/spire/journal/data.py#L32
39+ """
40+
41+ ignore = "ignore"
42+ replace = "replace"
43+ merge = "merge"
44+
45+
3146class Journal :
3247 """
3348 Represent a journal from Bugout.
@@ -301,12 +316,18 @@ def update_entry_content(
301316 entry_id : Union [str , uuid .UUID ],
302317 title : str ,
303318 content : str ,
319+ tags : Optional [List [str ]] = None ,
320+ tags_action : TagsAction = TagsAction .merge ,
304321 ) -> BugoutJournalEntryContent :
305322 entry_id_content_path = f"journals/{ journal_id } /entries/{ entry_id } /content"
306- json = {
323+ params : Dict [str , str ] = {}
324+ json : Dict [str , Any ] = {
307325 "title" : title ,
308326 "content" : content ,
309327 }
328+ if tags is not None :
329+ json ["tags" ] = tags
330+ params ["tags_action" ] = tags_action .value
310331 headers = {
311332 "Authorization" : f"Bearer { token } " ,
312333 }
@@ -315,6 +336,7 @@ def update_entry_content(
315336 path = entry_id_content_path ,
316337 headers = headers ,
317338 json = json ,
339+ params = params ,
318340 )
319341 return BugoutJournalEntryContent (** result )
320342
0 commit comments