Coverage for fingerprint_server_sdk / models / proximity.py: 76%

37 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 Annotated, Any, ClassVar, Optional, Union 

19 

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

21from typing_extensions import Self 

22 

23 

24class Proximity(BaseModel): 

25 """ 

26 Proximity ID represents a fixed geographical zone in a discrete global grid within which the device is observed. 

27 """ 

28 

29 id: StrictStr = Field( 

30 description='A stable privacy-preserving identifier for a given proximity zone. ' 

31 ) 

32 precision_radius: StrictInt = Field( 

33 description='The radius of the proximity zone’s precision level, in meters. ' 

34 ) 

35 confidence: Union[ 

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

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

38 ] = Field( 

39 description='A value between `0` and `1` representing the likelihood that the true device location lies within the mapped proximity zone. * Scores closer to `1` indicate high confidence that the location is inside the mapped proximity zone. * Scores closer to `0` indicate lower confidence, suggesting the true location may fall in an adjacent zone. ' 

40 ) 

41 __properties: ClassVar[list[str]] = ['id', 'precision_radius', 'confidence'] 

42 

43 @field_validator('precision_radius') 

44 def precision_radius_validate_enum(cls, value: Any) -> Any: 

45 """Validates the enum""" 

46 if value not in set([10, 25, 65, 175, 450, 1200, 3300, 8500, 22500]): 

47 raise ValueError( 

48 'must be one of enum values (10, 25, 65, 175, 450, 1200, 3300, 8500, 22500)' 

49 ) 

50 return value 

51 

52 model_config = ConfigDict( 

53 populate_by_name=True, 

54 validate_assignment=True, 

55 protected_namespaces=(), 

56 ) 

57 

58 def to_str(self) -> str: 

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

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

61 

62 def to_json(self) -> str: 

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

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

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

66 

67 @classmethod 

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

69 """Create an instance of Proximity from a JSON string""" 

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

71 

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

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

74 

75 This has the following differences from calling pydantic's 

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

77 

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

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

80 are ignored. 

81 """ 

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

83 

84 _dict = self.model_dump( 

85 by_alias=True, 

86 exclude=excluded_fields, 

87 exclude_none=True, 

88 ) 

89 return _dict 

90 

91 @classmethod 

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

93 """Create an instance of Proximity from a dict""" 

94 if obj is None: 

95 return None 

96 

97 if not isinstance(obj, dict): 

98 return cls.model_validate(obj) 

99 

100 _obj = cls.model_validate( 

101 { 

102 'id': obj.get('id'), 

103 'precision_radius': obj.get('precision_radius'), 

104 'confidence': obj.get('confidence'), 

105 } 

106 ) 

107 return _obj