metabase 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81b474ef16616cede8c43fbf52bf63a392d8ebc2ae1f6b293045b667b934690c
4
- data.tar.gz: ee3d20b64a53e2572c770daff55fdf70b4e225678be2c8192b3ba58131ec605b
3
+ metadata.gz: 1783bf9b1eeb771207cbee0e3198a6e66713558f2e9c9eeffddf8866f45f0b68
4
+ data.tar.gz: e2c0da8ff794d3e93381dfd816b9b42aa5cdb0e21cac991fe7cf131072973d78
5
5
  SHA512:
6
- metadata.gz: d92204e8e4bf684909bed8219eb4374a8704e8d14a29ecd5a16d44abc4c1e8517f05f9c0bdcb39cc6a263cedc7d470ba277d0c28e5c2358cdfb44b1289955f4a
7
- data.tar.gz: 984a2550d9a3912e840629ab0268e8f0df0635d129ff5dbcf40a346d26758f97e36ed571a79b538efe35fe46bcccaf1f55857088ea9a61163f396b3cb30afb84
6
+ metadata.gz: b5f72ac62d1d37245508ebc87a8663337f9449b62911e25f8a2f985c7a72204bf97d5cfe71f45c5d27fb7b3bce08185d42c21df4436a296ddc8a64e143d52ccf
7
+ data.tar.gz: addc0a5aabbebc2e8188df851090120b5d1de9333bafb904309d3257bffa8ce21db78e371a969e7346b16e1b9deb008a794b522e42ab192f15419367d74d9584
@@ -0,0 +1,3 @@
1
+ 2020-06-07 05:19:25 jdbc[5]: exception
2
+ org.h2.jdbc.JdbcSQLException: Table "DATABASECHANGELOGLOCK" not found; SQL statement:
3
+ SELECT COUNT(*) FROM PUBLIC.DATABASECHANGELOGLOCK [42102-197]
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 3.0
3
4
  - 2.7
4
5
  - 2.6
5
6
  - 2.5
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metabase (0.4.0)
5
- faraday (>= 0.8)
4
+ metabase (0.5.0)
5
+ faraday (>= 1.2.0)
6
6
  faraday_middleware
7
7
 
8
8
  GEM
@@ -10,69 +10,74 @@ GEM
10
10
  specs:
11
11
  addressable (2.7.0)
12
12
  public_suffix (>= 2.0.2, < 5.0)
13
- amazing_print (1.1.0)
14
- ast (2.4.0)
15
- bump (0.9.0)
13
+ amazing_print (1.2.2)
14
+ ast (2.4.1)
15
+ bump (0.10.0)
16
16
  coderay (1.1.3)
17
- crack (0.4.3)
18
- safe_yaml (~> 1.0.0)
19
- diff-lcs (1.3)
20
- docile (1.3.2)
21
- faraday (1.0.1)
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.4.4)
20
+ docile (1.3.4)
21
+ faraday (1.3.0)
22
+ faraday-net_http (~> 1.0)
22
23
  multipart-post (>= 1.2, < 3)
24
+ ruby2_keywords
25
+ faraday-net_http (1.0.1)
23
26
  faraday_middleware (1.0.0)
24
27
  faraday (~> 1.0)
25
28
  hashdiff (1.0.1)
26
29
  method_source (1.0.0)
27
30
  multipart-post (2.1.1)
28
- parallel (1.19.1)
29
- parser (2.7.1.3)
30
- ast (~> 2.4.0)
31
+ parallel (1.20.1)
32
+ parser (3.0.0.0)
33
+ ast (~> 2.4.1)
31
34
  pry (0.13.1)
32
35
  coderay (~> 1.1)
33
36
  method_source (~> 1.0)
34
- public_suffix (4.0.5)
37
+ public_suffix (4.0.6)
35
38
  rainbow (3.0.0)
36
- rake (13.0.1)
37
- regexp_parser (1.7.0)
39
+ rake (13.0.3)
40
+ regexp_parser (2.0.3)
38
41
  rexml (3.2.4)
