Coverage for fingerprint_server_sdk / models / bot_info.py: 60%

45 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, StrictStr, field_validator 

21from typing_extensions import Self 

22 

23 

24class BotInfo(BaseModel): 

25 """ 

26 Extended bot information. 

27 """ 

28 

29 category: StrictStr = Field(description='The type and purpose of the bot.') 

30 provider: StrictStr = Field(description='The organization or company operating the bot.') 

31 provider_url: Optional[StrictStr] = Field( 

32 default=None, description="The URL of the bot provider's website." 

33 ) 

34 name: StrictStr = Field(description='The specific name or identifier of the bot.') 

35 identity: StrictStr = Field( 

36 description="The verification status of the bot's identity: * `verified` - well-known bot with publicly verifiable identity, directed by the bot provider. * `signed` - bot that signs its platform via Web Bot Auth, directed by the bot provider’s customers. * `spoofed` - bot that claims a public identity but fails verification. * `unknown` - bot that does not publish a verifiable identity. " 

37 ) 

38 confidence: StrictStr = Field(description='Confidence level of the bot identification.') 

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

40 'category', 

41 'provider', 

42 'provider_url', 

43 'name', 

44 'identity', 

45 'confidence', 

46 ] 

47 

48 @field_validator('identity') 

49 def identity_validate_enum(cls, value: Any) -> Any: 

50 """Validates the enum""" 

51 if value not in set(['verified', 'signed', 'spoofed', 'unknown']): 

52 raise ValueError( 

53 "must be one of enum values ('verified', 'signed', 'spoofed', 'unknown')" 

54 ) 

55 return value 

56 

57 @field_validator('confidence') 

58 def confidence_validate_enum(cls, value: Any) -> Any: 

59 """Validates the enum""" 

60 if value not in set(['low', 'medium', 'high']): 

61 raise ValueError("must be one of enum values ('low', 'medium', 'high')") 

62 return value 

63 

64 model_config = ConfigDict( 

65 populate_by_name=True, 

66 validate_assignment=True, 

67 protected_namespaces=(), 

68 ) 

69 

70 def to_str(self) -> str: 

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

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

73 

74 def to_json(self) -> str: 

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

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

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

78 

79 @classmethod 

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

81 """Create an instance of BotInfo from a JSON string""" 

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

83 

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

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

86 

87 This has the following differences from calling pydantic's 

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

89 

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

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

92 are ignored. 

93 """ 

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

95 

96 _dict = self.model_dump( 

97 by_alias=True, 

98 exclude=excluded_fields, 

99 exclude_none=True, 

100 ) 

101 return _dict 

102 

103 @classmethod 

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

105 """Create an instance of BotInfo from a dict""" 

106 if obj is None: 

107 return None 

108 

109 if not isinstance(obj, dict): 

110 return cls.model_validate(obj) 

111 

112 _obj = cls.model_validate( 

113 { 

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

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

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

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

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

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

120 } 

121 ) 

122 return _obj