Coverage for fingerprint_server_sdk / models / error.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, StrictStr 

21from typing_extensions import Self 

22 

23from fingerprint_server_sdk.models.error_code import ErrorCode 

24 

25 

26class Error(BaseModel): 

27 """ 

28 Error 

29 """ 

30 

31 code: ErrorCode 

32 message: StrictStr 

33 __properties: ClassVar[list[str]] = ['code', 'message'] 

34 

35 model_config = ConfigDict( 

36 populate_by_name=True, 

37 validate_assignment=True, 

38 protected_namespaces=(), 

39 ) 

40 

41 def to_str(self) -> str: 

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

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

44 

45 def to_json(self) -> str: 

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

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

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

49 

50 @classmethod 

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

52 """Create an instance of Error from a JSON string""" 

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

54 

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

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

57 

58 This has the following differences from calling pydantic's 

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

60 

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

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

63 are ignored. 

64 """ 

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

66 

67 _dict = self.model_dump( 

68 by_alias=True, 

69 exclude=excluded_fields, 

70 exclude_none=True, 

71 ) 

72 return _dict 

73 

74 @classmethod 

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

76 """Create an instance of Error from a dict""" 

77 if obj is None: 

78 return None 

79 

80 if not isinstance(obj, dict): 

81 return cls.model_validate(obj) 

82 

83 _obj = cls.model_validate({'code': obj.get('code'), 'message': obj.get('message')}) 

84 return _obj