Coverage for fingerprint_server_sdk/models/error_response.py: 70%
33 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-14 10:45 +0000
« 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.
7The version of the OpenAPI document: 4
8Contact: support@fingerprint.com
9Generated by OpenAPI Generator (https://openapi-generator.tech)
11Do not edit the class manually.
12""" # noqa: E501
14from __future__ import annotations
16import json
17import pprint
18import re # noqa: F401
19from typing import Any, ClassVar, Optional
21from pydantic import BaseModel, ConfigDict
22from typing_extensions import Self
24from fingerprint_server_sdk.models.error import Error
27class ErrorResponse(BaseModel):
28 """
29 ErrorResponse
30 """
32 error: Error
33 __properties: ClassVar[list[str]] = ['error']
35 model_config = ConfigDict(
36 populate_by_name=True,
37 validate_assignment=True,
38 protected_namespaces=(),
39 )
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))
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())
50 @classmethod
51 def from_json(cls, json_str: str) -> Optional[Self]:
52 """Create an instance of ErrorResponse from a JSON string"""
53 return cls.from_dict(json.loads(json_str))
55 def to_dict(self) -> dict[str, Any]:
56 """Return the dictionary representation of the model using alias.
58 This has the following differences from calling pydantic's
59 `self.model_dump(by_alias=True)`:
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([])
67 _dict = self.model_dump(
68 by_alias=True,
69 exclude=excluded_fields,
70 exclude_none=True,
71 )
72 # override the default output from pydantic by calling `to_dict()` of error
73 if self.error:
74 _dict['error'] = self.error.to_dict()
75 return _dict
77 @classmethod
78 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
79 """Create an instance of ErrorResponse from a dict"""
80 if obj is None:
81 return None
83 if not isinstance(obj, dict):
84 return cls.model_validate(obj)
86 _obj = cls.model_validate(
87 {'error': Error.from_dict(obj['error']) if obj.get('error') is not None else None}
88 )
89 return _obj