Class: OCI::Waas::Models::CachingRule

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

Overview

CachingRule model.

Constant Summary collapse

ACTION_ENUM =
[
  ACTION_CACHE = 'CACHE'.freeze,
  ACTION_BYPASS_CACHE = 'BYPASS_CACHE'.freeze,
  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 = {}) ⇒ CachingRule

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/oci/waas/models/caching_rule.rb', line 95

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

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

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

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

  self.caching_duration = attributes[:'cachingDuration'] if attributes[:'cachingDuration']

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

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

  self.is_client_caching_enabled = attributes[:'isClientCachingEnabled'] unless attributes[:'isClientCachingEnabled'].nil?

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

  self.is_client_caching_enabled = attributes[:'is_client_caching_enabled'] unless attributes[:'is_client_caching_enabled'].nil?

  self.client_caching_duration = attributes[:'clientCachingDuration'] if attributes[:'clientCachingDuration']

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

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

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

Instance Attribute Details

#actionString

[Required] The action to take when the criteria of a caching rule are met. - CACHE: Caches requested content when the criteria of the rule are met.

  • BYPASS_CACHE: Allows requests to bypass the cache and be directed to the origin when the criteria of the rule is met.

Returns:

  • (String)


31
32
33
# File 'lib/oci/waas/models/caching_rule.rb', line 31

def action
  @action
end

#caching_durationString

The duration to cache content for the caching rule, specified in ISO 8601 extended format. Supported units: seconds, minutes, hours, days, weeks, months. The maximum value that can be set for any unit is 99. Mixing of multiple units is not supported. Only applies when the action is set to CACHE. Example: PT1H

Returns:

  • (String)


36
37
38
# File 'lib/oci/waas/models/caching_rule.rb', line 36

def caching_duration
  @caching_duration
end

#client_caching_durationString

The duration to cache content in the user's browser, specified in ISO 8601 extended format. Supported units: seconds, minutes, hours, days, weeks, months. The maximum value that can be set for any unit is 99. Mixing of multiple units is not supported. Only applies when the action is set to CACHE. Example: PT1H

Returns:

  • (String)


46
47
48
# File 'lib/oci/waas/models/caching_rule.rb', line 46

def client_caching_duration
  @client_caching_duration
end

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

[Required] The array of the rule criteria with condition and value. The caching rule would be applied for the requests that matched any of the listed conditions.



50
51
52
# File 'lib/oci/waas/models/caching_rule.rb', line 50

def criteria
  @criteria
end

#is_client_caching_enabledBOOLEAN

Enables or disables client caching. Browsers use the Cache-Control header value for caching content locally in the browser. This setting overrides the addition of a Cache-Control header in responses.

Returns:

  • (BOOLEAN)


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

def is_client_caching_enabled
  @is_client_caching_enabled
end

#keyString

The unique key for the caching rule.

Returns:

  • (String)


20
21
22
# File 'lib/oci/waas/models/caching_rule.rb', line 20

def key
  @key
end

#nameString

[Required] The name of the caching rule.

Returns:

  • (String)


24
25
26
# File 'lib/oci/waas/models/caching_rule.rb', line 24

def name
  @name
end

Class Method Details

.attribute_mapObject

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



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/oci/waas/models/caching_rule.rb', line 53

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'key': :'key',
    'name': :'name',
    'action': :'action',
    'caching_duration': :'cachingDuration',
    'is_client_caching_enabled': :'isClientCachingEnabled',
    'client_caching_duration': :'clientCachingDuration',
    'criteria': :'criteria'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/oci/waas/models/caching_rule.rb', line 68

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'key': :'String',
    'name': :'String',
    'action': :'String',
    'caching_duration': :'String',
    'is_client_caching_enabled': :'BOOLEAN',
    'client_caching_duration': :'String',
    'criteria': :'Array<OCI::Waas::Models::CachingRuleCriteria>'
    # 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



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/oci/waas/models/caching_rule.rb', line 145

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

  self.class == other.class &&
    key == other.key &&
    name == other.name &&
    action == other.action &&
    caching_duration == other.caching_duration &&
    is_client_caching_enabled == other.is_client_caching_enabled &&
    client_caching_duration == other.client_caching_duration &&
    criteria == other.criteria
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



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/oci/waas/models/caching_rule.rb', line 181

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


161
162
163
# File 'lib/oci/waas/models/caching_rule.rb', line 161

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



170
171
172
# File 'lib/oci/waas/models/caching_rule.rb', line 170

def hash
  [key, name, action, caching_duration, is_client_caching_enabled, client_caching_duration, criteria].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



214
215
216
217
218
219
220
221
222
223
# File 'lib/oci/waas/models/caching_rule.rb', line 214

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



208
209
210
# File 'lib/oci/waas/models/caching_rule.rb', line 208

def to_s
  to_hash.to_s
end