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

20 

21from pydantic import BaseModel, ConfigDict, StrictStr 

22from typing_extensions import Self 

23 

24from fingerprint_server_sdk.models.error_code import ErrorCode 

25 

26 

27class Error(BaseModel): 

28 """ 

29 Error 

30 """ 

31 

32 code: ErrorCode 

33 message: StrictStr 

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

35 

36 model_config = ConfigDict( 

37 populate_by_name=True, 

38 validate_assignment=True, 

39 protected_namespaces=(), 

40 ) 

41 

42 def to_str(self) -> str: 

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

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

45 

46 def to_json(self) -> str: 

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

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

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

50 

51 @classmethod 

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

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

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

55 

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

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

58 

59 This has the following differences from calling pydantic's 

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

61 

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

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

64 are ignored. 

65 """ 

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

67 

68 _dict = self.model_dump( 

69 by_alias=True, 

70 exclude=excluded_fields, 

71 exclude_none=True, 

72 ) 

73 return _dict 

74 

75 @classmethod 

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

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

78 if obj is None: 

79 return None 

80 

81 if not isinstance(obj, dict): 

82 return cls.model_validate(obj) 

83 

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

85 return _obj