Class: MistApi::InsightMetrics

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/insight_metrics.rb

Overview

InsightMetrics Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(mend = nil, interval = nil, start = nil, limit = SKIP, results = SKIP) ⇒ InsightMetrics

Returns a new instance of InsightMetrics.



58
59
60
61
62
63
64
65
# File 'lib/mist_api/models/insight_metrics.rb', line 58

def initialize(mend = nil, interval = nil, start = nil, limit = SKIP,
               results = SKIP)
  @mend = mend
  @interval = interval
  @limit = limit unless limit == SKIP
  @results = results unless results == SKIP
  @start = start
end

Instance Attribute Details

#intervalInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/mist_api/models/insight_metrics.rb', line 18

def interval
  @interval
end

#limitInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/mist_api/models/insight_metrics.rb', line 22

def limit
  @limit
end

#mendInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/mist_api/models/insight_metrics.rb', line 14

def mend
  @mend
end

#resultsArray[Object]

Results depends on the ‘metric` - some return numbers (e.g. bytes, ap-count), others return objects

Returns:

  • (Array[Object])


27
28
29
# File 'lib/mist_api/models/insight_metrics.rb', line 27

def results
  @results
end

#startInteger

Results depends on the ‘metric` - some return numbers (e.g. bytes, ap-count), others return objects

Returns:

  • (Integer)


32
33
34
# File 'lib/mist_api/models/insight_metrics.rb', line 32

def start
  @start
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/mist_api/models/insight_metrics.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mend = hash.key?('end') ? hash['end'] : nil
  interval = hash.key?('interval') ? hash['interval'] : nil
  start = hash.key?('start') ? hash['start'] : nil
  limit = hash.key?('limit') ? hash['limit'] : SKIP
  results = hash.key?('results') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:InsightMetricsResultsItem), hash['results']
  ) : SKIP

  # Create object from extracted values.
  InsightMetrics.new(mend,
                     interval,
                     start,
                     limit,
                     results)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/mist_api/models/insight_metrics.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mend'] = 'end'
  @_hash['interval'] = 'interval'
  @_hash['limit'] = 'limit'
  @_hash['results'] = 'results'
  @_hash['start'] = 'start'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/mist_api/models/insight_metrics.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
# File 'lib/mist_api/models/insight_metrics.rb', line 46

def self.optionals
  %w[
    limit
    results
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InsightMetrics | Hash)

    value against the validation is performed.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/mist_api/models/insight_metrics.rb', line 90

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.mend,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.interval,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.start,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['end'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['interval'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['start'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



122
123
124
125
126
# File 'lib/mist_api/models/insight_metrics.rb', line 122

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} mend: #{@mend.inspect}, interval: #{@interval.inspect}, limit:"\
  " #{@limit.inspect}, results: #{@results.inspect}, start: #{@start.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



115
116
117
118
119
# File 'lib/mist_api/models/insight_metrics.rb', line 115

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} mend: #{@mend}, interval: #{@interval}, limit: #{@limit}, results:"\
  " #{@results}, start: #{@start}>"
end