Skip to content

Commit e45589e

Browse files
authored
Merge pull request #52 from bugout-dev/search-entity
Search entity representation
2 parents 1c3e5da + 6d85e76 commit e45589e

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

bugout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
__email__ = "[email protected]"
99
__license__ = "MIT"
10-
__version__ = "0.2.11"
10+
__version__ = "0.2.12"
1111

1212
__all__ = (
1313
"__author__",

bugout/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,9 @@ def search(
10351035
content: bool = True,
10361036
timeout: float = REQUESTS_TIMEOUT,
10371037
order: SearchOrder = SearchOrder.DESCENDING,
1038+
representation: Union[
1039+
str, data.EntryRepresentationTypes
1040+
] = data.EntryRepresentationTypes.ENTRY,
10381041
auth_type: str = data.AuthType.bearer.name,
10391042
**kwargs: Dict[str, Any],
10401043
) -> data.BugoutSearchResults:
@@ -1048,6 +1051,7 @@ def search(
10481051
offset,
10491052
content,
10501053
order=order,
1054+
representation=data.EntryRepresentationTypes(representation),
10511055
auth_type=data.AuthType[auth_type],
10521056
**kwargs,
10531057
)

bugout/data.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,6 @@ class BugoutSearchResult(BaseModel):
272272
context_id: Optional[str] = None
273273

274274

275-
class BugoutSearchResults(BaseModel):
276-
total_results: int
277-
offset: int
278-
next_offset: Optional[int]
279-
max_score: float
280-
results: List[BugoutSearchResult]
281-
282-
283275
class BugoutHumbugIntegration(BaseModel):
284276
id: uuid.UUID
285277
group_id: uuid.UUID
@@ -338,3 +330,26 @@ class BugoutJournalEntity(BaseModel):
338330

339331
class BugoutJournalEntities(BaseModel):
340332
entities: List[BugoutJournalEntity] = Field(default_factory=list)
333+
334+
335+
class BugoutSearchResultAsEntity(BaseModel):
336+
journal_id: str
337+
entity_url: str
338+
title: str
339+
address: Optional[str] = None
340+
blockchain: Optional[str] = None
341+
required_fields: List[Dict[str, Any]] = Field(default_factory=list)
342+
secondary_fields: Dict[str, Any] = Field(default_factory=dict)
343+
created_at: str
344+
updated_at: str
345+
score: float
346+
347+
348+
class BugoutSearchResults(BaseModel):
349+
total_results: int
350+
offset: int
351+
next_offset: Optional[int]
352+
max_score: float
353+
results: List[Union[BugoutSearchResult, BugoutSearchResultAsEntity]] = Field(
354+
default_factory=list
355+
)

bugout/journal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
BugoutJournalScopeSpecs,
2222
BugoutScopes,
2323
BugoutSearchResults,
24+
EntryRepresentationTypes,
2425
HolderType,
2526
JournalTypes,
2627
Method,
@@ -729,6 +730,7 @@ def search(
729730
offset: int = 0,
730731
content: bool = True,
731732
order: SearchOrder = SearchOrder.DESCENDING,
733+
representation: EntryRepresentationTypes = EntryRepresentationTypes.ENTRY,
732734
auth_type: AuthType = AuthType.bearer,
733735
**kwargs: Dict[str, Any],
734736
) -> BugoutSearchResults:
@@ -745,6 +747,7 @@ def search(
745747
"offset": offset,
746748
"content": content,
747749
"order": order.value,
750+
"representation": representation.value,
748751
}
749752
result = self._call(
750753
method=Method.get, path=search_path, params=query_params, headers=headers

0 commit comments

Comments
 (0)