Coverage for fingerprint_server_sdk / models / event.py: 71%
143 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-26 17:42 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-26 17:42 +0000
1"""
2Server API
3Fingerprint Server API allows you to get, search, and update Events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios.
4Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device.
6The version of the OpenAPI document: 4
7Contact: support@fingerprint.com
8Generated by OpenAPI Generator (https://openapi-generator.tech)
10Do not edit the class manually.
11""" # noqa: E501
13from __future__ import annotations
15import json
16import pprint
17import re # noqa: F401
18from typing import Annotated, Any, ClassVar, Optional, Union
20from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
21from typing_extensions import Self
23from fingerprint_server_sdk.models.bot_info import BotInfo
24from fingerprint_server_sdk.models.bot_result import BotResult
25from fingerprint_server_sdk.models.browser_details import BrowserDetails
26from fingerprint_server_sdk.models.event_rule_action import EventRuleAction
27from fingerprint_server_sdk.models.identification import Identification
28from fingerprint_server_sdk.models.incremental_identification_status import (
29 IncrementalIdentificationStatus,
30)
31from fingerprint_server_sdk.models.ip_block_list import IPBlockList
32from fingerprint_server_sdk.models.ip_info import IPInfo
33from fingerprint_server_sdk.models.labels_inner import LabelsInner
34from fingerprint_server_sdk.models.proximity import Proximity
35from fingerprint_server_sdk.models.proxy_confidence import ProxyConfidence
36from fingerprint_server_sdk.models.proxy_details import ProxyDetails
37from fingerprint_server_sdk.models.rare_device_percentile_bucket import RareDevicePercentileBucket
38from fingerprint_server_sdk.models.raw_device_attributes import RawDeviceAttributes
39from fingerprint_server_sdk.models.sdk import SDK
40from fingerprint_server_sdk.models.supplementary_id_high_recall import SupplementaryIDHighRecall
41from fingerprint_server_sdk.models.tampering_confidence import TamperingConfidence
42from fingerprint_server_sdk.models.tampering_details import TamperingDetails
43from fingerprint_server_sdk.models.velocity import Velocity
44from fingerprint_server_sdk.models.vpn_confidence import VpnConfidence
45from fingerprint_server_sdk.models.vpn_methods import VpnMethods
48class Event(BaseModel):
49 """
50 Contains results from Fingerprint Identification and all active Smart Signals.
51 """
53 event_id: StrictStr = Field(
54 description="Unique identifier of the user's request. The first portion of the event_id is a unix epoch milliseconds timestamp For example: `1758130560902.8tRtrH` "
55 )
56 timestamp: StrictInt = Field(
57 description='Timestamp of the event with millisecond precision in Unix time.'
58 )
59 incremental_identification_status: Optional[IncrementalIdentificationStatus] = None
60 linked_id: Optional[StrictStr] = Field(
61 default=None, description='A customer-provided id that was sent with the request.'
62 )
63 environment_id: Optional[StrictStr] = Field(
64 default=None,
65 description='Environment Id of the event. For example: `ae_47abaca3db2c7c43` ',
66 )
67 suspect: Optional[StrictBool] = Field(
68 default=None,
69 description='Field is `true` if you have previously set the `suspect` flag for this event using the [Server API Update event endpoint](https://docs.fingerprint.com/reference/server-api-v4-update-event).',
70 )
71 sdk: Optional[SDK] = None
72 replayed: Optional[StrictBool] = Field(
73 default=None,
74 description='`true` if we determined that this payload was replayed, `false` otherwise. ',
75 )
76 identification: Optional[Identification] = None
77 supplementary_id_high_recall: Optional[SupplementaryIDHighRecall] = None
78 tags: Optional[dict[str, Any]] = Field(
79 default=None,
80 description='A customer-provided value or an object that was sent with the identification request or updated later.',
81 )
82 url: Optional[StrictStr] = Field(
83 default=None,
84 description='Page URL from which the request was sent. For example `https://example.com/` ',
85 )
86 bundle_id: Optional[StrictStr] = Field(
87 default=None,
88 description='Bundle Id of the iOS application integrated with the Fingerprint SDK for the event. For example: `com.foo.app` ',
89 )
90 package_name: Optional[StrictStr] = Field(
91 default=None,
92 description='Package name of the Android application integrated with the Fingerprint SDK for the event. For example: `com.foo.app` ',
93 )
94 ip_address: Optional[StrictStr] = Field(
95 default=None, description='IP address of the requesting browser or bot.'
96 )
97 user_agent: Optional[StrictStr] = Field(
98 default=None,
99 description='User Agent of the client, for example: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) ....` ',
100 )
101 client_referrer: Optional[StrictStr] = Field(
102 default=None,
103 description='Client Referrer field corresponds to the `document.referrer` field gathered during an identification request. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, by using a bookmark) For example: `https://example.com/blog/my-article` ',
104 )
105 browser_details: Optional[BrowserDetails] = None
106 proximity: Optional[Proximity] = None
107 bot: Optional[BotResult] = None
108 bot_type: Optional[StrictStr] = Field(
109 default=None, description='Additional classification of the bot type if detected. '
110 )
111 bot_info: Optional[BotInfo] = None
112 cloned_app: Optional[StrictBool] = Field(
113 default=None,
114 description='Android specific cloned application detection. There are 2 values: * `true` - Presence of app cloners work detected (e.g. fully cloned application found or launch of it inside of a not main working profile detected). * `false` - No signs of cloned application detected or the client is not Android. ',
115 )
116 developer_tools: Optional[StrictBool] = Field(
117 default=None,
118 description='`true` if the browser has DevTools open (Chrome, Firefox) or the Android/iOS device has Developer Tools enabled, `false` otherwise. ',
119 )
120 emulator: Optional[StrictBool] = Field(
121 default=None,
122 description='Android specific emulator detection. There are 2 values: * `true` - Emulated environment detected (e.g. launch inside of AVD). * `false` - No signs of emulated environment detected or the client is not Android. ',
123 )
124 factory_reset_timestamp: Optional[StrictInt] = Field(
125 default=None,
126 description='The time of the most recent factory reset that happened on the **mobile device** is expressed as Unix epoch time. When a factory reset cannot be detected on the mobile device or when the request is initiated from a browser, this field will correspond to the *epoch* time (i.e 1 Jan 1970 UTC) as a value of 0. See [Factory Reset Detection](https://docs.fingerprint.com/docs/smart-signals-reference#factory-reset-detection) to learn more about this Smart Signal. ',
127 )
128 frida: Optional[StrictBool] = Field(
129 default=None,
130 description='[Frida](https://frida.re/docs/) detection for Android and iOS devices. There are 2 values: * `true` - Frida detected * `false` - No signs of Frida or the client is not a mobile device. ',
131 )
132 ip_blocklist: Optional[IPBlockList] = None
133 ip_info: Optional[IPInfo] = None
134 proxy: Optional[StrictBool] = Field(
135 default=None,
136 description='IP address was used by a public proxy provider or belonged to a known recent residential proxy ',
137 )
138 proxy_confidence: Optional[ProxyConfidence] = None
139 proxy_details: Optional[ProxyDetails] = None
140 proxy_ml_score: Optional[
141 Union[
142 Annotated[float, Field(le=1, strict=True, ge=0)],
143 Annotated[int, Field(le=1, strict=True, ge=0)],
144 ]
145 ] = Field(
146 default=None,
147 description='Machine learning–based proxy score, represented as a floating-point value between 0 and 1 (inclusive), with up to three decimal places of precision. A higher score means a higher confidence in the positive `proxy` detection result. This Smart Signal is currently in beta and only available to select customers. If you are interested, please [contact our support team](https://fingerprint.com/support/). ',
148 )
149 incognito: Optional[StrictBool] = Field(
150 default=None,
151 description='`true` if we detected incognito mode used in the browser, `false` otherwise. ',
152 )
153 jailbroken: Optional[StrictBool] = Field(
154 default=None,
155 description='iOS specific jailbreak detection. There are 2 values: * `true` - Jailbreak detected. * `false` - No signs of jailbreak or the client is not iOS. ',
156 )
157 location_spoofing: Optional[StrictBool] = Field(
158 default=None,
159 description='Flag indicating whether the request came from a mobile device with location spoofing enabled.',
160 )
161 mitm_attack: Optional[StrictBool] = Field(
162 default=None,
163 description="* `true` - When requests made from your users' mobile devices to Fingerprint servers have been intercepted and potentially modified. * `false` - Otherwise or when the request originated from a browser. See [MitM Attack Detection](https://docs.fingerprint.com/docs/smart-signals-reference#mitm-attack-detection) to learn more about this Smart Signal. ",
164 )
165 privacy_settings: Optional[StrictBool] = Field(
166 default=None,
167 description='`true` if the request is from a privacy aware browser (e.g. Tor) or from a browser in which fingerprinting is blocked. Otherwise `false`. ',
168 )
169 root_apps: Optional[StrictBool] = Field(
170 default=None,
171 description="Android specific root management apps detection. There are 2 values: * `true` - Root Management Apps detected (e.g. Magisk). * `false` - No Root Management Apps detected or the client isn't Android. ",
172 )
173 rule_action: Optional[EventRuleAction] = None
174 simulator: Optional[StrictBool] = Field(
175 default=None,
176 description='iOS specific simulator detection. There are 2 values: * `true` - Simulator environment detected. * `false` - No signs of simulator or the client is not iOS. ',
177 )
178 suspect_score: Optional[StrictInt] = Field(
179 default=None,
180 description='Suspect Score is an easy way to integrate Smart Signals into your fraud protection work flow. It is a weighted representation of all Smart Signals present in the payload that helps identify suspicious activity. The value range is [0; S] where S is sum of all Smart Signals weights. See more details here: https://docs.fingerprint.com/docs/suspect-score ',
181 )
182 tampering: Optional[StrictBool] = Field(
183 default=None,
184 description='The field can be used as a standalone flag for tampering detection. Alternatively, the more granular fields documented below can be used for workflows that require more context. * `true` if tampering is detected through an anomalous browser signature, anti-detect browser detection, or other tampering-related methods * `false` if none of the tampering checks return a positive result ',
185 )
186 tampering_confidence: Optional[TamperingConfidence] = None
187 tampering_ml_score: Optional[
188 Union[
189 Annotated[float, Field(le=1, strict=True, ge=0)],
190 Annotated[int, Field(le=1, strict=True, ge=0)],
191 ]
192 ] = Field(
193 default=None,
194 description='The output of this model is captured as tampering_ml_score, a number indicating how likely an event is coming from an anti detect browser. Values close to 1 signify higher confidence and we consider anything above the threshold of 0.8 to be actionable (the result and anti_detect_browser fields conveniently captures that fact) ',
195 )
196 tampering_details: Optional[TamperingDetails] = None
197 velocity: Optional[Velocity] = None
198 virtual_machine: Optional[StrictBool] = Field(
199 default=None,
200 description='`true` if the request came from a browser running inside a virtual machine (e.g. VMWare), `false` otherwise. ',
201 )
202 virtual_machine_ml_score: Optional[
203 Union[
204 Annotated[float, Field(le=1, strict=True, ge=0)],
205 Annotated[int, Field(le=1, strict=True, ge=0)],
206 ]
207 ] = Field(
208 default=None,
209 description='Machine learning–based virtual machine score, represented as a floating-point value between 0 and 1 (inclusive), with up to three decimal places of precision. A higher score means a higher confidence in the positive `virtual_machine` detection result. This Smart Signal is currently in beta and only available to select customers. If you are interested, please [contact our support team](https://fingerprint.com/support/). ',
210 )
211 vpn: Optional[StrictBool] = Field(
212 default=None,
213 description='VPN or other anonymizing service has been used when sending the request. ',
214 )
215 vpn_confidence: Optional[VpnConfidence] = None
216 vpn_origin_timezone: Optional[StrictStr] = Field(
217 default=None, description='Local timezone which is used in timezone_mismatch method. '
218 )
219 vpn_origin_country: Optional[StrictStr] = Field(
220 default=None,
221 description='Country of the request (only for Android SDK version >= 2.4.0, ISO 3166 format or unknown). ',
222 )
223 vpn_methods: Optional[VpnMethods] = None
224 high_activity_device: Optional[StrictBool] = Field(
225 default=None,
226 description='Flag indicating if the request came from a high-activity visitor.',
227 )
228 rare_device: Optional[StrictBool] = Field(
229 default=None,
230 description='`true` if the device is considered rare based on its combination of hardware and software attributes. A device is classified as rare if it falls within the top 99.9 percentile (lowest-frequency segment) of observed traffic, or if its configuration has not been previously seen (`not_seen`). > This Smart Signal is currently in beta and only available to select customers. If you are interested, please [contact our support team](https://fingerprint.com/support/). ',
231 )
232 rare_device_percentile_bucket: Optional[RareDevicePercentileBucket] = None
233 raw_device_attributes: Optional[RawDeviceAttributes] = None
234 labels: Optional[list[LabelsInner]] = Field(
235 default=None,
236 description='Each label returns a prediction (true or false) for a specific use case (label field) based on a machine learning score. The machine learning score is determined by a model trained on customer data for that use case. This field is in the beta phase and only available to select customers. If you are interested, please [contact our support team](https://fingerprint.com/support/). ',
237 )
238 __properties: ClassVar[list[str]] = [
239 'event_id',
240 'timestamp',
241 'incremental_identification_status',
242 'linked_id',
243 'environment_id',
244 'suspect',
245 'sdk',
246 'replayed',
247 'identification',
248 'supplementary_id_high_recall',
249 'tags',
250 'url',
251 'bundle_id',
252 'package_name',
253 'ip_address',
254 'user_agent',
255 'client_referrer',
256 'browser_details',
257 'proximity',
258 'bot',
259 'bot_type',
260 'bot_info',
261 'cloned_app',
262 'developer_tools',
263 'emulator',
264 'factory_reset_timestamp',
265 'frida',
266 'ip_blocklist',
267 'ip_info',
268 'proxy',
269 'proxy_confidence',
270 'proxy_details',
271 'proxy_ml_score',
272 'incognito',
273 'jailbroken',
274 'location_spoofing',
275 'mitm_attack',
276 'privacy_settings',
277 'root_apps',
278 'rule_action',
279 'simulator',
280 'suspect_score',
281 'tampering',
282 'tampering_confidence',
283 'tampering_ml_score',
284 'tampering_details',
285 'velocity',
286 'virtual_machine',
287 'virtual_machine_ml_score',
288 'vpn',
289 'vpn_confidence',
290 'vpn_origin_timezone',
291 'vpn_origin_country',
292 'vpn_methods',
293 'high_activity_device',
294 'rare_device',
295 'rare_device_percentile_bucket',
296 'raw_device_attributes',
297 'labels',
298 ]
300 model_config = ConfigDict(
301 populate_by_name=True,
302 validate_assignment=True,
303 protected_namespaces=(),
304 )
306 def to_str(self) -> str:
307 """Returns the string representation of the model using alias"""
308 return pprint.pformat(self.model_dump(by_alias=True))
310 def to_json(self) -> str:
311 """Returns the JSON representation of the model using alias"""
312 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
313 return json.dumps(self.to_dict())
315 @classmethod
316 def from_json(cls, json_str: str) -> Optional[Self]:
317 """Create an instance of Event from a JSON string"""
318 return cls.from_dict(json.loads(json_str))
320 def to_dict(self) -> dict[str, Any]:
321 """Return the dictionary representation of the model using alias.
323 This has the following differences from calling pydantic's
324 `self.model_dump(by_alias=True)`:
326 * `None` is only added to the output dict for nullable fields that
327 were set at model initialization. Other fields with value `None`
328 are ignored.
329 """
330 excluded_fields: set[str] = set([])
332 _dict = self.model_dump(
333 by_alias=True,
334 exclude=excluded_fields,
335 exclude_none=True,
336 )
337 # override the default output from pydantic by calling `to_dict()` of sdk
338 if self.sdk:
339 _dict['sdk'] = self.sdk.to_dict()
340 # override the default output from pydantic by calling `to_dict()` of identification
341 if self.identification:
342 _dict['identification'] = self.identification.to_dict()
343 # override the default output from pydantic by calling `to_dict()` of supplementary_id_high_recall
344 if self.supplementary_id_high_recall:
345 _dict['supplementary_id_high_recall'] = self.supplementary_id_high_recall.to_dict()
346 # override the default output from pydantic by calling `to_dict()` of browser_details
347 if self.browser_details:
348 _dict['browser_details'] = self.browser_details.to_dict()
349 # override the default output from pydantic by calling `to_dict()` of proximity
350 if self.proximity:
351 _dict['proximity'] = self.proximity.to_dict()
352 # override the default output from pydantic by calling `to_dict()` of bot_info
353 if self.bot_info:
354 _dict['bot_info'] = self.bot_info.to_dict()
355 # override the default output from pydantic by calling `to_dict()` of ip_blocklist
356 if self.ip_blocklist:
357 _dict['ip_blocklist'] = self.ip_blocklist.to_dict()
358 # override the default output from pydantic by calling `to_dict()` of ip_info
359 if self.ip_info:
360 _dict['ip_info'] = self.ip_info.to_dict()
361 # override the default output from pydantic by calling `to_dict()` of proxy_details
362 if self.proxy_details:
363 _dict['proxy_details'] = self.proxy_details.to_dict()
364 # override the default output from pydantic by calling `to_dict()` of rule_action
365 if self.rule_action:
366 _dict['rule_action'] = self.rule_action.to_dict()
367 # override the default output from pydantic by calling `to_dict()` of tampering_details
368 if self.tampering_details:
369 _dict['tampering_details'] = self.tampering_details.to_dict()
370 # override the default output from pydantic by calling `to_dict()` of velocity
371 if self.velocity:
372 _dict['velocity'] = self.velocity.to_dict()
373 # override the default output from pydantic by calling `to_dict()` of vpn_methods
374 if self.vpn_methods:
375 _dict['vpn_methods'] = self.vpn_methods.to_dict()
376 # override the default output from pydantic by calling `to_dict()` of raw_device_attributes
377 if self.raw_device_attributes:
378 _dict['raw_device_attributes'] = self.raw_device_attributes.to_dict()
379 # override the default output from pydantic by calling `to_dict()` of each item in labels (list)
380 _items = []
381 if self.labels:
382 for _item_labels in self.labels:
383 if _item_labels:
384 _items.append(_item_labels.to_dict())
385 _dict['labels'] = _items
386 return _dict
388 @classmethod
389 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
390 """Create an instance of Event from a dict"""
391 if obj is None:
392 return None
394 if not isinstance(obj, dict):
395 return cls.model_validate(obj)
397 _obj = cls.model_validate(
398 {
399 'event_id': obj.get('event_id'),
400 'timestamp': obj.get('timestamp'),
401 'incremental_identification_status': obj.get('incremental_identification_status'),
402 'linked_id': obj.get('linked_id'),
403 'environment_id': obj.get('environment_id'),
404 'suspect': obj.get('suspect'),
405 'sdk': SDK.from_dict(obj['sdk']) if obj.get('sdk') is not None else None,
406 'replayed': obj.get('replayed'),
407 'identification': Identification.from_dict(obj['identification'])
408 if obj.get('identification') is not None
409 else None,
410 'supplementary_id_high_recall': SupplementaryIDHighRecall.from_dict(
411 obj['supplementary_id_high_recall']
412 )
413 if obj.get('supplementary_id_high_recall') is not None
414 else None,
415 'tags': obj.get('tags'),
416 'url': obj.get('url'),
417 'bundle_id': obj.get('bundle_id'),
418 'package_name': obj.get('package_name'),
419 'ip_address': obj.get('ip_address'),
420 'user_agent': obj.get('user_agent'),
421 'client_referrer': obj.get('client_referrer'),
422 'browser_details': BrowserDetails.from_dict(obj['browser_details'])
423 if obj.get('browser_details') is not None
424 else None,
425 'proximity': Proximity.from_dict(obj['proximity'])
426 if obj.get('proximity') is not None
427 else None,
428 'bot': obj.get('bot'),
429 'bot_type': obj.get('bot_type'),
430 'bot_info': BotInfo.from_dict(obj['bot_info'])
431 if obj.get('bot_info') is not None
432 else None,
433 'cloned_app': obj.get('cloned_app'),
434 'developer_tools': obj.get('developer_tools'),
435 'emulator': obj.get('emulator'),
436 'factory_reset_timestamp': obj.get('factory_reset_timestamp'),
437 'frida': obj.get('frida'),
438 'ip_blocklist': IPBlockList.from_dict(obj['ip_blocklist'])
439 if obj.get('ip_blocklist') is not None
440 else None,
441 'ip_info': IPInfo.from_dict(obj['ip_info'])
442 if obj.get('ip_info') is not None
443 else None,
444 'proxy': obj.get('proxy'),
445 'proxy_confidence': obj.get('proxy_confidence'),
446 'proxy_details': ProxyDetails.from_dict(obj['proxy_details'])
447 if obj.get('proxy_details') is not None
448 else None,
449 'proxy_ml_score': obj.get('proxy_ml_score'),
450 'incognito': obj.get('incognito'),
451 'jailbroken': obj.get('jailbroken'),
452 'location_spoofing': obj.get('location_spoofing'),
453 'mitm_attack': obj.get('mitm_attack'),
454 'privacy_settings': obj.get('privacy_settings'),
455 'root_apps': obj.get('root_apps'),
456 'rule_action': EventRuleAction.from_dict(obj['rule_action'])
457 if obj.get('rule_action') is not None
458 else None,
459 'simulator': obj.get('simulator'),
460 'suspect_score': obj.get('suspect_score'),
461 'tampering': obj.get('tampering'),
462 'tampering_confidence': obj.get('tampering_confidence'),
463 'tampering_ml_score': obj.get('tampering_ml_score'),
464 'tampering_details': TamperingDetails.from_dict(obj['tampering_details'])
465 if obj.get('tampering_details') is not None
466 else None,
467 'velocity': Velocity.from_dict(obj['velocity'])
468 if obj.get('velocity') is not None
469 else None,
470 'virtual_machine': obj.get('virtual_machine'),
471 'virtual_machine_ml_score': obj.get('virtual_machine_ml_score'),
472 'vpn': obj.get('vpn'),
473 'vpn_confidence': obj.get('vpn_confidence'),
474 'vpn_origin_timezone': obj.get('vpn_origin_timezone'),
475 'vpn_origin_country': obj.get('vpn_origin_country'),
476 'vpn_methods': VpnMethods.from_dict(obj['vpn_methods'])
477 if obj.get('vpn_methods') is not None
478 else None,
479 'high_activity_device': obj.get('high_activity_device'),
480 'rare_device': obj.get('rare_device'),
481 'rare_device_percentile_bucket': obj.get('rare_device_percentile_bucket'),
482 'raw_device_attributes': RawDeviceAttributes.from_dict(
483 obj['raw_device_attributes']
484 )
485 if obj.get('raw_device_attributes') is not None
486 else None,
487 'labels': [LabelsInner.from_dict(_item) for _item in obj['labels']]
488 if obj.get('labels') is not None
489 else None,
490 }
491 )
492 return _obj