Coverage for fingerprint_server_sdk / models / event.py: 73%

131 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-23 09:55 +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. 

5 

6The version of the OpenAPI document: 4 

7Contact: support@fingerprint.com 

8Generated by OpenAPI Generator (https://openapi-generator.tech) 

9 

10Do not edit the class manually. 

11""" # noqa: E501 

12 

13from __future__ import annotations 

14 

15import json 

16import pprint 

17import re # noqa: F401 

18from typing import Annotated, Any, ClassVar, Optional, Union 

19 

20from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr 

21from typing_extensions import Self 

22 

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.proximity import Proximity 

34from fingerprint_server_sdk.models.proxy_confidence import ProxyConfidence 

35from fingerprint_server_sdk.models.proxy_details import ProxyDetails 

36from fingerprint_server_sdk.models.raw_device_attributes import RawDeviceAttributes 

37from fingerprint_server_sdk.models.sdk import SDK 

38from fingerprint_server_sdk.models.supplementary_id_high_recall import SupplementaryIDHighRecall 

39from fingerprint_server_sdk.models.tampering_confidence import TamperingConfidence 

40from fingerprint_server_sdk.models.tampering_details import TamperingDetails 

41from fingerprint_server_sdk.models.velocity import Velocity 

42from fingerprint_server_sdk.models.vpn_confidence import VpnConfidence 

43from fingerprint_server_sdk.models.vpn_methods import VpnMethods 

44 

45 

46class Event(BaseModel): 

47 """ 

48 Contains results from Fingerprint Identification and all active Smart Signals. 

49 """ 

50 

51 event_id: StrictStr = Field( 

52 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` " 

53 ) 

54 timestamp: StrictInt = Field( 

55 description='Timestamp of the event with millisecond precision in Unix time.' 

56 ) 

57 incremental_identification_status: Optional[IncrementalIdentificationStatus] = None 

58 linked_id: Optional[StrictStr] = Field( 

59 default=None, description='A customer-provided id that was sent with the request.' 

60 ) 

61 environment_id: Optional[StrictStr] = Field( 

62 default=None, 

63 description='Environment Id of the event. For example: `ae_47abaca3db2c7c43` ', 

64 ) 

65 suspect: Optional[StrictBool] = Field( 

66 default=None, 

67 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).', 

68 ) 

69 sdk: Optional[SDK] = None 

70 replayed: Optional[StrictBool] = Field( 

71 default=None, 

72 description='`true` if we determined that this payload was replayed, `false` otherwise. ', 

73 ) 

74 identification: Optional[Identification] = None 

75 supplementary_id_high_recall: Optional[SupplementaryIDHighRecall] = None 

76 tags: Optional[dict[str, Any]] = Field( 

77 default=None, 

78 description='A customer-provided value or an object that was sent with the identification request or updated later.', 

79 ) 

80 url: Optional[StrictStr] = Field( 

81 default=None, 

82 description='Page URL from which the request was sent. For example `https://example.com/` ', 

83 ) 

84 bundle_id: Optional[StrictStr] = Field( 

85 default=None, 

86 description='Bundle Id of the iOS application integrated with the Fingerprint SDK for the event. For example: `com.foo.app` ', 

87 ) 

88 package_name: Optional[StrictStr] = Field( 

89 default=None, 

90 description='Package name of the Android application integrated with the Fingerprint SDK for the event. For example: `com.foo.app` ', 

91 ) 

92 ip_address: Optional[StrictStr] = Field( 

93 default=None, description='IP address of the requesting browser or bot.' 

94 ) 

95 user_agent: Optional[StrictStr] = Field( 

96 default=None, 

97 description='User Agent of the client, for example: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) ....` ', 

98 ) 

99 client_referrer: Optional[StrictStr] = Field( 

100 default=None, 

101 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` ', 

102 ) 

103 browser_details: Optional[BrowserDetails] = None 

104 proximity: Optional[Proximity] = None 

105 bot: Optional[BotResult] = None 

106 bot_type: Optional[StrictStr] = Field( 

107 default=None, description='Additional classification of the bot type if detected. ' 

108 ) 

109 bot_info: Optional[BotInfo] = None 

110 cloned_app: Optional[StrictBool] = Field( 

111 default=None, 

112 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. ', 

113 ) 

114 developer_tools: Optional[StrictBool] = Field( 

115 default=None, 

116 description='`true` if the browser is Chrome with DevTools open or Firefox with Developer Tools open, `false` otherwise. ', 

117 ) 

118 emulator: Optional[StrictBool] = Field( 

119 default=None, 

120 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. ', 

121 ) 

122 factory_reset_timestamp: Optional[StrictInt] = Field( 

123 default=None, 

124 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. ', 

125 ) 

126 frida: Optional[StrictBool] = Field( 

127 default=None, 

128 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. ', 

129 ) 

130 ip_blocklist: Optional[IPBlockList] = None 

131 ip_info: Optional[IPInfo] = None 

132 proxy: Optional[StrictBool] = Field( 

133 default=None, 

134 description='IP address was used by a public proxy provider or belonged to a known recent residential proxy ', 

135 ) 

136 proxy_confidence: Optional[ProxyConfidence] = None 

137 proxy_details: Optional[ProxyDetails] = None 

138 incognito: Optional[StrictBool] = Field( 

139 default=None, 

140 description='`true` if we detected incognito mode used in the browser, `false` otherwise. ', 

141 ) 

142 jailbroken: Optional[StrictBool] = Field( 

143 default=None, 

144 description='iOS specific jailbreak detection. There are 2 values: * `true` - Jailbreak detected. * `false` - No signs of jailbreak or the client is not iOS. ', 

145 ) 

146 location_spoofing: Optional[StrictBool] = Field( 

147 default=None, 

148 description='Flag indicating whether the request came from a mobile device with location spoofing enabled.', 

149 ) 

150 mitm_attack: Optional[StrictBool] = Field( 

151 default=None, 

152 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. ", 

153 ) 

154 privacy_settings: Optional[StrictBool] = Field( 

155 default=None, 

156 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`. ', 

157 ) 

158 root_apps: Optional[StrictBool] = Field( 

159 default=None, 

160 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. ", 

161 ) 

162 rule_action: Optional[EventRuleAction] = None 

163 simulator: Optional[StrictBool] = Field( 

164 default=None, 

165 description='iOS specific simulator detection. There are 2 values: * `true` - Simulator environment detected. * `false` - No signs of simulator or the client is not iOS. ', 

166 ) 

167 suspect_score: Optional[StrictInt] = Field( 

168 default=None, 

169 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 ', 

170 ) 

171 tampering: Optional[StrictBool] = Field( 

172 default=None, 

173 description='Flag indicating browser tampering was detected. This happens when either: * There are inconsistencies in the browser configuration that cross internal tampering thresholds (see `tampering_details.anomaly_score`). * The browser signature resembles an "anti-detect" browser specifically designed to evade fingerprinting (see `tampering_details.anti_detect_browser`). ', 

174 ) 

175 tampering_confidence: Optional[TamperingConfidence] = None 

176 tampering_ml_score: Optional[ 

177 Union[ 

178 Annotated[float, Field(le=1, strict=True, ge=0)], 

179 Annotated[int, Field(le=1, strict=True, ge=0)], 

180 ] 

181 ] = Field( 

182 default=None, 

183 description='A score that indicates the models calculated probability that an event is coming from an anti detect browser. * Values above `0.8` indicate that the request is an anti detect browser based on the ml model * Values below `0.8` indicate that the request is not an anti detect browser based on the ml model ', 

184 ) 

185 tampering_details: Optional[TamperingDetails] = None 

186 velocity: Optional[Velocity] = None 

187 virtual_machine: Optional[StrictBool] = Field( 

188 default=None, 

189 description='`true` if the request came from a browser running inside a virtual machine (e.g. VMWare), `false` otherwise. ', 

190 ) 

191 virtual_machine_ml_score: Optional[ 

192 Union[ 

193 Annotated[float, Field(le=1, strict=True, ge=0)], 

194 Annotated[int, Field(le=1, strict=True, ge=0)], 

195 ] 

196 ] = Field( 

197 default=None, 

198 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 ', 

199 ) 

200 vpn: Optional[StrictBool] = Field( 

201 default=None, 

202 description='VPN or other anonymizing service has been used when sending the request. ', 

203 ) 

204 vpn_confidence: Optional[VpnConfidence] = None 

205 vpn_origin_timezone: Optional[StrictStr] = Field( 

206 default=None, description='Local timezone which is used in timezone_mismatch method. ' 

207 ) 

208 vpn_origin_country: Optional[StrictStr] = Field( 

209 default=None, 

210 description='Country of the request (only for Android SDK version >= 2.4.0, ISO 3166 format or unknown). ', 

211 ) 

212 vpn_methods: Optional[VpnMethods] = None 

213 high_activity_device: Optional[StrictBool] = Field( 

214 default=None, 

215 description='Flag indicating if the request came from a high-activity visitor.', 

216 ) 

217 raw_device_attributes: Optional[RawDeviceAttributes] = None 

218 __properties: ClassVar[list[str]] = [ 

219 'event_id', 

220 'timestamp', 

221 'incremental_identification_status', 

222 'linked_id', 

223 'environment_id', 

224 'suspect', 

225 'sdk', 

226 'replayed', 

227 'identification', 

228 'supplementary_id_high_recall', 

229 'tags', 

230 'url', 

231 'bundle_id', 

232 'package_name', 

233 'ip_address', 

234 'user_agent', 

235 'client_referrer', 

236 'browser_details', 

237 'proximity', 

238 'bot', 

239 'bot_type', 

240 'bot_info', 

241 'cloned_app', 

242 'developer_tools', 

243 'emulator', 

244 'factory_reset_timestamp', 

245 'frida', 

246 'ip_blocklist', 

247 'ip_info', 

248 'proxy', 

249 'proxy_confidence', 

250 'proxy_details', 

251 'incognito', 

252 'jailbroken', 

253 'location_spoofing', 

254 'mitm_attack', 

255 'privacy_settings', 

256 'root_apps', 

257 'rule_action', 

258 'simulator', 

259 'suspect_score', 

260 'tampering', 

261 'tampering_confidence', 

262 'tampering_ml_score', 

263 'tampering_details', 

264 'velocity', 

265 'virtual_machine', 

266 'virtual_machine_ml_score', 

267 'vpn', 

268 'vpn_confidence', 

269 'vpn_origin_timezone', 

270 'vpn_origin_country', 

271 'vpn_methods', 

272 'high_activity_device', 

273 'raw_device_attributes', 

274 ] 

275 

276 model_config = ConfigDict( 

277 populate_by_name=True, 

278 validate_assignment=True, 

279 protected_namespaces=(), 

280 ) 

281 

282 def to_str(self) -> str: 

283 """Returns the string representation of the model using alias""" 

284 return pprint.pformat(self.model_dump(by_alias=True)) 

285 

286 def to_json(self) -> str: 

287 """Returns the JSON representation of the model using alias""" 

288 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 

289 return json.dumps(self.to_dict()) 

290 

291 @classmethod 

292 def from_json(cls, json_str: str) -> Optional[Self]: 

293 """Create an instance of Event from a JSON string""" 

294 return cls.from_dict(json.loads(json_str)) 

295 

296 def to_dict(self) -> dict[str, Any]: 

297 """Return the dictionary representation of the model using alias. 

298 

299 This has the following differences from calling pydantic's 

300 `self.model_dump(by_alias=True)`: 

301 

302 * `None` is only added to the output dict for nullable fields that 

303 were set at model initialization. Other fields with value `None` 

304 are ignored. 

305 """ 

306 excluded_fields: set[str] = set([]) 

307 

308 _dict = self.model_dump( 

309 by_alias=True, 

310 exclude=excluded_fields, 

311 exclude_none=True, 

312 ) 

313 # override the default output from pydantic by calling `to_dict()` of sdk 

314 if self.sdk: 

315 _dict['sdk'] = self.sdk.to_dict() 

316 # override the default output from pydantic by calling `to_dict()` of identification 

317 if self.identification: 

318 _dict['identification'] = self.identification.to_dict() 

319 # override the default output from pydantic by calling `to_dict()` of supplementary_id_high_recall 

320 if self.supplementary_id_high_recall: 

321 _dict['supplementary_id_high_recall'] = self.supplementary_id_high_recall.to_dict() 

322 # override the default output from pydantic by calling `to_dict()` of browser_details 

323 if self.browser_details: 

324 _dict['browser_details'] = self.browser_details.to_dict() 

325 # override the default output from pydantic by calling `to_dict()` of proximity 

326 if self.proximity: 

327 _dict['proximity'] = self.proximity.to_dict() 

328 # override the default output from pydantic by calling `to_dict()` of bot_info 

329 if self.bot_info: 

330 _dict['bot_info'] = self.bot_info.to_dict() 

331 # override the default output from pydantic by calling `to_dict()` of ip_blocklist 

332 if self.ip_blocklist: 

333 _dict['ip_blocklist'] = self.ip_blocklist.to_dict() 

334 # override the default output from pydantic by calling `to_dict()` of ip_info 

335 if self.ip_info: 

336 _dict['ip_info'] = self.ip_info.to_dict() 

337 # override the default output from pydantic by calling `to_dict()` of proxy_details 

338 if self.proxy_details: 

339 _dict['proxy_details'] = self.proxy_details.to_dict() 

340 # override the default output from pydantic by calling `to_dict()` of rule_action 

341 if self.rule_action: 

342 _dict['rule_action'] = self.rule_action.to_dict() 

343 # override the default output from pydantic by calling `to_dict()` of tampering_details 

344 if self.tampering_details: 

345 _dict['tampering_details'] = self.tampering_details.to_dict() 

346 # override the default output from pydantic by calling `to_dict()` of velocity 

347 if self.velocity: 

348 _dict['velocity'] = self.velocity.to_dict() 

349 # override the default output from pydantic by calling `to_dict()` of vpn_methods 

350 if self.vpn_methods: 

351 _dict['vpn_methods'] = self.vpn_methods.to_dict() 

352 # override the default output from pydantic by calling `to_dict()` of raw_device_attributes 

353 if self.raw_device_attributes: 

354 _dict['raw_device_attributes'] = self.raw_device_attributes.to_dict() 

355 return _dict 

356 

357 @classmethod 

358 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]: 

359 """Create an instance of Event from a dict""" 

360 if obj is None: 

361 return None 

362 

363 if not isinstance(obj, dict): 

364 return cls.model_validate(obj) 

365 

366 _obj = cls.model_validate( 

367 { 

368 'event_id': obj.get('event_id'), 

369 'timestamp': obj.get('timestamp'), 

370 'incremental_identification_status': obj.get('incremental_identification_status'), 

371 'linked_id': obj.get('linked_id'), 

372 'environment_id': obj.get('environment_id'), 

373 'suspect': obj.get('suspect'), 

374 'sdk': SDK.from_dict(obj['sdk']) if obj.get('sdk') is not None else None, 

375 'replayed': obj.get('replayed'), 

376 'identification': Identification.from_dict(obj['identification']) 

377 if obj.get('identification') is not None 

378 else None, 

379 'supplementary_id_high_recall': SupplementaryIDHighRecall.from_dict( 

380 obj['supplementary_id_high_recall'] 

381 ) 

382 if obj.get('supplementary_id_high_recall') is not None 

383 else None, 

384 'tags': obj.get('tags'), 

385 'url': obj.get('url'), 

386 'bundle_id': obj.get('bundle_id'), 

387 'package_name': obj.get('package_name'), 

388 'ip_address': obj.get('ip_address'), 

389 'user_agent': obj.get('user_agent'), 

390 'client_referrer': obj.get('client_referrer'), 

391 'browser_details': BrowserDetails.from_dict(obj['browser_details']) 

392 if obj.get('browser_details') is not None 

393 else None, 

394 'proximity': Proximity.from_dict(obj['proximity']) 

395 if obj.get('proximity') is not None 

396 else None, 

397 'bot': obj.get('bot'), 

398 'bot_type': obj.get('bot_type'), 

399 'bot_info': BotInfo.from_dict(obj['bot_info']) 

400 if obj.get('bot_info') is not None 

401 else None, 

402 'cloned_app': obj.get('cloned_app'), 

403 'developer_tools': obj.get('developer_tools'), 

404 'emulator': obj.get('emulator'), 

405 'factory_reset_timestamp': obj.get('factory_reset_timestamp'), 

406 'frida': obj.get('frida'), 

407 'ip_blocklist': IPBlockList.from_dict(obj['ip_blocklist']) 

408 if obj.get('ip_blocklist') is not None 

409 else None, 

410 'ip_info': IPInfo.from_dict(obj['ip_info']) 

411 if obj.get('ip_info') is not None 

412 else None, 

413 'proxy': obj.get('proxy'), 

414 'proxy_confidence': obj.get('proxy_confidence'), 

415 'proxy_details': ProxyDetails.from_dict(obj['proxy_details']) 

416 if obj.get('proxy_details') is not None 

417 else None, 

418 'incognito': obj.get('incognito'), 

419 'jailbroken': obj.get('jailbroken'), 

420 'location_spoofing': obj.get('location_spoofing'), 

421 'mitm_attack': obj.get('mitm_attack'), 

422 'privacy_settings': obj.get('privacy_settings'), 

423 'root_apps': obj.get('root_apps'), 

424 'rule_action': EventRuleAction.from_dict(obj['rule_action']) 

425 if obj.get('rule_action') is not None 

426 else None, 

427 'simulator': obj.get('simulator'), 

428 'suspect_score': obj.get('suspect_score'), 

429 'tampering': obj.get('tampering'), 

430 'tampering_confidence': obj.get('tampering_confidence'), 

431 'tampering_ml_score': obj.get('tampering_ml_score'), 

432 'tampering_details': TamperingDetails.from_dict(obj['tampering_details']) 

433 if obj.get('tampering_details') is not None 

434 else None, 

435 'velocity': Velocity.from_dict(obj['velocity']) 

436 if obj.get('velocity') is not None 

437 else None, 

438 'virtual_machine': obj.get('virtual_machine'), 

439 'virtual_machine_ml_score': obj.get('virtual_machine_ml_score'), 

440 'vpn': obj.get('vpn'), 

441 'vpn_confidence': obj.get('vpn_confidence'), 

442 'vpn_origin_timezone': obj.get('vpn_origin_timezone'), 

443 'vpn_origin_country': obj.get('vpn_origin_country'), 

444 'vpn_methods': VpnMethods.from_dict(obj['vpn_methods']) 

445 if obj.get('vpn_methods') is not None 

446 else None, 

447 'high_activity_device': obj.get('high_activity_device'), 

448 'raw_device_attributes': RawDeviceAttributes.from_dict( 

449 obj['raw_device_attributes'] 

450 ) 

451 if obj.get('raw_device_attributes') is not None 

452 else None, 

453 } 

454 ) 

455 return _obj