File: firewallrule_properties.py

package info (click to toggle)
python-ionoscloud 6.1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,084 kB
  • sloc: python: 44,694; makefile: 4
file content (460 lines) | stat: -rw-r--r-- 18,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# coding: utf-8

"""
    CLOUD API

     IONOS Enterprise-grade Infrastructure as a Service (IaaS) solutions can be managed through the Cloud API, in addition or as an alternative to the \"Data Center Designer\" (DCD) browser-based tool.    Both methods employ consistent concepts and features, deliver similar power and flexibility, and can be used to perform a multitude of management tasks, including adding servers, volumes, configuring networks, and so on.  # noqa: E501

    The version of the OpenAPI document: 6.0
    Generated by: https://openapi-generator.tech
"""


import pprint
import re  # noqa: F401

import six

from ionoscloud.configuration import Configuration


class FirewallruleProperties(object):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    """
    Attributes:
      openapi_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    """
    openapi_types = {

        'name': 'str',

        'protocol': 'str',

        'source_mac': 'str',

        'ip_version': 'str',

        'source_ip': 'str',

        'target_ip': 'str',

        'icmp_code': 'int',

        'icmp_type': 'int',

        'port_range_start': 'int',

        'port_range_end': 'int',

        'type': 'str',
    }

    attribute_map = {

        'name': 'name',

        'protocol': 'protocol',

        'source_mac': 'sourceMac',

        'ip_version': 'ipVersion',

        'source_ip': 'sourceIp',

        'target_ip': 'targetIp',

        'icmp_code': 'icmpCode',

        'icmp_type': 'icmpType',

        'port_range_start': 'portRangeStart',

        'port_range_end': 'portRangeEnd',

        'type': 'type',
    }

    def __init__(self, name=None, protocol=None, source_mac=None, ip_version=None, source_ip=None, target_ip=None, icmp_code=None, icmp_type=None, port_range_start=None, port_range_end=None, type=None, local_vars_configuration=None):  # noqa: E501
        """FirewallruleProperties - a model defined in OpenAPI"""  # noqa: E501
        if local_vars_configuration is None:
            local_vars_configuration = Configuration()
        self.local_vars_configuration = local_vars_configuration

        self._name = None
        self._protocol = None
        self._source_mac = None
        self._ip_version = None
        self._source_ip = None
        self._target_ip = None
        self._icmp_code = None
        self._icmp_type = None
        self._port_range_start = None
        self._port_range_end = None
        self._type = None
        self.discriminator = None

        if name is not None:
            self.name = name
        if protocol is not None:
            self.protocol = protocol
        self.source_mac = source_mac
        self.ip_version = ip_version
        self.source_ip = source_ip
        self.target_ip = target_ip
        self.icmp_code = icmp_code
        self.icmp_type = icmp_type
        if port_range_start is not None:
            self.port_range_start = port_range_start
        if port_range_end is not None:
            self.port_range_end = port_range_end
        if type is not None:
            self.type = type


    @property
    def name(self):
        """Gets the name of this FirewallruleProperties.  # noqa: E501

        The name of the  resource.  # noqa: E501

        :return: The name of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._name

    @name.setter
    def name(self, name):
        """Sets the name of this FirewallruleProperties.

        The name of the  resource.  # noqa: E501

        :param name: The name of this FirewallruleProperties.  # noqa: E501
        :type name: str
        """

        self._name = name

    @property
    def protocol(self):
        """Gets the protocol of this FirewallruleProperties.  # noqa: E501

        The protocol for the rule. Property cannot be modified after it is created (disallowed in update requests).  # noqa: E501

        :return: The protocol of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._protocol

    @protocol.setter
    def protocol(self, protocol):
        """Sets the protocol of this FirewallruleProperties.

        The protocol for the rule. Property cannot be modified after it is created (disallowed in update requests).  # noqa: E501

        :param protocol: The protocol of this FirewallruleProperties.  # noqa: E501
        :type protocol: str
        """
        allowed_values = ["TCP", "UDP", "ICMP", "ICMPv6", "GRE", "VRRP", "ESP", "AH", "ANY"]  # noqa: E501
        if self.local_vars_configuration.client_side_validation and protocol not in allowed_values:  # noqa: E501
            raise ValueError(
                "Invalid value for `protocol` ({0}), must be one of {1}"  # noqa: E501
                .format(protocol, allowed_values)
            )

        self._protocol = protocol

    @property
    def source_mac(self):
        """Gets the source_mac of this FirewallruleProperties.  # noqa: E501

        Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows traffic from any MAC address.  # noqa: E501

        :return: The source_mac of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._source_mac

    @source_mac.setter
    def source_mac(self, source_mac):
        """Sets the source_mac of this FirewallruleProperties.

        Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows traffic from any MAC address.  # noqa: E501

        :param source_mac: The source_mac of this FirewallruleProperties.  # noqa: E501
        :type source_mac: str
        """

        self._source_mac = source_mac

    @property
    def ip_version(self):
        """Gets the ip_version of this FirewallruleProperties.  # noqa: E501

        The IP version for this rule. If sourceIp or targetIp are specified, you can omit this value - the IP version will then be deduced from the IP address(es) used; if you specify it anyway, it must match the specified IP address(es). If neither sourceIp nor targetIp are specified, this rule allows traffic only for the specified IP version. If neither sourceIp, targetIp nor ipVersion are specified, this rule will only allow IPv4 traffic.  # noqa: E501

        :return: The ip_version of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._ip_version

    @ip_version.setter
    def ip_version(self, ip_version):
        """Sets the ip_version of this FirewallruleProperties.

        The IP version for this rule. If sourceIp or targetIp are specified, you can omit this value - the IP version will then be deduced from the IP address(es) used; if you specify it anyway, it must match the specified IP address(es). If neither sourceIp nor targetIp are specified, this rule allows traffic only for the specified IP version. If neither sourceIp, targetIp nor ipVersion are specified, this rule will only allow IPv4 traffic.  # noqa: E501

        :param ip_version: The ip_version of this FirewallruleProperties.  # noqa: E501
        :type ip_version: str
        """
        allowed_values = [None,"IPv4", "IPv6"]  # noqa: E501
        if self.local_vars_configuration.client_side_validation and ip_version not in allowed_values:  # noqa: E501
            raise ValueError(
                "Invalid value for `ip_version` ({0}), must be one of {1}"  # noqa: E501
                .format(ip_version, allowed_values)
            )

        self._ip_version = ip_version

    @property
    def source_ip(self):
        """Gets the source_ip of this FirewallruleProperties.  # noqa: E501

        Only traffic originating from the respective IP address (or CIDR block) is allowed. Value null allows traffic from any IP address (according to the selected ipVersion).  # noqa: E501

        :return: The source_ip of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._source_ip

    @source_ip.setter
    def source_ip(self, source_ip):
        """Sets the source_ip of this FirewallruleProperties.

        Only traffic originating from the respective IP address (or CIDR block) is allowed. Value null allows traffic from any IP address (according to the selected ipVersion).  # noqa: E501

        :param source_ip: The source_ip of this FirewallruleProperties.  # noqa: E501
        :type source_ip: str
        """

        self._source_ip = source_ip

    @property
    def target_ip(self):
        """Gets the target_ip of this FirewallruleProperties.  # noqa: E501

        If the target NIC has multiple IP addresses, only the traffic directed to the respective IP address (or CIDR block) of the NIC is allowed. Value null allows traffic to any target IP address (according to the selected ipVersion).  # noqa: E501

        :return: The target_ip of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._target_ip

    @target_ip.setter
    def target_ip(self, target_ip):
        """Sets the target_ip of this FirewallruleProperties.

        If the target NIC has multiple IP addresses, only the traffic directed to the respective IP address (or CIDR block) of the NIC is allowed. Value null allows traffic to any target IP address (according to the selected ipVersion).  # noqa: E501

        :param target_ip: The target_ip of this FirewallruleProperties.  # noqa: E501
        :type target_ip: str
        """

        self._target_ip = target_ip

    @property
    def icmp_code(self):
        """Gets the icmp_code of this FirewallruleProperties.  # noqa: E501

        Defines the allowed code (from 0 to 254) if protocol ICMP or ICMPv6 is chosen. Value null allows all codes.  # noqa: E501

        :return: The icmp_code of this FirewallruleProperties.  # noqa: E501
        :rtype: int
        """
        return self._icmp_code

    @icmp_code.setter
    def icmp_code(self, icmp_code):
        """Sets the icmp_code of this FirewallruleProperties.

        Defines the allowed code (from 0 to 254) if protocol ICMP or ICMPv6 is chosen. Value null allows all codes.  # noqa: E501

        :param icmp_code: The icmp_code of this FirewallruleProperties.  # noqa: E501
        :type icmp_code: int
        """
        if (self.local_vars_configuration.client_side_validation and
                icmp_code is not None and icmp_code > 254):  # noqa: E501
            raise ValueError("Invalid value for `icmp_code`, must be a value less than or equal to `254`")  # noqa: E501
        if (self.local_vars_configuration.client_side_validation and
                icmp_code is not None and icmp_code < 0):  # noqa: E501
            raise ValueError("Invalid value for `icmp_code`, must be a value greater than or equal to `0`")  # noqa: E501

        self._icmp_code = icmp_code

    @property
    def icmp_type(self):
        """Gets the icmp_type of this FirewallruleProperties.  # noqa: E501

        Defines the allowed type (from 0 to 254) if the protocol ICMP or ICMPv6 is chosen. Value null allows all types.  # noqa: E501

        :return: The icmp_type of this FirewallruleProperties.  # noqa: E501
        :rtype: int
        """
        return self._icmp_type

    @icmp_type.setter
    def icmp_type(self, icmp_type):
        """Sets the icmp_type of this FirewallruleProperties.

        Defines the allowed type (from 0 to 254) if the protocol ICMP or ICMPv6 is chosen. Value null allows all types.  # noqa: E501

        :param icmp_type: The icmp_type of this FirewallruleProperties.  # noqa: E501
        :type icmp_type: int
        """
        if (self.local_vars_configuration.client_side_validation and
                icmp_type is not None and icmp_type > 254):  # noqa: E501
            raise ValueError("Invalid value for `icmp_type`, must be a value less than or equal to `254`")  # noqa: E501
        if (self.local_vars_configuration.client_side_validation and
                icmp_type is not None and icmp_type < 0):  # noqa: E501
            raise ValueError("Invalid value for `icmp_type`, must be a value greater than or equal to `0`")  # noqa: E501

        self._icmp_type = icmp_type

    @property
    def port_range_start(self):
        """Gets the port_range_start of this FirewallruleProperties.  # noqa: E501

        Defines the start range of the allowed port (from 1 to 65535) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.  # noqa: E501

        :return: The port_range_start of this FirewallruleProperties.  # noqa: E501
        :rtype: int
        """
        return self._port_range_start

    @port_range_start.setter
    def port_range_start(self, port_range_start):
        """Sets the port_range_start of this FirewallruleProperties.

        Defines the start range of the allowed port (from 1 to 65535) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.  # noqa: E501

        :param port_range_start: The port_range_start of this FirewallruleProperties.  # noqa: E501
        :type port_range_start: int
        """
        if (self.local_vars_configuration.client_side_validation and
                port_range_start is not None and port_range_start > 65535):  # noqa: E501
            raise ValueError("Invalid value for `port_range_start`, must be a value less than or equal to `65535`")  # noqa: E501
        if (self.local_vars_configuration.client_side_validation and
                port_range_start is not None and port_range_start < 1):  # noqa: E501
            raise ValueError("Invalid value for `port_range_start`, must be a value greater than or equal to `1`")  # noqa: E501

        self._port_range_start = port_range_start

    @property
    def port_range_end(self):
        """Gets the port_range_end of this FirewallruleProperties.  # noqa: E501

        Defines the end range of the allowed port (from 1 to 65535) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports.  # noqa: E501

        :return: The port_range_end of this FirewallruleProperties.  # noqa: E501
        :rtype: int
        """
        return self._port_range_end

    @port_range_end.setter
    def port_range_end(self, port_range_end):
        """Sets the port_range_end of this FirewallruleProperties.

        Defines the end range of the allowed port (from 1 to 65535) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports.  # noqa: E501

        :param port_range_end: The port_range_end of this FirewallruleProperties.  # noqa: E501
        :type port_range_end: int
        """
        if (self.local_vars_configuration.client_side_validation and
                port_range_end is not None and port_range_end > 65535):  # noqa: E501
            raise ValueError("Invalid value for `port_range_end`, must be a value less than or equal to `65535`")  # noqa: E501
        if (self.local_vars_configuration.client_side_validation and
                port_range_end is not None and port_range_end < 1):  # noqa: E501
            raise ValueError("Invalid value for `port_range_end`, must be a value greater than or equal to `1`")  # noqa: E501

        self._port_range_end = port_range_end

    @property
    def type(self):
        """Gets the type of this FirewallruleProperties.  # noqa: E501

        The type of the firewall rule. If not specified, the default INGRESS value is used.  # noqa: E501

        :return: The type of this FirewallruleProperties.  # noqa: E501
        :rtype: str
        """
        return self._type

    @type.setter
    def type(self, type):
        """Sets the type of this FirewallruleProperties.

        The type of the firewall rule. If not specified, the default INGRESS value is used.  # noqa: E501

        :param type: The type of this FirewallruleProperties.  # noqa: E501
        :type type: str
        """
        allowed_values = ["INGRESS", "EGRESS"]  # noqa: E501
        if self.local_vars_configuration.client_side_validation and type not in allowed_values:  # noqa: E501
            raise ValueError(
                "Invalid value for `type` ({0}), must be one of {1}"  # noqa: E501
                .format(type, allowed_values)
            )

        self._type = type
    def to_dict(self):
        """Returns the model properties as a dict"""
        result = {}

        for attr, _ in six.iteritems(self.openapi_types):
            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
                    value
                ))
            elif hasattr(value, "to_dict"):
                result[attr] = value.to_dict()
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1].to_dict())
                    if hasattr(item[1], "to_dict") else item,
                    value.items()
                ))
            else:
                result[attr] = value

        return result

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self.to_dict())

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, FirewallruleProperties):
            return False

        return self.to_dict() == other.to_dict()

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        if not isinstance(other, FirewallruleProperties):
            return True

        return self.to_dict() != other.to_dict()