Class: OCI::LoadBalancer::Models::ControlAccessUsingHttpMethodsRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb

Overview

An object that represents the action of returning a specified response code when the requested HTTP method is not in the list of allowed methods for the listener. The load balancer does not forward a disallowed request to the back end servers. The default response code is 405 Method Not Allowed.

If you set the response code to 405 or leave it blank, the system adds an "allow" response header that contains a list of the allowed methods for the listener. If you set the response code to anything other than 405 (or blank), the system does not add the "allow" response header with a list of allowed methods.

This rule applies only to HTTP listeners. No more than one ControlAccessUsingHttpMethodsRule object can be present in a given listener.

Constant Summary

Constants inherited from Rule

Rule::ACTION_ENUM

Instance Attribute Summary collapse

Attributes inherited from Rule

#action

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rule

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ ControlAccessUsingHttpMethodsRule

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :allowed_methods (Array<String>)

    The value to assign to the #allowed_methods property

  • :status_code (Integer)

    The value to assign to the #status_code property



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 78

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

  attributes['action'] = 'CONTROL_ACCESS_USING_HTTP_METHODS'

  super(attributes)

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

  self.allowed_methods = attributes[:'allowedMethods'] if attributes[:'allowedMethods']

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

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

  self.status_code = attributes[:'statusCode'] if attributes[:'statusCode']
  self.status_code = 405 if status_code.nil? && !attributes.key?(:'statusCode') # rubocop:disable Style/StringLiterals

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

  self.status_code = attributes[:'status_code'] if attributes[:'status_code']
  self.status_code = 405 if status_code.nil? && !attributes.key?(:'statusCode') && !attributes.key?(:'status_code') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#allowed_methodsArray<String>

[Required] The list of HTTP methods allowed for this listener.

By default, you can specify only the standard HTTP methods defined in the HTTP Method Registry. You can also see a list of supported standard HTTP methods in the Load Balancing service documentation at Managing Rule Sets.

Your backend application must be able to handle the methods specified in this list.

The list of HTTP methods is extensible. If you need to configure custom HTTP methods, contact My Oracle Support to remove the restriction for your tenancy.

Example: ["GET", "PUT", "POST", "PROPFIND"]

Returns:

  • (Array<String>)


37
38
39
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 37

def allowed_methods
  @allowed_methods
end

#status_codeInteger

The HTTP status code to return when the requested HTTP method is not in the list of allowed methods. The associated status line returned with the code is mapped from the standard HTTP specification. The default value is 405 (Method Not Allowed).

Example: 403

Returns:

  • (Integer)


46
47
48
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 46

def status_code
  @status_code
end

Class Method Details

.attribute_mapObject

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



49
50
51
52
53
54
55
56
57
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 49

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'action': :'action',
    'allowed_methods': :'allowedMethods',
    'status_code': :'statusCode'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



60
61
62
63
64
65
66
67
68
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 60

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'action': :'String',
    'allowed_methods': :'Array<String>',
    'status_code': :'Integer'
    # 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



110
111
112
113
114
115
116
117
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 110

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

  self.class == other.class &&
    action == other.action &&
    allowed_methods == other.allowed_methods &&
    status_code == other.status_code
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



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 142

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


122
123
124
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 122

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



131
132
133
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 131

def hash
  [action, allowed_methods, status_code].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



175
176
177
178
179
180
181
182
183
184
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 175

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



169
170
171
# File 'lib/oci/load_balancer/models/control_access_using_http_methods_rule.rb', line 169

def to_s
  to_hash.to_s
end