Class: OCI::Autoscaling::Models::MetricBase
- Inherits:
-
Object
- Object
- OCI::Autoscaling::Models::MetricBase
- Defined in:
- lib/oci/autoscaling/models/metric_base.rb
Overview
MetricBase model. This class has direct subclasses. If you are using this class as input to a service operations then you should favor using a subclass over the base class
Direct Known Subclasses
Constant Summary collapse
- METRIC_SOURCE_ENUM =
[ METRIC_SOURCE_COMPUTE_AGENT = 'COMPUTE_AGENT'.freeze, METRIC_SOURCE_CUSTOM_QUERY = 'CUSTOM_QUERY'.freeze, METRIC_SOURCE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze ].freeze
Instance Attribute Summary collapse
-
#metric_source ⇒ String
Source of the metric data for creating the alarm used to trigger autoscaling actions.
-
#pending_duration ⇒ String
The period of time that the condition defined in the alarm must persist before the alarm state changes from "OK" to "FIRING" or vice versa.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.get_subtype(object_hash) ⇒ Object
Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks equality by comparing each attribute.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ MetricBase
constructor
Initializes the object.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(attributes = {}) ⇒ MetricBase
Initializes the object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 86 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.pending_duration = attributes[:'pendingDuration'] if attributes[:'pendingDuration'] self.pending_duration = "PT3M" if pending_duration.nil? && !attributes.key?(:'pendingDuration') # rubocop:disable Style/StringLiterals raise 'You cannot provide both :pendingDuration and :pending_duration' if attributes.key?(:'pendingDuration') && attributes.key?(:'pending_duration') self.pending_duration = attributes[:'pending_duration'] if attributes[:'pending_duration'] self.pending_duration = "PT3M" if pending_duration.nil? && !attributes.key?(:'pendingDuration') && !attributes.key?(:'pending_duration') # rubocop:disable Style/StringLiterals self.metric_source = attributes[:'metricSource'] if attributes[:'metricSource'] self.metric_source = "COMPUTE_AGENT" if metric_source.nil? && !attributes.key?(:'metricSource') # rubocop:disable Style/StringLiterals raise 'You cannot provide both :metricSource and :metric_source' if attributes.key?(:'metricSource') && attributes.key?(:'metric_source') self.metric_source = attributes[:'metric_source'] if attributes[:'metric_source'] self.metric_source = "COMPUTE_AGENT" if metric_source.nil? && !attributes.key?(:'metricSource') && !attributes.key?(:'metric_source') # rubocop:disable Style/StringLiterals end |
Instance Attribute Details
#metric_source ⇒ String
Source of the metric data for creating the alarm used to trigger autoscaling actions.
The following values are supported:
-
COMPUTE_AGENT: CPU or memory metrics emitted by the Compute Instance Monitoring plugin. -
CUSTOM_QUERY: A custom Monitoring Query Language (MQL) expression.
40 41 42 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 40 def metric_source @metric_source end |
#pending_duration ⇒ String
The period of time that the condition defined in the alarm must persist before the alarm state changes from "OK" to "FIRING" or vice versa. For example, a value of 5 minutes means that the alarm must persist in breaching the condition for five minutes before the alarm updates its state to "FIRING"; likewise, the alarm must persist in not breaching the condition for five minutes before the alarm updates its state to "OK."
The duration is specified as a string in ISO 8601 format (PT10M for ten minutes or PT1H for one hour). Minimum: PT3M. Maximum: PT1H. Default: PT3M.
29 30 31 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 29 def pending_duration @pending_duration end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
43 44 45 46 47 48 49 50 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 43 def self.attribute_map { # rubocop:disable Style/SymbolLiteral 'pending_duration': :'pendingDuration', 'metric_source': :'metricSource' # rubocop:enable Style/SymbolLiteral } end |
.get_subtype(object_hash) ⇒ Object
Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.
67 68 69 70 71 72 73 74 75 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 67 def self.get_subtype(object_hash) type = object_hash[:'metricSource'] # rubocop:disable Style/SymbolLiteral return 'OCI::Autoscaling::Models::CustomMetric' if type == 'CUSTOM_QUERY' return 'OCI::Autoscaling::Models::Metric' if type == 'COMPUTE_AGENT' # TODO: Log a warning when the subtype is not found. 'OCI::Autoscaling::Models::MetricBase' end |
.swagger_types ⇒ Object
Attribute type mapping.
53 54 55 56 57 58 59 60 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 53 def self.swagger_types { # rubocop:disable Style/SymbolLiteral 'pending_duration': :'String', 'metric_source': :'String' # rubocop:enable Style/SymbolLiteral } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
129 130 131 132 133 134 135 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 129 def ==(other) return true if equal?(other) self.class == other.class && pending_duration == other.pending_duration && metric_source == other.metric_source end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 160 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
140 141 142 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 140 def eql?(other) self == other end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
149 150 151 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 149 def hash [pending_duration, metric_source].hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 193 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_s ⇒ String
Returns the string representation of the object
187 188 189 |
# File 'lib/oci/autoscaling/models/metric_base.rb', line 187 def to_s to_hash.to_s end |