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

45 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.rule_action_header_field import RuleActionHeaderField 

25 

26 

27class RequestHeaderModifications(BaseModel): 

28 """ 

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

30 """ 

31 

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

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

34 ) 

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

36 default=None, 

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

38 ) 

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

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

41 ) 

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

43 

44 model_config = ConfigDict( 

45 populate_by_name=True, 

46 validate_assignment=True, 

47 protected_namespaces=(), 

48 ) 

49 

50 def to_str(self) -> str: 

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

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

53 

54 def to_json(self) -> str: 

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

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

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

58 

59 @classmethod 

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

61 """Create an instance of RequestHeaderModifications from a JSON string""" 

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

63 

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

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

66 

67 This has the following differences from calling pydantic's 

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

69 

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

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

72 are ignored. 

73 """ 

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

75 

76 _dict = self.model_dump( 

77 by_alias=True, 

78 exclude=excluded_fields, 

79 exclude_none=True, 

80 ) 

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

82 _items = [] 

83 if self.set: 

84 for _item_set in self.set: 

85 if _item_set: 

86 _items.append(_item_set.to_dict()) 

87 _dict['set'] = _items 

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

89 _items = [] 

90 if self.append: 

91 for _item_append in self.append: 

92 if _item_append: 

93 _items.append(_item_append.to_dict()) 

94 _dict['append'] = _items 

95 return _dict 

96 

97 @classmethod 

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

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

100 if obj is None: 

101 return None 

102 

103 if not isinstance(obj, dict): 

104 return cls.model_validate(obj) 

105 

106 _obj = cls.model_validate( 

107 { 

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

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

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

111 else None, 

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

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

114 else None, 

115 } 

116 ) 

117 return _obj