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

32 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-26 17:42 +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 Annotated, Any, ClassVar, Optional, Union 

19 

20from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr 

21from typing_extensions import Self 

22 

23 

24class LabelsInner(BaseModel): 

25 """ 

26 LabelsInner 

27 """ 

28 

29 label: StrictStr 

30 prediction: Optional[StrictBool] = None 

31 ml_score: Optional[ 

32 Union[ 

33 Annotated[float, Field(le=1, strict=True, ge=0)], 

34 Annotated[int, Field(le=1, strict=True, ge=0)], 

35 ] 

36 ] = None 

37 __properties: ClassVar[list[str]] = ['label', 'prediction', 'ml_score'] 

38 

39 model_config = ConfigDict( 

40 populate_by_name=True, 

41 validate_assignment=True, 

42 protected_namespaces=(), 

43 ) 

44 

45 def to_str(self) -> str: 

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

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

48 

49 def to_json(self) -> str: 

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

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

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

53 

54 @classmethod 

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

56 """Create an instance of LabelsInner from a JSON string""" 

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

58 

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

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

61 

62 This has the following differences from calling pydantic's 

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

64 

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

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

67 are ignored. 

68 """ 

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

70 

71 _dict = self.model_dump( 

72 by_alias=True, 

73 exclude=excluded_fields, 

74 exclude_none=True, 

75 ) 

76 return _dict 

77 

78 @classmethod 

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

80 """Create an instance of LabelsInner from a dict""" 

81 if obj is None: 

82 return None 

83 

84 if not isinstance(obj, dict): 

85 return cls.model_validate(obj) 

86 

87 _obj = cls.model_validate( 

88 { 

89 'label': obj.get('label'), 

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

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

92 } 

93 ) 

94 return _obj