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

124 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-11 18:41 +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 Any, ClassVar, Optional 

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.ip_block_list import IPBlockList 

29from fingerprint_server_sdk.models.ip_info import IPInfo 

30from fingerprint_server_sdk.models.proximity import Proximity 

31from fingerprint_server_sdk.models.proxy_confidence import ProxyConfidence 

32from fingerprint_server_sdk.models.proxy_details import ProxyDetails 

33from fingerprint_server_sdk.models.raw_device_attributes import RawDeviceAttributes 

34from fingerprint_server_sdk.models.sdk import SDK 

35from fingerprint_server_sdk.models.supplementary_id_high_recall import SupplementaryIDHighRecall 

36from fingerprint_server_sdk.models.tampering_details import TamperingDetails 

37from fingerprint_server_sdk.models.velocity import Velocity 

38from fingerprint_server_sdk.models.vpn_confidence import VpnConfidence 

39from fingerprint_server_sdk.models.vpn_methods import VpnMethods 

40 

41 

42class Event(BaseModel): 

43 """ 

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

45 """ 

46 

47 event_id: StrictStr = Field( 

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

49 ) 

50 timestamp: StrictInt = Field( 

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

52 ) 

53 linked_id: Optional[StrictStr] = Field( 

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

55 ) 

56 environment_id: Optional[StrictStr] = Field( 

57 default=None, 

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

59 ) 

60 suspect: Optional[StrictBool] = Field( 

61 default=None, 

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

63 ) 

64 sdk: Optional[SDK] = None 

65 replayed: Optional[StrictBool] = Field( 

66 default=None, 

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

68 ) 

69 identification: Optional[Identification] = None 

70 supplementary_id_high_recall: Optional[SupplementaryIDHighRecall] = None 

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

72 default=None, 

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

74 ) 

75 url: Optional[StrictStr] = Field( 

76 default=None, 

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

78 ) 

79 bundle_id: Optional[StrictStr] = Field( 

80 default=None, 

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

82 ) 

83 package_name: Optional[StrictStr] = Field( 

84 default=None, 

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

86 ) 

87 ip_address: Optional[StrictStr] = Field( 

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

89 ) 

90 user_agent: Optional[StrictStr] = Field( 

91 default=None, 

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

93 ) 

94 client_referrer: Optional[StrictStr] = Field( 

95 default=None, 

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

97 ) 

98 browser_details: Optional[BrowserDetails] = None 

99 proximity: Optional[Proximity] = None 

100 bot: Optional[BotResult] = None 

101 bot_type: Optional[StrictStr] = Field( 

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

103 ) 

104 bot_info: Optional[BotInfo] = None 

105 cloned_app: Optional[StrictBool] = Field( 

106 default=None, 

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

108 ) 

109 developer_tools: Optional[StrictBool] = Field( 

110 default=None, 

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

112 ) 

113 emulator: Optional[StrictBool] = Field( 

114 default=None, 

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

116 ) 

117 factory_reset_timestamp: Optional[StrictInt] = Field( 

118 default=None, 

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

120 ) 

121 frida: Optional[StrictBool] = Field( 

122 default=None, 

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

124 ) 

125 ip_blocklist: Optional[IPBlockList] = None 

126 ip_info: Optional[IPInfo] = None 

127 proxy: Optional[StrictBool] = Field( 

128 default=None, 

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

130 ) 

131 proxy_confidence: Optional[ProxyConfidence] = None 

132 proxy_details: Optional[ProxyDetails] = None 

133 incognito: Optional[StrictBool] = Field( 

134 default=None, 

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

136 ) 

137 jailbroken: Optional[StrictBool] = Field( 

138 default=None, 

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

140 ) 

141 location_spoofing: Optional[StrictBool] = Field( 

142 default=None, 

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

144 ) 

145 mitm_attack: Optional[StrictBool] = Field( 

146 default=None, 

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

148 ) 

149 privacy_settings: Optional[StrictBool] = Field( 

150 default=None, 

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

152 ) 

153 root_apps: Optional[StrictBool] = Field( 

154 default=None, 

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

156 ) 

157 rule_action: Optional[EventRuleAction] = None 

158 suspect_score: Optional[StrictInt] = Field( 

159 default=None, 

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

161 ) 

162 tampering: Optional[StrictBool] = Field( 

163 default=None, 

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

165 ) 

166 tampering_details: Optional[TamperingDetails] = None 

