huaweicloud-sdk-python-v3/huaweicloud-sdk-vpc/huaweicloudsdkvpc/v2/model/security_group_rule.py

370 lines
12 KiB
Python
Raw Normal View History

2020-05-18 07:34:40 +00:00
# coding: utf-8
import pprint
import re
import six
class SecurityGroupRule:
2020-05-18 07:34:40 +00:00
"""
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.
"""
sensitive_list = []
2020-05-18 07:34:40 +00:00
openapi_types = {
'id': 'str',
'description': 'str',
'security_group_id': 'str',
'direction': 'str',
'ethertype': 'str',
'protocol': 'str',
'port_range_min': 'int',
'port_range_max': 'int',
'remote_ip_prefix': 'str',
'remote_group_id': 'str',
'tenant_id': 'str'
2020-05-18 07:34:40 +00:00
}
attribute_map = {
'id': 'id',
'description': 'description',
'security_group_id': 'security_group_id',
'direction': 'direction',
'ethertype': 'ethertype',
'protocol': 'protocol',
'port_range_min': 'port_range_min',
'port_range_max': 'port_range_max',
'remote_ip_prefix': 'remote_ip_prefix',
'remote_group_id': 'remote_group_id',
'tenant_id': 'tenant_id'
2020-05-18 07:34:40 +00:00
}
def __init__(self, id=None, description=None, security_group_id=None, direction=None, ethertype=None, protocol=None, port_range_min=None, port_range_max=None, remote_ip_prefix=None, remote_group_id=None, tenant_id=None):
2020-05-18 07:34:40 +00:00
"""SecurityGroupRule - a model defined in huaweicloud sdk"""
2020-05-18 07:34:40 +00:00
self._id = None
self._description = None
self._security_group_id = None
self._direction = None
self._ethertype = None
self._protocol = None
self._port_range_min = None
self._port_range_max = None
self._remote_ip_prefix = None
self._remote_group_id = None
self._tenant_id = None
2020-05-18 07:34:40 +00:00
self.discriminator = None
self.id = id
self.description = description
self.security_group_id = security_group_id
self.direction = direction
self.ethertype = ethertype
self.protocol = protocol
self.port_range_min = port_range_min
self.port_range_max = port_range_max
self.remote_ip_prefix = remote_ip_prefix
self.remote_group_id = remote_group_id
self.tenant_id = tenant_id
2020-05-18 07:34:40 +00:00
@property
def id(self):
"""Gets the id of this SecurityGroupRule.
安全组规则ID
:return: The id of this SecurityGroupRule.
:rtype: str
"""
return self._id
@id.setter
def id(self, id):
"""Sets the id of this SecurityGroupRule.
安全组规则ID
:param id: The id of this SecurityGroupRule.
:type: str
"""
self._id = id
@property
def description(self):
"""Gets the description of this SecurityGroupRule.
功能说明安全组规则描述 取值范围0-255个字符支持数字字母中文字符
:return: The description of this SecurityGroupRule.
:rtype: str
"""
return self._description
@description.setter
def description(self, description):
"""Sets the description of this SecurityGroupRule.
功能说明安全组规则描述 取值范围0-255个字符支持数字字母中文字符
:param description: The description of this SecurityGroupRule.
:type: str
"""
self._description = description
@property
def security_group_id(self):
"""Gets the security_group_id of this SecurityGroupRule.
安全组ID
:return: The security_group_id of this SecurityGroupRule.
:rtype: str
"""
return self._security_group_id
@security_group_id.setter
def security_group_id(self, security_group_id):
"""Sets the security_group_id of this SecurityGroupRule.
安全组ID
:param security_group_id: The security_group_id of this SecurityGroupRule.
:type: str
"""
self._security_group_id = security_group_id
@property
def direction(self):
"""Gets the direction of this SecurityGroupRule.
功能说明出入控制方向 取值范围 - egress出方向 - ingress入方向
:return: The direction of this SecurityGroupRule.
:rtype: str
"""
return self._direction
@direction.setter
def direction(self, direction):
"""Sets the direction of this SecurityGroupRule.
功能说明出入控制方向 取值范围 - egress出方向 - ingress入方向
:param direction: The direction of this SecurityGroupRule.
:type: str
"""
self._direction = direction
@property
def ethertype(self):
"""Gets the ethertype of this SecurityGroupRule.
功能说明IP协议类型 取值范围IPv4,IPv6
:return: The ethertype of this SecurityGroupRule.
:rtype: str
"""
return self._ethertype
@ethertype.setter
def ethertype(self, ethertype):
"""Sets the ethertype of this SecurityGroupRule.
功能说明IP协议类型 取值范围IPv4,IPv6
:param ethertype: The ethertype of this SecurityGroupRule.
:type: str
"""
self._ethertype = ethertype
@property
def protocol(self):
"""Gets the protocol of this SecurityGroupRule.
功能说明协议类型 取值范围tcpudpicmp或IP协议编号0~255 约束为空表示支持所有协议
:return: The protocol of this SecurityGroupRule.
:rtype: str
"""
return self._protocol
@protocol.setter
def protocol(self, protocol):
"""Sets the protocol of this SecurityGroupRule.
功能说明协议类型 取值范围tcpudpicmp或IP协议编号0~255 约束为空表示支持所有协议
:param protocol: The protocol of this SecurityGroupRule.
:type: str
"""
self._protocol = protocol
@property
def port_range_min(self):
"""Gets the port_range_min of this SecurityGroupRule.
功能说明起始端口值 取值范围1~65535 约束不能大于port_range_max的值为空表示所有端口如果协议是icmp类型取值范围请参见 [安全组规则icmp协议名称对应关系表](https://support.huaweicloud.com/api-vpc/vpc_api_0009.html)
:return: The port_range_min of this SecurityGroupRule.
:rtype: int
"""
return self._port_range_min
@port_range_min.setter
def port_range_min(self, port_range_min):
"""Sets the port_range_min of this SecurityGroupRule.
功能说明起始端口值 取值范围1~65535 约束不能大于port_range_max的值为空表示所有端口如果协议是icmp类型取值范围请参见 [安全组规则icmp协议名称对应关系表](https://support.huaweicloud.com/api-vpc/vpc_api_0009.html)
:param port_range_min: The port_range_min of this SecurityGroupRule.
:type: int
"""
self._port_range_min = port_range_min
@property
def port_range_max(self):
"""Gets the port_range_max of this SecurityGroupRule.
功能说明结束端口值 取值范围1~65535 约束取值不能小于port_range_min的值为空表示所有端口如果协议是icmp类型取值范围请参见 [安全组规则icmp协议名称对应关系表](https://support.huaweicloud.com/api-vpc/vpc_api_0009.html)
:return: The port_range_max of this SecurityGroupRule.
:rtype: int
"""
return self._port_range_max
@port_range_max.setter
def port_range_max(self, port_range_max):
"""Sets the port_range_max of this SecurityGroupRule.
功能说明结束端口值 取值范围1~65535 约束取值不能小于port_range_min的值为空表示所有端口如果协议是icmp类型取值范围请参见 [安全组规则icmp协议名称对应关系表](https://support.huaweicloud.com/api-vpc/vpc_api_0009.html)
:param port_range_max: The port_range_max of this SecurityGroupRule.
:type: int
"""
self._port_range_max = port_range_max
@property
def remote_ip_prefix(self):
"""Gets the remote_ip_prefix of this SecurityGroupRule.
功能说明远端IP地址当direction是egress时为虚拟机访问端的地址当direction是ingress时为访问虚拟机的地址 取值范围IP地址或者cidr格式 约束和remote_group_id互斥
:return: The remote_ip_prefix of this SecurityGroupRule.
:rtype: str
"""
return self._remote_ip_prefix
@remote_ip_prefix.setter
def remote_ip_prefix(self, remote_ip_prefix):
"""Sets the remote_ip_prefix of this SecurityGroupRule.
功能说明远端IP地址当direction是egress时为虚拟机访问端的地址当direction是ingress时为访问虚拟机的地址 取值范围IP地址或者cidr格式 约束和remote_group_id互斥
:param remote_ip_prefix: The remote_ip_prefix of this SecurityGroupRule.
:type: str
"""
self._remote_ip_prefix = remote_ip_prefix
@property
def remote_group_id(self):
"""Gets the remote_group_id of this SecurityGroupRule.
功能说明对端安全组ID 约束和remote_ip_prefix互斥
:return: The remote_group_id of this SecurityGroupRule.
:rtype: str
"""
return self._remote_group_id
@remote_group_id.setter
def remote_group_id(self, remote_group_id):
"""Sets the remote_group_id of this SecurityGroupRule.
功能说明对端安全组ID 约束和remote_ip_prefix互斥
:param remote_group_id: The remote_group_id of this SecurityGroupRule.
:type: str
"""
self._remote_group_id = remote_group_id
@property
def tenant_id(self):
"""Gets the tenant_id of this SecurityGroupRule.
安全组所属项目ID
:return: The tenant_id of this SecurityGroupRule.
:rtype: str
"""
return self._tenant_id
@tenant_id.setter
def tenant_id(self, tenant_id):
"""Sets the tenant_id of this SecurityGroupRule.
安全组所属项目ID
:param tenant_id: The tenant_id of this SecurityGroupRule.
:type: str
"""
self._tenant_id = tenant_id
2020-05-18 07:34:40 +00:00
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:
if attr in self.sensitive_list:
result[attr] = "****"
else:
result[attr] = value
2020-05-18 07:34:40 +00:00
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, SecurityGroupRule):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other