Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .metabase.db/metabase.db.mv.db
Binary file not shown.
28 changes: 28 additions & 0 deletions lib/metabase/endpoint/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ module Database
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
27 changes: 27 additions & 0 deletions spec/metabase/endpoint/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,31 @@
end
end
end

describe 'database', vcr: true do
context 'success' do
it 'returns a database' do
database = client.database(1)
expect(database).to be_kind_of(Hash)
end
end
end

describe 'schemas', vcr: true do
context 'success' do
it 'returns all schemas of a database' do
schemas = client.schemas(1)
expect(schemas).to be_kind_of(Array)
end
end
end

describe 'schema', vcr: true do
context 'success' do
it 'returns all tables of a schema of a database' do
tables = client.schema(1, "PUBLIC")
expect(tables).to be_kind_of(Array)
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading