|
1 | 1 | import uuid |
2 | 2 | from enum import Enum |
| 3 | +import json |
3 | 4 | from typing import Any, Dict, List, Optional, Union |
4 | 5 |
|
5 | 6 | from .calls import make_request |
|
11 | 12 | BugoutJournalEntry, |
12 | 13 | BugoutJournalEntryContent, |
13 | 14 | BugoutJournalEntryTags, |
| 15 | + BugoutJournalEntriesTagsRequest, |
14 | 16 | BugoutJournalPermissions, |
15 | 17 | BugoutJournals, |
16 | 18 | BugoutJournalScopeSpecs, |
@@ -464,6 +466,29 @@ def create_tags( |
464 | 466 | ) |
465 | 467 | return result |
466 | 468 |
|
| 469 | + def create_entries_tags( |
| 470 | + self, |
| 471 | + token: Union[str, uuid.UUID], |
| 472 | + journal_id: Union[str, uuid.UUID], |
| 473 | + entries_tags: BugoutJournalEntriesTagsRequest, |
| 474 | + auth_type: AuthType = AuthType.bearer, |
| 475 | + **kwargs: Dict[str, Any], |
| 476 | + ) -> BugoutJournalEntries: |
| 477 | + tags_path = f"journals/{journal_id}/bulk_entries_tags" |
| 478 | + headers = { |
| 479 | + "Authorization": f"{auth_type.value} {token}", |
| 480 | + } |
| 481 | + json_body = json.loads(entries_tags.json()) |
| 482 | + if "headers" in kwargs.keys(): |
| 483 | + headers.update(kwargs["headers"]) |
| 484 | + result = self._call( |
| 485 | + method=Method.post, path=tags_path, headers=headers, json=json_body |
| 486 | + ) |
| 487 | + |
| 488 | + return BugoutJournalEntries( |
| 489 | + entries=[BugoutJournalEntry(**entry) for entry in result] |
| 490 | + ) |
| 491 | + |
467 | 492 | def get_tags( |
468 | 493 | self, |
469 | 494 | token: Union[str, uuid.UUID], |
@@ -523,6 +548,29 @@ def delete_tag( |
523 | 548 | ) |
524 | 549 | return BugoutJournalEntryTags(**result) |
525 | 550 |
|
| 551 | + def delete_entries_tags( |
| 552 | + self, |
| 553 | + token: Union[str, uuid.UUID], |
| 554 | + journal_id: Union[str, uuid.UUID], |
| 555 | + entries_tags: BugoutJournalEntriesTagsRequest, |
| 556 | + auth_type: AuthType = AuthType.bearer, |
| 557 | + **kwargs: Dict[str, Any], |
| 558 | + ) -> BugoutJournalEntries: |
| 559 | + tags_path = f"journals/{journal_id}/bulk_entries_tags" |
| 560 | + headers = { |
| 561 | + "Authorization": f"{auth_type.value} {token}", |
| 562 | + } |
| 563 | + json_body = json.loads(entries_tags.json()) |
| 564 | + if "headers" in kwargs.keys(): |
| 565 | + headers.update(kwargs["headers"]) |
| 566 | + result = self._call( |
| 567 | + method=Method.delete, path=tags_path, headers=headers, json=json_body |
| 568 | + ) |
| 569 | + |
| 570 | + return BugoutJournalEntries( |
| 571 | + entries=[BugoutJournalEntry(**entry) for entry in result] |
| 572 | + ) |
| 573 | + |
526 | 574 | # Search module |
527 | 575 | def search( |
528 | 576 | self, |
|
0 commit comments