internetdata 1.0.0

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.
@@ -0,0 +1,349 @@
1
+ =begin
2
+ #InternetData API
3
+
4
+ #The InternetData API. Please see https://docs.internetdata.io/api for more details.
5
+
6
+ The version of the OpenAPI document: 2026.09.04
7
+ Contact: dev@internetdata.io
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 InternetData
17
+ # One database FAMILY, with your organization's licence beside it. A licence covers the family, while a download names a specific version, so the ids passed to `download` and `checksum` come from `versions`.
18
+ class Database < ApiModelBase
19
+ # The family, e.g. `vpn_ip`. What a licence is held against.
20
+ attr_accessor :base
21
+
22
+ attr_accessor :name
23
+
24
+ # One line on what the newest version contains.
25
+ attr_accessor :summary
26
+
27
+ # `licensed` is a live grant, `expired` one whose term has ended, and `unlicensed` a database published but never bought.
28
+ attr_accessor :standing
29
+
30
+ # What your licence permits you to do with the data. Null when there is no licence.
31
+ attr_accessor :redistribution
32
+
33
+ attr_accessor :starts
34
+
35
+ # Null when the licence has no end date, or when there is none.
36
+ attr_accessor :expires
37
+
38
+ # Every published version of this family, oldest first. Old versions are frozen rather than migrated, so both stay downloadable.
39
+ attr_accessor :versions
40
+
41
+ class EnumAttributeValidator
42
+ attr_reader :datatype
43
+ attr_reader :allowable_values
44
+
45
+ def initialize(datatype, allowable_values)
46
+ @allowable_values = allowable_values.map do |value|
47
+ case datatype.to_s
48
+ when /Integer/i
49
+ value.to_i
50
+ when /Float/i
51
+ value.to_f
52
+ else
53
+ value
54
+ end
55
+ end
56
+ end
57
+
58
+ def valid?(value)
59
+ !value || allowable_values.include?(value)
60
+ end
61
+ end
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'base' => :'base',
67
+ :'name' => :'name',
68
+ :'summary' => :'summary',
69
+ :'standing' => :'standing',
70
+ :'redistribution' => :'redistribution',
71
+ :'starts' => :'starts',
72
+ :'expires' => :'expires',
73
+ :'versions' => :'versions'
74
+ }
75
+ end
76
+
77
+ # Returns attribute mapping this model knows about
78
+ def self.acceptable_attribute_map
79
+ attribute_map
80
+ end
81
+
82
+ # Returns all the JSON keys this model knows about
83
+ def self.acceptable_attributes
84
+ acceptable_attribute_map.values
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.openapi_types
89
+ {
90
+ :'base' => :'String',
91
+ :'name' => :'String',
92
+ :'summary' => :'String',
93
+ :'standing' => :'String',
94
+ :'redistribution' => :'String',
95
+ :'starts' => :'Time',
96
+ :'expires' => :'Time',
97
+ :'versions' => :'Array<DatabaseVersion>'
98
+ }
99
+ end
100
+
101
+ # List of attributes with nullable: true
102
+ def self.openapi_nullable
103
+ Set.new([
104
+ :'redistribution',
105
+ :'starts',
106
+ :'expires',
107
+ ])
108
+ end
109
+
110
+ # Initializes the object
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ def initialize(attributes = {})
113
+ if (!attributes.is_a?(Hash))
114
+ fail ArgumentError, "The input argument (attributes) must be a hash in `InternetData::Database` initialize method"
115
+ end
116
+
117
+ # check to see if the attribute exists and convert string to symbol for hash key
118
+ acceptable_attribute_map = self.class.acceptable_attribute_map
119
+ attributes = attributes.each_with_object({}) { |(k, v), h|
120
+ if (!acceptable_attribute_map.key?(k.to_sym))
121
+ fail ArgumentError, "`#{k}` is not a valid attribute in `InternetData::Database`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
122
+ end
123
+ h[k.to_sym] = v
124
+ }
125
+
126
+ if attributes.key?(:'base')
127
+ self.base = attributes[:'base']
128
+ else
129
+ self.base = nil
130
+ end
131
+
132
+ if attributes.key?(:'name')
133
+ self.name = attributes[:'name']
134
+ else
135
+ self.name = nil
136
+ end
137
+
138
+ if attributes.key?(:'summary')
139
+ self.summary = attributes[:'summary']
140
+ else
141
+ self.summary = nil
142
+ end
143
+
144
+ if attributes.key?(:'standing')
145
+ self.standing = attributes[:'standing']
146
+ else
147
+ self.standing = nil
148
+ end
149
+
150
+ if attributes.key?(:'redistribution')
151
+ self.redistribution = attributes[:'redistribution']
152
+ else
153
+ self.redistribution = nil
154
+ end
155
+
156
+ if attributes.key?(:'starts')
157
+ self.starts = attributes[:'starts']
158
+ else
159
+ self.starts = nil
160
+ end
161
+
162
+ if attributes.key?(:'expires')
163
+ self.expires = attributes[:'expires']
164
+ else
165
+ self.expires = nil
166
+ end
167
+
168
+ if attributes.key?(:'versions')
169
+ if (value = attributes[:'versions']).is_a?(Array)
170
+ self.versions = value
171
+ end
172
+ else
173
+ self.versions = nil
174
+ end
175
+ end
176
+
177
+ # Show invalid properties with the reasons. Usually used together with valid?
178
+ # @return Array for valid properties with the reasons
179
+ def list_invalid_properties
180
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
181
+ invalid_properties = Array.new
182
+ if @base.nil?
183
+ invalid_properties.push('invalid value for "base", base cannot be nil.')
184
+ end
185
+
186
+ if @name.nil?
187
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
188
+ end
189
+
190
+ if @summary.nil?
191
+ invalid_properties.push('invalid value for "summary", summary cannot be nil.')
192
+ end
193
+
194
+ if @standing.nil?
195
+ invalid_properties.push('invalid value for "standing", standing cannot be nil.')
196
+ end
197
+
198
+ if @versions.nil?
199
+ invalid_properties.push('invalid value for "versions", versions cannot be nil.')
200
+ end
201
+
202
+ invalid_properties
203
+ end
204
+
205
+ # Check to see if the all the properties in the model are valid
206
+ # @return true if the model is valid
207
+ def valid?
208
+ warn '[DEPRECATED] the `valid?` method is obsolete'
209
+ return false if @base.nil?
210
+ return false if @name.nil?
211
+ return false if @summary.nil?
212
+ return false if @standing.nil?
213
+ standing_validator = EnumAttributeValidator.new('String', ["licensed", "expired", "unlicensed"])
214
+ return false unless standing_validator.valid?(@standing)
215
+ redistribution_validator = EnumAttributeValidator.new('String', ["evaluation", "internal", "redistribute"])
216
+ return false unless redistribution_validator.valid?(@redistribution)
217
+ return false if @versions.nil?
218
+ true
219
+ end
220
+
221
+ # Custom attribute writer method with validation
222
+ # @param [Object] base Value to be assigned
223
+ def base=(base)
224
+ if base.nil?
225
+ fail ArgumentError, 'base cannot be nil'
226
+ end
227
+
228
+ @base = base
229
+ end
230
+
231
+ # Custom attribute writer method with validation
232
+ # @param [Object] name Value to be assigned
233
+ def name=(name)
234
+ if name.nil?
235
+ fail ArgumentError, 'name cannot be nil'
236
+ end
237
+
238
+ @name = name
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] summary Value to be assigned
243
+ def summary=(summary)
244
+ if summary.nil?
245
+ fail ArgumentError, 'summary cannot be nil'
246
+ end
247
+
248
+ @summary = summary
249
+ end
250
+
251
+ # Custom attribute writer method checking allowed values (enum).
252
+ # @param [Object] standing Object to be assigned
253
+ def standing=(standing)
254
+ validator = EnumAttributeValidator.new('String', ["licensed", "expired", "unlicensed"])
255
+ unless validator.valid?(standing)
256
+ fail ArgumentError, "invalid value for \"standing\", must be one of #{validator.allowable_values}."
257
+ end
258
+ @standing = standing
259
+ end
260
+
261
+ # Custom attribute writer method checking allowed values (enum).
262
+ # @param [Object] redistribution Object to be assigned
263
+ def redistribution=(redistribution)
264
+ validator = EnumAttributeValidator.new('String', ["evaluation", "internal", "redistribute"])
265
+ unless validator.valid?(redistribution)
266
+ fail ArgumentError, "invalid value for \"redistribution\", must be one of #{validator.allowable_values}."
267
+ end
268
+ @redistribution = redistribution
269
+ end
270
+
271
+ # Custom attribute writer method with validation
272
+ # @param [Object] versions Value to be assigned
273
+ def versions=(versions)
274
+ if versions.nil?
275
+ fail ArgumentError, 'versions cannot be nil'
276
+ end
277
+
278
+ @versions = versions
279
+ end
280
+
281
+ # Checks equality by comparing each attribute.
282
+ # @param [Object] Object to be compared
283
+ def ==(o)
284
+ return true if self.equal?(o)
285
+ self.class == o.class &&
286
+ base == o.base &&
287
+ name == o.name &&
288
+ summary == o.summary &&
289
+ standing == o.standing &&
290
+ redistribution == o.redistribution &&
291
+ starts == o.starts &&
292
+ expires == o.expires &&
293
+ versions == o.versions
294
+ end
295
+
296
+ # @see the `==` method
297
+ # @param [Object] Object to be compared
298
+ def eql?(o)
299
+ self == o
300
+ end
301
+
302
+ # Calculates hash code according to all attributes.
303
+ # @return [Integer] Hash code
304
+ def hash
305
+ [base, name, summary, standing, redistribution, starts, expires, versions].hash
306
+ end
307
+
308
+ # Builds the object from hash
309
+ # @param [Hash] attributes Model attributes in the form of hash
310
+ # @return [Object] Returns the model itself
311
+ def self.build_from_hash(attributes)
312
+ return nil unless attributes.is_a?(Hash)
313
+ attributes = attributes.transform_keys(&:to_sym)
314
+ transformed_hash = {}
315
+ openapi_types.each_pair do |key, type|
316
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
317
+ transformed_hash["#{key}"] = nil
318
+ elsif type =~ /\AArray<(.*)>/i
319
+ # check to ensure the input is an array given that the attribute
320
+ # is documented as an array but the input is not
321
+ if attributes[attribute_map[key]].is_a?(Array)
322
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
323
+ end
324
+ elsif !attributes[attribute_map[key]].nil?
325
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
326
+ end
327
+ end
328
+ new(transformed_hash)
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ if value.nil?
338
+ is_nullable = self.class.openapi_nullable.include?(attr)
339
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
340
+ end
341
+
342
+ hash[param] = _to_hash(value)
343
+ end
344
+ hash
345
+ end
346
+
347
+ end
348
+
349
+ end
@@ -0,0 +1,240 @@
1
+ =begin
2
+ #InternetData API
3
+
4
+ #The InternetData API. Please see https://docs.internetdata.io/api for more details.
5
+
6
+ The version of the OpenAPI document: 2026.09.04
7
+ Contact: dev@internetdata.io
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 InternetData
17
+ class DatabaseChecksumsResponse < ApiModelBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :format
21
+
22
+ attr_accessor :checksums
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'id' => :'id',
50
+ :'format' => :'format',
51
+ :'checksums' => :'checksums'
52
+ }
53
+ end
54
+
55
+ # Returns attribute mapping this model knows about
56
+ def self.acceptable_attribute_map
57
+ attribute_map
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ acceptable_attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'id' => :'String',
69
+ :'format' => :'String',
70
+ :'checksums' => :'DbChecksums'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `InternetData::DatabaseChecksumsResponse` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ acceptable_attribute_map = self.class.acceptable_attribute_map
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!acceptable_attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `InternetData::DatabaseChecksumsResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'id')
97
+ self.id = attributes[:'id']
98
+ else
99
+ self.id = nil
100
+ end
101
+
102
+ if attributes.key?(:'format')
103
+ self.format = attributes[:'format']
104
+ else
105
+ self.format = nil
106
+ end
107
+
108
+ if attributes.key?(:'checksums')
109
+ self.checksums = attributes[:'checksums']
110
+ else
111
+ self.checksums = nil
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
119
+ invalid_properties = Array.new
120
+ if @id.nil?
121
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
122
+ end
123
+
124
+ if @format.nil?
125
+ invalid_properties.push('invalid value for "format", format cannot be nil.')
126
+ end
127
+
128
+ if @checksums.nil?
129
+ invalid_properties.push('invalid value for "checksums", checksums cannot be nil.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ warn '[DEPRECATED] the `valid?` method is obsolete'
139
+ return false if @id.nil?
140
+ return false if @format.nil?
141
+ format_validator = EnumAttributeValidator.new('String', ["csvgz", "mmdb"])
142
+ return false unless format_validator.valid?(@format)
143
+ return false if @checksums.nil?
144
+ true
145
+ end
146
+
147
+ # Custom attribute writer method with validation
148
+ # @param [Object] id Value to be assigned
149
+ def id=(id)
150
+ if id.nil?
151
+ fail ArgumentError, 'id cannot be nil'
152
+ end
153
+
154
+ @id = id
155
+ end
156
+
157
+ # Custom attribute writer method checking allowed values (enum).
158
+ # @param [Object] format Object to be assigned
159
+ def format=(format)
160
+ validator = EnumAttributeValidator.new('String', ["csvgz", "mmdb"])
161
+ unless validator.valid?(format)
162
+ fail ArgumentError, "invalid value for \"format\", must be one of #{validator.allowable_values}."
163
+ end
164
+ @format = format
165
+ end
166
+
167
+ # Custom attribute writer method with validation
168
+ # @param [Object] checksums Value to be assigned
169
+ def checksums=(checksums)
170
+ if checksums.nil?
171
+ fail ArgumentError, 'checksums cannot be nil'
172
+ end
173
+
174
+ @checksums = checksums
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ id == o.id &&
183
+ format == o.format &&
184
+ checksums == o.checksums
185
+ end
186
+
187
+ # @see the `==` method
188
+ # @param [Object] Object to be compared
189
+ def eql?(o)
190
+ self == o
191
+ end
192
+
193
+ # Calculates hash code according to all attributes.
194
+ # @return [Integer] Hash code
195
+ def hash
196
+ [id, format, checksums].hash
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def self.build_from_hash(attributes)
203
+ return nil unless attributes.is_a?(Hash)
204
+ attributes = attributes.transform_keys(&:to_sym)
205
+ transformed_hash = {}
206
+ openapi_types.each_pair do |key, type|
207
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
208
+ transformed_hash["#{key}"] = nil
209
+ elsif type =~ /\AArray<(.*)>/i
210
+ # check to ensure the input is an array given that the attribute
211
+ # is documented as an array but the input is not
212
+ if attributes[attribute_map[key]].is_a?(Array)
213
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
214
+ end
215
+ elsif !attributes[attribute_map[key]].nil?
216
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
217
+ end
218
+ end
219
+ new(transformed_hash)
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ end
239
+
240
+ end