internetdata 2.10.0 → 2.10.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8682eb2a09e7c95b8a6bafe0c2849783249c6e1cc458722aa4b2b210453a4c5f
4
- data.tar.gz: 50f5a7facc448be5f76a82db05924ac3b7ceabd1617315e0fc0f786006ada7e9
3
+ metadata.gz: 8d551a2233a205fbf677c4bab66f4e48970795b8948f5253736e13795e1100e1
4
+ data.tar.gz: 66390534b688de43157024deb0a86b217f681f2649e32f128df5a78358def68c
5
5
  SHA512:
6
- metadata.gz: ea33930ef4ba1e8e1c70a7154d19fb3f5f75d5e4da63e914182a50db6577df4c642dc8945c3f277969f278b959b1e17d25e253a64de8b2b64c4daa19b355efc4
7
- data.tar.gz: d7475a144284fb3a2cf63fad78a6c745218e98f103ea1ac2d4fd084475338ace705bb22f9bc6848bbaf445a4865b9901c5535f24cc0ba20e799820be99d3ae52
6
+ metadata.gz: 1874592aab4b4c990fbfc5dd7bab23620c9109fa9eed5c2bb51cf954d52160fb73506a2e52186568b9fcd3f656943145a081c09c1459a51d5a95ac105a4d0a03
7
+ data.tar.gz: 030c478b5e77d67f10ce5b6c0698841732ba35cfe025a546cf003a081b05af02ba4c39b20a1856a6eaf048facb941cdf5fa730c9f8a3582d28848eb3bfb21696
data/README.md CHANGED
@@ -61,7 +61,7 @@ domain.is_registered # => true
61
61
  domain.dns # its records, on a paid plan
