Activities
albert.collections.activities.ActivityCollection
Bases: BaseCollection
Read the Albert activity feed (audit trail) for entities and users.
An Activity is a single logged event in Albert's audit trail, recording an action (such as a read or a write) performed on an entity by a user. The feed is used to answer questions like "what changed on this item and when" or "what has this user done recently". Activities are produced by the platform and are read-only through the SDK; there is no create, update, or delete.
Use get_all to page through the raw feed scoped to a single entity,
user, or date, and search to run a full-text/filtered query across
activity records.
This collection is accessed as client.activities.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for activity requests. |
Methods:
| Name | Description |
|---|---|
get_all |
Page through the activity feed scoped by entity, user, or date. |
search |
Search activity records using full-text and filter criteria. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/activities.py
get_all
get_all(
*,
type: ActivityType,
id: str | None = None,
start_date: date | None = None,
end_date: date | None = None,
operation_id: ActivityOperationId | None = None,
action: ActivityAction | None = WRITE,
order_by: OrderBy | None = DESCENDING,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Activity]
Page through the activity feed scoped by entity, user, or date.
Returns the raw activity records for a single scope, chosen with type:
the events for one entity, one user, one parent entity, one UUID, or a
date/date range. Results are a lazily paginated iterator, so iterating
fetches additional pages on demand. To run a broader full-text or
multi-filter query instead, use search.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
ActivityType
|
Which kind of scope |
required |
id
|
str
|
The identifier of the scope selected by |
None
|
start_date
|
date
|
Only include activities on or after this date. |
None
|
end_date
|
date
|
Only include activities on or before this date. |
None
|
operation_id
|
ActivityOperationId
|
Restrict to a specific logged operation. Applies only to recency
support for SDS/label events. See
|
None
|
action
|
ActivityAction
|
Whether to list read or write activities. Defaults to
|
WRITE
|
order_by
|
OrderBy
|
Sort direction. Defaults to |
DESCENDING
|
start_key
|
str
|
Pagination key of the first record to evaluate; used to resume paging. |
None
|
max_items
|
int
|
Maximum number of records to return in total. If None, iterates over all available records. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Activity]
|
A lazily paginated iterator of activity records. |
Source code in src/albert/collections/activities.py
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 | |
search
search(
*,
text: str | None = None,
sort_by: str | None = None,
order_by: OrderBy | None = None,
operation_id: list[str] | None = None,
user: list[str] | None = None,
user_class: list[str] | None = None,
user_role: list[str] | None = None,
object_id: list[str] | None = None,
object_type: list[str] | None = None,
object_class: list[str] | None = None,
start_date: date | None = None,
end_date: date | None = None,
uuid: list[str] | None = None,
activity_id: list[str] | None = None,
max_items: int | None = None,
) -> Iterator[ActivitySearchItem]
Search activity records using full-text and filter criteria.
Returns lightweight ActivitySearchItem
results and is the flexible way to query the audit trail across entities
and users at once (e.g. everything a set of users did to a given object
type in a date window). To page the raw feed for a single entity or user
instead, use get_all. Results are a lazily paginated iterator.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched across activity fields. |
None
|
sort_by
|
str
|
Field to sort results by. Supported value: |
None
|
order_by
|
OrderBy
|
Sort direction, ascending or descending. |
None
|
operation_id
|
list[str]
|
Filter by one or more operation IDs. |
None
|
user
|
list[str]
|
Filter by one or more user IDs. |
None
|
user_class
|
list[str]
|
Filter by one or more user class values. |
None
|
user_role
|
list[str]
|
Filter by one or more user roles. |
None
|
object_id
|
list[str]
|
Filter by one or more object (entity) IDs. |
None
|
object_type
|
list[str]
|
Filter by one or more object types. |
None
|
object_class
|
list[str]
|
Filter by one or more object class values. |
None
|
start_date
|
date
|
Start of the date range to filter results. |
None
|
end_date
|
date
|
End of the date range to filter results. |
None
|
uuid
|
list[str]
|
Filter by one or more activity UUIDs. |
None
|
activity_id
|
list[str]
|
Filter by one or more activity IDs. |
None
|
max_items
|
int
|
Maximum number of records to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[ActivitySearchItem]
|
A lazily paginated iterator of matching search results. |
Source code in src/albert/collections/activities.py
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 | |