Coverage for fingerprint_server_sdk / models / event_search.py: 64%

39 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, StrictInt, StrictStr 

21from typing_extensions import Self 

22 

23from fingerprint_server_sdk.models.event import Event 

24 

25 

26class EventSearch(BaseModel): 

27 """ 

28 Contains a list of all identification events matching the specified search criteria. 

29 """ 

30 

31 events: list[Event] 

32 pagination_key: Optional[StrictStr] = Field( 

33 default=None, 

34 description='Use this value in the `pagination_key` parameter to request the next page of search results.', 

35 ) 

36 total_hits: Optional[StrictInt] = Field( 

37 default=None, 

38 description='This value represents the total number of events matching the search query, up to the limit provided in the `total_hits` query parameter. Only present if the `total_hits` query parameter was provided.', 

39 ) 

40 __properties: ClassVar[list[str]] = ['events', 'pagination_key', 'total_hits'] 

41 

42 model_config = ConfigDict( 

43 populate_by_name=True, 

44 validate_assignment=True, 

45 protected_namespaces=(), 

46 ) 

47 

48 def to_str(self) -> str: 

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

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

51 

52 def to_json(self) -> str: 

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

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

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

56 

57 @classmethod 

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

59 """Create an instance of EventSearch from a JSON string""" 

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

61 

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

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

64 

65 This has the following differences from calling pydantic's 

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

67 

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

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

70 are ignored. 

71 """ 

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

73 

74 _dict = self.model_dump( 

75 by_alias=True, 

76 exclude=excluded_fields, 

77 exclude_none=True, 

78 ) 

79 # override the default output from pydantic by calling `to_dict()` of each item in events (list) 

80 _items = [] 

81 if self.events: 

82 for _item_events in self.events: 

83 if _item_events: 

84 _items.append(_item_events.to_dict()) 

85 _dict['events'] = _items 

86 return _dict 

87 

88 @classmethod 

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

90 """Create an instance of EventSearch from a dict""" 

91 if obj is None: 

92 return None 

93 

94 if not isinstance(obj, dict): 

95 return cls.model_validate(obj) 

96 

97 _obj = cls.model_validate( 

98 { 

99 'events': [Event.from_dict(_item) for _item in obj['events']] 

100 if obj.get('events') is not None 

101 else None, 

102 'pagination_key': obj.get('pagination_key'), 

103 'total_hits': obj.get('total_hits'), 

104 } 

105 ) 

106 return _obj