Coverage for fingerprint_server_sdk/models/raw_device_attributes.py: 69%
85 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-14 10:45 +0000
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-14 10:45 +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.
5The API also supports collection of Automation Intelligence for requests to your server in edge, pre-origin, or middleware contexts.
7The version of the OpenAPI document: 4
8Contact: support@fingerprint.com
9Generated by OpenAPI Generator (https://openapi-generator.tech)
11Do not edit the class manually.
12""" # noqa: E501
14from __future__ import annotations
16import json
17import pprint
18import re # noqa: F401
19from typing import Annotated, Any, ClassVar, Optional, Union
21from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
22from typing_extensions import Self
24from fingerprint_server_sdk.models.canvas import Canvas
25from fingerprint_server_sdk.models.emoji import Emoji
26from fingerprint_server_sdk.models.font_preferences import FontPreferences
27from fingerprint_server_sdk.models.plugins_inner import PluginsInner
28from fingerprint_server_sdk.models.touch_support import TouchSupport
29from fingerprint_server_sdk.models.web_gl_basics import WebGlBasics
30from fingerprint_server_sdk.models.web_gl_extensions import WebGlExtensions
33class RawDeviceAttributes(BaseModel):
34 """
35 A curated subset of raw browser/device attributes that the API surface exposes. Each property contains a value or object with the data for the collected signal.
36 """
38 font_preferences: Optional[FontPreferences] = None
39 emoji: Optional[Emoji] = None
40 fonts: Optional[list[StrictStr]] = Field(
41 default=None, description='List of fonts detected on the device.'
42 )
43 device_memory: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(
44 default=None, description='Rounded amount of RAM in gigabytes.'
45 )
46 timezone: Optional[StrictStr] = Field(
47 default=None, description='Timezone identifier detected on the client.'
48 )
49 canvas: Optional[Canvas] = None
50 languages: Optional[list[list[StrictStr]]] = Field(
51 default=None,
52 description='Navigator languages reported by the agent including fallbacks. Each inner array represents ordered language preferences reported by different APIs. Available for browsers, iOS, and Android devices. ',
53 )
54 webgl_extensions: Optional[WebGlExtensions] = None
55 webgl_basics: Optional[WebGlBasics] = None
56 screen_resolution: Optional[Annotated[list[StrictInt], Field(min_length=2, max_length=2)]] = (
57 Field(
58 default=None,
59 description='Current screen resolution. Available for both browsers and iOS devices',
60 )
61 )
62 touch_support: Optional[TouchSupport] = None
63 oscpu: Optional[StrictStr] = Field(default=None, description='Navigator `oscpu` string.')
64 architecture: Optional[StrictInt] = Field(
65 default=None,
66 description='Integer representing the CPU architecture exposed by the browser.',
67 )
68 cookies_enabled: Optional[StrictBool] = Field(
69 default=None, description='Whether the cookies are enabled in the browser.'
70 )
71 hardware_concurrency: Optional[StrictInt] = Field(
72 default=None, description='Number of logical CPU cores reported by the browser.'
73 )
74 date_time_locale: Optional[StrictStr] = Field(
75 default=None,
76 description='Locale derived from the Intl.DateTimeFormat API. Negative values indicate known error states. The negative statuses can be: - "-1": A permanent status for browsers that don\'t support Intl API. - "-2": A permanent status for browsers that don\'t supportDateTimeFormat constructor. - "-3": A permanent status for browsers in which DateTimeFormat locale is undefined or null. ',
77 )
78 vendor: Optional[StrictStr] = Field(default=None, description='Navigator vendor string.')
79 color_depth: Optional[StrictInt] = Field(
80 default=None, description='Screen color depth in bits.'
81 )
82 platform: Optional[StrictStr] = Field(default=None, description='Navigator platform string.')
83 session_storage: Optional[StrictBool] = Field(
84 default=None, description='Whether sessionStorage is available.'
85 )
86 local_storage: Optional[StrictBool] = Field(
87 default=None, description='Whether localStorage is available.'
88 )
89 audio: Optional[Union[StrictFloat, StrictInt]] = Field(
90 default=None,
91 description="AudioContext fingerprint or negative status when unavailable. The negative statuses can be: - -1: A permanent status for those browsers which are known to always suspend audio context - -2: A permanent status for browsers that don't support the signal - -3: A temporary status that means that an unexpected timeout has happened ",
92 )
93 plugins: Optional[list[PluginsInner]] = Field(
94 default=None, description='Browser plugins reported by `navigator.plugins`.'
95 )
96 indexed_db: Optional[StrictBool] = Field(
97 default=None, description='Whether IndexedDB is available.'
98 )
99 math: Optional[StrictStr] = Field(
100 default=None, description='Hash of Math APIs used for entropy collection.'
101 )
102 device_model: Optional[StrictStr] = Field(
103 default=None,
104 description='Device model string. Available only for Android and iOS devices.',
105 )
106 device_manufacturer: Optional[StrictStr] = Field(
107 default=None,
108 description='Device manufacturer string. Available only for Android and iOS devices.',
109 )
110 font_hash: Optional[StrictStr] = Field(
111 default=None, description='Unique identifier for the user’s installed fonts.'
112 )
113 timezone_offset: Optional[StrictStr] = Field(
114 default=None,
115 description='UTC offset in "±HH:MM" format derived from the detected IANA timezone.',
116 )
117 battery_level: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(
118 default=None,
119 description='Battery charge level as a percentage (0-100). Available only for Android and iOS devices.',
120 )
121 battery_low_power_mode: Optional[StrictBool] = Field(
122 default=None,
123 description="Whether the device's low power mode is enabled. Available only for Android and iOS devices.",
124 )
125 __properties: ClassVar[list[str]] = [
126 'font_preferences',
127 'emoji',
128 'fonts',
129 'device_memory',
130 'timezone',
131 'canvas',
132 'languages',
133 'webgl_extensions',
134 'webgl_basics',
135 'screen_resolution',
136 'touch_support',
137 'oscpu',
138 'architecture',
139 'cookies_enabled',
140 'hardware_concurrency',
141 'date_time_locale',
142 'vendor',
143 'color_depth',
144 'platform',
145 'session_storage',
146 'local_storage',
147 'audio',
148 'plugins',
149 'indexed_db',
150 'math',
151 'device_model',
152 'device_manufacturer',
153 'font_hash',
154 'timezone_offset',
155 'battery_level',
156 'battery_low_power_mode',
157 ]
159 model_config = ConfigDict(
160 populate_by_name=True,
161 validate_assignment=True,
162 protected_namespaces=(),
163 )
165 def to_str(self) -> str:
166 """Returns the string representation of the model using alias"""
167 return pprint.pformat(self.model_dump(by_alias=True))
169 def to_json(self) -> str:
170 """Returns the JSON representation of the model using alias"""
171 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
172 return json.dumps(self.to_dict())
174 @classmethod
175 def from_json(cls, json_str: str) -> Optional[Self]:
176 """Create an instance of RawDeviceAttributes from a JSON string"""
177 return cls.from_dict(json.loads(json_str))
179 def to_dict(self) -> dict[str, Any]:
180 """Return the dictionary representation of the model using alias.
182 This has the following differences from calling pydantic's
183 `self.model_dump(by_alias=True)`:
185 * `None` is only added to the output dict for nullable fields that
186 were set at model initialization. Other fields with value `None`
187 are ignored.
188 """
189 excluded_fields: set[str] = set([])
191 _dict = self.model_dump(
192 by_alias=True,
193 exclude=excluded_fields,
194 exclude_none=True,
195 )
196 # override the default output from pydantic by calling `to_dict()` of font_preferences
197 if self.font_preferences:
198 _dict['font_preferences'] = self.font_preferences.to_dict()
199 # override the default output from pydantic by calling `to_dict()` of emoji
200 if self.emoji:
201 _dict['emoji'] = self.emoji.to_dict()
202 # override the default output from pydantic by calling `to_dict()` of canvas
203 if self.canvas:
204 _dict['canvas'] = self.canvas.to_dict()
205 # override the default output from pydantic by calling `to_dict()` of webgl_extensions
206 if self.webgl_extensions:
207 _dict['webgl_extensions'] = self.webgl_extensions.to_dict()
208 # override the default output from pydantic by calling `to_dict()` of webgl_basics
209 if self.webgl_basics:
210 _dict['webgl_basics'] = self.webgl_basics.to_dict()
211 # override the default output from pydantic by calling `to_dict()` of touch_support
212 if self.touch_support:
213 _dict['touch_support'] = self.touch_support.to_dict()
214 # override the default output from pydantic by calling `to_dict()` of each item in plugins (list)
215 _items = []
216 if self.plugins:
217 for _item_plugins in self.plugins:
218 if _item_plugins:
219 _items.append(_item_plugins.to_dict())
220 _dict['plugins'] = _items
221 return _dict
223 @classmethod
224 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
225 """Create an instance of RawDeviceAttributes from a dict"""
226 if obj is None:
227 return None
229 if not isinstance(obj, dict):
230 return cls.model_validate(obj)
232 _obj = cls.model_validate(
233 {
234 'font_preferences': FontPreferences.from_dict(obj['font_preferences'])
235 if obj.get('font_preferences') is not None
236 else None,
237 'emoji': Emoji.from_dict(obj['emoji']) if obj.get('emoji') is not None else None,
238 'fonts': obj.get('fonts'),
239 'device_memory': obj.get('device_memory'),
240 'timezone': obj.get('timezone'),
241 'canvas': Canvas.from_dict(obj['canvas'])
242 if obj.get('canvas') is not None
243 else None,
244 'languages': obj.get('languages'),
245 'webgl_extensions': WebGlExtensions.from_dict(obj['webgl_extensions'])
246 if obj.get('webgl_extensions') is not None
247 else None,
248 'webgl_basics': WebGlBasics.from_dict(obj['webgl_basics'])
249 if obj.get('webgl_basics') is not None
250 else None,
251 'screen_resolution': obj.get('screen_resolution'),
252 'touch_support': TouchSupport.from_dict(obj['touch_support'])
253 if obj.get('touch_support') is not None
254 else None,
255 'oscpu': obj.get('oscpu'),
256 'architecture': obj.get('architecture'),
257 'cookies_enabled': obj.get('cookies_enabled'),
258 'hardware_concurrency': obj.get('hardware_concurrency'),
259 'date_time_locale': obj.get('date_time_locale'),
260 'vendor': obj.get('vendor'),
261 'color_depth': obj.get('color_depth'),
262 'platform': obj.get('platform'),
263 'session_storage': obj.get('session_storage'),
264 'local_storage': obj.get('local_storage'),
265 'audio': obj.get('audio'),
266 'plugins': [PluginsInner.from_dict(_item) for _item in obj['plugins']]
267 if obj.get('plugins') is not None
268 else None,
269 'indexed_db': obj.get('indexed_db'),
270 'math': obj.get('math'),
271 'device_model': obj.get('device_model'),
272 'device_manufacturer': obj.get('device_manufacturer'),
273 'font_hash': obj.get('font_hash'),
274 'timezone_offset': obj.get('timezone_offset'),
275 'battery_level': obj.get('battery_level'),
276 'battery_low_power_mode': obj.get('battery_low_power_mode'),
277 }
278 )
279 return _obj