abliteration 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/docs/DownloadAnomaly.md +32 -0
  4. data/docs/DownloadPoint.md +20 -0
  5. data/docs/GetModelDownloadHistory200Response.md +32 -0
  6. data/docs/GetModelReadmeAt200Response.md +32 -0
  7. data/docs/ListAnomalies200Response.md +32 -0
  8. data/docs/ListModelReadmeDrifts200Response.md +32 -0
  9. data/docs/ModelsApi.md +304 -0
  10. data/docs/ReadmeAt.md +22 -0
  11. data/docs/ReadmeDrift.md +26 -0
  12. data/lib/abliteration/api/models_api.rb +327 -0
  13. data/lib/abliteration/models/download_anomaly.rb +250 -0
  14. data/lib/abliteration/models/download_point.rb +158 -0
  15. data/lib/abliteration/models/get_model_download_history200_response.rb +386 -0
  16. data/lib/abliteration/models/get_model_readme_at200_response.rb +384 -0
  17. data/lib/abliteration/models/list_anomalies200_response.rb +386 -0
  18. data/lib/abliteration/models/list_model_readme_drifts200_response.rb +386 -0
  19. data/lib/abliteration/models/readme_at.rb +169 -0
  20. data/lib/abliteration/models/readme_drift.rb +188 -0
  21. data/lib/abliteration/version.rb +1 -1
  22. data/lib/abliteration.rb +8 -0
  23. data/spec/models/download_anomaly_spec.rb +82 -0
  24. data/spec/models/download_point_spec.rb +42 -0
  25. data/spec/models/get_model_download_history200_response_spec.rb +82 -0
  26. data/spec/models/get_model_readme_at200_response_spec.rb +82 -0
  27. data/spec/models/list_anomalies200_response_spec.rb +82 -0
  28. data/spec/models/list_model_readme_drifts200_response_spec.rb +82 -0
  29. data/spec/models/readme_at_spec.rb +48 -0
  30. data/spec/models/readme_drift_spec.rb +60 -0
  31. metadata +33 -1
@@ -139,6 +139,249 @@ module Abliteration
139
139
  return data, status_code, headers
140
140
  end
141
141
 
