Class: OCI::Waas::Models::AccessRuleCriteria

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

Overview

When defined, the parent challenge would be applied only for the requests that matched all the listed conditions.

Constant Summary collapse

CONDITION_ENUM =
[
  CONDITION_URL_IS = 'URL_IS'.freeze,
  CONDITION_URL_IS_NOT = 'URL_IS_NOT'.freeze,
  CONDITION_URL_STARTS_WITH = 'URL_STARTS_WITH'.freeze,
  CONDITION_URL_PART_ENDS_WITH = 'URL_PART_ENDS_WITH'.freeze,
  CONDITION_URL_PART_CONTAINS = 'URL_PART_CONTAINS'.freeze,
  CONDITION_URL_REGEX = 'URL_REGEX'.freeze,
  CONDITION_URL_DOES_NOT_MATCH_REGEX = 'URL_DOES_NOT_MATCH_REGEX'.freeze,
  CONDITION_URL_DOES_NOT_START_WITH = 'URL_DOES_NOT_START_WITH'.freeze,
  CONDITION_URL_PART_DOES_NOT_CONTAIN = 'URL_PART_DOES_NOT_CONTAIN'.freeze,
  CONDITION_URL_PART_DOES_NOT_END_WITH = 'URL_PART_DOES_NOT_END_WITH'.freeze,
  CONDITION_IP_IS = 'IP_IS'.freeze,
  CONDITION_IP_IS_NOT = 'IP_IS_NOT'.freeze,
  CONDITION_IP_IN_LIST = 'IP_IN_LIST'.freeze,
  CONDITION_IP_NOT_IN_LIST = 'IP_NOT_IN_LIST'.freeze,
  CONDITION_HTTP_HEADER_CONTAINS = 'HTTP_HEADER_CONTAINS'.freeze,
  CONDITION_HTTP_METHOD_IS = 'HTTP_METHOD_IS'.freeze,
  CONDITION_HTTP_METHOD_IS_NOT = 'HTTP_METHOD_IS_NOT'.freeze,
  CONDITION_COUNTRY_IS = 'COUNTRY_IS'.freeze,
  CONDITION_COUNTRY_IS_NOT = 'COUNTRY_IS_NOT'.freeze,
  CONDITION_USER_AGENT_IS = 'USER_AGENT_IS'.freeze,
  CONDITION_USER_AGENT_IS_NOT = 'USER_AGENT_IS_NOT'.freeze,
  CONDITION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AccessRuleCriteria

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :condition (String)

    The value to assign to the #condition property

  • :value (String)

    The value to assign to the #value property

  • :is_case_sensitive (BOOLEAN)

    The value to assign to the #is_case_sensitive property



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 130

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

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

  self.is_case_sensitive = attributes[:'isCaseSensitive'] unless attributes[:'isCaseSensitive'].nil?
  self.is_case_sensitive = false if is_case_sensitive.nil? && !attributes.key?(:'isCaseSensitive') # rubocop:disable Style/StringLiterals

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

  self.is_case_sensitive = attributes[:'is_case_sensitive'] unless attributes[:'is_case_sensitive'].nil?
  self.is_case_sensitive = false if is_case_sensitive.nil? && !attributes.key?(:'isCaseSensitive') && !attributes.key?(:'is_case_sensitive') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#conditionString

[Required] The criteria the access rule and JavaScript Challenge uses to determine if action should be taken on a request. - URL_IS: Matches if the concatenation of request URL path and query is identical to the contents of the value field. URL must start with a /. - URL_IS_NOT: Matches if the concatenation of request URL path and query is not identical to the contents of the value field. URL must start with a /. - URL_STARTS_WITH: Matches if the concatenation of request URL path and query starts with the contents of the value field. URL must start with a /. - URL_PART_ENDS_WITH: Matches if the concatenation of request URL path and query ends with the contents of the value field. - URL_PART_CONTAINS: Matches if the concatenation of request URL path and query contains the contents of the value field. - URL_REGEX: Matches if the concatenation of request URL path and query is described by the regular expression in the value field. The value must be a valid regular expression recognized by the PCRE library in Nginx (www.pcre.org). - URL_DOES_NOT_MATCH_REGEX: Matches if the concatenation of request URL path and query is not described by the regular expression in the value field. The value must be a valid regular expression recognized by the PCRE library in Nginx (www.pcre.org). - URL_DOES_NOT_START_WITH: Matches if the concatenation of request URL path and query does not start with the contents of the value field. - URL_PART_DOES_NOT_CONTAIN: Matches if the concatenation of request URL path and query does not contain the contents of the value field. - URL_PART_DOES_NOT_END_WITH: Matches if the concatenation of request URL path and query does not end with the contents of the value field. - IP_IS: Matches if the request originates from one of the IP addresses contained in the defined address list. The value in this case is string with one or multiple IPs or CIDR notations separated by new line symbol \

Example: "1.1.1.1\ 1.1.1.2\ 1.2.2.1/30" - IP_IS_NOT: Matches if the request does not originate from any of the IP addresses contained in the defined address list. The value in this case is string with one or multiple IPs or CIDR notations separated by new line symbol \

Example: "1.1.1.1\ 1.1.1.2\ 1.2.2.1/30" - IP_IN_LIST: Matches if the request originates from one of the IP addresses contained in the referenced address list. The value in this case is OCID of the address list. - IP_NOT_IN_LIST: Matches if the request does not originate from any IP address contained in the referenced address list. The value field in this case is OCID of the address list. - HTTP_HEADER_CONTAINS: The HTTP_HEADER_CONTAINS criteria is defined using a compound value separated by a colon: a header field name and a header field value. host:test.example.com is an example of a criteria value where host is the header field name and test.example.com is the header field value. A request matches when the header field name is a case insensitive match and the header field value is a case insensitive, substring match. Example: With a criteria value of host:test.example.com, where host is the name of the field and test.example.com is the value of the host field, a request with the header values, Host: www.test.example.com will match, where as a request with header values of host: www.example.com or host: test.sub.example.com will not match. - HTTP_METHOD_IS: Matches if the request method is identical to one of the values listed in field. The value in this case is string with one or multiple HTTP methods separated by new line symbol \ The list of available methods: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH

Example: "GET\ POST"

  • HTTP_METHOD_IS_NOT: Matches if the request is not identical to any of the contents of the value field. The value in this case is string with one or multiple HTTP methods separated by new line symbol \ The list of available methods: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH

Example: "GET\ POST"

  • COUNTRY_IS: Matches if the request originates from one of countries in the value field. The value in this case is string with one or multiple countries separated by new line symbol \ Country codes are in ISO 3166-1 alpha-2 format. For a list of codes, see ISO’s website. Example: "AL\ DZ\ AM"

  • COUNTRY_IS_NOT: Matches if the request does not originate from any of countries in the value field. The value in this case is string with one or multiple countries separated by new line symbol \ Country codes are in ISO 3166-1 alpha-2 format. For a list of codes, see ISO’s website. Example: "AL\ DZ\ AM"

  • USER_AGENT_IS: Matches if the requesting user agent is identical to the contents of the value field. Example: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0

  • USER_AGENT_IS_NOT: Matches if the requesting user agent is not identical to the contents of the value field. Example: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0

Returns:

  • (String)


89
90
91
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 89

def condition
  @condition
end

#is_case_sensitiveBOOLEAN

When enabled, the condition will be matched with case-sensitive rules.

Returns:

  • (BOOLEAN)


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

def is_case_sensitive
  @is_case_sensitive
end

#valueString

[Required] The criteria value.

Returns:

  • (String)


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

def value
  @value
end

Class Method Details

.attribute_mapObject

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



100
101
102
103
104
105
106
107
108
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 100

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'condition': :'condition',
    'value': :'value',
    'is_case_sensitive': :'isCaseSensitive'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



111
112
113
114
115
116
117
118
119
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 111

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'condition': :'String',
    'value': :'String',
    'is_case_sensitive': :'BOOLEAN'
    # 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



169
170
171
172
173
174
175
176
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 169

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

  self.class == other.class &&
    condition == other.condition &&
    value == other.value &&
    is_case_sensitive == other.is_case_sensitive
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



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_criteria.rb', line 201

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


181
182
183
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 181

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



190
191
192
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 190

def hash
  [condition, value, is_case_sensitive].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



234
235
236
237
238
239
240
241
242
243
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 234

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



228
229
230
# File 'lib/oci/waas/models/access_rule_criteria.rb', line 228

def to_s
  to_hash.to_s
end