API Reference
Sync
Sync
Sync(
url: str,
*,
filter: Optional[str] = None,
projection: Optional[Iterable[str]] = None,
start: Union[datetime, int, float, None] = None,
user_agent: Optional[str] = None,
allow_insecure: bool = False,
**kwargs: Any,
)
Synchronize events from sharing API.
Reads every event matching the given conditions in database insertion order, so that a caller can keep its own copy of the events up to date without missing any.
The name refers to that synchronization, not to the sharing API's
synchronous endpoints. This class queries the asynchronous endpoints,
as Query does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Sharing API url, must be an |
required |
filter
|
Optional[str]
|
Rulelang filter. |
None
|
projection
|
Optional[Iterable[str]]
|
List of event field names to include in the results. Note that the list of keys provided by the server can only be limited by this parameter. |
None
|
start
|
Union[datetime, int, float, None]
|
Start time for the initial query. Can also be set with seek(). Default value |
None
|
user_agent
|
Optional[str]
|
Value appended to the |
None
|
allow_insecure
|
bool
|
Accept a plain |
False
|
Source code in src/arcticsecurity/sharing_api/sharing_api.py
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 | |
read
read(
*,
token: Optional[str] = None,
pagesize: int = 1000,
timeout: Optional[float] = 600,
) -> SyncReadResponse
Read the next batch of events to synchronize.
Events are returned sorted by insertion time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
Optional[str]
|
Continuation token. If not given, the start time set earlier is used. |
None
|
pagesize
|
int
|
Maximum number of events to return. |
1000
|
timeout
|
Optional[float]
|
Timeout for the operation in [s]. |
600
|
Returns:
| Type | Description |
|---|---|
SyncReadResponse
|
Batch of events and a continuation token for the next query. |
Source code in src/arcticsecurity/sharing_api/sharing_api.py
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 | |
seek
seek(ts: Union[datetime, int, float, None]) -> None
Set sync start to specific time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts
|
Union[datetime, int, float, None]
|
See start in init. |
required |
Source code in src/arcticsecurity/sharing_api/sharing_api.py
173 174 175 176 177 178 179 | |
SyncReadResponse
dataclass
SyncReadResponse(events: list[Event], token: Optional[str], has_more: bool)
Result of a single Sync.read() call.
Attributes:
| Name | Type | Description |
|---|---|---|
events |
list[Event]
|
The batch of events, in database insertion order. |
token |
Optional[str]
|
Continuation token to pass to the next |
has_more |
bool
|
Whether more events already exist in the database at the
moment. When |
Query
Query
Query(
url: str,
*,
user_agent: Optional[str] = None,
allow_insecure: bool = False,
**kwargs: Any,
)
Query events from sharing API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Sharing API url, must be an |
required |
user_agent
|
Optional[str]
|
Value appended to the |
None
|
allow_insecure
|
bool
|
Accept a plain |
False
|
Source code in src/arcticsecurity/sharing_api/sharing_api.py
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 | |
query
query(
*,
filter: Optional[str] = None,
projection: Optional[Iterable[str]] = None,
start: Union[datetime, int, float, None] = None,
end: Union[datetime, int, float, None] = None,
reverse: bool = False,
max_events: int = 0,
timeout: Optional[float] = 600,
**kwargs: Any,
) -> Iterator[Event]
Query sharing API.
Events are returned sorted by timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
Optional[str]
|
Rulelang filter. |
None
|
projection
|
Optional[Iterable[str]]
|
List of event field names to include in the results. Note that the list of keys provided by the server can only be limited by this parameter. |
None
|
start
|
Union[datetime, int, float, None]
|
Start time for the query. Default value |
None
|
end
|
Union[datetime, int, float, None]
|
End time for the query. Default value |
None
|
reverse
|
bool
|
Return events in reverse order. |
False
|
max_events
|
int
|
Maximum number of events to generate. |
0
|
timeout
|
Optional[float]
|
Timeout for one sharing API query fetching more events in [s]. |
600
|
Returns:
| Type | Description |
|---|---|
Iterator[Event]
|
Generator yielding events matching the query. |
Source code in src/arcticsecurity/sharing_api/sharing_api.py
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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
query
query(url: str, **kwargs: Any) -> Iterable[Event]
Shortcut to Query(url).query().
Source code in src/arcticsecurity/sharing_api/sharing_api.py
350 351 352 | |
Types
Event
module-attribute
Event = dict[str, Union[str, list[str]]]
A single event, mapping a field name to its value or list of values.
Exception classes
Error
Error(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Exception
Base class for all errors.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
ConfigError
ConfigError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Error
User error in query configuration.
This error may be raised by this library or by the server.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
AuthError
AuthError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: ConfigError
The server rejected the api key.
The share url is missing, has an expired or revoked api key, or the key does not grant access to the requested share. Retrying will not help until the url is fixed.
This is a subclass of ConfigError, since it always indicates a problem
with the configured share url.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
InvalidTokenError
InvalidTokenError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Error
The server responded with "invalid token" error.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
ServerError
ServerError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Error
The server responded with a error message.
This results from a server which doesn't operate properly at the moment.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
NetworkError
NetworkError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Error
Error communicating with the sharing API server.
This results from error communicating the with the sharing API server.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
TimeoutError
TimeoutError(*args: Any, url: Optional[str] = None, **kwargs: Any)
Bases: Error
Query to sharing API server timed out.
The three-phase query to the sharing API exceeded the configured timeout.
Source code in src/arcticsecurity/sharing_api/errors.py
24 25 26 | |
Retry
Retry(*args: Any, after: Union[str, int, float, None] = None, **kwargs: Any)
Bases: NetworkError
Network error that should be retried.
This is raised from errors that are likely transient and may succeed if retried
after some time.
Attributes:
after: Number of seconds the server asked the client to wait before
retrying, or None if the server did not say (or said something
unparseable). This value is advisory and is not bounded; the caller
decides how long it is willing to wait.
Source code in src/arcticsecurity/sharing_api/errors.py
97 98 99 100 101 102 | |