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

22from typing_extensions import Self 

23 

24from fingerprint_server_sdk.models.integration import Integration 

25 

26 

27class SDK(BaseModel): 

28 """ 

29 Contains information about the SDK used to perform the request. 

30 """ 

31 

32 platform: StrictStr = Field( 

33 description='Platform of the SDK used for the identification request.' 

34 ) 

35 version: StrictStr = Field( 

36 description='Version string of the SDK used for the identification request.' 

37 ) 

38 integrations: Optional[list[Integration]] = None 

39 __properties: ClassVar[list[str]] = ['platform', 'version', 'integrations'] 

40 

41 model_config = ConfigDict( 

42 populate_by_name=True, 

43 validate_assignment=True, 

44 protected_namespaces=(), 

45 ) 

46 

47 def to_str(self) -> str: 

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

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

50 

51 def to_json(self) -> str: 

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

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

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

55 

56 @classmethod 

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

58 """Create an instance of SDK from a JSON string""" 

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

60 

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

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

63 

64 This has the following differences from calling pydantic's 

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

66 

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

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

69 are ignored. 

70 """ 

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

72 

73 _dict = self.model_dump( 

74 by_alias=True, 

75 exclude=excluded_fields, 

76 exclude_none=True, 

77 ) 

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

79 _items = [] 

80 if self.integrations: 

81 for _item_integrations in self.integrations: 

82 if _item_integrations: 

83 _items.append(_item_integrations.to_dict()) 

84 _dict['integrations'] = _items 

85 return _dict 

86 

87 @classmethod 

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

89 """Create an instance of SDK from a dict""" 

90 if obj is None: 

91 return None 

92 

93 if not isinstance(obj, dict): 

94 return cls.model_validate(obj) 

95 

96 _obj = cls.model_validate( 

97 { 

98 'platform': obj.get('platform'), 

99 'version': obj.get('version'), 

100 'integrations': [Integration.from_dict(_item) for _item in obj['integrations']] 

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

102 else None, 

103 } 

104 ) 

105 return _obj