142
+ # Per-model download timeline
143
+ # Cost: 5 credits, flat. Raw signal that /market/anomalies scans over. Callers with a chart or their own anomaly detector pull it once per model.
144
+ # @param id [String]
145
+ # @param [Hash] opts the optional parameters
146
+ # @option opts [Integer] :days Window in days (max 365). Pass 0 for full history. (default to 90)
147
+ # @return [GetModelDownloadHistory200Response]
148
+ def get_model_download_history(id, opts = {})
149
+ data, _status_code, _headers = get_model_download_history_with_http_info(id, opts)
150
+ data
151
+ end
152
+
153
+ # Per-model download timeline
154
+ # Cost: 5 credits, flat. Raw signal that /market/anomalies scans over. Callers with a chart or their own anomaly detector pull it once per model.
155
+ # @param id [String]
156
+ # @param [Hash] opts the optional parameters
157
+ # @option opts [Integer] :days Window in days (max 365). Pass 0 for full history. (default to 90)
158
+ # @return [Array<(GetModelDownloadHistory200Response, Integer, Hash)>] GetModelDownloadHistory200Response data, response status code and response headers
159
+ def get_model_download_history_with_http_info(id, opts = {})
160
+ if @api_client.config.debugging
161
+ @api_client.config.logger.debug 'Calling API: ModelsApi.get_model_download_history ...'
162
+ end
163
+ # verify the required parameter 'id' is set
164
+ if @api_client.config.client_side_validation && id.nil?
165
+ fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.get_model_download_history"
166
+ end
167
+ if @api_client.config.client_side_validation && !opts[:'days'].nil? && opts[:'days'] > 365
168
+ fail ArgumentError, 'invalid value for "opts[:"days"]" when calling ModelsApi.get_model_download_history, must be smaller than or equal to 365.'
169
+ end
170
+
171
+ if @api_client.config.client_side_validation && !opts[:'days'].nil? && opts[:'days'] < 0
172
+ fail ArgumentError, 'invalid value for "opts[:"days"]" when calling ModelsApi.get_model_download_history, must be greater than or equal to 0.'
173
+ end
174
+
175
+ # resource path
176
+ local_var_path = '/api/v1/models/{id}/download-history'.sub('{id}', CGI.escape(id.to_s))
177
+
178
+ # query parameters
179
+ query_params = opts[:query_params] || {}
180
+ query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?
181
+
182
+ # header parameters
183
+ header_params = opts[:header_params] || {}
184
+ # HTTP header 'Accept' (if needed)
185
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
186
+
187
+ # form parameters
188
+ form_params = opts[:form_params] || {}
189
+
190
+ # http body (model)
191
+ post_body = opts[:debug_body]
192
+
193
+ # return_type
194
+ return_type = opts[:debug_return_type] || 'GetModelDownloadHistory200Response'
195
+
196
+ # auth_names
197
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
198
+
199
+ new_options = opts.merge(
200
+ :operation => :"ModelsApi.get_model_download_history",
201
+ :header_params => header_params,
202
+ :query_params => query_params,
203
+ :form_params => form_params,
204
+ :body => post_body,
205
+ :auth_names => auth_names,
206
+ :return_type => return_type
207
+ )
208
+
209
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
210
+ if @api_client.config.debugging
211
+ @api_client.config.logger.debug "API called: ModelsApi#get_model_download_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
212
+ end
213
+ return data, status_code, headers
214
+ end
215
+
216
+ # README content at one commit (wayback)
217
+ # Cost: 10 credits, flat. The wayback-machine leg of the change-stream. Returns the exact README content for one model at one commit sha — used after spotting a suspicious drift on GET /api/v1/models/{id}/drifts.
218
+ # @param id [String]
219
+ # @param commit [String] HF commit sha for the README, from /drifts.
220
+ # @param [Hash] opts the optional parameters
221
+ # @return [GetModelReadmeAt200Response]
222
+ def get_model_readme_at(id, commit, opts = {})
223
+ data, _status_code, _headers = get_model_readme_at_with_http_info(id, commit, opts)
224
+ data
225
+ end
226
+
227
+ # README content at one commit (wayback)
228
+ # Cost: 10 credits, flat. The wayback-machine leg of the change-stream. Returns the exact README content for one model at one commit sha — used after spotting a suspicious drift on GET /api/v1/models/{id}/drifts.
229
+ # @param id [String]
230
+ # @param commit [String] HF commit sha for the README, from /drifts.
231
+ # @param [Hash] opts the optional parameters
232
+ # @return [Array<(GetModelReadmeAt200Response, Integer, Hash)>] GetModelReadmeAt200Response data, response status code and response headers
233
+ def get_model_readme_at_with_http_info(id, commit, opts = {})
234
+ if @api_client.config.debugging
235
+ @api_client.config.logger.debug 'Calling API: ModelsApi.get_model_readme_at ...'
236
+ end
237
+ # verify the required parameter 'id' is set
238
+ if @api_client.config.client_side_validation && id.nil?
239
+ fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.get_model_readme_at"
240
+ end
241
+ # verify the required parameter 'commit' is set
242
+ if @api_client.config.client_side_validation && commit.nil?
243
+ fail ArgumentError, "Missing the required parameter 'commit' when calling ModelsApi.get_model_readme_at"
244
+ end
245
+ # resource path
246
+ local_var_path = '/api/v1/models/{id}/readme-at/{commit}'.sub('{id}', CGI.escape(id.to_s)).sub('{commit}', CGI.escape(commit.to_s))
247
+
248
+ # query parameters
249
+ query_params = opts[:query_params] || {}
250
+
251
+ # header parameters
252
+ header_params = opts[:header_params] || {}
253
+ # HTTP header 'Accept' (if needed)
254
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
255
+
256
+ # form parameters
257
+ form_params = opts[:form_params] || {}
258
+
259
+ # http body (model)
260
+ post_body = opts[:debug_body]
261
+
262
+ # return_type
263
+ return_type = opts[:debug_return_type] || 'GetModelReadmeAt200Response'
264
+
265
+ # auth_names
266
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
267
+
268
+ new_options = opts.merge(
269
+ :operation => :"ModelsApi.get_model_readme_at",
270
+ :header_params => header_params,
271
+ :query_params => query_params,
272
+ :form_params => form_params,
273
+ :body => post_body,
274
+ :auth_names => auth_names,
275
+ :return_type => return_type
276
+ )
277
+
278
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
279
+ if @api_client.config.debugging
280
+ @api_client.config.logger.debug "API called: ModelsApi#get_model_readme_at\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
281
+ end
282
+ return data, status_code, headers
283
+ end
284
+
285
+ # Anomalies in the download counter (change stream)
286
+ # Cost: 15 credits, flat. Every row is a model whose downloads-per-window has crossed a threshold: 2× jump = `spike`, 0.5× fall = `drop`. Sorted by absolute delta so biggest movers surface first. Consumers get \"what is happening in the field right now\" without re-implementing the ETL over `download_history`.
287
+ # @param [Hash] opts the optional parameters
288
+ # @option opts [Integer] :window_days Baseline distance in days. Default 7, min 1, max 365. (default to 7)
289
+ # @option opts [Integer] :min_baseline Only rows where baseline downloads &gt;&#x3D; this. Filters &#x60;0→10&#x60; noise. Default 1000. (default to 1000)
290
+ # @option opts [String] :kind Filter to one class. Omit for both.
291
+ # @option opts [Integer] :limit Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)
292
+ # @option opts [Integer] :offset Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)
293
+ # @return [ListAnomalies200Response]
294
+ def list_anomalies(opts = {})
295
+ data, _status_code, _headers = list_anomalies_with_http_info(opts)
296
+ data
297
+ end
298
+
299
+ # Anomalies in the download counter (change stream)
300
+ # Cost: 15 credits, flat. Every row is a model whose downloads-per-window has crossed a threshold: 2× jump &#x3D; &#x60;spike&#x60;, 0.5× fall &#x3D; &#x60;drop&#x60;. Sorted by absolute delta so biggest movers surface first. Consumers get \&quot;what is happening in the field right now\&quot; without re-implementing the ETL over &#x60;download_history&#x60;.
301
+ # @param [Hash] opts the optional parameters
302
+ # @option opts [Integer] :window_days Baseline distance in days. Default 7, min 1, max 365. (default to 7)
303
+ # @option opts [Integer] :min_baseline Only rows where baseline downloads &gt;&#x3D; this. Filters &#x60;0→10&#x60; noise. Default 1000. (default to 1000)
304
+ # @option opts [String] :kind Filter to one class. Omit for both.
305
+ # @option opts [Integer] :limit Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)
306
+ # @option opts [Integer] :offset Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)
307
+ # @return [Array<(ListAnomalies200Response, Integer, Hash)>] ListAnomalies200Response data, response status code and response headers
308
+ def list_anomalies_with_http_info(opts = {})
309
+ if @api_client.config.debugging
310
+ @api_client.config.logger.debug 'Calling API: ModelsApi.list_anomalies ...'
311
+ end
312
+ if @api_client.config.client_side_validation && !opts[:'window_days'].nil? && opts[:'window_days'] > 365
313
+ fail ArgumentError, 'invalid value for "opts[:"window_days"]" when calling ModelsApi.list_anomalies, must be smaller than or equal to 365.'
314
+ end
315
+
316
+ if @api_client.config.client_side_validation && !opts[:'window_days'].nil? && opts[:'window_days'] < 1
317
+ fail ArgumentError, 'invalid value for "opts[:"window_days"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
318
+ end
319
+
320
+ if @api_client.config.client_side_validation && !opts[:'min_baseline'].nil? && opts[:'min_baseline'] < 1
321
+ fail ArgumentError, 'invalid value for "opts[:"min_baseline"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
322
+ end
323
+
324
+ allowable_values = ["spike", "drop"]
325
+ if @api_client.config.client_side_validation && opts[:'kind'] && !allowable_values.include?(opts[:'kind'])
326
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{allowable_values}"
327
+ end
328
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
329
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_anomalies, must be smaller than or equal to 1000.'
330
+ end
331
+
332
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
333
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
334
+ end
335
+
336
+ if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
337
+ fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 0.'
338
+ end
339
+
340
+ # resource path
341
+ local_var_path = '/api/v1/market/anomalies'
342
+
343
+ # query parameters
344
+ query_params = opts[:query_params] || {}
345
+ query_params[:'window_days'] = opts[:'window_days'] if !opts[:'window_days'].nil?
346
+ query_params[:'min_baseline'] = opts[:'min_baseline'] if !opts[:'min_baseline'].nil?
347
+ query_params[:'kind'] = opts[:'kind'] if !opts[:'kind'].nil?
348
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
349
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
350
+
351
+ # header parameters
352
+ header_params = opts[:header_params] || {}
353
+ # HTTP header 'Accept' (if needed)
354
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
355
+
356
+ # form parameters
357
+ form_params = opts[:form_params] || {}
358
+
359
+ # http body (model)
360
+ post_body = opts[:debug_body]
361
+
362
+ # return_type
363
+ return_type = opts[:debug_return_type] || 'ListAnomalies200Response'
364
+
365
+ # auth_names
366
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
367
+
368
+ new_options = opts.merge(
369
+ :operation => :"ModelsApi.list_anomalies",
370
+ :header_params => header_params,
371
+ :query_params => query_params,
372
+ :form_params => form_params,
373
+ :body => post_body,
374
+ :auth_names => auth_names,
375
+ :return_type => return_type
376
+ )
377
+
378
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
379
+ if @api_client.config.debugging
380
+ @api_client.config.logger.debug "API called: ModelsApi#list_anomalies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
381
+ end
382
+ return data, status_code, headers
383
+ end
384
+
142
385
  # List delisted models (change stream)