167 velocity: Optional[Velocity] = None 

168 virtual_machine: Optional[StrictBool] = Field( 

169 default=None, 

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

171 ) 

172 vpn: Optional[StrictBool] = Field( 

173 default=None, 

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

175 ) 

176 vpn_confidence: Optional[VpnConfidence] = None 

177 vpn_origin_timezone: Optional[StrictStr] = Field( 

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

179 ) 

180 vpn_origin_country: Optional[StrictStr] = Field( 

181 default=None, 

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

183 ) 

184 vpn_methods: Optional[VpnMethods] = None 

185 high_activity_device: Optional[StrictBool] = Field( 

186 default=None, 

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

188 ) 

189 raw_device_attributes: Optional[RawDeviceAttributes] = None 

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

191 'event_id', 

192 'timestamp', 

193 'linked_id', 

194 'environment_id', 

195 'suspect', 

196 'sdk', 

197 'replayed', 

198 'identification', 

199 'supplementary_id_high_recall', 

200 'tags', 

201 'url', 

202 'bundle_id', 

203 'package_name', 

204 'ip_address', 

205 'user_agent', 

206 'client_referrer', 

207 'browser_details', 

208 'proximity', 

209 'bot', 

210 'bot_type', 

211 'bot_info', 

212 'cloned_app', 

213 'developer_tools', 

214 'emulator', 

215 'factory_reset_timestamp', 

216 'frida', 

217 'ip_blocklist', 

218 'ip_info', 

219 'proxy', 

220 'proxy_confidence', 

221 'proxy_details', 

222 'incognito', 

223 'jailbroken', 

224 'location_spoofing', 

225 'mitm_attack', 

226 'privacy_settings', 

227 'root_apps', 

228 'rule_action', 

229 'suspect_score', 

230 'tampering', 

231 'tampering_details', 

232 'velocity', 

233 'virtual_machine', 

234 'vpn', 

235 'vpn_confidence', 

236 'vpn_origin_timezone', 

237 'vpn_origin_country', 

238 'vpn_methods', 

239 'high_activity_device', 

240 'raw_device_attributes', 

241 ] 

242 

243 model_config = ConfigDict( 

244 populate_by_name=True, 

245 validate_assignment=True, 

246 protected_namespaces=(), 

247 ) 

248 

249 def to_str(self) -> str: 

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

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

252 

253 def to_json(self) -> str: 

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

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

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

257 

258 @classmethod 

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

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

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

262 

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

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

265 

266 This has the following differences from calling pydantic's 

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

268 

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

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

271 are ignored. 

272 """ 

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

274 

275 _dict = self.model_dump( 

276 by_alias=True, 

277 exclude=excluded_fields, 

278 exclude_none=True, 

279 ) 

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

281 if self.sdk: 

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

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

284 if self.identification: 

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

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

287 if self.supplementary_id_high_recall: 

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

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

290 if self.browser_details: 

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

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

293 if self.proximity: 

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

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

296 if self.bot_info: 

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

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

299 if self.ip_blocklist: 

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

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

302 if self.ip_info: 

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

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

305 if self.proxy_details: 

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

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

308 if self.rule_action: 

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

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

311 if self.tampering_details: 

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

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

314 if self.velocity: 

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

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

317 if self.vpn_methods: 

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

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

320 if self.raw_device_attributes: 

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

322 return _dict 

323 

324 @classmethod 

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

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

327 if obj is None: 

328 return None 

329 

330 if not isinstance(obj, dict): 

331 return cls.model_validate(obj) 

332 

333 _obj = cls.model_validate( 

334 { 

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

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

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

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

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

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

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

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

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

344 else None, 

345 'supplementary_id_high_recall': SupplementaryIDHighRecall.from_dict( 

346 obj['supplementary_id_high_recall'] 

347 ) 

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

349 else None, 

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

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

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

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

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

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

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

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

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

359 else None, 

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

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

362 else None, 

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

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

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

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

367 else None, 

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

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

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

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

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

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

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

375 else None, 

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

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

378 else None, 

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

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

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

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

383 else None, 

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

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

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

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

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

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

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

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

392 else None, 

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

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

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

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

397 else None, 

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

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

400 else None, 

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

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

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

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

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

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

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

408 else None, 

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

410 'raw_device_attributes': RawDeviceAttributes.from_dict( 

411 obj['raw_device_attributes'] 

412 ) 

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

414 else None, 

415 } 

416 ) 

417 return _obj