stackit-albwaf 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. src/stackit/albwaf/__init__.py +164 -0
  2. src/stackit/albwaf/api/__init__.py +4 -0
  3. src/stackit/albwaf/api/default_api.py +4611 -0
  4. src/stackit/albwaf/api_client.py +649 -0
  5. src/stackit/albwaf/api_response.py +22 -0
  6. src/stackit/albwaf/configuration.py +162 -0
  7. src/stackit/albwaf/exceptions.py +217 -0
  8. src/stackit/albwaf/models/__init__.py +75 -0
  9. src/stackit/albwaf/models/action.py +37 -0
  10. src/stackit/albwaf/models/behavior.py +99 -0
  11. src/stackit/albwaf/models/condition.py +102 -0
  12. src/stackit/albwaf/models/condition_operator.py +87 -0
  13. src/stackit/albwaf/models/condition_variable.py +87 -0
  14. src/stackit/albwaf/models/create_custom_rule.py +109 -0
  15. src/stackit/albwaf/models/create_custom_rule_group_payload.py +154 -0
  16. src/stackit/albwaf/models/create_managed_rule_set_payload.py +141 -0
  17. src/stackit/albwaf/models/create_waf_payload.py +183 -0
  18. src/stackit/albwaf/models/crg_config_quota.py +87 -0
  19. src/stackit/albwaf/models/crg_usage.py +87 -0
  20. src/stackit/albwaf/models/get_behavior.py +107 -0
  21. src/stackit/albwaf/models/get_custom_rule.py +111 -0
  22. src/stackit/albwaf/models/get_custom_rule_group_response.py +118 -0
  23. src/stackit/albwaf/models/get_limited_managed_rule_set_response.py +119 -0
  24. src/stackit/albwaf/models/get_managed_rule_set_response.py +136 -0
  25. src/stackit/albwaf/models/get_quota_response.py +132 -0
  26. src/stackit/albwaf/models/get_waf_response.py +143 -0
  27. src/stackit/albwaf/models/google_protobuf_any.py +98 -0
  28. src/stackit/albwaf/models/list_custom_rule_group_response.py +121 -0
  29. src/stackit/albwaf/models/list_managed_rule_set_response.py +121 -0
  30. src/stackit/albwaf/models/list_waf_response.py +117 -0
  31. src/stackit/albwaf/models/mode.py +37 -0
  32. src/stackit/albwaf/models/mrs_config_quota.py +88 -0
  33. src/stackit/albwaf/models/mrs_rule.py +99 -0
  34. src/stackit/albwaf/models/mrs_rule_group.py +116 -0
  35. src/stackit/albwaf/models/mrs_usage.py +83 -0
  36. src/stackit/albwaf/models/operator.py +50 -0
  37. src/stackit/albwaf/models/patch_managed_rule_set_payload.py +161 -0
  38. src/stackit/albwaf/models/patch_mrs_rule.py +84 -0
  39. src/stackit/albwaf/models/patch_mrs_rule_group.py +99 -0
  40. src/stackit/albwaf/models/quotas.py +111 -0
  41. src/stackit/albwaf/models/severity.py +42 -0
  42. src/stackit/albwaf/models/status.py +112 -0
  43. src/stackit/albwaf/models/transformation.py +40 -0
  44. src/stackit/albwaf/models/type.py +35 -0
  45. src/stackit/albwaf/models/update_custom_rule_group_payload.py +158 -0
  46. src/stackit/albwaf/models/update_waf_payload.py +185 -0
  47. src/stackit/albwaf/models/variable.py +56 -0
  48. src/stackit/albwaf/models/waf_config_quota.py +88 -0
  49. src/stackit/albwaf/models/waf_usage.py +102 -0
  50. src/stackit/albwaf/models/waf_usage_item.py +91 -0
  51. src/stackit/albwaf/py.typed +0 -0
  52. src/stackit/albwaf/rest.py +163 -0
  53. stackit_albwaf-0.0.1.dist-info/METADATA +45 -0
  54. stackit_albwaf-0.0.1.dist-info/RECORD +55 -0
  55. stackit_albwaf-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,87 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Application Load Balancer Web Application Firewall API