62
62
  ```
63
63
 
64
- Both are sent as you give them, and the API reads `AS9009` and an internationalized domain too. Neither is cached.
64
+ Both are sent as you give them, and the API reads `AS9009` and an internationalized domain too. Neither is cached. `lookup` takes an IP address alone, and raises a `:bad_request` for anything else before sending it.
65
65
 
66
66
  ### Your own address
67
67
 
@@ -30,6 +30,11 @@ module InternetData
30
30
  (addr.ipv4? ? v4 : v6).any? { |range| range.include?(addr) }
31
31
  end
32
32
 
33
+ # Whether `ip` reads as one IP address; a prefix is not one.
34
+ def address?(ip)
35
+ !parse(ip).nil?
36
+ end
37
+
33
38
  # The IPv4 address an IPv4-mapped IPv6 address (::ffff:a.b.c.d, in any
34
39
  # spelling) carries, dotted, and any other address as given. A server
35
40
  # listening on :: sees every IPv4 visitor in that form, which read whole is
@@ -89,6 +89,8 @@ module InternetData
89
89
  #
90
90
  # @param retries [Integer, nil] extra attempts, for THIS call only.
91
91
  # @param timeout [Numeric, nil] seconds each attempt may take, for THIS call only.
92
+ # @raise [Error] `:bad_request`, before any request, for anything but an IP
93
+ # address: {#lookup_asn} and {#lookup_domain} look an AS and a domain up.
92
94
  # @return [Result]
93
95
  def lookup(ip, retries: nil, timeout: nil)
94
96
  # Here as well as in the transport: a bogon or a cached answer returns before any request.
@@ -96,6 +98,12 @@ module InternetData
96
98
  Retries.checked_count(retries) unless retries.nil?
97
99
  # Judged, cached and sent as the IPv4 address it carries, if it is mapped.
98
100
  ip = Bogon.unmapped(ip)
101
+ # The API answers an AS or a domain at this path too, as an answer this call
102
+ # cannot read, so one is refused unsent rather than retried as unreadable.
103
+ unless Bogon.address?(ip)
104
+ raise Error.new(:bad_request, "#{ip.inspect} is not an IP address: look an AS up with lookup_asn " \
105
+ 'and a domain with lookup_domain')
106
+ end
99
107
  return Bogon.result(ip) if Bogon.bogon?(ip)
100
108
 
101
109
  loop do
@@ -111,64 +111,44 @@ module InternetData
111
111
 
112
112
  if attributes.key?(:'verified')
113
113
  self.verified = attributes[:'verified']
114
- else
115
- self.verified = nil
116
114
  end
117
115
 
118
116
  if attributes.key?(:'id_matches_ip')
119
117
  self.id_matches_ip = attributes[:'id_matches_ip']
120
- else
121
- self.id_matches_ip = nil
122
118
  end
123
119
 
124
120
  if attributes.key?(:'first_seen')
125
121
  self.first_seen = attributes[:'first_seen']
126
- else
127
- self.first_seen = nil
128
122
  end
129
123
 
130
124
  if attributes.key?(:'last_seen')
131
125
  self.last_seen = attributes[:'last_seen']
132
- else
133
- self.last_seen = nil
134
126
  end
135
127
 
136
128
  if attributes.key?(:'last_reachable')
137
129
  self.last_reachable = attributes[:'last_reachable']
138
- else
139
- self.last_reachable = nil
140
130
  end
141
131
 
142
132
  if attributes.key?(:'days_seen')
143
133
  self.days_seen = attributes[:'days_seen']
144
- else
145
- self.days_seen = nil
146
134
  end
147
135
 
148
136
  if attributes.key?(:'num_ports')
149
137
  self.num_ports = attributes[:'num_ports']
150
- else
151
- self.num_ports = nil
152
138
  end
153
139
 
154
140
  if attributes.key?(:'peak_num_ports')
155
141
  self.peak_num_ports = attributes[:'peak_num_ports']
156
- else
157
- self.peak_num_ports = nil
158
142
  end
159
143
 
160
144
  if attributes.key?(:'indexer')
161
145
  self.indexer = attributes[:'indexer']
162
- else
163
- self.indexer = nil
164
146
  end
165
147
 
166
148
  if attributes.key?(:'clients')
167
149
  if (value = attributes[:'clients']).is_a?(Array)
168
150
  self.clients = value
169
151
  end
170
- else
171
- self.clients = nil
172
152
  end
173
153
  end
174
154
 
@@ -177,46 +157,6 @@ module InternetData
177
157
  def list_invalid_properties
178
158
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
179
159
  invalid_properties = Array.new
180
- if @verified.nil?
181
- invalid_properties.push('invalid value for "verified", verified cannot be nil.')
182
- end
183
-
184
- if @id_matches_ip.nil?
185
- invalid_properties.push('invalid value for "id_matches_ip", id_matches_ip cannot be nil.')
186
- end
187
-
188
- if @first_seen.nil?
189
- invalid_properties.push('invalid value for "first_seen", first_seen cannot be nil.')
190
- end
191
-
192
- if @last_seen.nil?
193
- invalid_properties.push('invalid value for "last_seen", last_seen cannot be nil.')
194
- end
195
-
196
- if @last_reachable.nil?
197
- invalid_properties.push('invalid value for "last_reachable", last_reachable cannot be nil.')
198
- end
199
-
200
- if @days_seen.nil?
201
- invalid_properties.push('invalid value for "days_seen", days_seen cannot be nil.')
202
- end
203
-
204
- if @num_ports.nil?
205
- invalid_properties.push('invalid value for "num_ports", num_ports cannot be nil.')
206
- end
207
-
208
- if @peak_num_ports.nil?
209
- invalid_properties.push('invalid value for "peak_num_ports", peak_num_ports cannot be nil.')
210
- end
211
-
212
- if @indexer.nil?
213
- invalid_properties.push('invalid value for "indexer", indexer cannot be nil.')
214
- end
215
-
216
- if @clients.nil?
217
- invalid_properties.push('invalid value for "clients", clients cannot be nil.')
218
- end
219
-
220
160
  invalid_properties
221
161
  end
222
162
 
@@ -224,119 +164,9 @@ module InternetData
224
164
  # @return true if the model is valid
225
165
  def valid?
226
166
  warn '[DEPRECATED] the `valid?` method is obsolete'
227
- return false if @verified.nil?
228
- return false if @id_matches_ip.nil?
229
- return false if @first_seen.nil?
230
- return false if @last_seen.nil?
231
- return false if @last_reachable.nil?
232
- return false if @days_seen.nil?
233
- return false if @num_ports.nil?
234
- return false if @peak_num_ports.nil?
235
- return false if @indexer.nil?
236
- return false if @clients.nil?
237
167
  true
238
168
  end
239
169
 
240
- # Custom attribute writer method with validation
241
- # @param [Object] verified Value to be assigned
242
- def verified=(verified)
243
- if verified.nil?
244
- fail ArgumentError, 'verified cannot be nil'
245
- end
246
-
247
- @verified = verified
248
- end
249
-
250
- # Custom attribute writer method with validation
251
- # @param [Object] id_matches_ip Value to be assigned
252
- def id_matches_ip=(id_matches_ip)
253
- if id_matches_ip.nil?
254
- fail ArgumentError, 'id_matches_ip cannot be nil'
255
- end
256
-
257
- @id_matches_ip = id_matches_ip
258
- end
259
-
260
- # Custom attribute writer method with validation
261
- # @param [Object] first_seen Value to be assigned
262
- def first_seen=(first_seen)
263
- if first_seen.nil?
264
- fail ArgumentError, 'first_seen cannot be nil'
265
- end
266
-
267
- @first_seen = first_seen
268
- end
269
-
270
- # Custom attribute writer method with validation
271
- # @param [Object] last_seen Value to be assigned
272
- def last_seen=(last_seen)
273
- if last_seen.nil?
274
- fail ArgumentError, 'last_seen cannot be nil'
275
- end
276
-
277
- @last_seen = last_seen
278
- end
279
-
280
- # Custom attribute writer method with validation
281
- # @param [Object] last_reachable Value to be assigned
282
- def last_reachable=(last_reachable)
283
- if last_reachable.nil?
284
- fail ArgumentError, 'last_reachable cannot be nil'
285
- end
286
-
287
- @last_reachable = last_reachable
288
- end
289
-
290
- # Custom attribute writer method with validation
291
- # @param [Object] days_seen Value to be assigned
292
- def days_seen=(days_seen)
293
- if days_seen.nil?
294
- fail ArgumentError, 'days_seen cannot be nil'
295
- end
296
-
297
- @days_seen = days_seen
298
- end
299
-
300
- # Custom attribute writer method with validation
301
- # @param [Object] num_ports Value to be assigned
302
- def num_ports=(num_ports)
303
- if num_ports.nil?
304
- fail ArgumentError, 'num_ports cannot be nil'
305
- end
306
-
307
- @num_ports = num_ports
308
- end
309
-
310
- # Custom attribute writer method with validation
311
- # @param [Object] peak_num_ports Value to be assigned
312
- def peak_num_ports=(peak_num_ports)
313
- if peak_num_ports.nil?
314
- fail ArgumentError, 'peak_num_ports cannot be nil'
315
- end
316
-
317
- @peak_num_ports = peak_num_ports
318
- end
319
-
320
- # Custom attribute writer method with validation
321
- # @param [Object] indexer Value to be assigned
322
- def indexer=(indexer)
323
- if indexer.nil?
324
- fail ArgumentError, 'indexer cannot be nil'
325
- end
326
-
327
- @indexer = indexer
328
- end
329
-
330
- # Custom attribute writer method with validation
331
- # @param [Object] clients Value to be assigned
332
- def clients=(clients)
333
- if clients.nil?
334
- fail ArgumentError, 'clients cannot be nil'
335
- end
336
-
337
- @clients = clients
338
- end
339
-
340
170
  # Checks equality by comparing each attribute.
341
171
  # @param [Object] Object to be compared
342
172
  def ==(o)
@@ -86,32 +86,22 @@ module InternetData
86
86
 
87
87
  if attributes.key?(:'name')
88
88
  self.name = attributes[:'name']
89
- else
90
- self.name = nil
91
89
  end
92
90
 
93
91
  if attributes.key?(:'mcc')
94
92
  self.mcc = attributes[:'mcc']
95
- else
96
- self.mcc = nil
97
93
  end
98
94
 
99
95
  if attributes.key?(:'mnc')
100
96
  self.mnc = attributes[:'mnc']
101
- else
102
- self.mnc = nil
103
97
  end
104
98
 
105
99
  if attributes.key?(:'country')
106
100
  self.country = attributes[:'country']
107
- else
108
- self.country = nil
109
101
  end
110
102
 
111
103
  if attributes.key?(:'confidence')
112
104
  self.confidence = attributes[:'confidence']
113
- else
114
- self.confidence = nil
115
105
  end
116
106
  end
117
107
 
@@ -120,26 +110,6 @@ module InternetData
120
110
  def list_invalid_properties
121
111
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
122
112
  invalid_properties = Array.new
123
- if @name.nil?
124
- invalid_properties.push('invalid value for "name", name cannot be nil.')
125
- end
126
-
127
- if @mcc.nil?
128
- invalid_properties.push('invalid value for "mcc", mcc cannot be nil.')
129
- end
130
-
131
- if @mnc.nil?
132
- invalid_properties.push('invalid value for "mnc", mnc cannot be nil.')
133
- end
134
-
135
- if @country.nil?
136
- invalid_properties.push('invalid value for "country", country cannot be nil.')
137
- end
138
-
139
- if @confidence.nil?
140
- invalid_properties.push('invalid value for "confidence", confidence cannot be nil.')
141
- end
142
-
143
113
  invalid_properties
144
114
  end
145
115
 
@@ -147,64 +117,9 @@ module InternetData
147
117
  # @return true if the model is valid
148
118
  def valid?
149
119
  warn '[DEPRECATED] the `valid?` method is obsolete'
150
- return false if @name.nil?
151
- return false if @mcc.nil?
152
- return false if @mnc.nil?
153
- return false if @country.nil?
154
- return false if @confidence.nil?
155
120
  true
156
121
  end
157
122
 
158
- # Custom attribute writer method with validation
159
- # @param [Object] name Value to be assigned
160
- def name=(name)
161
- if name.nil?
162
- fail ArgumentError, 'name cannot be nil'
163
- end
164
-
165
- @name = name
166
- end
167
-
168
- # Custom attribute writer method with validation
169
- # @param [Object] mcc Value to be assigned
170
- def mcc=(mcc)
171
- if mcc.nil?
172
- fail ArgumentError, 'mcc cannot be nil'
173
- end
174
-
175
- @mcc = mcc
176
- end
177
-
178
- # Custom attribute writer method with validation
179
- # @param [Object] mnc Value to be assigned
180
- def mnc=(mnc)
181
- if mnc.nil?
182
- fail ArgumentError, 'mnc cannot be nil'
183
- end
184
-
185
- @mnc = mnc
186
- end
187
-
188
- # Custom attribute writer method with validation
189
- # @param [Object] country Value to be assigned
190
- def country=(country)
191
- if country.nil?
192
- fail ArgumentError, 'country cannot be nil'
193
- end
194
-
195
- @country = country
196
- end
197
-
198
- # Custom attribute writer method with validation
199
- # @param [Object] confidence Value to be assigned
200
- def confidence=(confidence)
201
- if confidence.nil?
202
- fail ArgumentError, 'confidence cannot be nil'
203
- end
204
-
205
- @confidence = confidence
206
- end
207
-
208
123
  # Checks equality by comparing each attribute.
209
124
  # @param [Object] Object to be compared
210
125
  def ==(o)
@@ -81,26 +81,18 @@ module InternetData
81
81
 
82
82
  if attributes.key?(:'provider')
83
83
  self.provider = attributes[:'provider']
84
- else
85
- self.provider = nil
86
84
  end
87
85
 
88
86
  if attributes.key?(:'provider_name')
89
87
  self.provider_name = attributes[:'provider_name']
90
- else
91
- self.provider_name = nil
92
88
  end
93
89
 
94
90
  if attributes.key?(:'confidence')
95
91
  self.confidence = attributes[:'confidence']
96
- else
97
- self.confidence = nil
98
92
  end
99
93
 
100
94
  if attributes.key?(:'last_seen')
101
95
  self.last_seen = attributes[:'last_seen']
102
- else
103
- self.last_seen = nil
104
96
  end
105
97
  end
106
98
 
@@ -109,22 +101,6 @@ module InternetData
109
101
  def list_invalid_properties
110
102
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
111
103
  invalid_properties = Array.new
112
- if @provider.nil?
113
- invalid_properties.push('invalid value for "provider", provider cannot be nil.')
114
- end
115
-
116
- if @provider_name.nil?
117
- invalid_properties.push('invalid value for "provider_name", provider_name cannot be nil.')
118
- end
119
-
120
- if @confidence.nil?
121
- invalid_properties.push('invalid value for "confidence", confidence cannot be nil.')
122
- end
123
-
124
- if @last_seen.nil?
125
- invalid_properties.push('invalid value for "last_seen", last_seen cannot be nil.')
126
- end
127
-
128
104
  invalid_properties
129
105
  end
130
106
 
@@ -132,53 +108,9 @@ module InternetData
132
108
  # @return true if the model is valid
133
109
  def valid?
134
110
  warn '[DEPRECATED] the `valid?` method is obsolete'
135
- return false if @provider.nil?
136
- return false if @provider_name.nil?
137
- return false if @confidence.nil?
138
- return false if @last_seen.nil?
139
111
  true
140
112
  end
141
113
 
142
- # Custom attribute writer method with validation
143
- # @param [Object] provider Value to be assigned
144
- def provider=(provider)
145
- if provider.nil?
146
- fail ArgumentError, 'provider cannot be nil'
147
- end
148
-
149
- @provider = provider
150
- end
151
-
152
- # Custom attribute writer method with validation
153
- # @param [Object] provider_name Value to be assigned
154
- def provider_name=(provider_name)
155
- if provider_name.nil?
156
- fail ArgumentError, 'provider_name cannot be nil'
157
- end
158
-
159
- @provider_name = provider_name
160
- end
161
-
162
- # Custom attribute writer method with validation
163
- # @param [Object] confidence Value to be assigned
164
- def confidence=(confidence)
165
- if confidence.nil?
166
- fail ArgumentError, 'confidence cannot be nil'
167
- end
168
-
169
- @confidence = confidence
170
- end
171
-
172
- # Custom attribute writer method with validation
173
- # @param [Object] last_seen Value to be assigned
174
- def last_seen=(last_seen)
175
- if last_seen.nil?
176
- fail ArgumentError, 'last_seen cannot be nil'
177
- end
178
-
179
- @last_seen = last_seen
180
- end
181
-
182
114
  # Checks equality by comparing each attribute.
183
115
  # @param [Object] Object to be compared
184
116
  def ==(o)
@@ -81,28 +81,20 @@ module InternetData
81
81
 
82
82
  if attributes.key?(:'confidence')
83
83
  self.confidence = attributes[:'confidence']
84
- else
85
- self.confidence = nil
86
84
  end
87
85
 
88
86
  if attributes.key?(:'providers')
89
87
  if (value = attributes[:'providers']).is_a?(Array)
90
88
  self.providers = value
91
89
  end
92
- else
93
- self.providers = nil
94
90
  end
95
91
 
96
92
  if attributes.key?(:'first_seen')
97
93
  self.first_seen = attributes[:'first_seen']
98
- else
99
- self.first_seen = nil
100
94
  end
101
95
 
102
96
  if attributes.key?(:'last_seen')
103
97
  self.last_seen = attributes[:'last_seen']
104
- else
105
- self.last_seen = nil
106
98
  end
107
99
  end
108
100
 
@@ -111,22 +103,6 @@ module InternetData
111
103
  def list_invalid_properties
112
104
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
113
105
  invalid_properties = Array.new
114
- if @confidence.nil?
115
- invalid_properties.push('invalid value for "confidence", confidence cannot be nil.')
116
- end
117
-
118
- if @providers.nil?
119
- invalid_properties.push('invalid value for "providers", providers cannot be nil.')
120
- end
121
-
122
- if @first_seen.nil?
123
- invalid_properties.push('invalid value for "first_seen", first_seen cannot be nil.')
124
- end
125
-
126
- if @last_seen.nil?
127
- invalid_properties.push('invalid value for "last_seen", last_seen cannot be nil.')
128
- end
129
-
130
106
  invalid_properties
131
107
  end
132
108
 
@@ -134,53 +110,9 @@ module InternetData
134
110
  # @return true if the model is valid
135
111
  def valid?
136
112
  warn '[DEPRECATED] the `valid?` method is obsolete'
137
- return false if @confidence.nil?
138
- return false if @providers.nil?
139
- return false if @first_seen.nil?
140
- return false if @last_seen.nil?
141
113
  true
142
114
  end
143
115
 
144
- # Custom attribute writer method with validation
145
- # @param [Object] confidence Value to be assigned
146
- def confidence=(confidence)
147
- if confidence.nil?
148
- fail ArgumentError, 'confidence cannot be nil'
149
- end
150
-
151
- @confidence = confidence
152
- end
153
-
154
- # Custom attribute writer method with validation
155
- # @param [Object] providers Value to be assigned
156
- def providers=(providers)
157
- if providers.nil?
158
- fail ArgumentError, 'providers cannot be nil'
159
- end
160
-
161
- @providers = providers
162
- end
163
-
164
- # Custom attribute writer method with validation
165
- # @param [Object] first_seen Value to be assigned
166
- def first_seen=(first_seen)
167
- if first_seen.nil?
168
- fail ArgumentError, 'first_seen cannot be nil'
169
- end
170
-
171
- @first_seen = first_seen
172
- end
173
-
174
- # Custom attribute writer method with validation
175
- # @param [Object] last_seen Value to be assigned
176
- def last_seen=(last_seen)
177
- if last_seen.nil?
178
- fail ArgumentError, 'last_seen cannot be nil'
179
- end
180
-
181
- @last_seen = last_seen
182
- end
183
-
184
116
  # Checks equality by comparing each attribute.
185
117
  # @param [Object] Object to be compared
186
118
  def ==(o)