Coverage for fingerprint_server_sdk / models / ip_info_v6.py: 75%

40 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, StrictBool, StrictStr 

21from typing_extensions import Self 

22 

23from fingerprint_server_sdk.models.geolocation import Geolocation 

24 

25 

26class IPInfoV6(BaseModel): 

27 """ 

28 IPInfoV6 

29 """ 

30 

31 address: StrictStr 

32 geolocation: Optional[Geolocation] = None 

33 asn: Optional[StrictStr] = None 

34 asn_name: Optional[StrictStr] = None 

35 asn_network: Optional[StrictStr] = None 

36 asn_type: Optional[StrictStr] = None 

37 datacenter_result: Optional[StrictBool] = None 

38 datacenter_name: Optional[StrictStr] = None 

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

40 'address', 

41 'geolocation', 

42 'asn', 

43 'asn_name', 

44 'asn_network', 

45 'asn_type', 

46 'datacenter_result', 

47 'datacenter_name', 

48 ] 

49 

50 model_config = ConfigDict( 

51 populate_by_name=True, 

52 validate_assignment=True, 

53 protected_namespaces=(), 

54 ) 

55 

56 def to_str(self) -> str: 

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

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

59 

60 def to_json(self) -> str: 

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

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

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

64 

65 @classmethod 

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

67 """Create an instance of IPInfoV6 from a JSON string""" 

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

69 

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

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

72 

73 This has the following differences from calling pydantic's 

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

75 

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

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

78 are ignored. 

79 """ 

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

81 

82 _dict = self.model_dump( 

83 by_alias=True, 

84 exclude=excluded_fields, 

85 exclude_none=True, 

86 ) 

87 # override the default output from pydantic by calling `to_dict()` of geolocation 

88 if self.geolocation: 

89 _dict['geolocation'] = self.geolocation.to_dict() 

90 return _dict 

91 

92 @classmethod 

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

94 """Create an instance of IPInfoV6 from a dict""" 

95 if obj is None: 

96 return None 

97 

98 if not isinstance(obj, dict): 

99 return cls.model_validate(obj) 

100 

101 _obj = cls.model_validate( 

102 { 

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

104 'geolocation': Geolocation.from_dict(obj['geolocation']) 

105 if obj.get('geolocation') is not None 

106 else None, 

107 'asn': obj.get('asn'), 

108 'asn_name': obj.get('asn_name'), 

109 'asn_network': obj.get('asn_network'), 

110 'asn_type': obj.get('asn_type'), 

111 'datacenter_result': obj.get('datacenter_result'), 

112 'datacenter_name': obj.get('datacenter_name'), 

113 } 

114 ) 

115 return _obj