Class: OCI::Waas::Models::AccessRule

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/waas/models/access_rule.rb

Overview

A content access rule. An access rule specifies an action to take if a set of criteria is matched by a request.

Constant Summary collapse

ACTION_ENUM =

rubocop:disable Metrics/LineLength

[
  ACTION_ALLOW = 'ALLOW'.freeze,
  ACTION_DETECT = 'DETECT'.freeze,
  ACTION_BLOCK = 'BLOCK'.freeze,
  ACTION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
BLOCK_ACTION_ENUM =
[
  BLOCK_ACTION_SET_RESPONSE_CODE = 'SET_RESPONSE_CODE'.freeze,
  BLOCK_ACTION_SHOW_ERROR_PAGE = 'SHOW_ERROR_PAGE'.freeze,
  BLOCK_ACTION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AccessRule

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/oci/waas/models/access_rule.rb', line 101

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.name = attributes[:'name'] if attributes[:'name']

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

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

  self.block_action = attributes[:'blockAction'] if attributes[:'blockAction']

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

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

  self.block_response_code = attributes[:'blockResponseCode'] if attributes[:'blockResponseCode']

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

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

  self.block_error_page_message = attributes[:'blockErrorPageMessage'] if attributes[:'blockErrorPageMessage']

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

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

  self.block_error_page_code = attributes[:'blockErrorPageCode'] if attributes[:'blockErrorPageCode']

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

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

  self.block_error_page_description = attributes[:'blockErrorPageDescription'] if attributes[:'blockErrorPageDescription']

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

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

Instance Attribute Details

#actionString

[Required] The action to take when the access criteria are met for a rule. If unspecified, defaults to ‘ALLOW`.

Returns:

  • (String)


33
34
35
# File 'lib/oci/waas/models/access_rule.rb', line 33

def action
  @action
end

#block_actionString

The method used to block requests if ‘action` is set to `BLOCK` and the access criteria are met. If unspecified, defaults to `SET_RESPONSE_CODE`.

Returns:

  • (String)


37
38
39
# File 'lib/oci/waas/models/access_rule.rb', line 37

def block_action
  @block_action
end

#block_error_page_codeString

The error code to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the access criteria are met. If unspecified, defaults to ’Access rules’.

Returns:

  • (String)


49
50
51
# File 'lib/oci/waas/models/access_rule.rb', line 49

def block_error_page_code
  @block_error_page_code
end

#block_error_page_descriptionString

The description text to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the access criteria are met. If unspecified, defaults to ’Access blocked by website owner. Please contact support.‘

Returns:

  • (String)


53
54
55
# File 'lib/oci/waas/models/access_rule.rb', line 53

def block_error_page_description
  @block_error_page_description
end

#block_error_page_messageString

The message to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the access criteria are met. If unspecified, defaults to ’Access to the website is blocked.‘

Returns:

  • (String)


45
46
47
# File 'lib/oci/waas/models/access_rule.rb', line 45

def block_error_page_message
  @block_error_page_message
end

#block_response_codeInteger

The response status code to return when ‘action` is set to `BLOCK`, `blockAction` is set to `SET_RESPONSE_CODE`, and the access criteria are met. If unspecified, defaults to `403`.

Returns:

  • (Integer)


41
42
43
# File 'lib/oci/waas/models/access_rule.rb', line 41

def block_response_code
  @block_response_code
end

#criteriaArray<OCI::Waas::Models::AccessRuleCriteria>

[Required] The list of access rule criteria.



29
30
31
# File 'lib/oci/waas/models/access_rule.rb', line 29

def criteria
  @criteria
end

#nameString

[Required] The unique name of the access rule.

Returns:

  • (String)


25
26
27
# File 'lib/oci/waas/models/access_rule.rb', line 25

def name
  @name
end

Class Method Details

.attribute_mapObject

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



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/oci/waas/models/access_rule.rb', line 56

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'name',
    'criteria': :'criteria',
    'action': :'action',
    'block_action': :'blockAction',
    'block_response_code': :'blockResponseCode',
    'block_error_page_message': :'blockErrorPageMessage',
    'block_error_page_code': :'blockErrorPageCode',
    'block_error_page_description': :'blockErrorPageDescription'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oci/waas/models/access_rule.rb', line 72

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'String',
    'criteria': :'Array<OCI::Waas::Models::AccessRuleCriteria>',
    'action': :'String',
    'block_action': :'String',
    'block_response_code': :'Integer',
    'block_error_page_message': :'String',
    'block_error_page_code': :'String',
    'block_error_page_description': :'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



181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/oci/waas/models/access_rule.rb', line 181

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

  self.class == other.class &&
    name == other.name &&
    criteria == other.criteria &&
    action == other.action &&
    block_action == other.block_action &&
    block_response_code == other.block_response_code &&
    block_error_page_message == other.block_error_page_message &&
    block_error_page_code == other.block_error_page_code &&
    block_error_page_description == other.block_error_page_description
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



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/oci/waas/models/access_rule.rb', line 218

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


198
199
200
# File 'lib/oci/waas/models/access_rule.rb', line 198

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



207
208
209
# File 'lib/oci/waas/models/access_rule.rb', line 207

def hash
  [name, criteria, action, block_action, block_response_code, block_error_page_message, block_error_page_code, block_error_page_description].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



251
252
253
254
255
256
257
258
259
260
# File 'lib/oci/waas/models/access_rule.rb', line 251

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



245
246
247
# File 'lib/oci/waas/models/access_rule.rb', line 245

def to_s
  to_hash.to_s
end