Class: OCI::NetworkFirewall::Models::SimpleUrlPattern

Inherits:
UrlPattern
  • Object
show all
Defined in:
lib/oci/network_firewall/models/simple_url_pattern.rb

Overview

Pattern describing an http/https URL or set thereof as a concatenation of optional host component and optional path component.

Key points:

  1. Use the specific URLs or construct the URL patterns you want to match using wildcard `*` and token characters `./`.

  2. In the host component and path component don't enter consecutive wildcard `*` for example: `example...com`.

  3. To match the exact domain and its subdirectories add a trailing slash `/` to your entry.

  4. The firewall interprets entries that do not end in a `/` or `*` with an implicit asterisk `*` to their end, which further increases the potential matches.

  5. The Use of multiple wildcards in a single pattern can impact the performance of the firewall.

Domain/subdomains match examples:

  1. `.example.com.` will match `sub1.sub2.example.com.info.us` and `sub1.example.com.us` and `sub1.example.com/subdirectory` but not match `sub1.example.com`.

  2. `*.example.com` will match `sub1.example.com` and `sub1.sub2.example.com` and `sub1.example.com.au` but not match `example.com`.

  3. `*.example.com/` will match `sub1.sub2.example.com` and `sub1.example.com` but not match `sub1.example.com.au`.

  4. `example.com` will match `example.com` and `example.com.au` and `example.com.info.us` and `example.com/subdirectory`.

  5. `example.com/` will match `example.com` and `example.com/foo` but not `example.com.info.us`.

  6. `example.*.com` will match `example.sub1.com` and `example.sub1.sub2.com` and `example.sub1.com.au` and `example.sub1.com/subdirecroty`.

  7. `example.*.com/` will match `example.sub1.com` and `example.sub1.sub2.com` and `example.sub1.com/subdirecroty` but not match `example.sub1.com.au`.

  8. `example.com.*` will match `example.com.us` and `example.com.info.us` and `example.com.us/subdirectory` but not match `sub1.example.com`.

Subdirectory or path match examples:

  1. `example.com/*` will match `example.com/foo` and `example.com/bar` and any `example.com/subdirectory`.

  2. `example.com/foo` will match `example.com/foo`.

  3. `www.example.com/foo/*` will match `www.exampe.com/foo/subdiectory`, but not match `www.example.com/FOO` or `www.example.com/bar/subdirectory`.

  4. `.example.com/foo/` will match `sub2.sub.example.com/foo/subdirectory` but not match `sub1.example.com/FOO` or `sub1.example.com/bar/subdirectory`.

Other examples containing IP addresses in urls:

  1. 103.12.14.122/ will match 103.12.14.122 and 103.12.14.122/subdirectory.

  2. 103.12.14.122:8081/ will match 103.12.14.122:8081 and 103.12.14.122:8081/subdirectory.

  3. 2607:9d80:4680:3f01:0000:0000:00d0:00c0/ will match 2607:9d80:4680:3f01:0000:0000:00d0:00c0 and 2607:9d80:4680:3f01:0000:0000:00d0:00c0/subdirecroty.

  4. [2607:9d80:4680:3f01:0000:0000:00d0:00c0]:8081/ will match [2607:9d80:4680:3f01:0000:0000:00d0:00c0]:8081 and [2607:9d80:4680:3f01:0000:0000:00d0:00c0]:8081/subdirecroty.

Constant Summary

Constants inherited from UrlPattern

UrlPattern::TYPE_ENUM

Instance Attribute Summary collapse

Attributes inherited from UrlPattern

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UrlPattern

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ SimpleUrlPattern

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :pattern (String)

    The value to assign to the #pattern property



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 78

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

  attributes['type'] = 'SIMPLE'

  super(attributes)

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

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

Instance Attribute Details

#patternString

**[Required]** A string consisting of a concatenation of optional host component and optional path component. The host component may start with `*.` to match the case-insensitive domain and all its subdomains. The path component must start with a `/`, and may end with `*` to match all paths of which it is a case-sensitive prefix. A missing host component matches all request domains, and a missing path component matches all request paths. An empty value matches all requests.

Returns:

  • (String)


49
50
51
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 49

def pattern
  @pattern
end

Class Method Details

.attribute_mapObject

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



52
53
54
55
56
57
58
59
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 52

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'type': :'type',
    'pattern': :'pattern'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



62
63
64
65
66
67
68
69
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 62

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'type': :'String',
    'pattern': :'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



98
99
100
101
102
103
104
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 98

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

  self.class == other.class &&
    type == other.type &&
    pattern == other.pattern
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



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 129

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


109
110
111
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 109

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



118
119
120
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 118

def hash
  [type, pattern].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



162
163
164
165
166
167
168
169
170
171
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 162

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



156
157
158
# File 'lib/oci/network_firewall/models/simple_url_pattern.rb', line 156

def to_s
  to_hash.to_s
end