Coverage for fingerprint_server_sdk / models / proxy_details.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 Any, ClassVar, Optional 

19 

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

21from typing_extensions import Self 

22 

23 

24class ProxyDetails(BaseModel): 

25 """ 

26 Proxy detection details (present if `proxy` is `true`) 

27 """ 

28 

29 proxy_type: StrictStr = Field( 

30 description='Residential proxies use real user IP addresses to appear as legitimate traffic, while data center proxies are public proxies hosted in data centers ' 

31 ) 

32 last_seen_at: Optional[StrictInt] = Field( 

33 default=None, 

34 description='Unix millisecond timestamp with hourly resolution of when this IP was last seen as a proxy ', 

35 ) 

36 provider: Optional[StrictStr] = Field( 

37 default=None, 

38 description='String representing the last proxy service provider detected when this IP was synced. An IP can be shared by multiple service providers. ', 

39 ) 

40 __properties: ClassVar[list[str]] = ['proxy_type', 'last_seen_at', 'provider'] 

41 

42 @field_validator('proxy_type') 

43 def proxy_type_validate_enum(cls, value: Any) -> Any: 

44 """Validates the enum""" 

45 if value not in set(['residential', 'data_center']): 

46 raise ValueError("must be one of enum values ('residential', 'data_center')") 

47 return value 

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 ProxyDetails 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 return _dict 

87 

88 @classmethod 

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

90 """Create an instance of ProxyDetails from a dict""" 

91 if obj is None: 

92 return None 

93 

94 if not isinstance(obj, dict): 

95 return cls.model_validate(obj) 

96 

97 _obj = cls.model_validate( 

98 { 

99 'proxy_type': obj.get('proxy_type'), 

100 'last_seen_at': obj.get('last_seen_at'), 

101 'provider': obj.get('provider'), 

102 } 

103 ) 

104 return _obj