Class: Abliteration::DownloadAnomaly

Inherits:
ApiModelBase show all
Defined in:
lib/abliteration/models/download_anomaly.rb

Overview

One model whose downloads-per-window crossed a threshold.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ DownloadAnomaly

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/abliteration/models/download_anomaly.rb', line 108

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Abliteration::DownloadAnomaly` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Abliteration::DownloadAnomaly`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'model_id')
    self.model_id = attributes[:'model_id']
  end

  if attributes.key?(:'current_at')
    self.current_at = attributes[:'current_at']
  end

  if attributes.key?(:'current_downloads')
    self.current_downloads = attributes[:'current_downloads']
  end

  if attributes.key?(:'baseline_at')
    self.baseline_at = attributes[:'baseline_at']
  end

  if attributes.key?(:'baseline_downloads')
    self.baseline_downloads = attributes[:'baseline_downloads']
  end

  if attributes.key?(:'ratio')
    self.ratio = attributes[:'ratio']
  end

  if attributes.key?(:'delta')
    self.delta = attributes[:'delta']
  end

  if attributes.key?(:'kind')
    self.kind = attributes[:'kind']
  end
end

Instance Attribute Details

#baseline_at ⇒ Object

ISO-8601 timestamp of the baseline snapshot the delta is computed against.



27
28
29
# File 'lib/abliteration/models/download_anomaly.rb', line 27

def baseline_at
  @baseline_at
end

#baseline_downloads ⇒ Object

Returns the value of attribute baseline_downloads.



29
30
31
# File 'lib/abliteration/models/download_anomaly.rb', line 29

def baseline_downloads
  @baseline_downloads
end

#current_at ⇒ Object

ISO-8601 timestamp of the current snapshot.



22
23
24
# File 'lib/abliteration/models/download_anomaly.rb', line 22

def current_at
  @current_at
end

#current_downloads ⇒ Object

Returns the value of attribute current_downloads.



24
25
26
# File 'lib/abliteration/models/download_anomaly.rb', line 24

def current_downloads
  @current_downloads
end

#delta ⇒ Object

current_downloads - baseline_downloads (signed).



35
36
37
# File 'lib/abliteration/models/download_anomaly.rb', line 35

def delta
  @delta
end

#kind ⇒ Object

spike when ratio >= 2, drop when ratio <= 0.5.



38
39
40
# File 'lib/abliteration/models/download_anomaly.rb', line 38

def kind
  @kind
end

#model_id ⇒ Object

Returns the value of attribute model_id.



19
20
21
# File 'lib/abliteration/models/download_anomaly.rb', line 19

def model_id
  @model_id
end

#ratio ⇒ Object

current_downloads / baseline_downloads.



32
33
34
# File 'lib/abliteration/models/download_anomaly.rb', line 32

def ratio
  @ratio
end

Class Method Details

.acceptable_attribute_map ⇒ Object

Returns attribute mapping this model knows about



77
78
79
# File 'lib/abliteration/models/download_anomaly.rb', line 77

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



82
83
84
# File 'lib/abliteration/models/download_anomaly.rb', line 82

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_map ⇒ Object

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



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/abliteration/models/download_anomaly.rb', line 63

def self.attribute_map
  {
    :'model_id' => :'model_id',
    :'current_at' => :'current_at',
    :'current_downloads' => :'current_downloads',
    :'baseline_at' => :'baseline_at',
    :'baseline_downloads' => :'baseline_downloads',
    :'ratio' => :'ratio',
    :'delta' => :'delta',
    :'kind' => :'kind'
  }
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



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/abliteration/models/download_anomaly.rb', line 212

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullable ⇒ Object

List of attributes with nullable: true



101
102
103
104
# File 'lib/abliteration/models/download_anomaly.rb', line 101

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_types ⇒ Object

Attribute type mapping.



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/abliteration/models/download_anomaly.rb', line 87

def self.openapi_types
  {
    :'model_id' => :'String',
    :'current_at' => :'String',
    :'current_downloads' => :'Integer',
    :'baseline_at' => :'String',
    :'baseline_downloads' => :'Integer',
    :'ratio' => :'Float',
    :'delta' => :'Integer',
    :'kind' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object) —

    to be compared



184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/abliteration/models/download_anomaly.rb', line 184

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      model_id == o.model_id &&
      current_at == o.current_at &&
      current_downloads == o.current_downloads &&
      baseline_at == o.baseline_at &&
      baseline_downloads == o.baseline_downloads &&
      ratio == o.ratio &&
      delta == o.delta &&
      kind == o.kind
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object) —

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


199
200
201
# File 'lib/abliteration/models/download_anomaly.rb', line 199

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



205
206
207
# File 'lib/abliteration/models/download_anomaly.rb', line 205

def hash
  [model_id, current_at, current_downloads, baseline_at, baseline_downloads, ratio, delta, kind].hash
end

#list_invalid_properties ⇒ Object

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



157
158
159
160
161
# File 'lib/abliteration/models/download_anomaly.rb', line 157

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/abliteration/models/download_anomaly.rb', line 234

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid? ⇒ Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean) —

    true if the model is valid



165
166
167
168
169
170
# File 'lib/abliteration/models/download_anomaly.rb', line 165

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  kind_validator = EnumAttributeValidator.new('String', ["spike", "drop"])
  return false unless kind_validator.valid?(@kind)
  true
end