Class: OCI::Dns::Models::SteeringPolicyRule

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/dns/models/steering_policy_rule.rb

Overview

The configuration of the sorting and filtering behaviors in a steering policy. Rules can filter and sort answers based on weight, priority, endpoint health, and other data.

A rule may optionally include a sequence of cases, each with an optional caseCondition expression. Cases allow a sequence of conditions to be defined that will apply different parameters to the rule when the conditions are met. For more information about cases, see Traffic Management API Guide.

Warning: Oracle recommends that you avoid using any confidential information when you supply string values using the API.

This class has direct subclasses. If you are using this class as input to a service operations then you should favor using a subclass over the base class

Constant Summary collapse

RULE_TYPE_ENUM =
[
  RULE_TYPE_FILTER = 'FILTER'.freeze,
  RULE_TYPE_HEALTH = 'HEALTH'.freeze,
  RULE_TYPE_WEIGHTED = 'WEIGHTED'.freeze,
  RULE_TYPE_PRIORITY = 'PRIORITY'.freeze,
  RULE_TYPE_LIMIT = 'LIMIT'.freeze,
  RULE_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SteeringPolicyRule

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :description (String)

    The value to assign to the #description property

  • :rule_type (String)

    The value to assign to the #rule_type property



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 110

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.description = attributes[:'description'] if attributes[:'description']

  self.rule_type = attributes[:'ruleType'] if attributes[:'ruleType']

  raise 'You cannot provide both :ruleType and :rule_type' if attributes.key?(:'ruleType') && attributes.key?(:'rule_type')

  self.rule_type = attributes[:'rule_type'] if attributes[:'rule_type']
end

Instance Attribute Details

#descriptionString

A user-defined description of the rule's purpose or behavior.

Returns:

  • (String)


35
36
37
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 35

def description
  @description
end

#rule_typeString

[Required] The type of a rule determines its sorting/filtering behavior. * FILTER - Filters the list of answers based on their defined boolean data. Answers remain only if their shouldKeep value is true.

  • HEALTH - Removes answers from the list if their rdata matches a target in the health check monitor referenced by the steering policy and the target is reported down.

  • WEIGHTED - Uses a number between 0 and 255 to determine how often an answer will be served in relation to other answers. Anwers with a higher weight will be served more frequently.

  • PRIORITY - Uses a defined rank value of answers to determine which answer to serve, moving those with the lowest values to the beginning of the list without changing the relative order of those with the same value. Answers can be given a value between 0 and 255.

  • LIMIT - Filters answers that are too far down the list. Parameter defaultCount specifies how many answers to keep. Example: If defaultCount has a value of 2 and there are five answers left, when the LIMIT rule is processed, only the first two answers will remain in the list.

Returns:

  • (String)


61
62
63
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 61

def rule_type
  @rule_type
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



64
65
66
67
68
69
70
71
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 64

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'description': :'description',
    'rule_type': :'ruleType'
    # rubocop:enable Style/SymbolLiteral
  }
end

.get_subtype(object_hash) ⇒ Object

Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 88

def self.get_subtype(object_hash)
  type = object_hash[:'ruleType'] # rubocop:disable Style/SymbolLiteral

  return 'OCI::Dns::Models::SteeringPolicyFilterRule' if type == 'FILTER'
  return 'OCI::Dns::Models::SteeringPolicyWeightedRule' if type == 'WEIGHTED'
  return 'OCI::Dns::Models::SteeringPolicyLimitRule' if type == 'LIMIT'
  return 'OCI::Dns::Models::SteeringPolicyHealthRule' if type == 'HEALTH'
  return 'OCI::Dns::Models::SteeringPolicyPriorityRule' if type == 'PRIORITY'

  # TODO: Log a warning when the subtype is not found.
  'OCI::Dns::Models::SteeringPolicyRule'
end

.swagger_typesObject

Attribute type mapping.



74
75
76
77
78
79
80
81
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 74

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'description': :'String',
    'rule_type': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



145
146
147
148
149
150
151
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 145

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    description == other.description &&
    rule_type == other.rule_type
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 176

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


156
157
158
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 156

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



165
166
167
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 165

def hash
  [description, rule_type].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



209
210
211
212
213
214
215
216
217
218
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 209

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



203
204
205
# File 'lib/oci/dns/models/steering_policy_rule.rb', line 203

def to_s
  to_hash.to_s
end