Class: OCI::ApmTraces::Models::CustomMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/apm_traces/models/custom_metric.rb

Overview

Definition of the Custom Metric.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CustomMetric

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :namespace (String)

    The value to assign to the #namespace property

  • :name (String)

    The value to assign to the #name property

  • :description (String)

    The value to assign to the #description property

  • :resource_group (String)

    The value to assign to the #resource_group property

  • :is_anomaly_detection_enabled (BOOLEAN)

    The value to assign to the #is_anomaly_detection_enabled property

  • :compartment (String)

    The value to assign to the #compartment property

  • :unit (String)

    The value to assign to the #unit property

  • :is_metric_published (BOOLEAN)

    The value to assign to the #is_metric_published property



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 102

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.namespace = attributes[:'namespace'] if attributes[:'namespace']
  self.namespace = "oracle_apm_custom" if namespace.nil? && !attributes.key?(:'namespace') # rubocop:disable Style/StringLiterals

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

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

  self.resource_group = attributes[:'resourceGroup'] if attributes[:'resourceGroup']

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

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

  self.is_anomaly_detection_enabled = attributes[:'isAnomalyDetectionEnabled'] unless attributes[:'isAnomalyDetectionEnabled'].nil?

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

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

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

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

  self.is_metric_published = attributes[:'isMetricPublished'] unless attributes[:'isMetricPublished'].nil?

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

  self.is_metric_published = attributes[:'is_metric_published'] unless attributes[:'is_metric_published'].nil?
end

Instance Attribute Details

#compartmentString

Compartment of the Monitoring Service. It defaults to the APM domain's compartment if not specified. If specified, the necessary OCI policies should be set to allow APM to write to that compartment.

Returns:

  • (String)


42
43
44
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 42

def compartment
  @compartment
end

#descriptionString

Description of the Custom Metric.

Returns:

  • (String)


26
27
28
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 26

def description
  @description
end

#is_anomaly_detection_enabledBOOLEAN

Indicates whether anomaly Detection should be performed on the generated metric.

Returns:

  • (BOOLEAN)


36
37
38
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 36

def is_anomaly_detection_enabled
  @is_anomaly_detection_enabled
end

#is_metric_publishedBOOLEAN

Used in conjunction with the dry run header. When the dry run header is set and the isPublishMetric flag is set to true, the scheduled query is not created, but validations happen to check if the right OCI policies have been set to write to the specified namespace/compartment.

Returns:

  • (BOOLEAN)


54
55
56
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 54

def is_metric_published
  @is_metric_published
end

#nameString

[Required] Name of the Custom Metric.

Returns:

  • (String)


21
22
23
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 21

def name
  @name
end

#namespaceString

Namespace in the Custom Metric. It defaults to oracle_apm_custom if not specified. If specified, the necessary OCI policies should be set to allow APM to write to that namespace.

Returns:

  • (String)


16
17
18
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 16

def namespace
  @namespace
end

#resource_groupString

Resource Group of the Custom Metric.

Returns:

  • (String)


31
32
33
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 31

def resource_group
  @resource_group
end

#unitString

Unit in which the metric value is reported. For example 'ms'.

Returns:

  • (String)


47
48
49
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 47

def unit
  @unit
end

Class Method Details

.attribute_mapObject

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



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 57

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'namespace': :'namespace',
    'name': :'name',
    'description': :'description',
    'resource_group': :'resourceGroup',
    'is_anomaly_detection_enabled': :'isAnomalyDetectionEnabled',
    'compartment': :'compartment',
    'unit': :'unit',
    'is_metric_published': :'isMetricPublished'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 73

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'namespace': :'String',
    'name': :'String',
    'description': :'String',
    'resource_group': :'String',
    'is_anomaly_detection_enabled': :'BOOLEAN',
    'compartment': :'String',
    'unit': :'String',
    'is_metric_published': :'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



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

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

  self.class == other.class &&
    namespace == other.namespace &&
    name == other.name &&
    description == other.description &&
    resource_group == other.resource_group &&
    is_anomaly_detection_enabled == other.is_anomaly_detection_enabled &&
    compartment == other.compartment &&
    unit == other.unit &&
    is_metric_published == other.is_metric_published
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



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

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


162
163
164
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 162

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



171
172
173
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 171

def hash
  [namespace, name, description, resource_group, is_anomaly_detection_enabled, compartment, unit, is_metric_published].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



215
216
217
218
219
220
221
222
223
224
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 215

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



209
210
211
# File 'lib/oci/apm_traces/models/custom_metric.rb', line 209

def to_s
  to_hash.to_s
end