Coverage for fingerprint_server_sdk/models/velocity_data.py: 75%
32 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 Any, ClassVar, Optional
21from pydantic import BaseModel, ConfigDict, Field, StrictInt
22from typing_extensions import Self
25class VelocityData(BaseModel):
26 """
27 Is absent if the velocity data could not be generated for the visitor Id.
28 """
30 var_5_minutes: StrictInt = Field(
31 description='Count for the last 5 minutes of velocity data, from the time of the event. ',
32 alias='5_minutes',
33 )
34 var_1_hour: StrictInt = Field(
35 description='Count for the last 1 hour of velocity data, from the time of the event. ',
36 alias='1_hour',
37 )
38 var_24_hours: Optional[StrictInt] = Field(
39 default=None,
40 description="The `24_hours` interval of `distinct_ip`, `distinct_linked_id`, `distinct_country`, `distinct_ip_by_linked_id` and `distinct_visitor_id_by_linked_id` will be omitted if the number of `events` for the visitor Id in the last 24 hours (`events.['24_hours']`) is higher than 20.000. ",
41 alias='24_hours',
42 )
43 __properties: ClassVar[list[str]] = ['5_minutes', '1_hour', '24_hours']
45 model_config = ConfigDict(
46 populate_by_name=True,
47 validate_assignment=True,
48 protected_namespaces=(),
49 )
51 def to_str(self) -> str:
52 """Returns the string representation of the model using alias"""
53 return pprint.pformat(self.model_dump(by_alias=True))
55 def to_json(self) -> str:
56 """Returns the JSON representation of the model using alias"""
57 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
58 return json.dumps(self.to_dict())
60 @classmethod
61 def from_json(cls, json_str: str) -> Optional[Self]:
62 """Create an instance of VelocityData from a JSON string"""
63 return cls.from_dict(json.loads(json_str))
65 def to_dict(self) -> dict[str, Any]:
66 """Return the dictionary representation of the model using alias.
68 This has the following differences from calling pydantic's
69 `self.model_dump(by_alias=True)`:
71 * `None` is only added to the output dict for nullable fields that
72 were set at model initialization. Other fields with value `None`
73 are ignored.
74 """
75 excluded_fields: set[str] = set([])
77 _dict = self.model_dump(
78 by_alias=True,
79 exclude=excluded_fields,
80 exclude_none=True,
81 )
82 return _dict
84 @classmethod
85 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
86 """Create an instance of VelocityData from a dict"""
87 if obj is None:
88 return None
90 if not isinstance(obj, dict):
91 return cls.model_validate(obj)
93 _obj = cls.model_validate(
94 {
95 '5_minutes': obj.get('5_minutes'),
96 '1_hour': obj.get('1_hour'),
97 '24_hours': obj.get('24_hours'),
98 }
99 )
100 return _obj