5
+
6
+ Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from pydantic_core import to_jsonable_python
22
+ from typing_extensions import Self
23
+
24
+ from stackit.albwaf.models.operator import Operator
25
+
26
+
27
+ class ConditionOperator(BaseModel):
28
+ """
29
+ ConditionOperator
30
+ """ # noqa: E501
31
+
32
+ type: Operator
33
+ value: Optional[StrictStr] = Field(
34
+ default=None, description="The text or rule regex pattern arguments applied inside the operator execution loop."
35
+ )
36
+ __properties: ClassVar[List[str]] = ["type", "value"]
37
+
38
+ model_config = ConfigDict(
39
+ validate_by_name=True,
40
+ validate_by_alias=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ return json.dumps(to_jsonable_python(self.to_dict()))
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of ConditionOperator from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of ConditionOperator from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({"type": obj.get("type"), "value": obj.get("value")})
87
+ return _obj
@@ -0,0 +1,87 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Application Load Balancer Web Application Firewall API
5
+
6
+ Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from pydantic_core import to_jsonable_python
22
+ from typing_extensions import Self
23
+
24
+ from stackit.albwaf.models.variable import Variable
25
+
26
+
27
+ class ConditionVariable(BaseModel):
28
+ """
29
+ ConditionVariable
30
+ """ # noqa: E501
31
+
32
+ type: Variable
33
+ value: Optional[StrictStr] = Field(
34
+ default=None, description="Optional key element context for map variables (e.g., matching a 'Host' header key)."
35
+ )
36
+ __properties: ClassVar[List[str]] = ["type", "value"]
37
+
38
+ model_config = ConfigDict(
39
+ validate_by_name=True,
40
+ validate_by_alias=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ return json.dumps(to_jsonable_python(self.to_dict()))
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of ConditionVariable from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of ConditionVariable from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({"type": obj.get("type"), "value": obj.get("value")})
87
+ return _obj
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Application Load Balancer Web Application Firewall API
5
+
6
+ Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from pydantic_core import to_jsonable_python
22
+ from typing_extensions import Self
23
+
24
+ from stackit.albwaf.models.behavior import Behavior
25
+ from stackit.albwaf.models.condition import Condition
26
+
27
+
28
+ class CreateCustomRule(BaseModel):
29
+ """
30
+ CreateCustomRule
31
+ """ # noqa: E501
32
+
33
+ behavior: Behavior
34
+ conditions: List[Condition] = Field(description="[HINT] Order matters! First condition match triggers execution.")
35
+ description: Optional[StrictStr] = Field(
36
+ default=None, description="A clear description explaining the threat vector or criteria addressed by this rule."
37
+ )
38
+ __properties: ClassVar[List[str]] = ["behavior", "conditions", "description"]
39
+
40
+ model_config = ConfigDict(
41
+ validate_by_name=True,
42
+ validate_by_alias=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
+ return json.dumps(to_jsonable_python(self.to_dict()))
54
+
55
+ @classmethod
56
+ def from_json(cls, json_str: str) -> Optional[Self]:
57
+ """Create an instance of CreateCustomRule from a JSON string"""
58
+ return cls.from_dict(json.loads(json_str))
59
+
60
+ def to_dict(self) -> Dict[str, Any]:
61
+ """Return the dictionary representation of the model using alias.
62
+
63
+ This has the following differences from calling pydantic's
64
+ `self.model_dump(by_alias=True)`:
65
+
66
+ * `None` is only added to the output dict for nullable fields that
67
+ were set at model initialization. Other fields with value `None`
68
+ are ignored.
69
+ """
70
+ excluded_fields: Set[str] = set([])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ # override the default output from pydantic by calling `to_dict()` of behavior
78
+ if self.behavior:
79
+ _dict["behavior"] = self.behavior.to_dict()
80
+ # override the default output from pydantic by calling `to_dict()` of each item in conditions (list)
81
+ _items = []
82
+ if self.conditions:
83
+ for _item_conditions in self.conditions:
84
+ if _item_conditions:
85
+ _items.append(_item_conditions.to_dict())
86
+ _dict["conditions"] = _items
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of CreateCustomRule 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
+ "behavior": Behavior.from_dict(obj["behavior"]) if obj.get("behavior") is not None else None,
101
+ "conditions": (
102
+ [Condition.from_dict(_item) for _item in obj["conditions"]]
103
+ if obj.get("conditions") is not None
104
+ else None
105
+ ),
106
+ "description": obj.get("description"),
107
+ }
108
+ )
109
+ return _obj
@@ -0,0 +1,154 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Application Load Balancer Web Application Firewall API
5
+
6
+ Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re # noqa: F401
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+ from uuid import UUID
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
23
+ from pydantic_core import to_jsonable_python
24
+ from typing_extensions import Annotated, Self
25
+
26
+ from stackit.albwaf.models.create_custom_rule import CreateCustomRule
27
+
28
+
29
+ class CreateCustomRuleGroupPayload(BaseModel):
30
+ """
31
+ Request payload for creating a CRG.
32
+ """ # noqa: E501
33
+
34
+ name: Annotated[str, Field(strict=True)] = Field(description="Custom rule group name.")
35
+ project_id: Optional[UUID] = Field(default=None, description="Project identifier", alias="projectId")
36
+ region: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Region")
37
+ rules: List[CreateCustomRule] = Field(
38
+ description="The collection of custom rule group SecLang parameters forming this execution group."
39
+ )
40
+ __properties: ClassVar[List[str]] = ["name", "projectId", "region", "rules"]
41
+
42
+ @field_validator("name")
43
+ def name_validate_regular_expression(cls, value):
44
+ """Validates the regular expression"""
45
+ if not isinstance(value, str):
46
+ value = str(value)
47
+
48
+ if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value):
49
+ raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/")
50
+ return value
51
+
52
+ @field_validator("project_id")
53
+ def project_id_validate_regular_expression(cls, value):
54
+ """Validates the regular expression"""
55
+ if value is None:
56
+ return value
57
+
58
+ if not isinstance(value, str):
59
+ value = str(value)
60
+
61
+ if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value):
62
+ raise ValueError(
63
+ r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/"
64
+ )
65
+ return value
66
+
67
+ @field_validator("region")
68
+ def region_validate_regular_expression(cls, value):
69
+ """Validates the regular expression"""
70
+ if value is None:
71
+ return value
72
+
73
+ if not isinstance(value, str):
74
+ value = str(value)
75
+
76
+ if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value):
77
+ raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/")
78
+ return value
79
+
80
+ model_config = ConfigDict(
81
+ validate_by_name=True,
82
+ validate_by_alias=True,
83
+ validate_assignment=True,
84
+ protected_namespaces=(),
85
+ )
86
+
87
+ def to_str(self) -> str:
88
+ """Returns the string representation of the model using alias"""
89
+ return pprint.pformat(self.model_dump(by_alias=True))
90
+
91
+ def to_json(self) -> str:
92
+ """Returns the JSON representation of the model using alias"""
93
+ return json.dumps(to_jsonable_python(self.to_dict()))
94
+
95
+ @classmethod
96
+ def from_json(cls, json_str: str) -> Optional[Self]:
97
+ """Create an instance of CreateCustomRuleGroupPayload from a JSON string"""
98
+ return cls.from_dict(json.loads(json_str))
99
+
100
+ def to_dict(self) -> Dict[str, Any]:
101
+ """Return the dictionary representation of the model using alias.
102
+
103
+ This has the following differences from calling pydantic's
104
+ `self.model_dump(by_alias=True)`:
105
+
106
+ * `None` is only added to the output dict for nullable fields that
107
+ were set at model initialization. Other fields with value `None`
108
+ are ignored.
109
+ * OpenAPI `readOnly` fields are excluded.
110
+ * OpenAPI `readOnly` fields are excluded.
111
+ """
112
+ excluded_fields: Set[str] = set(
113
+ [
114
+ "project_id",
115
+ "region",
116
+ ]
117
+ )
118
+
119
+ _dict = self.model_dump(
120
+ by_alias=True,
121
+ exclude=excluded_fields,
122
+ exclude_none=True,
123
+ )
124
+ # override the default output from pydantic by calling `to_dict()` of each item in rules (list)
125
+ _items = []
126
+ if self.rules:
127
+ for _item_rules in self.rules:
128
+ if _item_rules:
129
+ _items.append(_item_rules.to_dict())
130
+ _dict["rules"] = _items
131
+ return _dict
132
+
133
+ @classmethod
134
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
135
+ """Create an instance of CreateCustomRuleGroupPayload from a dict"""
136
+ if obj is None:
137
+ return None
138
+
139
+ if not isinstance(obj, dict):
140
+ return cls.model_validate(obj)
141
+
142
+ _obj = cls.model_validate(
143
+ {
144
+ "name": obj.get("name"),
145
+ "projectId": obj.get("projectId"),
146
+ "region": obj.get("region"),
147
+ "rules": (
148
+ [CreateCustomRule.from_dict(_item) for _item in obj["rules"]]
149
+ if obj.get("rules") is not None
150
+ else None
151
+ ),
152
+ }
153
+ )
154
+ return _obj
@@ -0,0 +1,141 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Application Load Balancer Web Application Firewall API
5
+
6
+ Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re # noqa: F401
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+ from uuid import UUID
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
23
+ from pydantic_core import to_jsonable_python
24
+ from typing_extensions import Annotated, Self
25
+
26
+ from stackit.albwaf.models.type import Type
27
+
28
+
29
+ class CreateManagedRuleSetPayload(BaseModel):
30
+ """
31
+ CreateManagedRuleSetRequest creates a rule configuration.
32
+ """ # noqa: E501
33
+
34
+ name: Annotated[str, Field(strict=True)] = Field(description="Managed rule set configuration name.")
35
+ project_id: Optional[UUID] = Field(default=None, description="Project identifier", alias="projectId")
36
+ region: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Region")
37
+ type: Type
38
+ __properties: ClassVar[List[str]] = ["name", "projectId", "region", "type"]
39
+
40
+ @field_validator("name")
41
+ def name_validate_regular_expression(cls, value):
42
+ """Validates the regular expression"""
43
+ if not isinstance(value, str):
44
+ value = str(value)
45
+
46
+ if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value):
47
+ raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/")
48
+ return value
49
+
50
+ @field_validator("project_id")
51
+ def project_id_validate_regular_expression(cls, value):
52
+ """Validates the regular expression"""
53
+ if value is None:
54
+ return value
55
+
56
+ if not isinstance(value, str):
57
+ value = str(value)
58
+
59
+ if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value):
60
+ raise ValueError(
61
+ r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/"
62
+ )
63
+ return value
64
+
65
+ @field_validator("region")
66
+ def region_validate_regular_expression(cls, value):
67
+ """Validates the regular expression"""
68
+ if value is None:
69
+ return value
70
+
71
+ if not isinstance(value, str):
72
+ value = str(value)
73
+
74
+ if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value):
75
+ raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/")
76
+ return value
77
+
78
+ model_config = ConfigDict(
79
+ validate_by_name=True,
80
+ validate_by_alias=True,
81
+ validate_assignment=True,
82
+ protected_namespaces=(),
83
+ )
84
+
85
+ def to_str(self) -> str:
86
+ """Returns the string representation of the model using alias"""
87
+ return pprint.pformat(self.model_dump(by_alias=True))
88
+
89
+ def to_json(self) -> str:
90
+ """Returns the JSON representation of the model using alias"""
91
+ return json.dumps(to_jsonable_python(self.to_dict()))
92
+
93
+ @classmethod
94
+ def from_json(cls, json_str: str) -> Optional[Self]:
95
+ """Create an instance of CreateManagedRuleSetPayload from a JSON string"""
96
+ return cls.from_dict(json.loads(json_str))
97
+
98
+ def to_dict(self) -> Dict[str, Any]:
99
+ """Return the dictionary representation of the model using alias.
100
+
101
+ This has the following differences from calling pydantic's
102
+ `self.model_dump(by_alias=True)`:
103
+
104
+ * `None` is only added to the output dict for nullable fields that
105
+ were set at model initialization. Other fields with value `None`
106
+ are ignored.
107
+ * OpenAPI `readOnly` fields are excluded.
108
+ * OpenAPI `readOnly` fields are excluded.
109
+ """
110
+ excluded_fields: Set[str] = set(
111
+ [
112
+ "project_id",
113
+ "region",
114
+ ]
115
+ )
116
+
117
+ _dict = self.model_dump(
118
+ by_alias=True,
119
+ exclude=excluded_fields,
120
+ exclude_none=True,
121
+ )
122
+ return _dict
123
+
124
+ @classmethod
125
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
126
+ """Create an instance of CreateManagedRuleSetPayload from a dict"""
127
+ if obj is None:
128
+ return None
129
+
130
+ if not isinstance(obj, dict):
131
+ return cls.model_validate(obj)
132
+
133
+ _obj = cls.model_validate(
134
+ {
135
+ "name": obj.get("name"),
136
+ "projectId": obj.get("projectId"),
137
+ "region": obj.get("region"),
138
+ "type": obj.get("type"),
139
+ }
140
+ )
141
+ return _obj