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

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

22from typing_extensions import Self 

23 

24from fingerprint_server_sdk.models.event import Event 

25 

26 

27class EventSearch(BaseModel): 

28 """ 

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

30 """ 

31 

32 events: list[Event] 

33 pagination_key: Optional[StrictStr] = Field( 

34 default=None, 

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

36 ) 

37 total_hits: Optional[StrictInt] = Field( 

38 default=None, 

39 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.', 

40 ) 

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

42 

43 model_config = ConfigDict( 

44 populate_by_name=True, 

45 validate_assignment=True, 

46 protected_namespaces=(), 

47 ) 

48 

49 def to_str(self) -> str: 

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

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

52 

53 def to_json(self) -> str: 

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

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

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

57 

58 @classmethod 

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

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

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

62 

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

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

65 

66 This has the following differences from calling pydantic's 

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

68 

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

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

71 are ignored. 

72 """ 

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

74 

75 _dict = self.model_dump( 

76 by_alias=True, 

77 exclude=excluded_fields, 

78 exclude_none=True, 

79 ) 

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

81 _items = [] 

82 if self.events: 

83 for _item_events in self.events: 

84 if _item_events: 

85 _items.append(_item_events.to_dict()) 

86 _dict['events'] = _items 

87 return _dict 

88 

89 @classmethod 

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

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

92 if obj is None: 

93 return None 

94 

95 if not isinstance(obj, dict): 

96 return cls.model_validate(obj) 

97 

98 _obj = cls.model_validate( 

99 { 

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

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

102 else None, 

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

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

105 } 

106 ) 

107 return _obj