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 =
[
  ACTION_ALLOW = 'ALLOW'.freeze,
  ACTION_DETECT = 'DETECT'.freeze,
  ACTION_BLOCK = 'BLOCK'.freeze,
  ACTION_BYPASS = 'BYPASS'.freeze,
  ACTION_REDIRECT = 'REDIRECT'.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
BYPASS_CHALLENGES_ENUM =
[
  BYPASS_CHALLENGES_JS_CHALLENGE = 'JS_CHALLENGE'.freeze,
  BYPASS_CHALLENGES_DEVICE_FINGERPRINT_CHALLENGE = 'DEVICE_FINGERPRINT_CHALLENGE'.freeze,
  BYPASS_CHALLENGES_HUMAN_INTERACTION_CHALLENGE = 'HUMAN_INTERACTION_CHALLENGE'.freeze,
  BYPASS_CHALLENGES_CAPTCHA = 'CAPTCHA'.freeze,
  BYPASS_CHALLENGES_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
REDIRECT_RESPONSE_CODE_ENUM =
[
  REDIRECT_RESPONSE_CODE_MOVED_PERMANENTLY = 'MOVED_PERMANENTLY'.freeze,
  REDIRECT_RESPONSE_CODE_FOUND = 'FOUND'.freeze,
  REDIRECT_RESPONSE_CODE_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):



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/oci/waas/models/access_rule.rb', line 162

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']

  self.bypass_challenges = attributes[:'bypassChallenges'] if attributes[:'bypassChallenges']

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

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

  self.redirect_url = attributes[:'redirectUrl'] if attributes[:'redirectUrl']

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

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

  self.redirect_response_code = attributes[:'redirectResponseCode'] if attributes[:'redirectResponseCode']
  self.redirect_response_code = "MOVED_PERMANENTLY" if redirect_response_code.nil? && !attributes.key?(:'redirectResponseCode') # rubocop:disable Style/StringLiterals

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

  self.redirect_response_code = attributes[:'redirect_response_code'] if attributes[:'redirect_response_code']
  self.redirect_response_code = "MOVED_PERMANENTLY" if redirect_response_code.nil? && !attributes.key?(:'redirectResponseCode') && !attributes.key?(:'redirect_response_code') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#actionString

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

  • ALLOW: Takes no action, just logs the request.

  • DETECT: Takes no action, but creates an alert for the request.

  • BLOCK: Blocks the request by returning specified response code or showing error page.

  • BYPASS: Bypasses some or all challenges.

  • REDIRECT: Redirects the request to the specified URL.

Regardless of action, no further rules are processed once a rule is matched.

Returns:

  • (String)


61
62
63
# File 'lib/oci/waas/models/access_rule.rb', line 61

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)


65
66
67
# File 'lib/oci/waas/models/access_rule.rb', line 65

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)


77
78
79
# File 'lib/oci/waas/models/access_rule.rb', line 77

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)


81
82
83
# File 'lib/oci/waas/models/access_rule.rb', line 81

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)


73
74
75
# File 'lib/oci/waas/models/access_rule.rb', line 73

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`. The list of available response codes: `200`, `201`, `202`, `204`, `206`, `300`, `301`, `302`, `303`, `304`, `307`, `400`, `401`, `403`, `404`, `405`, `408`, `409`, `411`, `412`, `413`, `414`, `415`, `416`, `422`, `444`, `499`, `500`, `501`, `502`, `503`, `504`, `507`.

Returns:

  • (Integer)


69
70
71
# File 'lib/oci/waas/models/access_rule.rb', line 69

def block_response_code
  @block_response_code
end

#bypass_challengesArray<String>

The list of challenges to bypass when ‘action` is set to `BYPASS`. If unspecified or empty, all challenges are bypassed.

  • JS_CHALLENGE: Bypasses JavaScript Challenge.

  • DEVICE_FINGERPRINT_CHALLENGE: Bypasses Device Fingerprint Challenge.

  • HUMAN_INTERACTION_CHALLENGE: Bypasses Human Interaction Challenge.

  • CAPTCHA: Bypasses CAPTCHA Challenge.

Returns:

  • (Array<String>)


93
94
95
# File 'lib/oci/waas/models/access_rule.rb', line 93

def bypass_challenges
  @bypass_challenges
end

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

[Required] The list of access rule criteria.



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

def criteria
  @criteria
end

#nameString

[Required] The unique name of the access rule.

Returns:

  • (String)


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

def name
  @name
end

#redirect_response_codeString

The response status code to return when ‘action` is set to `REDIRECT`.

  • MOVED_PERMANENTLY: Used for designating the permanent movement of a page (numerical code - 301).

  • FOUND: Used for designating the temporary movement of a page (numerical code - 302).

Returns:

  • (String)


105
106
107
# File 'lib/oci/waas/models/access_rule.rb', line 105

def redirect_response_code
  @redirect_response_code
end

#redirect_urlString

The target to which the request should be redirected, represented as a URI reference.

Returns:

  • (String)


97
98
99
# File 'lib/oci/waas/models/access_rule.rb', line 97

def redirect_url
  @redirect_url
end

Class Method Details

.attribute_mapObject

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



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/oci/waas/models/access_rule.rb', line 108

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',
    'bypass_challenges': :'bypassChallenges',
    'redirect_url': :'redirectUrl',
    'redirect_response_code': :'redirectResponseCode'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/oci/waas/models/access_rule.rb', line 127

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',
    'bypass_challenges': :'Array<String>',
    'redirect_url': :'String',
    'redirect_response_code': :'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



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/oci/waas/models/access_rule.rb', line 291

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 &&
    bypass_challenges == other.bypass_challenges &&
    redirect_url == other.redirect_url &&
    redirect_response_code == other.redirect_response_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



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/oci/waas/models/access_rule.rb', line 331

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


311
312
313
# File 'lib/oci/waas/models/access_rule.rb', line 311

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



320
321
322
# File 'lib/oci/waas/models/access_rule.rb', line 320

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

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



364
365
366
367
368
369
370
371
372
373
# File 'lib/oci/waas/models/access_rule.rb', line 364

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



358
359
360
# File 'lib/oci/waas/models/access_rule.rb', line 358

def to_s
  to_hash.to_s
end