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

32 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 Annotated, Any, ClassVar, Optional, Union 

20 

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

22from typing_extensions import Self 

23 

24 

25class LabelsInner(BaseModel): 

26 """ 

27 LabelsInner 

28 """ 

29 

30 label: StrictStr 

31 prediction: Optional[StrictBool] = None 

32 ml_score: Optional[ 

33 Union[ 

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

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

36 ] 

37 ] = None 

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

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 LabelsInner 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 LabelsInner 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 'label': obj.get('label'), 

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

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

93 } 

94 ) 

95 return _obj