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

21from typing_extensions import Self 

22 

23 

24class Canvas(BaseModel): 

25 """ 

26 Canvas fingerprint containing winding flag plus geometry/text hashes. 

27 """ 

28 

29 winding: Optional[StrictBool] = None 

30 geometry: Optional[StrictStr] = Field( 

31 default=None, description='Hash of geometry rendering output or `unsupported` markers.' 

32 ) 

33 text: Optional[StrictStr] = Field( 

34 default=None, description='Hash of text rendering output or `unsupported` markers.' 

35 ) 

36 __properties: ClassVar[list[str]] = ['winding', 'geometry', 'text'] 

37 

38 model_config = ConfigDict( 

39 populate_by_name=True, 

40 validate_assignment=True, 

41 protected_namespaces=(), 

42 ) 

43 

44 def to_str(self) -> str: 

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

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

47 

48 def to_json(self) -> str: 

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

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

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

52 

53 @classmethod 

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

55 """Create an instance of Canvas from a JSON string""" 

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

57 

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

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

60 

61 This has the following differences from calling pydantic's 

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

63 

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

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

66 are ignored. 

67 """ 

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

69 

70 _dict = self.model_dump( 

71 by_alias=True, 

72 exclude=excluded_fields, 

73 exclude_none=True, 

74 ) 

75 return _dict 

76 

77 @classmethod 

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

79 """Create an instance of Canvas from a dict""" 

80 if obj is None: 

81 return None 

82 

83 if not isinstance(obj, dict): 

84 return cls.model_validate(obj) 

85 

86 _obj = cls.model_validate( 

87 { 

88 'winding': obj.get('winding'), 

89 'geometry': obj.get('geometry'), 

90 'text': obj.get('text'), 

91 } 

92 ) 

93 return _obj