Coverage for fingerprint_server_sdk/models/velocity.py: 57%

51 statements  

« 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. 

6 

7The version of the OpenAPI document: 4 

8Contact: support@fingerprint.com 

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

10 

11Do not edit the class manually. 

12""" # noqa: E501 

13 

14from __future__ import annotations 

15 

16import json 

17import pprint 

18import re # noqa: F401 

19from typing import Any, ClassVar, Optional 

20 

21from pydantic import BaseModel, ConfigDict 

22from typing_extensions import Self 

23 

24from fingerprint_server_sdk.models.velocity_data import VelocityData 

25 

26 

27class Velocity(BaseModel): 

28 """ 

29 Sums key data points for a specific `visitor_id`, `ip_address` and `linked_id` at three distinct time intervals: 5 minutes, 1 hour, and 24 hours as follows: - Number of distinct IP addresses associated to the visitor Id. - Number of distinct linked Ids associated with the visitor Id. - Number of distinct countries associated with the visitor Id. - Number of identification events associated with the visitor Id. - Number of identification events associated with the detected IP address. - Number of distinct IP addresses associated with the provided linked Id. - Number of distinct visitor Ids associated with the provided linked Id. The `24h` 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.['24h']`) is higher than 20.000. All will not necessarily be returned in a response, some may be omitted if the associated event does not have the required data, such as a linked_id. 

30 """ 

31 

32 distinct_ip: Optional[VelocityData] = None 

33 distinct_linked_id: Optional[VelocityData] = None 

34 distinct_country: Optional[VelocityData] = None 

35 events: Optional[VelocityData] = None 

36 ip_events: Optional[VelocityData] = None 

37 distinct_ip_by_linked_id: Optional[VelocityData] = None 

38 distinct_visitor_id_by_linked_id: Optional[VelocityData] = None 

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

40 'distinct_ip', 

41 'distinct_linked_id', 

42 'distinct_country', 

43 'events', 

44 'ip_events', 

45 'distinct_ip_by_linked_id', 

46 'distinct_visitor_id_by_linked_id', 

47 ] 

48 

49 model_config = ConfigDict( 

50 populate_by_name=True, 

51 validate_assignment=True, 

52 protected_namespaces=(), 

53 ) 

54 

55 def to_str(self) -> str: 

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

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

58 

59 def to_json(self) -> str: 

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

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

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

63 

64 @classmethod 

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

66 """Create an instance of Velocity from a JSON string""" 

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

68 

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

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

71 

72 This has the following differences from calling pydantic's 

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

74 

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

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

77 are ignored. 

78 """ 

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

80 

81 _dict = self.model_dump( 

82 by_alias=True, 

83 exclude=excluded_fields, 

84 exclude_none=True, 

85 ) 

86 # override the default output from pydantic by calling `to_dict()` of distinct_ip 

87 if self.distinct_ip: 

88 _dict['distinct_ip'] = self.distinct_ip.to_dict() 

89 # override the default output from pydantic by calling `to_dict()` of distinct_linked_id 

90 if self.distinct_linked_id: 

91 _dict['distinct_linked_id'] = self.distinct_linked_id.to_dict() 

92 # override the default output from pydantic by calling `to_dict()` of distinct_country 

93 if self.distinct_country: 

94 _dict['distinct_country'] = self.distinct_country.to_dict() 

95 # override the default output from pydantic by calling `to_dict()` of events 

96 if self.events: 

97 _dict['events'] = self.events.to_dict() 

98 # override the default output from pydantic by calling `to_dict()` of ip_events 

99 if self.ip_events: 

100 _dict['ip_events'] = self.ip_events.to_dict() 

101 # override the default output from pydantic by calling `to_dict()` of distinct_ip_by_linked_id 

102 if self.distinct_ip_by_linked_id: 

103 _dict['distinct_ip_by_linked_id'] = self.distinct_ip_by_linked_id.to_dict() 

104 # override the default output from pydantic by calling `to_dict()` of distinct_visitor_id_by_linked_id 

105 if self.distinct_visitor_id_by_linked_id: 

106 _dict['distinct_visitor_id_by_linked_id'] = ( 

107 self.distinct_visitor_id_by_linked_id.to_dict() 

108 ) 

109 return _dict 

110 

111 @classmethod 

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

113 """Create an instance of Velocity from a dict""" 

114 if obj is None: 

115 return None 

116 

117 if not isinstance(obj, dict): 

118 return cls.model_validate(obj) 

119 

120 _obj = cls.model_validate( 

121 { 

122 'distinct_ip': VelocityData.from_dict(obj['distinct_ip']) 

123 if obj.get('distinct_ip') is not None 

124 else None, 

125 'distinct_linked_id': VelocityData.from_dict(obj['distinct_linked_id']) 

126 if obj.get('distinct_linked_id') is not None 

127 else None, 

128 'distinct_country': VelocityData.from_dict(obj['distinct_country']) 

129 if obj.get('distinct_country') is not None 

130 else None, 

131 'events': VelocityData.from_dict(obj['events']) 

132 if obj.get('events') is not None 

133 else None, 

134 'ip_events': VelocityData.from_dict(obj['ip_events']) 

135 if obj.get('ip_events') is not None 

136 else None, 

137 'distinct_ip_by_linked_id': VelocityData.from_dict(obj['distinct_ip_by_linked_id']) 

138 if obj.get('distinct_ip_by_linked_id') is not None 

139 else None, 

140 'distinct_visitor_id_by_linked_id': VelocityData.from_dict( 

141 obj['distinct_visitor_id_by_linked_id'] 

142 ) 

143 if obj.get('distinct_visitor_id_by_linked_id') is not None 

144 else None, 

145 } 

146 ) 

147 return _obj