-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfeedentry.py
More file actions
277 lines (229 loc) · 10 KB
/
feedentry.py
File metadata and controls
277 lines (229 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .announcement import Announcement, AnnouncementTypedDict
from .appresult import AppResult, AppResultTypedDict
from .calendarevent import CalendarEvent, CalendarEventTypedDict
from .chatsuggestion import ChatSuggestion, ChatSuggestionTypedDict
from .collection import Collection, CollectionTypedDict
from .collectionitem import CollectionItem, CollectionItemTypedDict
from .countinfo import CountInfo, CountInfoTypedDict
from .digest import Digest, DigestTypedDict
from .displayablelistitemuiconfig import (
DisplayableListItemUIConfig,
DisplayableListItemUIConfigTypedDict,
)
from .document import Document, DocumentTypedDict
from .person import Person, PersonTypedDict
from .prompttemplateresult import PromptTemplateResult, PromptTemplateResultTypedDict
from .thumbnail import Thumbnail, ThumbnailTypedDict
from .useractivity import UserActivity, UserActivityTypedDict
from .workflowresult import WorkflowResult, WorkflowResultTypedDict
from enum import Enum
from glean.api_client import models, utils
from glean.api_client.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import field_serializer, model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
class Format(str, Enum):
r"""defines how to render this particular displayable list card"""
LIST = "LIST"
class UIConfigTypedDict(TypedDict):
format_: NotRequired[Format]
r"""defines how to render this particular displayable list card"""
additional_flags: NotRequired[DisplayableListItemUIConfigTypedDict]
r"""UI configurations for each item of the list"""
class UIConfig(BaseModel):
format_: Annotated[Optional[Format], pydantic.Field(alias="format")] = None
r"""defines how to render this particular displayable list card"""
additional_flags: Annotated[
Optional[DisplayableListItemUIConfig], pydantic.Field(alias="additionalFlags")
] = None
r"""UI configurations for each item of the list"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["format", "additionalFlags"])
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
class JustificationType(str, Enum, metaclass=utils.OpenEnumMeta):
r"""Type of the justification."""
FREQUENTLY_ACCESSED = "FREQUENTLY_ACCESSED"
RECENTLY_ACCESSED = "RECENTLY_ACCESSED"
TRENDING_DOCUMENT = "TRENDING_DOCUMENT"
VERIFICATION_REMINDER = "VERIFICATION_REMINDER"
SUGGESTED_DOCUMENT = "SUGGESTED_DOCUMENT"
EMPTY_STATE_SUGGESTION = "EMPTY_STATE_SUGGESTION"
FRECENCY_SCORED = "FRECENCY_SCORED"
SERVER_GENERATED = "SERVER_GENERATED"
USE_CASE = "USE_CASE"
UPDATE_SINCE_LAST_VIEW = "UPDATE_SINCE_LAST_VIEW"
RECENTLY_STARTED = "RECENTLY_STARTED"
EVENT = "EVENT"
USER_MENTION = "USER_MENTION"
ANNOUNCEMENT = "ANNOUNCEMENT"
EXTERNAL_ANNOUNCEMENT = "EXTERNAL_ANNOUNCEMENT"
POPULARITY_BASED_TRENDING = "POPULARITY_BASED_TRENDING"
COMPANY_RESOURCE = "COMPANY_RESOURCE"
EVENT_DOCUMENT_FROM_CONTENT = "EVENT_DOCUMENT_FROM_CONTENT"
EVENT_DOCUMENT_FROM_SEARCH = "EVENT_DOCUMENT_FROM_SEARCH"
VISIT_AFFINITY_SCORED = "VISIT_AFFINITY_SCORED"
SUGGESTED_APP = "SUGGESTED_APP"
SUGGESTED_PERSON = "SUGGESTED_PERSON"
ACTIVITY_HIGHLIGHT = "ACTIVITY_HIGHLIGHT"
SAVED_SEARCH = "SAVED_SEARCH"
SUGGESTED_CHANNEL = "SUGGESTED_CHANNEL"
PEOPLE_CELEBRATIONS = "PEOPLE_CELEBRATIONS"
SOCIAL_LINK = "SOCIAL_LINK"
ZERO_STATE_CHAT_SUGGESTION = "ZERO_STATE_CHAT_SUGGESTION"
ZERO_STATE_CHAT_TOOL_SUGGESTION = "ZERO_STATE_CHAT_TOOL_SUGGESTION"
ZERO_STATE_PROMPT_TEMPLATE_SUGGESTION = "ZERO_STATE_PROMPT_TEMPLATE_SUGGESTION"
ZERO_STATE_STATIC_WORKFLOW_SUGGESTION = "ZERO_STATE_STATIC_WORKFLOW_SUGGESTION"
ZERO_STATE_AGENT_SUGGESTION = "ZERO_STATE_AGENT_SUGGESTION"
PERSONALIZED_CHAT_SUGGESTION = "PERSONALIZED_CHAT_SUGGESTION"
DAILY_DIGEST = "DAILY_DIGEST"
TASK = "TASK"
PLAN_MY_DAY = "PLAN_MY_DAY"
END_MY_DAY = "END_MY_DAY"
STARTER_KIT_EXTENSION = "STARTER_KIT_EXTENSION"
STARTER_KIT_ORG_CHART = "STARTER_KIT_ORG_CHART"
STARTER_KIT_ADD_DOC = "STARTER_KIT_ADD_DOC"
MEETING_RECAP = "MEETING_RECAP"
ACTIVE_DISCUSSION = "ACTIVE_DISCUSSION"
MID_DAY_CATCH_UP = "MID_DAY_CATCH_UP"
QUERY_SUGGESTION = "QUERY_SUGGESTION"
WEEKLY_MEETINGS = "WEEKLY_MEETINGS"
FOLLOW_UP = "FOLLOW_UP"
MILESTONE_TIMELINE_CHECK = "MILESTONE_TIMELINE_CHECK"
PROJECT_DISCUSSION_DIGEST = "PROJECT_DISCUSSION_DIGEST"
PROJECT_NEXT_STEP = "PROJECT_NEXT_STEP"
class FeedEntryTypedDict(TypedDict):
title: str
r"""Title for the result. Can be document title, event title and so on."""
entry_id: NotRequired[str]
r"""optional ID associated with a single feed entry (displayable_list_id)"""
thumbnail: NotRequired[ThumbnailTypedDict]
created_by: NotRequired[PersonTypedDict]
ui_config: NotRequired[UIConfigTypedDict]
justification_type: NotRequired[JustificationType]
r"""Type of the justification."""
justification: NotRequired[str]
r"""Server side generated justification string if server provides one."""
tracking_token: NotRequired[str]
r"""An opaque token that represents this particular feed entry in this particular response. To be used for /feedback reporting."""
view_url: NotRequired[str]
r"""View URL for the entry if based on links that are not documents in Glean."""
document: NotRequired[DocumentTypedDict]
event: NotRequired[CalendarEventTypedDict]
announcement: NotRequired[AnnouncementTypedDict]
digest: NotRequired[DigestTypedDict]
collection: NotRequired[CollectionTypedDict]
collection_item: NotRequired[CollectionItemTypedDict]
person: NotRequired[PersonTypedDict]
app: NotRequired[AppResultTypedDict]
chat_suggestion: NotRequired[ChatSuggestionTypedDict]
prompt_template: NotRequired[PromptTemplateResultTypedDict]
workflow: NotRequired[WorkflowResultTypedDict]
activities: NotRequired[List[UserActivityTypedDict]]
r"""List of activity where each activity has user, action, timestamp."""
document_visitor_count: NotRequired[CountInfoTypedDict]
class FeedEntry(BaseModel):
title: str
r"""Title for the result. Can be document title, event title and so on."""
entry_id: Annotated[Optional[str], pydantic.Field(alias="entryId")] = None
r"""optional ID associated with a single feed entry (displayable_list_id)"""
thumbnail: Optional[Thumbnail] = None
created_by: Annotated[Optional[Person], pydantic.Field(alias="createdBy")] = None
ui_config: Annotated[Optional[UIConfig], pydantic.Field(alias="uiConfig")] = None
justification_type: Annotated[
Optional[JustificationType], pydantic.Field(alias="justificationType")
] = None
r"""Type of the justification."""
justification: Optional[str] = None
r"""Server side generated justification string if server provides one."""
tracking_token: Annotated[Optional[str], pydantic.Field(alias="trackingToken")] = (
None
)
r"""An opaque token that represents this particular feed entry in this particular response. To be used for /feedback reporting."""
view_url: Annotated[Optional[str], pydantic.Field(alias="viewUrl")] = None
r"""View URL for the entry if based on links that are not documents in Glean."""
document: Optional[Document] = None
event: Optional[CalendarEvent] = None
announcement: Optional[Announcement] = None
digest: Optional[Digest] = None
collection: Optional[Collection] = None
collection_item: Annotated[
Optional[CollectionItem], pydantic.Field(alias="collectionItem")
] = None
person: Optional[Person] = None
app: Optional[AppResult] = None
chat_suggestion: Annotated[
Optional[ChatSuggestion], pydantic.Field(alias="chatSuggestion")
] = None
prompt_template: Annotated[
Optional[PromptTemplateResult], pydantic.Field(alias="promptTemplate")
] = None
workflow: Optional[WorkflowResult] = None
activities: Optional[List[UserActivity]] = None
r"""List of activity where each activity has user, action, timestamp."""
document_visitor_count: Annotated[
Optional[CountInfo], pydantic.Field(alias="documentVisitorCount")
] = None
@field_serializer("justification_type")
def serialize_justification_type(self, value):
if isinstance(value, str):
try:
return models.JustificationType(value)
except ValueError:
return value
return value
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(
[
"entryId",
"thumbnail",
"createdBy",
"uiConfig",
"justificationType",
"justification",
"trackingToken",
"viewUrl",
"document",
"event",
"announcement",
"digest",
"collection",
"collectionItem",
"person",
"app",
"chatSuggestion",
"promptTemplate",
"workflow",
"activities",
"documentVisitorCount",
]
)
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
try:
UIConfig.model_rebuild()
except NameError:
pass
try:
FeedEntry.model_rebuild()
except NameError:
pass