# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import pulumi
import pulumi.runtime

class SecGroupRule(pulumi.CustomResource):
    """
    Manages a V2 neutron security group rule resource within OpenStack.
    Unlike Nova security groups, neutron separates the group from the rules
    and also allows an admin to target a specific tenant_id.
    """
    def __init__(__self__, __name__, __opts__=None, direction=None, ethertype=None, port_range_max=None, port_range_min=None, protocol=None, region=None, remote_group_id=None, remote_ip_prefix=None, security_group_id=None, tenant_id=None):
        """Create a SecGroupRule resource with the given unique name, props, and options."""
        if not __name__:
            raise TypeError('Missing resource name argument (for URN creation)')
        if not isinstance(__name__, basestring):
            raise TypeError('Expected resource name to be a string')
        if __opts__ and not isinstance(__opts__, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')

        __props__ = dict()

        if not direction:
            raise TypeError('Missing required property direction')
        elif not isinstance(direction, basestring):
            raise TypeError('Expected property direction to be a basestring')
        __self__.direction = direction
        """
        The direction of the rule, valid values are __ingress__
        or __egress__. Changing this creates a new security group rule.
        """
        __props__['direction'] = direction

        if not ethertype:
            raise TypeError('Missing required property ethertype')
        elif not isinstance(ethertype, basestring):
            raise TypeError('Expected property ethertype to be a basestring')
        __self__.ethertype = ethertype
        """
        The layer 3 protocol type, valid values are __IPv4__
        or __IPv6__. Changing this creates a new security group rule.
        """
        __props__['ethertype'] = ethertype

        if port_range_max and not isinstance(port_range_max, int):
            raise TypeError('Expected property port_range_max to be a int')
        __self__.port_range_max = port_range_max
        """
        The higher part of the allowed port range, valid
        integer value needs to be between 1 and 65535. Changing this creates a new
        security group rule.
        """
        __props__['portRangeMax'] = port_range_max

        if port_range_min and not isinstance(port_range_min, int):
            raise TypeError('Expected property port_range_min to be a int')
        __self__.port_range_min = port_range_min
        """
        The lower part of the allowed port range, valid
        integer value needs to be between 1 and 65535. Changing this creates a new
        security group rule.
        """
        __props__['portRangeMin'] = port_range_min

        if protocol and not isinstance(protocol, basestring):
            raise TypeError('Expected property protocol to be a basestring')
        __self__.protocol = protocol
        """
        The layer 4 protocol type, valid values are following. Changing this creates a new security group rule. This is required if you want to specify a port range.
        * __tcp__
        * __udp__
        * __icmp__
        * __ah__
        * __dccp__
        * __egp__
        * __esp__
        * __gre__
        * __igmp__
        * __ipv6-encap__
        * __ipv6-frag__
        * __ipv6-icmp__
        * __ipv6-nonxt__
        * __ipv6-opts__
        * __ipv6-route__
        * __ospf__
        * __pgm__
        * __rsvp__
        * __sctp__
        * __udplite__
        * __vrrp__
        """
        __props__['protocol'] = protocol

        if region and not isinstance(region, basestring):
            raise TypeError('Expected property region to be a basestring')
        __self__.region = region
        """
        The region in which to obtain the V2 networking client.
        A networking client is needed to create a port. If omitted, the
        `region` argument of the provider is used. Changing this creates a new
        security group rule.
        """
        __props__['region'] = region

        if remote_group_id and not isinstance(remote_group_id, basestring):
            raise TypeError('Expected property remote_group_id to be a basestring')
        __self__.remote_group_id = remote_group_id
        """
        The remote group id, the value needs to be an
        Openstack ID of a security group in the same tenant. Changing this creates
        a new security group rule.
        """
        __props__['remoteGroupId'] = remote_group_id

        if remote_ip_prefix and not isinstance(remote_ip_prefix, basestring):
            raise TypeError('Expected property remote_ip_prefix to be a basestring')
        __self__.remote_ip_prefix = remote_ip_prefix
        """
        The remote CIDR, the value needs to be a valid
        CIDR (i.e. 192.168.0.0/16). Changing this creates a new security group rule.
        """
        __props__['remoteIpPrefix'] = remote_ip_prefix

        if not security_group_id:
            raise TypeError('Missing required property security_group_id')
        elif not isinstance(security_group_id, basestring):
            raise TypeError('Expected property security_group_id to be a basestring')
        __self__.security_group_id = security_group_id
        """
        The security group id the rule should belong
        to, the value needs to be an Openstack ID of a security group in the same
        tenant. Changing this creates a new security group rule.
        """
        __props__['securityGroupId'] = security_group_id

        if tenant_id and not isinstance(tenant_id, basestring):
            raise TypeError('Expected property tenant_id to be a basestring')
        __self__.tenant_id = tenant_id
        """
        The owner of the security group. Required if admin
        wants to create a port for another tenant. Changing this creates a new
        security group rule.
        """
        __props__['tenantId'] = tenant_id

        super(SecGroupRule, __self__).__init__(
            'openstack:networking/secGroupRule:SecGroupRule',
            __name__,
            __props__,
            __opts__)

    def set_outputs(self, outs):
        if 'direction' in outs:
            self.direction = outs['direction']
        if 'ethertype' in outs:
            self.ethertype = outs['ethertype']
        if 'portRangeMax' in outs:
            self.port_range_max = outs['portRangeMax']
        if 'portRangeMin' in outs:
            self.port_range_min = outs['portRangeMin']
        if 'protocol' in outs:
            self.protocol = outs['protocol']
        if 'region' in outs:
            self.region = outs['region']
        if 'remoteGroupId' in outs:
            self.remote_group_id = outs['remoteGroupId']
        if 'remoteIpPrefix' in outs:
            self.remote_ip_prefix = outs['remoteIpPrefix']
        if 'securityGroupId' in outs:
            self.security_group_id = outs['securityGroupId']
        if 'tenantId' in outs:
            self.tenant_id = outs['tenantId']
