Coverage for fingerprint_server_sdk/models/event_rule_action_allow.py: 63%
38 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-14 10:45 +0000
« 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.
7The version of the OpenAPI document: 4
8Contact: support@fingerprint.com
9Generated by OpenAPI Generator (https://openapi-generator.tech)
11Do not edit the class manually.
12""" # noqa: E501
14from __future__ import annotations
16import json
17import pprint
18import re # noqa: F401
19from typing import Any, ClassVar, Optional
21from pydantic import BaseModel, ConfigDict, Field, StrictStr
22from typing_extensions import Self
24from fingerprint_server_sdk.models.request_header_modifications import RequestHeaderModifications
25from fingerprint_server_sdk.models.rule_action_type import RuleActionType
28class EventRuleActionAllow(BaseModel):
29 """
30 Informs the client that the request should be forwarded to the origin with optional request header modifications.
31 """
33 ruleset_id: StrictStr = Field(description='The ID of the evaluated ruleset.')
34 rule_id: Optional[StrictStr] = Field(
35 default=None, description='The ID of the rule that matched the identification event.'
36 )
37 rule_expression: Optional[StrictStr] = Field(
38 default=None,
39 description='The expression of the rule that matched the identification event.',
40 )
41 type: RuleActionType
42 request_header_modifications: Optional[RequestHeaderModifications] = None
43 __properties: ClassVar[list[str]] = [
44 'ruleset_id',
45 'rule_id',
46 'rule_expression',
47 'type',
48 'request_header_modifications',
49 ]
51 model_config = ConfigDict(
52 populate_by_name=True,
53 validate_assignment=True,
54 protected_namespaces=(),
55 )
57 def to_str(self) -> str:
58 """Returns the string representation of the model using alias"""
59 return pprint.pformat(self.model_dump(by_alias=True))
61 def to_json(self) -> str:
62 """Returns the JSON representation of the model using alias"""
63 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
64 return json.dumps(self.to_dict())
66 @classmethod
67 def from_json(cls, json_str: str) -> Optional[Self]:
68 """Create an instance of EventRuleActionAllow from a JSON string"""
69 return cls.from_dict(json.loads(json_str))
71 def to_dict(self) -> dict[str, Any]:
72 """Return the dictionary representation of the model using alias.
74 This has the following differences from calling pydantic's
75 `self.model_dump(by_alias=True)`:
77 * `None` is only added to the output dict for nullable fields that
78 were set at model initialization. Other fields with value `None`
79 are ignored.
80 """
81 excluded_fields: set[str] = set([])
83 _dict = self.model_dump(
84 by_alias=True,
85 exclude=excluded_fields,
86 exclude_none=True,
87 )
88 # override the default output from pydantic by calling `to_dict()` of request_header_modifications
89 if self.request_header_modifications:
90 _dict['request_header_modifications'] = self.request_header_modifications.to_dict()
91 return _dict
93 @classmethod
94 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
95 """Create an instance of EventRuleActionAllow from a dict"""
96 if obj is None:
97 return None
99 if not isinstance(obj, dict):
100 return cls.model_validate(obj)
102 _obj = cls.model_validate(
103 {
104 'ruleset_id': obj.get('ruleset_id'),
105 'rule_id': obj.get('rule_id'),
106 'rule_expression': obj.get('rule_expression'),
107 'type': obj.get('type'),
108 'request_header_modifications': RequestHeaderModifications.from_dict(
109 obj['request_header_modifications']
110 )
111 if obj.get('request_header_modifications') is not None
112 else None,
113 }
114 )
115 return _obj