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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +125 -0
- data/lib/internetdata/api/database_v2_api.rb +376 -0
- data/lib/internetdata/api_client.rb +397 -0
- data/lib/internetdata/api_error.rb +58 -0
- data/lib/internetdata/api_model_base.rb +88 -0
- data/lib/internetdata/client.rb +34 -0
- data/lib/internetdata/configuration.rb +315 -0
- data/lib/internetdata/database_api.rb +182 -0
- data/lib/internetdata/errors.rb +110 -0
- data/lib/internetdata/models/database.rb +349 -0
- data/lib/internetdata/models/database_checksums_response.rb +240 -0
- data/lib/internetdata/models/database_list.rb +166 -0
- data/lib/internetdata/models/database_metadata.rb +299 -0
- data/lib/internetdata/models/database_metadata_column.rb +199 -0
- data/lib/internetdata/models/database_version.rb +258 -0
- data/lib/internetdata/models/db_checksums.rb +246 -0
- data/lib/internetdata/models/download.rb +329 -0
- data/lib/internetdata/models/download_list.rb +166 -0
- data/lib/internetdata/models/error_envelope.rb +165 -0
- data/lib/internetdata/retries.rb +33 -0
- data/lib/internetdata/transport.rb +72 -0
- data/lib/internetdata/version.rb +5 -0
- data/lib/internetdata.rb +26 -0
- metadata +84 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module InternetData
|
|
6
|
+
# The generated wire client, with the three things it gets wrong for this API
|
|
7
|
+
# corrected in one place.
|
|
8
|
+
class Transport < ApiClient
|
|
9
|
+
# The generated Configuration applies a security scheme whatever it holds, so
|
|
10
|
+
# a keyless client would send `Authorization: Bearer ` - an empty credential,
|
|
11
|
+
# which the API answers 401 to rather than treating as no credential at all.
|
|
12
|
+
# That is also exactly what an unset `${{ secrets.X }}` interpolates to.
|
|
13
|
+
class Config < Configuration
|
|
14
|
+
def initialize(api_key: nil, base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT)
|
|
15
|
+
super()
|
|
16
|
+
uri = URI.parse(base_url)
|
|
17
|
+
self.scheme = uri.scheme
|
|
18
|
+
self.host = uri.port == uri.default_port ? uri.host : "#{uri.host}:#{uri.port}"
|
|
19
|
+
self.base_path = uri.path
|
|
20
|
+
self.access_token = api_key
|
|
21
|
+
self.timeout = timeout
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def auth_settings
|
|
25
|
+
return {} if access_token.nil? || access_token.to_s.empty?
|
|
26
|
+
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def initialize(config)
|
|
32
|
+
super
|
|
33
|
+
@default_headers['User-Agent'] = "internetdata-ruby/#{VERSION}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# `follow_location = opts[:follow_location] || true` in the generated client
|
|
37
|
+
# is true for every value it can be given, so the download's 302 would be
|
|
38
|
+
# chased and a multi-gigabyte database read into memory. Nothing this API
|
|
39
|
+
# serves is meant to be followed.
|
|
40
|
+
def build_request(http_method, path, opts = {})
|
|
41
|
+
request = super
|
|
42
|
+
request.options[:followlocation] = false
|
|
43
|
+
request
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# A GET for the presigned link the download endpoint hands out.
|
|
47
|
+
#
|
|
48
|
+
# Built here rather than through {#build_request} so it carries NO
|
|
49
|
+
# credential: the presigned URL authorizes itself, and forwarding the API key
|
|
50
|
+
# would hand it to a host with no business holding it. Redirects ARE followed,
|
|
51
|
+
# unlike every other request this client makes, because this one IS the far
|
|
52
|
+
# side of one; the guard exists to stop the API's own 302 pulling a database
|
|
53
|
+
# into memory, not to stop object storage from moving a bucket.
|
|
54
|
+
#
|
|
55
|
+
# The whole-request timeout is dropped and only the connect phase is bounded.
|
|
56
|
+
# Thirty seconds is a sane ceiling on a catalog read and the wrong one on
|
|
57
|
+
# several gigabytes.
|
|
58
|
+
def storage_request(url)
|
|
59
|
+
options = {
|
|
60
|
+
method: :get,
|
|
61
|
+
headers: { 'User-Agent' => @default_headers['User-Agent'] },
|
|
62
|
+
followlocation: true,
|
|
63
|
+
maxredirs: 5,
|
|
64
|
+
connecttimeout: @config.timeout,
|
|
65
|
+
ssl_verifypeer: @config.verify_ssl,
|
|
66
|
+
ssl_verifyhost: @config.verify_ssl_host ? 2 : 0,
|
|
67
|
+
}
|
|
68
|
+
options[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
|
69
|
+
Typhoeus::Request.new(url, options)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/internetdata.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'internetdata/version'
|
|
4
|
+
|
|
5
|
+
# The wire layer, generated from spec/openapi.yaml by scripts/generate.sh.
|
|
6
|
+
# Models are loaded by glob because the set of them is the generator's to
|
|
7
|
+
# decide; they subclass ApiModelBase and so must follow it.
|
|
8
|
+
require 'internetdata/api_client'
|
|
9
|
+
require 'internetdata/api_error'
|
|
10
|
+
require 'internetdata/api_model_base'
|
|
11
|
+
require 'internetdata/configuration'
|
|
12
|
+
Dir[File.join(__dir__, 'internetdata', 'models', '*.rb')].sort.each { |model| require model }
|
|
13
|
+
Dir[File.join(__dir__, 'internetdata', 'api', '*.rb')].sort.each { |api| require api }
|
|
14
|
+
|
|
15
|
+
require 'internetdata/errors'
|
|
16
|
+
require 'internetdata/retries'
|
|
17
|
+
require 'internetdata/transport'
|
|
18
|
+
require 'internetdata/database_api'
|
|
19
|
+
require 'internetdata/client'
|
|
20
|
+
|
|
21
|
+
# The official Ruby client library for the InternetData API.
|
|
22
|
+
#
|
|
23
|
+
# client = InternetData::Client.new(api_key: ENV['INTERNETDATA_API_KEY'])
|
|
24
|
+
# client.database.download('bogon_ip_v1', 'mmdb', './bogon_ip_v1.mmdb')
|
|
25
|
+
module InternetData
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: internetdata
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mslm Dev
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: typhoeus
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.4'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.4'
|
|
26
|
+
description: Download InternetData IP and ASN databases, and read their metadata,
|
|
27
|
+
checksums and download history.
|
|
28
|
+
email:
|
|
29
|
+
- dev@internetdata.io
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- LICENSE
|
|
35
|
+
- README.md
|
|
36
|
+
- lib/internetdata.rb
|
|
37
|
+
- lib/internetdata/api/database_v2_api.rb
|
|
38
|
+
- lib/internetdata/api_client.rb
|
|
39
|
+
- lib/internetdata/api_error.rb
|
|
40
|
+
- lib/internetdata/api_model_base.rb
|
|
41
|
+
- lib/internetdata/client.rb
|
|
42
|
+
- lib/internetdata/configuration.rb
|
|
43
|
+
- lib/internetdata/database_api.rb
|
|
44
|
+
- lib/internetdata/errors.rb
|
|
45
|
+
- lib/internetdata/models/database.rb
|
|
46
|
+
- lib/internetdata/models/database_checksums_response.rb
|
|
47
|
+
- lib/internetdata/models/database_list.rb
|
|
48
|
+
- lib/internetdata/models/database_metadata.rb
|
|
49
|
+
- lib/internetdata/models/database_metadata_column.rb
|
|
50
|
+
- lib/internetdata/models/database_version.rb
|
|
51
|
+
- lib/internetdata/models/db_checksums.rb
|
|
52
|
+
- lib/internetdata/models/download.rb
|
|
53
|
+
- lib/internetdata/models/download_list.rb
|
|
54
|
+
- lib/internetdata/models/error_envelope.rb
|
|
55
|
+
- lib/internetdata/retries.rb
|
|
56
|
+
- lib/internetdata/transport.rb
|
|
57
|
+
- lib/internetdata/version.rb
|
|
58
|
+
homepage: https://internetdata.io
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata:
|
|
62
|
+
homepage_uri: https://internetdata.io
|
|
63
|
+
source_code_uri: https://github.com/internetdata/sdk-ruby
|
|
64
|
+
bug_tracker_uri: https://github.com/internetdata/sdk-ruby/issues
|
|
65
|
+
changelog_uri: https://github.com/internetdata/sdk-ruby/releases
|
|
66
|
+
documentation_uri: https://docs.internetdata.io
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '3.1'
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
requirements: []
|
|
81
|
+
rubygems_version: 3.6.9
|
|
82
|
+
specification_version: 4
|
|
83
|
+
summary: Official Ruby client library for the InternetData API.
|
|
84
|
+
test_files: []
|