class OCI::Waas::Models::CachingRule
CachingRule
model.
Constants
- ACTION_ENUM
Attributes
[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.
@return [String]
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` @return [String]
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` @return [String]
[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. @return [Array<OCI::Waas::Models::CachingRuleCriteria>]
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. @return [BOOLEAN]
The unique key for the caching rule. @return [String]
[Required] The name of the caching rule. @return [String]
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/oci/waas/models/caching_rule.rb, line 52 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
Initializes the object @param [Hash] attributes Model attributes in the form of hash @option attributes [String] :key The value to assign to the {#key} property @option attributes [String] :name The value to assign to the {#name} property @option attributes [String] :action The value to assign to the {#action} property @option attributes [String] :caching_duration The value to assign to the {#caching_duration} property @option attributes [BOOLEAN] :is_client_caching_enabled The value to assign to the {#is_client_caching_enabled} property @option attributes [String] :client_caching_duration The value to assign to the {#client_caching_duration} property @option attributes [Array<OCI::Waas::Models::CachingRuleCriteria>] :criteria The value to assign to the {#criteria} property
# File lib/oci/waas/models/caching_rule.rb, line 94 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
Attribute type mapping.
# File lib/oci/waas/models/caching_rule.rb, line 67 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
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] other the other object to be compared
# File lib/oci/waas/models/caching_rule.rb, line 144 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
Custom attribute writer method checking allowed values (enum). @param [Object] action Object
to be assigned
# File lib/oci/waas/models/caching_rule.rb, line 128 def action=(action) # rubocop:disable Style/ConditionalAssignment if action && !ACTION_ENUM.include?(action) OCI.logger.debug("Unknown value for 'action' [" + action + "]. Mapping to 'ACTION_UNKNOWN_ENUM_VALUE'") if OCI.logger @action = ACTION_UNKNOWN_ENUM_VALUE else @action = action end # rubocop:enable Style/ConditionalAssignment end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/oci/waas/models/caching_rule.rb, line 180 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
@see the `==` method @param [Object] other the other object to be compared
# File lib/oci/waas/models/caching_rule.rb, line 160 def eql?(other) self == other end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/oci/waas/models/caching_rule.rb, line 169 def hash [key, name, action, caching_duration, is_client_caching_enabled, client_caching_duration, criteria].hash end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/oci/waas/models/caching_rule.rb, line 213 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
Returns the string representation of the object @return [String] String presentation of the object
# File lib/oci/waas/models/caching_rule.rb, line 207 def to_s to_hash.to_s end
Private Instance Methods
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/oci/waas/models/caching_rule.rb, line 230 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end