/api/database endpoints.
/api/database endpoints.
Schema for a valid database engine name, e.g. h2
or postgres
.
Schema for a valid database engine name, e.g. `h2` or `postgres`.
## `DELETE /api/database/:id` Delete a `Database`. ##### PARAMS: * **`id`**
Schema for the :schedules
key we add to the response containing 'expanded' versions of the CRON schedules.
This same key is used in reverse to update the schedules.
Schema for the `:schedules` key we add to the response containing 'expanded' versions of the CRON schedules. This same key is used in reverse to update the schedules.
GET /api/database/
Fetch all Databases
. include_tables
means we should hydrate the Tables belonging to each DB. include_cards
here
means we should also include virtual Table entries for saved Questions, e.g. so we can easily use them as source
Tables in queries. Default for both is false
.
include_tables
value may be nil, or if non-nil, value must be a valid boolean string ('true' or 'false').
include_cards
value may be nil, or if non-nil, value must be a valid boolean string ('true' or 'false').
## `GET /api/database/` Fetch all `Databases`. `include_tables` means we should hydrate the Tables belonging to each DB. `include_cards` here means we should also include virtual Table entries for saved Questions, e.g. so we can easily use them as source Tables in queries. Default for both is `false`. ##### PARAMS: * **`include_tables`** value may be nil, or if non-nil, value must be a valid boolean string ('true' or 'false'). * **`include_cards`** value may be nil, or if non-nil, value must be a valid boolean string ('true' or 'false').
## `GET /api/database/:id` Get `Database` with ID. ##### PARAMS: * **`id`**
GET /api/database/:id/autocomplete_suggestions
Return a list of autocomplete suggestions for a given PREFIX.
This is intened for use with the ACE Editor when the User is typing raw SQL.
Suggestions include matching Tables
and Fields
in this Database
.
Tables are returned in the format [table_name "Table"]
;
Fields are returned in the format [field_name "table_name base_type special_type"]
id
prefix
value must be a non-blank string.
## `GET /api/database/:id/autocomplete_suggestions` Return a list of autocomplete suggestions for a given PREFIX. This is intened for use with the ACE Editor when the User is typing raw SQL. Suggestions include matching `Tables` and `Fields` in this `Database`. Tables are returned in the format `[table_name "Table"]`; Fields are returned in the format `[field_name "table_name base_type special_type"]` ##### PARAMS: * **`id`** * **`prefix`** value must be a non-blank string.
## `GET /api/database/:id/fields` Get a list of all `Fields` in `Database`. ##### PARAMS: * **`id`**
## `GET /api/database/:id/idfields` Get a list of all primary key `Fields` for `Database`. ##### PARAMS: * **`id`**
GET /api/database/:id/metadata
Get metadata about a Database
, including all of its Tables
and Fields
.
Returns DB, fields, and field values.
id
## `GET /api/database/:id/metadata` Get metadata about a `Database`, including all of its `Tables` and `Fields`. Returns DB, fields, and field values. ##### PARAMS: * **`id`**
GET /api/database/:id/schema/:schema
Returns a list of tables for the given database id
and schema
id
schema
## `GET /api/database/:id/schema/:schema` Returns a list of tables for the given database `id` and `schema` ##### PARAMS: * **`id`** * **`schema`**
GET /api/database/:id/schemas
Returns a list of all the schemas found for the database id
id
## `GET /api/database/:id/schemas` Returns a list of all the schemas found for the database `id` ##### PARAMS: * **`id`**
GET /api/database/:virtual-db/metadata
Endpoint that provides metadata for the Saved Questions 'virtual' database. Used for fooling the frontend and allowing it to treat the Saved Questions virtual DB just like any other database.
## `GET /api/database/:virtual-db/metadata` Endpoint that provides metadata for the Saved Questions 'virtual' database. Used for fooling the frontend and allowing it to treat the Saved Questions virtual DB just like any other database.
POST /api/database/
Add a new Database
.
You must be a superuser to do this.
name
value must be a non-blank string.
engine
value must be a valid database engine.
details
value must be a map.
is_full_sync
value may be nil, or if non-nil, value must be a boolean.
is_on_demand
value may be nil, or if non-nil, value must be a boolean.
schedules
value may be nil, or if non-nil, value must be a valid map of schedule maps for a DB.
## `POST /api/database/` Add a new `Database`. You must be a superuser to do this. ##### PARAMS: * **`name`** value must be a non-blank string. * **`engine`** value must be a valid database engine. * **`details`** value must be a map. * **`is_full_sync`** value may be nil, or if non-nil, value must be a boolean. * **`is_on_demand`** value may be nil, or if non-nil, value must be a boolean. * **`schedules`** value may be nil, or if non-nil, value must be a valid map of schedule maps for a DB.
POST /api/database/:id/discard_values
Discards all saved field values for this Database
.
You must be a superuser to do this.
id
## `POST /api/database/:id/discard_values` Discards all saved field values for this `Database`. You must be a superuser to do this. ##### PARAMS: * **`id`**
POST /api/database/:id/rescan_values
Trigger a manual scan of the field values for this Database
.
You must be a superuser to do this.
id
## `POST /api/database/:id/rescan_values` Trigger a manual scan of the field values for this `Database`. You must be a superuser to do this. ##### PARAMS: * **`id`**
POST /api/database/:id/sync
Update the metadata for this Database
. This happens asynchronously.
id
## `POST /api/database/:id/sync` Update the metadata for this `Database`. This happens asynchronously. ##### PARAMS: * **`id`**
POST /api/database/:id/sync_schema
Trigger a manual update of the schema metadata for this Database
.
You must be a superuser to do this.
id
## `POST /api/database/:id/sync_schema` Trigger a manual update of the schema metadata for this `Database`. You must be a superuser to do this. ##### PARAMS: * **`id`**
POST /api/database/sample_dataset
Add the sample dataset as a new Database
.
You must be a superuser to do this.
## `POST /api/database/sample_dataset` Add the sample dataset as a new `Database`. You must be a superuser to do this.
POST /api/database/validate
Validate that we can connect to a database given a set of details.
You must be a superuser to do this.
engine
value must be a valid database engine.
details
value must be a map.
## `POST /api/database/validate` Validate that we can connect to a database given a set of details. You must be a superuser to do this. ##### PARAMS: * **`engine`** value must be a valid database engine. * **`details`** value must be a map.
PUT /api/database/:id
Update a Database
.
You must be a superuser to do this.
engine
value may be nil, or if non-nil, value must be a valid database engine.
schedules
value may be nil, or if non-nil, value must be a valid map of schedule maps for a DB.
points_of_interest
value may be nil, or if non-nil, value must be a string.
description
value may be nil, or if non-nil, value must be a string.
name
value may be nil, or if non-nil, value must be a non-blank string.
caveats
value may be nil, or if non-nil, value must be a string.
is_full_sync
details
value may be nil, or if non-nil, value must be a map.
id
is_on_demand
## `PUT /api/database/:id` Update a `Database`. You must be a superuser to do this. ##### PARAMS: * **`engine`** value may be nil, or if non-nil, value must be a valid database engine. * **`schedules`** value may be nil, or if non-nil, value must be a valid map of schedule maps for a DB. * **`points_of_interest`** value may be nil, or if non-nil, value must be a string. * **`description`** value may be nil, or if non-nil, value must be a string. * **`name`** value may be nil, or if non-nil, value must be a non-blank string. * **`caveats`** value may be nil, or if non-nil, value must be a string. * **`is_full_sync`** * **`details`** value may be nil, or if non-nil, value must be a map. * **`id`** * **`is_on_demand`**
Ring routes for api/database: (POST_ PUT_:id POST_:id_discard_values POST_sample_dataset POST_:id_rescan_values POST_validate POST_:id_sync_schema GET_:id_idfields GET_:id_autocomplete_suggestions GET_:id_metadata GET_:id_schema_:schema POST_:id_sync GET_:virtual-db_metadata GET_ GET_:id_schemas GET_:id_fields DELETE_:id GET_:id)
Ring routes for api/database: (POST_ PUT_:id POST_:id_discard_values POST_sample_dataset POST_:id_rescan_values POST_validate POST_:id_sync_schema GET_:id_idfields GET_:id_autocomplete_suggestions GET_:id_metadata GET_:id_schema_:schema POST_:id_sync GET_:virtual-db_metadata GET_ GET_:id_schemas GET_:id_fields DELETE_:id GET_:id)
(schedule-map->cron-strings {:keys [metadata_sync cache_field_values]})
Inputs: [{:keys [metadata_sync cache_field_values]} :- ExpandedSchedulesMap] Returns: CronSchedulesMap
Convert a map of :schedules
as passed in by the frontend to a map of cron strings with the approriate keys for
Database. This map can then be merged directly inserted into the DB, or merged with a map of other columns to
insert/update.
Inputs: [{:keys [metadata_sync cache_field_values]} :- ExpandedSchedulesMap] Returns: CronSchedulesMap Convert a map of `:schedules` as passed in by the frontend to a map of cron strings with the approriate keys for Database. This map can then be merged directly inserted into the DB, or merged with a map of other columns to insert/update.
(test-database-connection engine
{:keys [host port] :as details}
&
{:keys [invalid-response-handler]
:or {invalid-response-handler
invalid-connection-response}})
Try out the connection details for a database and useful error message if connection fails, returns nil
if
connection succeeds.
Try out the connection details for a database and useful error message if connection fails, returns `nil` if connection succeeds.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close