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

32 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, StrictBool 

21from typing_extensions import Self 

22 

23 

24class IPBlockList(BaseModel): 

25 """ 

26 IPBlockList 

27 """ 

28 

29 email_spam: Optional[StrictBool] = Field( 

30 default=None, description='IP address was part of a known email spam attack (SMTP).' 

31 ) 

32 attack_source: Optional[StrictBool] = Field( 

33 default=None, description='IP address was part of a known network attack (SSH/HTTPS).' 

34 ) 

35 tor_node: Optional[StrictBool] = Field( 

36 default=None, description='IP address was part of known TOR network activity.' 

37 ) 

38 __properties: ClassVar[list[str]] = ['email_spam', 'attack_source', 'tor_node'] 

39 

40 model_config = ConfigDict( 

41 populate_by_name=True, 

42 validate_assignment=True, 

43 protected_namespaces=(), 

44 ) 

45 

46 def to_str(self) -> str: 

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

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

49 

50 def to_json(self) -> str: 

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

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

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

54 

55 @classmethod 

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

57 """Create an instance of IPBlockList from a JSON string""" 

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

59 

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

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

62 

63 This has the following differences from calling pydantic's 

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

65 

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

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

68 are ignored. 

69 """ 

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

71 

72 _dict = self.model_dump( 

73 by_alias=True, 

74 exclude=excluded_fields, 

75 exclude_none=True, 

76 ) 

77 return _dict 

78 

79 @classmethod 

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

81 """Create an instance of IPBlockList from a dict""" 

82 if obj is None: 

83 return None 

84 

85 if not isinstance(obj, dict): 

86 return cls.model_validate(obj) 

87 

88 _obj = cls.model_validate( 

89 { 

90 'email_spam': obj.get('email_spam'), 

91 'attack_source': obj.get('attack_source'), 

92 'tor_node': obj.get('tor_node'), 

93 } 

94 ) 

95 return _obj