143
386
  # Cost: 5 credits, flat. Change-stream companion to /models: every row is a tombstone — a model that HF no longer serves, preserved here at its final state. Poll with `since=<last_seen_at of your previous run>` to fetch only new casualties; callers building compliance dashboards, safety-research corpora, or \"wayback\" tools live on this endpoint. See /api#change-stream.
144
387
  # @param [Hash] opts the optional parameters
@@ -316,6 +559,90 @@ module Abliteration
316
559
  return data, status_code, headers
317
560
  end
318
561
 
562
+ # README drift stream for one model
563
+ # Cost: 5 credits, flat. Every commit that changed the model's README on HF, with `size_delta` between commits so a consumer spots growth spurts and hard prunes without fetching each version. Poll with `since_ts=<max commit_ts of your previous run>` for an incremental drift feed.
564
+ # @param id [String]
565
+ # @param [Hash] opts the optional parameters
566
+ # @option opts [Integer] :since_ts Unix epoch seconds. Rows with commit_ts &gt;&#x3D; it only.
567
+ # @option opts [Integer] :limit Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)
568
+ # @option opts [Integer] :offset Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)
569
+ # @return [ListModelReadmeDrifts200Response]
570
+ def list_model_readme_drifts(id, opts = {})
571
+ data, _status_code, _headers = list_model_readme_drifts_with_http_info(id, opts)
572
+ data
573
+ end
574
+
575
+ # README drift stream for one model
576
+ # Cost: 5 credits, flat. Every commit that changed the model&#39;s README on HF, with &#x60;size_delta&#x60; between commits so a consumer spots growth spurts and hard prunes without fetching each version. Poll with &#x60;since_ts&#x3D;&lt;max commit_ts of your previous run&gt;&#x60; for an incremental drift feed.
577
+ # @param id [String]
578
+ # @param [Hash] opts the optional parameters
579
+ # @option opts [Integer] :since_ts Unix epoch seconds. Rows with commit_ts &gt;&#x3D; it only.
580
+ # @option opts [Integer] :limit Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)
581
+ # @option opts [Integer] :offset Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)
582
+ # @return [Array<(ListModelReadmeDrifts200Response, Integer, Hash)>] ListModelReadmeDrifts200Response data, response status code and response headers
583
+ def list_model_readme_drifts_with_http_info(id, opts = {})
584
+ if @api_client.config.debugging
585
+ @api_client.config.logger.debug 'Calling API: ModelsApi.list_model_readme_drifts ...'
586
+ end
587
+ # verify the required parameter 'id' is set
588
+ if @api_client.config.client_side_validation && id.nil?
589
+ fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.list_model_readme_drifts"
590
+ end
591
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
592
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_model_readme_drifts, must be smaller than or equal to 1000.'
593
+ end
594
+
595
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
596
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_model_readme_drifts, must be greater than or equal to 1.'
597
+ end
598
+
599
+ if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
600
+ fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_model_readme_drifts, must be greater than or equal to 0.'
601
+ end
602
+
603
+ # resource path
604
+ local_var_path = '/api/v1/models/{id}/drifts'.sub('{id}', CGI.escape(id.to_s))
605
+
606
+ # query parameters
607
+ query_params = opts[:query_params] || {}
608
+ query_params[:'since_ts'] = opts[:'since_ts'] if !opts[:'since_ts'].nil?
609
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
610
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
611
+
612
+ # header parameters
613
+ header_params = opts[:header_params] || {}
614
+ # HTTP header 'Accept' (if needed)
615
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
616
+
617
+ # form parameters
618
+ form_params = opts[:form_params] || {}
619
+
620
+ # http body (model)
621
+ post_body = opts[:debug_body]
622
+
623
+ # return_type
624
+ return_type = opts[:debug_return_type] || 'ListModelReadmeDrifts200Response'
625
+
626
+ # auth_names
627
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
628
+
629
+ new_options = opts.merge(
630
+ :operation => :"ModelsApi.list_model_readme_drifts",
631
+ :header_params => header_params,
632
+ :query_params => query_params,
633
+ :form_params => form_params,
634
+ :body => post_body,
635
+ :auth_names => auth_names,
636
+ :return_type => return_type
637
+ )
638
+
639
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
640
+ if @api_client.config.debugging
641
+ @api_client.config.logger.debug "API called: ModelsApi#list_model_readme_drifts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
642
+ end
643
+ return data, status_code, headers
644
+ end
645
+
319
646
  # List models
