# 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 json
import warnings
import pulumi
import pulumi.runtime
from typing import Union
from .. import utilities, tables

class GetSecurityGroupRulesResult:
    """
    A collection of values returned by getSecurityGroupRules.
    """
    def __init__(__self__, direction=None, group_desc=None, group_id=None, group_name=None, ip_protocol=None, nic_type=None, output_file=None, policy=None, rules=None, id=None):
        if direction and not isinstance(direction, str):
            raise TypeError("Expected argument 'direction' to be a str")
        __self__.direction = direction
        """
        Authorization direction, `ingress` or `egress`.
        """
        if group_desc and not isinstance(group_desc, str):
            raise TypeError("Expected argument 'group_desc' to be a str")
        __self__.group_desc = group_desc
        """
        The description of the security group that owns the rules.
        """
        if group_id and not isinstance(group_id, str):
            raise TypeError("Expected argument 'group_id' to be a str")
        __self__.group_id = group_id
        if group_name and not isinstance(group_name, str):
            raise TypeError("Expected argument 'group_name' to be a str")
        __self__.group_name = group_name
        """
        The name of the security group that owns the rules.
        """
        if ip_protocol and not isinstance(ip_protocol, str):
            raise TypeError("Expected argument 'ip_protocol' to be a str")
        __self__.ip_protocol = ip_protocol
        """
        The protocol. Can be `tcp`, `udp`, `icmp`, `gre` or `all`.
        """
        if nic_type and not isinstance(nic_type, str):
            raise TypeError("Expected argument 'nic_type' to be a str")
        __self__.nic_type = nic_type
        """
        Network type, `internet` or `intranet`.
        """
        if output_file and not isinstance(output_file, str):
            raise TypeError("Expected argument 'output_file' to be a str")
        __self__.output_file = output_file
        if policy and not isinstance(policy, str):
            raise TypeError("Expected argument 'policy' to be a str")
        __self__.policy = policy
        """
        Authorization policy. Can be either `accept` or `drop`.
        """
        if rules and not isinstance(rules, list):
            raise TypeError("Expected argument 'rules' to be a list")
        __self__.rules = rules
        """
        A list of security group rules. Each element contains the following attributes:
        """
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        __self__.id = id
        """
        id is the provider-assigned unique ID for this managed resource.
        """
class AwaitableGetSecurityGroupRulesResult(GetSecurityGroupRulesResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetSecurityGroupRulesResult(
            direction=self.direction,
            group_desc=self.group_desc,
            group_id=self.group_id,
            group_name=self.group_name,
            ip_protocol=self.ip_protocol,
            nic_type=self.nic_type,
            output_file=self.output_file,
            policy=self.policy,
            rules=self.rules,
            id=self.id)

def get_security_group_rules(direction=None,group_id=None,ip_protocol=None,nic_type=None,output_file=None,policy=None,opts=None):
    """
    The `ecs.getSecurityGroupRules` data source provides a collection of security permissions of a specific security group.
    Each collection item represents a single `ingress` or `egress` permission rule.
    The ID of the security group can be provided via a variable or the result from the other data source `ecs.getSecurityGroups`.
    
    :param str direction: Authorization direction. Valid values are: `ingress` or `egress`.
    :param str group_id: The ID of the security group that owns the rules.
    :param str ip_protocol: The IP protocol. Valid values are: `tcp`, `udp`, `icmp`, `gre` and `all`.
    :param str nic_type: Refers to the network type. Can be either `internet` or `intranet`. The default value is `internet`.
    :param str policy: Authorization policy. Can be either `accept` or `drop`. The default value is `accept`.

    > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/d/security_group_rules.html.markdown.
    """
    __args__ = dict()

    __args__['direction'] = direction
    __args__['groupId'] = group_id
    __args__['ipProtocol'] = ip_protocol
    __args__['nicType'] = nic_type
    __args__['outputFile'] = output_file
    __args__['policy'] = policy
    if opts is None:
        opts = pulumi.InvokeOptions()
    if opts.version is None:
        opts.version = utilities.get_version()
    __ret__ = pulumi.runtime.invoke('alicloud:ecs/getSecurityGroupRules:getSecurityGroupRules', __args__, opts=opts).value

    return AwaitableGetSecurityGroupRulesResult(
        direction=__ret__.get('direction'),
        group_desc=__ret__.get('groupDesc'),
        group_id=__ret__.get('groupId'),
        group_name=__ret__.get('groupName'),
        ip_protocol=__ret__.get('ipProtocol'),
        nic_type=__ret__.get('nicType'),
        output_file=__ret__.get('outputFile'),
        policy=__ret__.get('policy'),
        rules=__ret__.get('rules'),
        id=__ret__.get('id'))
