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,162 @@
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
+ import sys
15
+ from typing import Dict, List, Optional, TypedDict
16
+
17
+ from typing_extensions import NotRequired
18
+
19
+ import os
20
+
21
+ ServerVariablesT = Dict[str, str]
22
+
23
+
24
+ class HostSettingVariable(TypedDict):
25
+ description: str
26
+ default_value: str
27
+ enum_values: List[str]
28
+
29
+
30
+ class HostSetting(TypedDict):
31
+ url: str
32
+ description: str
33
+ variables: NotRequired[Dict[str, HostSettingVariable]]
34
+
35
+
36
+ class HostConfiguration:
37
+ def __init__(
38
+ self,
39
+ region=None,
40
+ server_index=None,
41
+ server_variables=None,
42
+ server_operation_index=None,
43
+ server_operation_variables=None,
44
+ ignore_operation_servers=False,
45
+ ) -> None:
46
+ print(
47
+ "WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
48
+ "as a function argument instead of being set in the client configuration.\n"
49
+ "Once all services have migrated, the methods to specify the region in the client configuration "
50
+ "will be removed.",
51
+ file=sys.stderr,
52
+ )
53
+ """Constructor
54
+ """
55
+ self._base_path = "https://alb-waf.api.stackit.cloud"
56
+ """Default Base url
57
+ """
58
+ self.server_index = 0 if server_index is None else server_index
59
+ self.server_operation_index = server_operation_index or {}
60
+ """Default server index
61
+ """
62
+ self.server_variables = server_variables or {}
63
+ if region:
64
+ self.server_variables["region"] = "{}.".format(region)
65
+ self.server_operation_variables = server_operation_variables or {}
66
+ """Default server variables
67
+ """
68
+ self.ignore_operation_servers = ignore_operation_servers
69
+ """Ignore operation servers
70
+ """
71
+
72
+ def get_host_settings(self) -> List[HostSetting]:
73
+ """Gets an array of host settings
74
+
75
+ :return: An array of host settings
76
+ """
77
+ return [
78
+ {
79
+ "url": "https://alb-waf.api.stackit.cloud",
80
+ "description": "No description provided",
81
+ "variables": {
82
+ "region": {
83
+ "description": "No description provided",
84
+ "default_value": "global",
85
+ }
86
+ },
87
+ }
88
+ ]
89
+
90
+ def get_host_from_settings(
91
+ self,
92
+ index: Optional[int],
93
+ variables: Optional[ServerVariablesT] = None,
94
+ servers: Optional[List[HostSetting]] = None,
95
+ ) -> str:
96
+ """Gets host URL based on the index and variables
97
+ :param index: array index of the host settings
98
+ :param variables: hash of variable and the corresponding value
99
+ :param servers: an array of host settings or None
100
+ :error: if a region is given for a global url
101
+ :return: URL based on host settings
102
+ """
103
+ if index is None:
104
+ return self._base_path
105
+
106
+ variables = {} if variables is None else variables
107
+ servers = self.get_host_settings() if servers is None else servers
108
+
109
+ try:
110
+ server = servers[index]
111
+ except IndexError:
112
+ raise ValueError(
113
+ "Invalid index {0} when selecting the host settings. "
114
+ "Must be less than {1}".format(index, len(servers))
115
+ )
116
+
117
+ url = server["url"]
118
+
119
+ # check if environment variable was provided for region
120
+ # if nothing was set this is None
121
+ region_env = os.environ.get("STACKIT_REGION")
122
+
123
+ # go through variables and replace placeholders
124
+ for variable_name, variable in server.get("variables", {}).items():
125
+ # If a region is provided by the user for a global url
126
+ # return an error (except for providing via environment variable).
127
+ # The region is provided as a function argument instead of being set in the client configuration.
128
+ if (
129
+ variable_name == "region"
130
+ and (variable["default_value"] == "global" or variable["default_value"] == "")
131
+ and region_env is None
132
+ and variables.get(variable_name) is not None
133
+ ):
134
+ raise ValueError(
135
+ "this API does not support setting a region in the client configuration, "
136
+ "please check if the region can be specified as a function parameter"
137
+ )
138
+ used_value = variables.get(variable_name, variable["default_value"])
139
+
140
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
141
+ given_value = variables[variable_name].replace(".", "")
142
+ valid_values = [v.replace(".", "") for v in variable["enum_values"]]
143
+ raise ValueError(
144
+ "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
145
+ variable_name, given_value, valid_values
146
+ )
147
+ )
148
+
149
+ url = url.replace("{" + variable_name + "}", used_value)
150
+
151
+ return url
152
+
153
+ @property
154
+ def host(self) -> str:
155
+ """Return generated host."""
156
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
157
+
158
+ @host.setter
159
+ def host(self, value: str) -> None:
160
+ """Fix base path."""
161
+ self._base_path = value
162
+ self.server_index = None
@@ -0,0 +1,217 @@
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 typing import Any, Optional
15
+
16
+ from typing_extensions import Self
17
+
18
+
19
+ class OpenApiException(Exception):
20
+ """The base exception class for all OpenAPIExceptions"""
21
+
22
+
23
+ class ApiTypeError(OpenApiException, TypeError):
24
+ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None:
25
+ """Raises an exception for TypeErrors
26
+
27
+ Args:
28
+ msg (str): the exception message
29
+
30
+ Keyword Args:
31
+ path_to_item (list): a list of keys an indices to get to the
32
+ current_item
33
+ None if unset
34
+ valid_classes (tuple): the primitive classes that current item
35
+ should be an instance of
36
+ None if unset
37
+ key_type (bool): False if our value is a value in a dict
38
+ True if it is a key in a dict
39
+ False if our item is an item in a list
40
+ None if unset
41
+ """
42
+ self.path_to_item = path_to_item
43
+ self.valid_classes = valid_classes
44
+ self.key_type = key_type
45
+ full_msg = msg
46
+ if path_to_item:
47
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
48
+ super(ApiTypeError, self).__init__(full_msg)
49
+
50
+
51
+ class ApiValueError(OpenApiException, ValueError):
52
+ def __init__(self, msg, path_to_item=None) -> None:
53
+ """
54
+ Args:
55
+ msg (str): the exception message
56
+
57
+ Keyword Args:
58
+ path_to_item (list) the path to the exception in the
59
+ received_data dict. None if unset
60
+ """
61
+
62
+ self.path_to_item = path_to_item
63
+ full_msg = msg
64
+ if path_to_item:
65
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
66
+ super(ApiValueError, self).__init__(full_msg)
67
+
68
+
69
+ class ApiAttributeError(OpenApiException, AttributeError):
70
+ def __init__(self, msg, path_to_item=None) -> None:
71
+ """
72
+ Raised when an attribute reference or assignment fails.
73
+
74
+ Args:
75
+ msg (str): the exception message
76
+
77
+ Keyword Args:
78
+ path_to_item (None/list) the path to the exception in the
79
+ received_data dict
80
+ """
81
+ self.path_to_item = path_to_item
82
+ full_msg = msg
83
+ if path_to_item:
84
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
85
+ super(ApiAttributeError, self).__init__(full_msg)
86
+
87
+
88
+ class ApiKeyError(OpenApiException, KeyError):
89
+ def __init__(self, msg, path_to_item=None) -> None:
90
+ """
91
+ Args:
92
+ msg (str): the exception message
93
+
94
+ Keyword Args:
95
+ path_to_item (None/list) the path to the exception in the
96
+ received_data dict
97
+ """
98
+ self.path_to_item = path_to_item
99
+ full_msg = msg
100
+ if path_to_item:
101
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
102
+ super(ApiKeyError, self).__init__(full_msg)
103
+
104
+
105
+ class ApiException(OpenApiException):
106
+
107
+ def __init__(
108
+ self,
109
+ status=None,
110
+ reason=None,
111
+ http_resp=None,
112
+ *,
113
+ body: Optional[str] = None,
114
+ data: Optional[Any] = None,
115
+ ) -> None:
116
+ self.status = status
117
+ self.reason = reason
118
+ self.body = body
119
+ self.data = data
120
+ self.headers = None
121
+
122
+ if http_resp:
123
+ if self.status is None:
124
+ self.status = http_resp.status
125
+ if self.reason is None:
126
+ self.reason = http_resp.reason
127
+ if self.body is None:
128
+ try:
129
+ self.body = http_resp.data.decode("utf-8")
130
+ except Exception: # noqa: S110
131
+ pass
132
+ self.headers = http_resp.headers
133
+
134
+ @classmethod
135
+ def from_response(
136
+ cls,
137
+ *,
138
+ http_resp,
139
+ body: Optional[str],
140
+ data: Optional[Any],
141
+ ) -> Self:
142
+ if http_resp.status == 400:
143
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 401:
146
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 403:
149
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
150
+
151
+ if http_resp.status == 404:
152
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
153
+
154
+ # Added new conditions for 409 and 422
155
+ if http_resp.status == 409:
156
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
157
+
158
+ if http_resp.status == 422:
159
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
160
+
161
+ if 500 <= http_resp.status <= 599:
162
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
163
+ raise ApiException(http_resp=http_resp, body=body, data=data)
164
+
165
+ def __str__(self):
166
+ """Custom error messages for exception"""
167
+ error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
168
+ if self.headers:
169
+ error_message += "HTTP response headers: {0}\n".format(self.headers)
170
+
171
+ if self.data or self.body:
172
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
173
+
174
+ return error_message
175
+
176
+
177
+ class BadRequestException(ApiException):
178
+ pass
179
+
180
+
181
+ class NotFoundException(ApiException):
182
+ pass
183
+
184
+
185
+ class UnauthorizedException(ApiException):
186
+ pass
187
+
188
+
189
+ class ForbiddenException(ApiException):
190
+ pass
191
+
192
+
193
+ class ServiceException(ApiException):
194
+ pass
195
+
196
+
197
+ class ConflictException(ApiException):
198
+ """Exception for HTTP 409 Conflict."""
199
+
200
+ pass
201
+
202
+
203
+ class UnprocessableEntityException(ApiException):
204
+ """Exception for HTTP 422 Unprocessable Entity."""
205
+
206
+ pass
207
+
208
+
209
+ def render_path(path_to_item):
210
+ """Returns a string representation of a path"""
211
+ result = ""
212
+ for pth in path_to_item:
213
+ if isinstance(pth, int):
214
+ result += "[{0}]".format(pth)
215
+ else:
216
+ result += "['{0}']".format(pth)
217
+ return result
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ STACKIT Application Load Balancer Web Application Firewall API
6
+
7
+ 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.
8
+
9
+ The version of the OpenAPI document: 1.0.0
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ # import models into model package
16
+ from stackit.albwaf.models.action import Action
17
+ from stackit.albwaf.models.behavior import Behavior
18
+ from stackit.albwaf.models.condition import Condition
19
+ from stackit.albwaf.models.condition_operator import ConditionOperator
20
+ from stackit.albwaf.models.condition_variable import ConditionVariable
21
+ from stackit.albwaf.models.create_custom_rule import CreateCustomRule
22
+ from stackit.albwaf.models.create_custom_rule_group_payload import (
23
+ CreateCustomRuleGroupPayload,
24
+ )
25
+ from stackit.albwaf.models.create_managed_rule_set_payload import (
26
+ CreateManagedRuleSetPayload,
27
+ )
28
+ from stackit.albwaf.models.create_waf_payload import CreateWAFPayload
29
+ from stackit.albwaf.models.crg_config_quota import CRGConfigQuota
30
+ from stackit.albwaf.models.crg_usage import CRGUsage
31
+ from stackit.albwaf.models.get_behavior import GetBehavior
32
+ from stackit.albwaf.models.get_custom_rule import GetCustomRule
33
+ from stackit.albwaf.models.get_custom_rule_group_response import (
34
+ GetCustomRuleGroupResponse,
35
+ )
36
+ from stackit.albwaf.models.get_limited_managed_rule_set_response import (
37
+ GetLimitedManagedRuleSetResponse,
38
+ )
39
+ from stackit.albwaf.models.get_managed_rule_set_response import (
40
+ GetManagedRuleSetResponse,
41
+ )
42
+ from stackit.albwaf.models.get_quota_response import GetQuotaResponse
43
+ from stackit.albwaf.models.get_waf_response import GetWAFResponse
44
+ from stackit.albwaf.models.google_protobuf_any import GoogleProtobufAny
45
+ from stackit.albwaf.models.list_custom_rule_group_response import (
46
+ ListCustomRuleGroupResponse,
47
+ )
48
+ from stackit.albwaf.models.list_managed_rule_set_response import (
49
+ ListManagedRuleSetResponse,
50
+ )
51
+ from stackit.albwaf.models.list_waf_response import ListWAFResponse
52
+ from stackit.albwaf.models.mode import Mode
53
+ from stackit.albwaf.models.mrs_config_quota import MRSConfigQuota
54
+ from stackit.albwaf.models.mrs_rule import MRSRule
55
+ from stackit.albwaf.models.mrs_rule_group import MRSRuleGroup
56
+ from stackit.albwaf.models.mrs_usage import MRSUsage
57
+ from stackit.albwaf.models.operator import Operator
58
+ from stackit.albwaf.models.patch_managed_rule_set_payload import (
59
+ PatchManagedRuleSetPayload,
60
+ )
61
+ from stackit.albwaf.models.patch_mrs_rule import PatchMRSRule
62
+ from stackit.albwaf.models.patch_mrs_rule_group import PatchMRSRuleGroup
63
+ from stackit.albwaf.models.quotas import Quotas
64
+ from stackit.albwaf.models.severity import Severity
65
+ from stackit.albwaf.models.status import Status
66
+ from stackit.albwaf.models.transformation import Transformation
67
+ from stackit.albwaf.models.type import Type
68
+ from stackit.albwaf.models.update_custom_rule_group_payload import (
69
+ UpdateCustomRuleGroupPayload,
70
+ )
71
+ from stackit.albwaf.models.update_waf_payload import UpdateWAFPayload
72
+ from stackit.albwaf.models.variable import Variable
73
+ from stackit.albwaf.models.waf_config_quota import WAFConfigQuota
74
+ from stackit.albwaf.models.waf_usage import WAFUsage
75
+ from stackit.albwaf.models.waf_usage_item import WAFUsageItem
@@ -0,0 +1,37 @@
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
+ from enum import Enum
18
+
19
+ from typing_extensions import Self
20
+
21
+
22
+ class Action(str, Enum):
23
+ """
24
+ The protective stance action. ACTION_DENY forces a 403 status response code.
25
+ """
26
+
27
+ """
28
+ allowed enum values
29
+ """
30
+ ACTION_DENY = "ACTION_DENY"
31
+ ACTION_PASS = "ACTION_PASS"
32
+ ACTION_ALLOW = "ACTION_ALLOW"
33
+
34
+ @classmethod
35
+ def from_json(cls, json_str: str) -> Self:
36
+ """Create an instance of Action from a JSON string"""
37
+ return cls(json.loads(json_str))
@@ -0,0 +1,99 @@
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 (
21
+ BaseModel,
22
+ ConfigDict,
23
+ Field,
24
+ StrictBool,
25
+ StrictStr,
26
+ )
27
+ from pydantic_core import to_jsonable_python
28
+ from typing_extensions import Self
29
+
30
+ from stackit.albwaf.models.action import Action
31
+
32
+
33
+ class Behavior(BaseModel):
34
+ """
35
+ Behavior
36
+ """ # noqa: E501
37
+
38
+ action: Action
39
+ log: Optional[StrictBool] = Field(
40
+ default=None,
41
+ description="Determines whether an entry should be generated in the security ledger upon a rule hit.",
42
+ )
43
+ log_msg: Optional[StrictStr] = Field(
44
+ default=None,
45
+ description="Custom notification message string mapped to underlying logdata contexts.",
46
+ alias="logMsg",
47
+ )
48
+ __properties: ClassVar[List[str]] = ["action", "log", "logMsg"]
49
+
50
+ model_config = ConfigDict(
51
+ validate_by_name=True,
52
+ validate_by_alias=True,
53
+ validate_assignment=True,
54
+ protected_namespaces=(),
55
+ )
56
+
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))
60
+
61
+ def to_json(self) -> str:
62
+ """Returns the JSON representation of the model using alias"""
63
+ return json.dumps(to_jsonable_python(self.to_dict()))
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of Behavior from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([])
81
+
82
+ _dict = self.model_dump(
83
+ by_alias=True,
84
+ exclude=excluded_fields,
85
+ exclude_none=True,
86
+ )
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of Behavior 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({"action": obj.get("action"), "log": obj.get("log"), "logMsg": obj.get("logMsg")})
99
+ return _obj
@@ -0,0 +1,102 @@
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
21
+ from pydantic_core import to_jsonable_python
22
+ from typing_extensions import Self
23
+
24
+ from stackit.albwaf.models.condition_operator import ConditionOperator
25
+ from stackit.albwaf.models.condition_variable import ConditionVariable
26
+ from stackit.albwaf.models.transformation import Transformation
27
+
28
+
29
+ class Condition(BaseModel):
30
+ """
31
+ Condition
32
+ """ # noqa: E501
33
+
34
+ operator: ConditionOperator
35
+ transformations: Optional[List[Transformation]] = Field(
36
+ default=None, description="[HINT] Ordered processing adjustments applied to clean inputs before match checking."
37
+ )
38
+ variable: ConditionVariable
39
+ __properties: ClassVar[List[str]] = ["operator", "transformations", "variable"]
40
+
41
+ model_config = ConfigDict(
42
+ validate_by_name=True,
43
+ validate_by_alias=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ return json.dumps(to_jsonable_python(self.to_dict()))
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of Condition 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 operator
79
+ if self.operator:
80
+ _dict["operator"] = self.operator.to_dict()
81
+ # override the default output from pydantic by calling `to_dict()` of variable
82
+ if self.variable:
83
+ _dict["variable"] = self.variable.to_dict()
84
+ return _dict
85
+
86
+ @classmethod
87
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
+ """Create an instance of Condition from a dict"""
89
+ if obj is None:
90
+ return None
91
+
92
+ if not isinstance(obj, dict):
93
+ return cls.model_validate(obj)
94
+
95
+ _obj = cls.model_validate(
96
+ {
97
+ "operator": ConditionOperator.from_dict(obj["operator"]) if obj.get("operator") is not None else None,
98
+ "transformations": obj.get("transformations"),
99
+ "variable": ConditionVariable.from_dict(obj["variable"]) if obj.get("variable") is not None else None,
100
+ }
101
+ )
102
+ return _obj