-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.rb
More file actions
44 lines (40 loc) · 1.32 KB
/
database.rb
File metadata and controls
44 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
module Metabase
module Endpoint
module Database
# Fetch all databases.
#
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apidatabase
def databases(**params)
get('/api/database', **params)
end
# Fetch a database.
#
# @param database_id [Integer, String] Database ID
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
def database(database_id, **params)
get("/api/database/#{database_id}", **params)
end
# Fetch schemas of a database.
#
# @param database_id [Integer, String] Database ID
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
def schemas(database_id)
get("/api/database/#{database_id}/schemas")
end
# Fetch tables of a schema of a database.
#
# @param database_id [Integer, String] Database ID
# @param schema [String] Schema name
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
def schema(database_id, schema)
get("/api/database/#{database_id}/schema/#{schema}")
end
end
end
end