39
- rspec (3.9.0)
40
- rspec-core (~> 3.9.0)
41
- rspec-expectations (~> 3.9.0)
42
- rspec-mocks (~> 3.9.0)
43
- rspec-core (3.9.2)
44
- rspec-support (~> 3.9.3)
45
- rspec-expectations (3.9.2)
42
+ rspec (3.10.0)
43
+ rspec-core (~> 3.10.0)
44
+ rspec-expectations (~> 3.10.0)
45
+ rspec-mocks (~> 3.10.0)
46
+ rspec-core (3.10.1)
47
+ rspec-support (~> 3.10.0)
48
+ rspec-expectations (3.10.1)
46
49
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-mocks (3.9.1)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-mocks (3.10.1)
49
52
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.9.0)
51
- rspec-support (3.9.3)
52
- rubocop (0.85.0)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-support (3.10.1)
55
+ rubocop (1.8.1)
53
56
  parallel (~> 1.10)
54
- parser (>= 2.7.0.1)
57
+ parser (>= 3.0.0.0)
55
58
  rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 1.7)
59
+ regexp_parser (>= 1.8, < 3.0)
57
60
  rexml
58
- rubocop-ast (>= 0.0.3)
61
+ rubocop-ast (>= 1.2.0, < 2.0)
59
62
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-ast (0.0.3)
62
- parser (>= 2.7.0.1)
63
- ruby-progressbar (1.10.1)
64
- safe_yaml (1.0.5)
65
- simplecov (0.18.5)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
64
+ rubocop-ast (1.4.0)
65
+ parser (>= 2.7.1.5)
66
+ ruby-progressbar (1.11.0)
67
+ ruby2_keywords (0.0.2)
68
+ simplecov (0.21.2)
66
69
  docile (~> 1.1)
67
70
  simplecov-html (~> 0.11)
68
- simplecov-html (0.12.2)
69
- unicode-display_width (1.7.0)
71
+ simplecov_json_formatter (~> 0.1)
72
+ simplecov-html (0.12.3)
73
+ simplecov_json_formatter (0.1.2)
74
+ unicode-display_width (2.0.0)
70
75
  vcr (6.0.0)
71
- webmock (3.8.3)
76
+ webmock (3.11.0)
72
77
  addressable (>= 2.3.6)
73
78
  crack (>= 0.3.2)
74
79
  hashdiff (>= 0.4.0, < 2.0.0)
75
- yard (0.9.25)
80
+ yard (0.9.26)
76
81
 
77
82
  PLATFORMS
78
83
  ruby
data/README.md CHANGED
@@ -71,6 +71,8 @@ client.query_public_card(card_uuid, format: :csv)
71
71
 
72
72
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
73
73
 
