# 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 Rule(pulumi.CustomResource):
    """
    Manages a v1 firewall rule resource within OpenStack.
    """
    def __init__(__self__, __name__, __opts__=None, action=None, description=None, destination_ip_address=None, destination_port=None, enabled=None, ip_version=None, name=None, protocol=None, region=None, source_ip_address=None, source_port=None, tenant_id=None, value_specs=None):
        """Create a Rule 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 action:
            raise TypeError('Missing required property action')
        elif not isinstance(action, basestring):
            raise TypeError('Expected property action to be a basestring')
        __self__.action = action
        """
        Action to be taken ( must be "allow" or "deny") when the
        firewall rule matches. Changing this updates the `action` of an existing
        firewall rule.
        """
        __props__['action'] = action

        if description and not isinstance(description, basestring):
            raise TypeError('Expected property description to be a basestring')
        __self__.description = description
        """
        A description for the firewall rule. Changing this
        updates the `description` of an existing firewall rule.
        """
        __props__['description'] = description

        if destination_ip_address and not isinstance(destination_ip_address, basestring):
            raise TypeError('Expected property destination_ip_address to be a basestring')
        __self__.destination_ip_address = destination_ip_address
        """
        The destination IP address on which the
        firewall rule operates. Changing this updates the `destination_ip_address`
        of an existing firewall rule.
        """
        __props__['destinationIpAddress'] = destination_ip_address

        if destination_port and not isinstance(destination_port, basestring):
            raise TypeError('Expected property destination_port to be a basestring')
        __self__.destination_port = destination_port
        """
        The destination port on which the firewall
        rule operates. Changing this updates the `destination_port` of an existing
        firewall rule.
        """
        __props__['destinationPort'] = destination_port

        if enabled and not isinstance(enabled, bool):
            raise TypeError('Expected property enabled to be a bool')
        __self__.enabled = enabled
        """
        Enabled status for the firewall rule (must be "true"
        or "false" if provided - defaults to "true"). Changing this updates the
        `enabled` status of an existing firewall rule.
        """
        __props__['enabled'] = enabled

        if ip_version and not isinstance(ip_version, int):
            raise TypeError('Expected property ip_version to be a int')
        __self__.ip_version = ip_version
        """
        IP version, either 4 (default) or 6. Changing this
        updates the `ip_version` of an existing firewall rule.
        """
        __props__['ipVersion'] = ip_version

        if name and not isinstance(name, basestring):
            raise TypeError('Expected property name to be a basestring')
        __self__.name = name
        """
        A unique name for the firewall rule. Changing this
        updates the `name` of an existing firewall rule.
        """
        __props__['name'] = name

        if not protocol:
            raise TypeError('Missing required property protocol')
        elif not isinstance(protocol, basestring):
            raise TypeError('Expected property protocol to be a basestring')
        __self__.protocol = protocol
        """
        The protocol type on which the firewall rule operates.
        Valid values are: `tcp`, `udp`, `icmp`, and `any`. Changing this updates the
        `protocol` of an existing firewall rule.
        """
        __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 v1 Compute client.
        A Compute client is needed to create a firewall rule. If omitted, the
        `region` argument of the provider is used. Changing this creates a new
        firewall rule.
        """
        __props__['region'] = region

        if source_ip_address and not isinstance(source_ip_address, basestring):
            raise TypeError('Expected property source_ip_address to be a basestring')
        __self__.source_ip_address = source_ip_address
        """
        The source IP address on which the firewall
        rule operates. Changing this updates the `source_ip_address` of an existing
        firewall rule.
        """
        __props__['sourceIpAddress'] = source_ip_address

        if source_port and not isinstance(source_port, basestring):
            raise TypeError('Expected property source_port to be a basestring')
        __self__.source_port = source_port
        """
        The source port on which the firewall
        rule operates. Changing this updates the `source_port` of an existing
        firewall rule.
        """
        __props__['sourcePort'] = source_port

        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 firewall rule. Required if admin
        wants to create a firewall rule for another tenant. Changing this creates a
        new firewall rule.
        """
        __props__['tenantId'] = tenant_id

        if value_specs and not isinstance(value_specs, dict):
            raise TypeError('Expected property value_specs to be a dict')
        __self__.value_specs = value_specs
        """
        Map of additional options.
        """
        __props__['valueSpecs'] = value_specs

        super(Rule, __self__).__init__(
            'openstack:firewall/rule:Rule',
            __name__,
            __props__,
            __opts__)

    def set_outputs(self, outs):
        if 'action' in outs:
            self.action = outs['action']
        if 'description' in outs:
            self.description = outs['description']
        if 'destinationIpAddress' in outs:
            self.destination_ip_address = outs['destinationIpAddress']
        if 'destinationPort' in outs:
            self.destination_port = outs['destinationPort']
        if 'enabled' in outs:
            self.enabled = outs['enabled']
        if 'ipVersion' in outs:
            self.ip_version = outs['ipVersion']
        if 'name' in outs:
            self.name = outs['name']
        if 'protocol' in outs:
            self.protocol = outs['protocol']
        if 'region' in outs:
            self.region = outs['region']
        if 'sourceIpAddress' in outs:
            self.source_ip_address = outs['sourceIpAddress']
        if 'sourcePort' in outs:
            self.source_port = outs['sourcePort']
        if 'tenantId' in outs:
            self.tenant_id = outs['tenantId']
        if 'valueSpecs' in outs:
            self.value_specs = outs['valueSpecs']
