Coverage for fingerprint_server_sdk / models / request_header_modifications.py: 47%

45 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, StrictStr 

21from typing_extensions import Self 

22 

23from fingerprint_server_sdk.models.rule_action_header_field import RuleActionHeaderField 

24 

25 

26class RequestHeaderModifications(BaseModel): 

27 """ 

28 The set of header modifications to apply, in the following order: remove, set, append. 

29 """ 

30 

31 remove: Optional[list[StrictStr]] = Field( 

32 default=None, description='The list of headers to remove.' 

33 ) 

34 set: Optional[list[RuleActionHeaderField]] = Field( 

35 default=None, 

36 description='The list of headers to set, overwriting any existing headers with the same name.', 

37 ) 

38 append: Optional[list[RuleActionHeaderField]] = Field( 

39 default=None, description='The list of headers to append.' 

40 ) 

41 __properties: ClassVar[list[str]] = ['remove', 'set', 'append'] 

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 RequestHeaderModifications 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 set (list) 

81 _items = [] 

82 if self.set: 

83 for _item_set in self.set: 

84 if _item_set: 

85 _items.append(_item_set.to_dict()) 

86 _dict['set'] = _items 

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

88 _items = [] 

89 if self.append: 

90 for _item_append in self.append: 

91 if _item_append: 

92 _items.append(_item_append.to_dict()) 

93 _dict['append'] = _items 

94 return _dict 

95 

96 @classmethod 

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

98 """Create an instance of RequestHeaderModifications from a dict""" 

99 if obj is None: 

100 return None 

101 

102 if not isinstance(obj, dict): 

103 return cls.model_validate(obj) 

104 

105 _obj = cls.model_validate( 

106 { 

107 'remove': obj.get('remove'), 

108 'set': [RuleActionHeaderField.from_dict(_item) for _item in obj['set']] 

109 if obj.get('set') is not None 

110 else None, 

111 'append': [RuleActionHeaderField.from_dict(_item) for _item in obj['append']] 

112 if obj.get('append') is not None 

113 else None, 

114 } 

115 ) 

116 return _obj