Skip to content

Commit 1babb09

Browse files
committed
Create and touch journal entry endpoints
1 parent d4ba790 commit 1babb09

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

bugout/app.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,42 @@ def get_public_journal_entries(
878878
self.journal.timeout = timeout
879879
return self.journal.get_public_journal_entries(journal_id=journal_id, **kwargs)
880880

881+
def create_public_journal_entry(
882+
self,
883+
journal_id: Union[str, uuid.UUID],
884+
title: str,
885+
content: str,
886+
tags: List[str] = [],
887+
context_url: Optional[str] = None,
888+
context_id: Optional[str] = None,
889+
context_type: Optional[str] = None,
890+
timeout: float = REQUESTS_TIMEOUT,
891+
**kwargs: Dict[str, Any],
892+
) -> data.BugoutJournalEntry:
893+
self.journal.timeout = timeout
894+
return self.journal.create_public_journal_entry(
895+
journal_id=journal_id,
896+
title=title,
897+
content=content,
898+
tags=tags,
899+
context_url=context_url,
900+
context_id=context_id,
901+
context_type=context_type,
902+
**kwargs,
903+
)
904+
905+
def touch_public_journal_entry(
906+
self,
907+
journal_id: Union[str, uuid.UUID],
908+
entry_id: Union[str, uuid.UUID],
909+
timeout: float = REQUESTS_TIMEOUT,
910+
**kwargs: Dict[str, Any],
911+
) -> List[str]:
912+
self.journal.timeout = timeout
913+
return self.journal.touch_public_journal_entry(
914+
journal_id=journal_id, entry_id=entry_id, **kwargs
915+
)
916+
881917
def get_public_journal_entry(
882918
self,
883919
journal_id: Union[str, uuid.UUID],

bugout/journal.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,51 @@ def get_public_journal_entries(
619619
)
620620
return BugoutJournalEntries(**result)
621621

622+
def create_public_journal_entry(
623+
self,
624+
journal_id: Union[str, uuid.UUID],
625+
title: str,
626+
content: str,
627+
tags: List[str] = [],
628+
context_url: Optional[str] = None,
629+
context_id: Optional[str] = None,
630+
context_type: Optional[str] = None,
631+
**kwargs: Dict[str, Any],
632+
) -> BugoutJournalEntry:
633+
entry_path = f"public/{journal_id}/entries"
634+
json = {
635+
"title": title,
636+
"content": content,
637+
"tags": tags,
638+
"context_url": context_url,
639+
"context_id": context_id,
640+
"context_type": context_type,
641+
}
642+
headers = {}
643+
if "headers" in kwargs.keys():
644+
headers.update(kwargs["headers"])
645+
result = self._call(
646+
method=Method.post, path=entry_path, headers=headers, json=json
647+
)
648+
return BugoutJournalEntry(**result)
649+
650+
def touch_public_journal_entry(
651+
self,
652+
journal_id: Union[str, uuid.UUID],
653+
entry_id: Union[str, uuid.UUID],
654+
**kwargs: Dict[str, Any],
655+
) -> List[str]:
656+
public_journal_path = f"public/{journal_id}/entries/{entry_id}"
657+
headers = {}
658+
if "headers" in kwargs.keys():
659+
headers.update(kwargs["headers"])
660+
result = self._call(
661+
method=Method.put,
662+
path=public_journal_path,
663+
headers=headers,
664+
)
665+
return result
666+
622667
def get_public_journal_entry(
623668
self,
624669
journal_id: Union[str, uuid.UUID],

0 commit comments

Comments
 (0)