Coverage for fingerprint_server_sdk / models / error_response.py: 70%

33 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 

21from typing_extensions import Self 

22 

23from fingerprint_server_sdk.models.error import Error 

24 

25 

26class ErrorResponse(BaseModel): 

27 """ 

28 ErrorResponse 

29 """ 

30 

31 error: Error 

32 __properties: ClassVar[list[str]] = ['error'] 

33 

34 model_config = ConfigDict( 

35 populate_by_name=True, 

36 validate_assignment=True, 

37 protected_namespaces=(), 

38 ) 

39 

40 def to_str(self) -> str: 

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

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

43 

44 def to_json(self) -> str: 

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

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

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

48 

49 @classmethod 

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

51 """Create an instance of ErrorResponse from a JSON string""" 

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

53 

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

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

56 

57 This has the following differences from calling pydantic's 

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

59 

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

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

62 are ignored. 

63 """ 

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

65 

66 _dict = self.model_dump( 

67 by_alias=True, 

68 exclude=excluded_fields, 

69 exclude_none=True, 

70 ) 

71 # override the default output from pydantic by calling `to_dict()` of error 

72 if self.error: 

73 _dict['error'] = self.error.to_dict() 

74 return _dict 

75 

76 @classmethod 

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

78 """Create an instance of ErrorResponse from a dict""" 

79 if obj is None: 

80 return None 

81 

82 if not isinstance(obj, dict): 

83 return cls.model_validate(obj) 

84 

85 _obj = cls.model_validate( 

86 {'error': Error.from_dict(obj['error']) if obj.get('error') is not None else None} 

87 ) 

88 return _obj