# 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 SecGroup(pulumi.CustomResource):
    """
    Manages a V2 security group resource within OpenStack.
    
    Please note that managing security groups through the OpenStack Compute API
    has been deprecated. Unless you are using an older OpenStack environment, it is
    recommended to use the [`openstack_networking_secgroup_v2`](networking_secgroup_v2.html)
    and [`openstack_networking_secgroup_rule_v2`](networking_secgroup_rule_v2.html)
    resources instead, which uses the OpenStack Networking API.
    """
    def __init__(__self__, __name__, __opts__=None, description=None, name=None, region=None, rules=None):
        """Create a SecGroup 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 description:
            raise TypeError('Missing required property description')
        elif not isinstance(description, basestring):
            raise TypeError('Expected property description to be a basestring')
        __self__.description = description
        """
        A description for the security group. Changing this
        updates the `description` of an existing security group.
        """
        __props__['description'] = description

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

        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 Compute client.
        A Compute client is needed to create a security group. If omitted, the
        `region` argument of the provider is used. Changing this creates a new
        security group.
        """
        __props__['region'] = region

        if rules and not isinstance(rules, list):
            raise TypeError('Expected property rules to be a list')
        __self__.rules = rules
        """
        A rule describing how the security group operates. The
        rule object structure is documented below. Changing this updates the
        security group rules. As shown in the example above, multiple rule blocks
        may be used.
        """
        __props__['rules'] = rules

        super(SecGroup, __self__).__init__(
            'openstack:compute/secGroup:SecGroup',
            __name__,
            __props__,
            __opts__)

    def set_outputs(self, outs):
        if 'description' in outs:
            self.description = outs['description']
        if 'name' in outs:
            self.name = outs['name']
        if 'region' in outs:
            self.region = outs['region']
        if 'rules' in outs:
            self.rules = outs['rules']
