Coverage for fingerprint_server_sdk/models/vpn_methods.py: 77%

35 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, Field, StrictBool 

22from typing_extensions import Self 

23 

24 

25class VpnMethods(BaseModel): 

26 """ 

27 VpnMethods 

28 """ 

29 

30 timezone_mismatch: Optional[StrictBool] = Field( 

31 default=None, 

32 description="The browser timezone doesn't match the timezone inferred from the request IP address.", 

33 ) 

34 public_vpn: Optional[StrictBool] = Field( 

35 default=None, 

36 description='Request IP address is owned and used by a public VPN service provider.', 

37 ) 

38 auxiliary_mobile: Optional[StrictBool] = Field( 

39 default=None, 

40 description='This method applies to mobile devices only. Indicates the result of additional methods used to detect a VPN in mobile devices.', 

41 ) 

42 os_mismatch: Optional[StrictBool] = Field( 

43 default=None, 

44 description='The browser runs on a different operating system than the operating system inferred from the request network signature.', 

45 ) 

46 relay: Optional[StrictBool] = Field( 

47 default=None, 

48 description="Request IP address belongs to a relay service provider, indicating the use of relay services like [Apple Private relay](https://support.apple.com/en-us/102602) or [Cloudflare Warp](https://developers.cloudflare.com/warp-client/). * Like VPNs, relay services anonymize the visitor's true IP address. * Unlike traditional VPNs, relay services don't let visitors spoof their location by choosing an exit node in a different country. This field allows you to differentiate VPN users and relay service users in your fraud prevention logic. ", 

49 ) 

50 ml_prediction: Optional[StrictBool] = Field( 

51 default=None, 

52 description='`true` if the request came from a device running a VPN, `false` otherwise. ', 

53 ) 

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

55 'timezone_mismatch', 

56 'public_vpn', 

57 'auxiliary_mobile', 

58 'os_mismatch', 

59 'relay', 

60 'ml_prediction', 

61 ] 

62 

63 model_config = ConfigDict( 

64 populate_by_name=True, 

65 validate_assignment=True, 

66 protected_namespaces=(), 

67 ) 

68 

69 def to_str(self) -> str: 

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

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

72 

73 def to_json(self) -> str: 

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

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

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

77 

78 @classmethod 

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

80 """Create an instance of VpnMethods from a JSON string""" 

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

82 

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

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

85 

86 This has the following differences from calling pydantic's 

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

88 

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

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

91 are ignored. 

92 """ 

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

94 

95 _dict = self.model_dump( 

96 by_alias=True, 

97 exclude=excluded_fields, 

98 exclude_none=True, 

99 ) 

100 return _dict 

101 

102 @classmethod 

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

104 """Create an instance of VpnMethods from a dict""" 

105 if obj is None: 

106 return None 

107 

108 if not isinstance(obj, dict): 

109 return cls.model_validate(obj) 

110 

111 _obj = cls.model_validate( 

112 { 

113 'timezone_mismatch': obj.get('timezone_mismatch'), 

114 'public_vpn': obj.get('public_vpn'), 

115 'auxiliary_mobile': obj.get('auxiliary_mobile'), 

116 'os_mismatch': obj.get('os_mismatch'), 

117 'relay': obj.get('relay'), 

118 'ml_prediction': obj.get('ml_prediction'), 

119 } 

120 ) 

121 return _obj