-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathactivityevent.py
More file actions
73 lines (57 loc) · 2.67 KB
/
activityevent.py
File metadata and controls
73 lines (57 loc) · 2.67 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
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .activityeventparams import ActivityEventParams, ActivityEventParamsTypedDict
from datetime import datetime
from enum import Enum
from glean.api_client.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
class ActivityEventAction(str, Enum):
r"""The type of activity this represents."""
# Represents a visit to the given `url`.
VIEW = "VIEW"
# Represents an edit of the document represented by the `url`.
EDIT = "EDIT"
# Represents a search performed at the given `url`.
SEARCH = "SEARCH"
# Represents a comment on the document represented by the `url`.
COMMENT = "COMMENT"
# Represents an explicit request to index the given `url` along with associated attributes in this payload.
CRAWL = "CRAWL"
# Represents a search performed at the given `url` as indicated by the user's history.
HISTORICAL_SEARCH = "HISTORICAL_SEARCH"
# Represents a visit to the given `url` as indicated by the user's history.
HISTORICAL_VIEW = "HISTORICAL_VIEW"
class ActivityEventTypedDict(TypedDict):
action: ActivityEventAction
r"""The type of activity this represents."""
timestamp: datetime
r"""The ISO 8601 timestamp when the activity began."""
url: str
r"""The URL of the activity."""
id: NotRequired[str]
r"""Universally unique identifier of the event. To allow for reliable retransmission, only the earliest received event of a given UUID is considered valid by the server and subsequent are ignored."""
params: NotRequired[ActivityEventParamsTypedDict]
class ActivityEvent(BaseModel):
action: ActivityEventAction
r"""The type of activity this represents."""
timestamp: datetime
r"""The ISO 8601 timestamp when the activity began."""
url: str
r"""The URL of the activity."""
id: Optional[str] = None
r"""Universally unique identifier of the event. To allow for reliable retransmission, only the earliest received event of a given UUID is considered valid by the server and subsequent are ignored."""
params: Optional[ActivityEventParams] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["id", "params"])
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m