74
+ When adding a new endpoint, run `docker-compose up` to start a local Metabase and run `rake spec`. API responses are recorded by [VCR](https://github.com/vcr/vcr). Commit Metabase database to the repository as well.
75
+
74
76
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
75
77
 
76
78
  ## Contributing
@@ -1,29 +1,8 @@
1
1
  version: '3'
2
2
  services:
3
3
  metabase:
4
- image: metabase/metabase:v0.30.3
5
- environment:
6
- MB_DB_TYPE: postgres
7
- MB_DB_DBNAME: metabase
8
- MB_DB_PORT: 5432
9
- MB_DB_USER: postgres
10
- MB_DB_PASS: NOmEh1tcxKojeDAY6bV5icFpuhEp0xUkhykvynNTPc7bTiOKIyjk2O3IYmEmvfIK
11
- MB_DB_HOST: db
12
- MB_PASSWORD_COMPLEXITY: normal
13
- MB_PASSWORD_LENGTH: 8
14
- MB_ENCRYPTION_SECRET_KEY: JjN8BPWVlGoDTtifSbgP12GC8wsVUQni3nocbhiCsEgIldsmGNn6yRrqZDMJSQxO
4
+ image: metabase/metabase:v0.35.4
15
5
  ports:
16
6
  - 3030:3000
17
- depends_on:
18
- - db
19
-
20
- db:
21
- image: postgres:10-alpine
22
- environment:
23
- POSTGRES_DB: metabase
24
- POSTGRES_PASSWORD: NOmEh1tcxKojeDAY6bV5icFpuhEp0xUkhykvynNTPc7bTiOKIyjk2O3IYmEmvfIK
25
7
  volumes:
26
- - postgres:/var/lib/postgresql/data
27
-
28
- volumes:
29
- postgres:
8
+ - .metabase.db:/metabase.db:cached
@@ -29,8 +29,11 @@ module Metabase
29
29
  private
30
30
 
31
31
  def request(method, path, params)
32
+ headers = params.delete(:headers)
33
+
32
34
  response = connection.public_send(method, path, params) do |request|
33
35
  request.headers['X-Metabase-Session'] = @token if @token
36
+ headers&.each_pair { |k, v| request.headers[k] = v }
34
37
  end
35
38
 
36
39
  error = Error.from_response(response)
@@ -41,8 +44,9 @@ module Metabase
41
44
 
42
45
  def connection
43
46
  @connection ||= Faraday.new(url: @url) do |c|
44
- c.request :json
47
+ c.request :json, content_type: /\bjson$/
45
48
  c.response :json, content_type: /\bjson$/
49
+ c.request :url_encoded, content_type: /x-www-form-urlencoded/
46
50
  c.adapter Faraday.default_adapter
47
51
  c.headers['User-Agent'] =
48
52
  "MetabaseRuby/#{VERSION} (#{RUBY_ENGINE}#{RUBY_VERSION})"
@@ -7,6 +7,7 @@ require 'metabase/endpoint/card'
7
7
  require 'metabase/endpoint/collection'
8
8
  require 'metabase/endpoint/dashboard'
9
9
  require 'metabase/endpoint/database'
10
+ require 'metabase/endpoint/dataset'
10
11
  require 'metabase/endpoint/metric'
11
12
  require 'metabase/endpoint/permissions'
12
13
  require 'metabase/endpoint/public'
@@ -30,6 +31,7 @@ module Metabase
30
31
  include Collection
31
32
  include Dashboard
32
33
  include Database
34
+ include Dataset
33
35
  include Metric
34
36
  include Permissions
35
37
  include Public
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metabase
4
+ module Endpoint
5
+ module Dataset
6
+ # Execute a query and retrieve the results in the usual format.
7
+ #
8
+ # @param query [Hash] Query. {query: 'JSON String'}
9
+ # @param format [Symbol, String] Export format (api, csv, json, xlsx)
10
+ # @return [Array<Hash>] Query results
11
+ # @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apidatasetexport-format
12
+ def query_dataset(format: :json, **params)
13
+ params.merge!({ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
14
+ post("/api/dataset/#{format}", **params)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -34,13 +34,20 @@ module Metabase
34
34
  end
35
35
 
36
36
  class ClientError < Error; end
37
+
37
38
  class BadRequest < Error; end
39
+
38
40
  class Unauthorized < Error; end
41
+
39
42
  class Forbidden < Error; end
43
+
40
44
  class NotFound < Error; end
41
45
 
42
46
  class ServerError < Error; end
47
+
43
48
  class InternalServerError < Error; end
49
+
44
50
  class BadGateway < Error; end
51
+
45
52
  class ServiceUnavailable < Error; end
46
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metabase
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '>= 2.5'
26
26
 
27
- spec.add_runtime_dependency 'faraday', '>= 0.8'
27
+ spec.add_runtime_dependency 'faraday', '>= 1.2.0'
28
28
  spec.add_runtime_dependency 'faraday_middleware'
29
29
 
30
30
  spec.add_development_dependency 'amazing_print'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metabase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Shimoju
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-07 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.8'
19
+ version: 1.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.8'
26
+ version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -200,6 +200,8 @@ extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
202
  - ".gitignore"
203
+ - ".metabase.db/metabase.db.mv.db"
204
+ - ".metabase.db/metabase.db.trace.db"
203
205
  - ".rspec"
204
206
  - ".rubocop.yml"
205
207
  - ".travis.yml"
@@ -222,6 +224,7 @@ files:
222
224
  - lib/metabase/endpoint/collection.rb
223
225
  - lib/metabase/endpoint/dashboard.rb
224
226
  - lib/metabase/endpoint/database.rb
227
+ - lib/metabase/endpoint/dataset.rb
225
228
  - lib/metabase/endpoint/metric.rb
226
229
  - lib/metabase/endpoint/permissions.rb
227
230
  - lib/metabase/endpoint/public.rb
@@ -257,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
260
  - !ruby/object:Gem::Version
258
261
  version: '0'
259
262
  requirements: []
260
- rubygems_version: 3.1.2
263
+ rubygems_version: 3.1.4
261
264
  signing_key:
262
265
  specification_version: 4
263
266
  summary: Ruby client library for Metabase API