320
647
  # Cost: 5-300+ credits, stepped by returned rows and multiplied by `1 + (offset/2500)²`. A filtered lookup up to 200 rows costs 5; a 1000-row page on the first page costs 300; on offset=10000, 5100. Filter cheap, dump expensive. See /api#pricing. Delisted models are excluded by default (`delisted=live`); pass `delisted=dead|all` to include tombstoned records. A dedicated change-stream endpoint is at GET /api/v1/models/delisted.
321
648
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,250 @@
1
+ =begin
2
+ #abliteration.org Public API
3
+
4
+ #Read access to the abliteration.org catalog: models and their method classification, alignment datasets and their passports, the M-code taxonomy, the four flagship indices and the curated field timeline. Every call is authenticated with a bearer key and metered in credits against the same wallet the Research Agent spends from. There is no free tier for machine traffic and no separate billing. Responses report `cost` and `credits_remaining` on every success. While `metering` reads `preview`, the cost shown is what the call will bill once metering is enabled and nothing is actually deducted; when it reads `billed`, it was.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Abliteration
17
+ # One model whose downloads-per-window crossed a threshold.
18
+ class DownloadAnomaly < ApiModelBase
19
+ attr_accessor :model_id
20
+
21
+ # ISO-8601 timestamp of the current snapshot.
22
+ attr_accessor :current_at
23
+
24
+ attr_accessor :current_downloads
25
+
26
+ # ISO-8601 timestamp of the baseline snapshot the delta is computed against.
27
+ attr_accessor :baseline_at
28
+
29
+ attr_accessor :baseline_downloads
30
+
31
+ # current_downloads / baseline_downloads.
32
+ attr_accessor :ratio
33
+
34
+ # current_downloads - baseline_downloads (signed).
35
+ attr_accessor :delta
36
+
37
+ # `spike` when ratio >= 2, `drop` when ratio <= 0.5.
38
+ attr_accessor :kind
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'model_id' => :'model_id',
66
+ :'current_at' => :'current_at',
67
+ :'current_downloads' => :'current_downloads',
68
+ :'baseline_at' => :'baseline_at',
69
+ :'baseline_downloads' => :'baseline_downloads',
70
+ :'ratio' => :'ratio',
71
+ :'delta' => :'delta',
72
+ :'kind' => :'kind'
73
+ }
74
+ end
75
+
76
+ # Returns attribute mapping this model knows about
77
+ def self.acceptable_attribute_map
78
+ attribute_map
79
+ end
80
+
81
+ # Returns all the JSON keys this model knows about
82
+ def self.acceptable_attributes
83
+ acceptable_attribute_map.values
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.openapi_types
88
+ {
89
+ :'model_id' => :'String',
90
+ :'current_at' => :'String',
91
+ :'current_downloads' => :'Integer',
92
+ :'baseline_at' => :'String',
93
+ :'baseline_downloads' => :'Integer',
94
+ :'ratio' => :'Float',
95
+ :'delta' => :'Integer',
96
+ :'kind' => :'String'
97
+ }
98
+ end
99
+
100
+ # List of attributes with nullable: true
101
+ def self.openapi_nullable
102
+ Set.new([
103
+ ])
104
+ end
105
+
106
+ # Initializes the object
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ def initialize(attributes = {})
109
+ if (!attributes.is_a?(Hash))
110
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Abliteration::DownloadAnomaly` initialize method"
111
+ end
112
+
113
+ # check to see if the attribute exists and convert string to symbol for hash key
114
+ acceptable_attribute_map = self.class.acceptable_attribute_map
115
+ attributes = attributes.each_with_object({}) { |(k, v), h|
116
+ if (!acceptable_attribute_map.key?(k.to_sym))
117
+ 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
118
+ end
119
+ h[k.to_sym] = v
120
+ }
121
+
122
+ if attributes.key?(:'model_id')
123
+ self.model_id = attributes[:'model_id']
124
+ end
125
+
126
+ if attributes.key?(:'current_at')
127
+ self.current_at = attributes[:'current_at']
128
+ end
129
+
130
+ if attributes.key?(:'current_downloads')
131
+ self.current_downloads = attributes[:'current_downloads']
132
+ end
133
+
134
+ if attributes.key?(:'baseline_at')
135
+ self.baseline_at = attributes[:'baseline_at']
136
+ end
137
+
138
+ if attributes.key?(:'baseline_downloads')
139
+ self.baseline_downloads = attributes[:'baseline_downloads']
140
+ end
141
+
142
+ if attributes.key?(:'ratio')
143
+ self.ratio = attributes[:'ratio']
144
+ end
145
+
146
+ if attributes.key?(:'delta')
147
+ self.delta = attributes[:'delta']
148
+ end
149
+
150
+ if attributes.key?(:'kind')
151
+ self.kind = attributes[:'kind']
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
159
+ invalid_properties = Array.new
160
+ invalid_properties
161
+ end
162
+
163
+ # Check to see if the all the properties in the model are valid
164
+ # @return true if the model is valid
165
+ def valid?
166
+ warn '[DEPRECATED] the `valid?` method is obsolete'
167
+ kind_validator = EnumAttributeValidator.new('String', ["spike", "drop"])
168
+ return false unless kind_validator.valid?(@kind)
169
+ true
170
+ end
171
+
172
+ # Custom attribute writer method checking allowed values (enum).
173
+ # @param [Object] kind Object to be assigned
174
+ def kind=(kind)
175
+ validator = EnumAttributeValidator.new('String', ["spike", "drop"])
176
+ unless validator.valid?(kind)
177
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
178
+ end
179
+ @kind = kind
180
+ end
181
+
182
+ # Checks equality by comparing each attribute.
183
+ # @param [Object] Object to be compared
184
+ def ==(o)
185
+ return true if self.equal?(o)
186
+ self.class == o.class &&
187
+ model_id == o.model_id &&
188
+ current_at == o.current_at &&
189
+ current_downloads == o.current_downloads &&
190
+ baseline_at == o.baseline_at &&
191
+ baseline_downloads == o.baseline_downloads &&
192
+ ratio == o.ratio &&
193
+ delta == o.delta &&
194
+ kind == o.kind
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [model_id, current_at, current_downloads, baseline_at, baseline_downloads, ratio, delta, kind].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ return nil unless attributes.is_a?(Hash)
214
+ attributes = attributes.transform_keys(&:to_sym)
215
+ transformed_hash = {}
216
+ openapi_types.each_pair do |key, type|
217
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
218
+ transformed_hash["#{key}"] = nil
219
+ elsif type =~ /\AArray<(.*)>/i
220
+ # check to ensure the input is an array given that the attribute
221
+ # is documented as an array but the input is not
222
+ if attributes[attribute_map[key]].is_a?(Array)
223
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
224
+ end
225
+ elsif !attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
227
+ end
228
+ end
229
+ new(transformed_hash)
230
+ end
231
+
232
+ # Returns the object in the form of hash
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_hash
235
+ hash = {}
236
+ self.class.attribute_map.each_pair do |attr, param|
237
+ value = self.send(attr)
238
+ if value.nil?
239
+ is_nullable = self.class.openapi_nullable.include?(attr)
240
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
241
+ end
242
+
243
+ hash[param] = _to_hash(value)
244
+ end
245
+ hash
246
+ end
247
+
248
+ end
249
+
250
+ end