Skip to content

Commit 5ad8cbe

Browse files
author
Andrey
committed
Add working version.
1 parent 180ecbe commit 5ad8cbe

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

bugout/app.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,9 @@ def create_entries_tags(
762762
timeout: float = REQUESTS_TIMEOUT,
763763
auth_type: str = data.AuthType.bearer.name,
764764
**kwargs: Dict[str, Any],
765-
) -> List[Any]:
765+
) -> data.BugoutJournalEntries:
766766
self.journal.timeout = timeout
767+
767768
entries_tags_obj = data.BugoutJournalEntriesTagsRequest(
768769
entries_tags=[
769770
data.BugoutJournalEntryTagsRequest(**entry_tags)
@@ -836,6 +837,30 @@ def delete_tag(
836837
**kwargs,
837838
)
838839

840+
def delete_entries_tags(
841+
self,
842+
token: Union[str, uuid.UUID],
843+
journal_id: Union[str, uuid.UUID],
844+
entries_tags: List[Dict[str, Any]],
845+
timeout: float = REQUESTS_TIMEOUT,
846+
auth_type: str = data.AuthType.bearer.name,
847+
**kwargs: Dict[str, Any],
848+
) -> data.BugoutJournalEntries:
849+
self.journal.timeout = timeout
850+
entries_tags_obj = data.BugoutJournalEntriesTagsRequest(
851+
entries_tags=[
852+
data.BugoutJournalEntryTagsRequest(**entry_tags)
853+
for entry_tags in entries_tags
854+
]
855+
)
856+
return self.journal.delete_entries_tags(
857+
token=token,
858+
journal_id=journal_id,
859+
entries_tags=entries_tags_obj,
860+
auth_type=data.AuthType[auth_type],
861+
**kwargs,
862+
)
863+
839864
# Search
840865
def search(
841866
self,

bugout/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class BugoutJournalEntryTagsRequest(BaseModel):
221221

222222

223223
class BugoutJournalEntriesTagsRequest(BaseModel):
224-
entries_tags: List[BugoutJournalEntryTags] = Field(default_factory=list)
224+
entries_tags: List[BugoutJournalEntryTagsRequest] = Field(default_factory=list)
225225

226226

227227
class BugoutSearchResult(BaseModel):

bugout/journal.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,15 @@ def create_entries_tags(
472472
entries_tags: BugoutJournalEntriesTagsRequest,
473473
auth_type: AuthType = AuthType.bearer,
474474
**kwargs: Dict[str, Any],
475-
) -> List[Any]:
475+
) -> BugoutJournalEntries:
476476
tags_path = f"journals/{journal_id}/bulk_entries_tags"
477477
headers = {
478478
"Authorization": f"{auth_type.value} {token}",
479479
}
480480
json = {
481481
"entries": [
482482
{
483-
"entry_id": entry.entry_id,
483+
"journal_entry_id": str(entry.entry_id),
484484
"tags": entry.tags,
485485
}
486486
for entry in entries_tags.entries_tags
@@ -491,7 +491,10 @@ def create_entries_tags(
491491
result = self._call(
492492
method=Method.post, path=tags_path, headers=headers, json=json
493493
)
494-
return result
494+
495+
return BugoutJournalEntries(
496+
entries=[BugoutJournalEntry(**entry) for entry in result]
497+
)
495498

496499
def get_tags(
497500
self,
@@ -559,15 +562,15 @@ def delete_entries_tags(
559562
entries_tags: BugoutJournalEntriesTagsRequest,
560563
auth_type: AuthType = AuthType.bearer,
561564
**kwargs: Dict[str, Any],
562-
) -> List[Any]:
565+
) -> BugoutJournalEntries:
563566
tags_path = f"journals/{journal_id}/bulk_entries_tags"
564567
headers = {
565568
"Authorization": f"{auth_type.value} {token}",
566569
}
567570
json = {
568571
"entries": [
569572
{
570-
"entry_id": entry.entry_id,
573+
"journal_entry_id": str(entry.entry_id),
571574
"tags": entry.tags,
572575
}
573576
for entry in entries_tags.entries_tags
@@ -578,7 +581,10 @@ def delete_entries_tags(
578581
result = self._call(
579582
method=Method.delete, path=tags_path, headers=headers, json=json
580583
)
581-
return result
584+
585+
return BugoutJournalEntries(
586+
entries=[BugoutJournalEntry(**entry) for entry in result]
587+
)
582588

583589
# Search module
584590
def search(

0 commit comments

Comments
 (0)