1# coding: utf-8
2# Copyright (c) 2016, 2021, Oracle and/or its affiliates.  All rights reserved.
3# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4
5
6from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel  # noqa: F401
7from oci.decorators import init_model_state_from_kwargs
8
9
10@init_model_state_from_kwargs
11class ResolverRuleDetails(object):
12    """
13    A rule for a resolver. Specifying both qnameCoverConditions and clientAddressConditions is not allowed.
14
15    **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
16    """
17
18    #: A constant which can be used with the action property of a ResolverRuleDetails.
19    #: This constant has a value of "FORWARD"
20    ACTION_FORWARD = "FORWARD"
21
22    def __init__(self, **kwargs):
23        """
24        Initializes a new ResolverRuleDetails object with values from keyword arguments. This class has the following subclasses and if you are using this class as input
25        to a service operations then you should favor using a subclass over the base class:
26
27        * :class:`~oci.dns.models.ResolverForwardRuleDetails`
28
29        The following keyword arguments are supported (corresponding to the getters/setters of this class):
30
31        :param client_address_conditions:
32            The value to assign to the client_address_conditions property of this ResolverRuleDetails.
33        :type client_address_conditions: list[str]
34
35        :param qname_cover_conditions:
36            The value to assign to the qname_cover_conditions property of this ResolverRuleDetails.
37        :type qname_cover_conditions: list[str]
38
39        :param action:
40            The value to assign to the action property of this ResolverRuleDetails.
41            Allowed values for this property are: "FORWARD"
42        :type action: str
43
44        """
45        self.swagger_types = {
46            'client_address_conditions': 'list[str]',
47            'qname_cover_conditions': 'list[str]',
48            'action': 'str'
49        }
50
51        self.attribute_map = {
52            'client_address_conditions': 'clientAddressConditions',
53            'qname_cover_conditions': 'qnameCoverConditions',
54            'action': 'action'
55        }
56
57        self._client_address_conditions = None
58        self._qname_cover_conditions = None
59        self._action = None
60
61    @staticmethod
62    def get_subtype(object_dictionary):
63        """
64        Given the hash representation of a subtype of this class,
65        use the info in the hash to return the class of the subtype.
66        """
67        type = object_dictionary['action']
68
69        if type == 'FORWARD':
70            return 'ResolverForwardRuleDetails'
71        else:
72            return 'ResolverRuleDetails'
73
74    @property
75    def client_address_conditions(self):
76        """
77        Gets the client_address_conditions of this ResolverRuleDetails.
78        A list of CIDR blocks. The query must come from a client within one of the blocks in order for the rule action
79        to apply.
80
81
82        :return: The client_address_conditions of this ResolverRuleDetails.
83        :rtype: list[str]
84        """
85        return self._client_address_conditions
86
87    @client_address_conditions.setter
88    def client_address_conditions(self, client_address_conditions):
89        """
90        Sets the client_address_conditions of this ResolverRuleDetails.
91        A list of CIDR blocks. The query must come from a client within one of the blocks in order for the rule action
92        to apply.
93
94
95        :param client_address_conditions: The client_address_conditions of this ResolverRuleDetails.
96        :type: list[str]
97        """
98        self._client_address_conditions = client_address_conditions
99
100    @property
101    def qname_cover_conditions(self):
102        """
103        Gets the qname_cover_conditions of this ResolverRuleDetails.
104        A list of domain names. The query must be covered by one of the domains in order for the rule action to apply.
105
106
107        :return: The qname_cover_conditions of this ResolverRuleDetails.
108        :rtype: list[str]
109        """
110        return self._qname_cover_conditions
111
112    @qname_cover_conditions.setter
113    def qname_cover_conditions(self, qname_cover_conditions):
114        """
115        Sets the qname_cover_conditions of this ResolverRuleDetails.
116        A list of domain names. The query must be covered by one of the domains in order for the rule action to apply.
117
118
119        :param qname_cover_conditions: The qname_cover_conditions of this ResolverRuleDetails.
120        :type: list[str]
121        """
122        self._qname_cover_conditions = qname_cover_conditions
123
124    @property
125    def action(self):
126        """
127        **[Required]** Gets the action of this ResolverRuleDetails.
128        The action determines the behavior of the rule. If a query matches a supplied condition, the action will
129        apply. If there are no conditions on the rule, all queries are subject to the specified action.
130        * `FORWARD` - Matching requests will be forwarded from the source interface to the destination address.
131
132        Allowed values for this property are: "FORWARD"
133
134
135        :return: The action of this ResolverRuleDetails.
136        :rtype: str
137        """
138        return self._action
139
140    @action.setter
141    def action(self, action):
142        """
143        Sets the action of this ResolverRuleDetails.
144        The action determines the behavior of the rule. If a query matches a supplied condition, the action will
145        apply. If there are no conditions on the rule, all queries are subject to the specified action.
146        * `FORWARD` - Matching requests will be forwarded from the source interface to the destination address.
147
148
149        :param action: The action of this ResolverRuleDetails.
150        :type: str
151        """
152        allowed_values = ["FORWARD"]
153        if not value_allowed_none_or_none_sentinel(action, allowed_values):
154            raise ValueError(
155                "Invalid value for `action`, must be None or one of {0}"
156                .format(allowed_values)
157            )
158        self._action = action
159
160    def __repr__(self):
161        return formatted_flat_dict(self)
162
163    def __eq__(self, other):
164        if other is None:
165            return False
166
167        return self.__dict__ == other.__dict__
168
169    def __ne__(self, other):
170        return not self == other
171