(bar-chart card {:keys [x-axis y-axis x-label y-label log? stacked?]})
Display as a bar chart, provide at a minimum the x-axis
/y-axis
dimensions.
Takes/returns a Card entity.
Display as a bar chart, provide at a minimum the `x-axis`/`y-axis` dimensions. Takes/returns a Card entity.
(connect {:keys [user password host port https? hato-client connect-timeout
secret-key middleware]
:or {connect-timeout 10000 https? false host "localhost" port 3000}
:as conn-opts})
Create a connection to the Metabase API. This does an authentication call to get a token that is used subsequently. Returns a Connection which wraps a Hato HttpClient instance, endpoint details, the token, and a cache atom to reduce requests.
Defaults to connecting to http://localhost:3000
To create embed urls a :secret-key
is also needed, to be found in the
Metabase embed settings.
Create a connection to the Metabase API. This does an authentication call to get a token that is used subsequently. Returns a Connection which wraps a Hato HttpClient instance, endpoint details, the token, and a cache atom to reduce requests. Defaults to connecting to `http://localhost:3000` To create embed urls a `:secret-key` is also needed, to be found in the Metabase embed settings.
(create-one! conn entity)
Create an entity in Metabase, based on the EDN description. This is a low level
operation, which bypasses caching, and deals with a single entity at a time.
The recommended API is find-or-create!
, which handles caching, and
creating multiple related entities.
entity
is the result of one of the data definition functions
like [[card]], dashboard
, etc.
Create an entity in Metabase, based on the EDN description. This is a low level operation, which bypasses caching, and deals with a single entity at a time. The recommended API is [[find-or-create!]], which handles caching, and creating multiple related entities. `entity` is the result of one of the data definition functions like [[card]], [[dashboard]], etc.
(dashboard {:keys [name cards]})
Data definition of a Dashboard entity.
Data definition of a Dashboard entity.
(dashboard-card {:keys [card card-id x y width height dashboard dashboard-id]
:or {width 10 height 10 x 0 y 0}})
Data definition of a DashboardCard entity
Data definition of a DashboardCard entity
(embed-payload-url conn
payload
{:keys [bordered? titled? filters]
:or {bordered? false titled? false filters {}}
:as opts})
Sign the payload with the :secret-key
from the connection, and use it to
request an embed-url.
Sign the payload with the `:secret-key` from the connection, and use it to request an embed-url.
(embed-url conn resource)
(embed-url conn
resource
{:keys [variables bordered? titled? filters timeout]
:or {timeout 3600 variables {}}
:as opts})
Get an embedding URL for a given resource.
Get an embedding URL for a given resource.
Keys that we add interally to entity maps. Generally we deal with data exactly as the Metabase API expects it and returns, but we add these namespaced keys for additional bookkeeping.
Keys that we add interally to entity maps. Generally we deal with data exactly as the Metabase API expects it and returns, but we add these namespaced keys for additional bookkeeping.
(fetch-all-groups client)
Get groups. Always does a request.
Get groups. Always does a request.
(fetch-all-users client)
Get users. Always does a request.
Get users. Always does a request.
(fetch-database-fields client db-id)
Get all tables/fields for a given db-id. Always does a request.
Get all tables/fields for a given db-id. Always does a request.
(fetch-users client option)
Get users:
When option is :all, then get all the users. Useful for getting all the users. When option is :active, then get only the active users.
Get users: When option is :all, then get all the users. Useful for getting all the users. When option is :active, then get only the active users.
(field-id conn db-name schema table field)
Find the numeric id of a given field in a database/schema/table. Leverages the cache.
Find the numeric id of a given field in a database/schema/table. Leverages the cache.
(find-database conn db-name)
Get a Database resource by name. This means fetching all databases, but the result is cached, so we only re-fetch if the given db-name is not yet present in the cache.
Mainly used for finding the numeric id of the given Database.
Get a Database resource by name. This means fetching all databases, but the result is cached, so we only re-fetch if the given db-name is not yet present in the cache. Mainly used for finding the numeric id of the given Database.
(find-or-create! conn
{:lambdaisland.embedkit/keys [card dashboard-cards]
:as entity})
Idempotently turn an EDN description into one or more Metabase entities.
Combine this function with the result from dashboard
or [[card]] to do the
heavy lifting.
This may create multiple entities, creating a Dashboard will also create (or reuse) Card and DashboardCard entities, and wire them up appropriately.
Entities are cached in a content-addressed in-memory cache, so calling this twice with the same EDN will immediately return the previously created entity.
Only the the in-memory cache is checked, so calling this on a freshly created
connection will always end up creating new entities. It's up to you to call
call populate-cache
after creating your connection, or on a regular basis,
so you can re-use what is already in Metabase.
If there is a cache miss a new entity will be created, even though there may be an entity in Metabase with the same hash that we are simply not aware of. As such this function only attempts to reuse entities, it does not guarantee it.
Idempotently turn an EDN description into one or more Metabase entities. Combine this function with the result from [[dashboard]] or [[card]] to do the heavy lifting. This may create multiple entities, creating a Dashboard will also create (or reuse) Card and DashboardCard entities, and wire them up appropriately. Entities are cached in a content-addressed in-memory cache, so calling this twice with the same EDN will immediately return the previously created entity. Only the the in-memory cache is checked, so calling this on a freshly created connection will always end up creating new entities. It's up to you to call call [[populate-cache]] after creating your connection, or on a regular basis, so you can re-use what is already in Metabase. If there is a cache miss a new entity will be created, even though there may be an entity in Metabase with the same hash that we are simply not aware of. As such this function only attempts to reuse entities, it does not guarantee it.
(group-id conn name)
Find the numeric id of a given group name. Leverages the cache.
Find the numeric id of a given group name. Leverages the cache.
(conn-cache _)
(path-url _ p)
(request _ method url opts)
(secret-key _)
(mb-delete conn path & [opts])
Perform a DELETE request to the Metabase API
Perform a DELETE request to the Metabase API
(mb-get conn path & [opts])
Perform a GET request to the Metabase API. Path can be a string or a vector.
(mb-get conn "/api/cards/6") (mb-get conn [:cards 6])
Perform a GET request to the Metabase API. Path can be a string or a vector. (mb-get conn "/api/cards/6") (mb-get conn [:cards 6])
(mb-post conn path & [opts])
Perform a POST request to the Metabase API
Perform a POST request to the Metabase API
(mb-put conn path & [opts])
Perform a PUT request to the Metabase API
Perform a PUT request to the Metabase API
(native-card
{:keys [name database sql display variables] :or {display "table"} :as opts})
Data definition of a native query. Returns a Card resource that can be passed to create!
.
:name
Name for this query:database
The metabase DB id:sql
The native query, as string or as honeysql query map. Can contain {{variable}}
placeholders.:display
How to visualize the result, e.g. "table"
:variables
Variables used in the native query, as a map from varname to options mapData definition of a native query. Returns a Card resource that can be passed to `create!`. - `:name` Name for this query - `:database` The metabase DB id - `:sql` The native query, as string or as honeysql query map. Can contain `{{variable}}` placeholders. - `:display` How to visualize the result, e.g. `"table"` - `:variables` Variables used in the native query, as a map from varname to options map
(populate-cache conn)
Fetch all existing cards and databases from Metabase, and add them to the
per-connection in-memory content addressed cache. Do this after creating your
connection but before calling find-or-create!
, to limit the number of
duplicate entities that are created. With a warmed up cache you can safely
call find-or-create!
repeatedly with the same arguments without fear of
causing an explosion of entities in Metabase.
Fetch all existing cards and databases from Metabase, and add them to the per-connection in-memory content addressed cache. Do this after creating your connection but before calling [[find-or-create!]], to limit the number of duplicate entities that are created. With a warmed up cache you can safely call [[find-or-create!]] repeatedly with the same arguments without fear of causing an explosion of entities in Metabase.
(resource-path {:lambdaisland.embedkit/keys [type dashboard-id] :keys [id]})
Get the API path (in vector representation) for a given resource.
Get the API path (in vector representation) for a given resource.
(table-id conn db-name schema table)
Find the numeric id of a given table in a database/schema. Leverages the cache.
Find the numeric id of a given table in a database/schema. Leverages the cache.
(trigger-db-fn! conn db-name db-fn-link)
When success, return ...
When success, return ...
(user-id conn email)
Find the numeric id of a given user email Leverages the cache.
Find the numeric id of a given user email Leverages the cache.
(viz-settings card settings)
Set a card's visualization settings, takes nested maps.
Set a card's visualization settings, takes nested maps.
(wrap-paginate f page-size)
(wrap-paginate f page-size error-logger)
Decorator of the normal mb-get
function
This decorator will create a new version of mb-get
which will collect all
the results of each page and return the concatenated list of [:body :data]
Note: error-logger
can be nil
Decorator of the normal `mb-get` function This decorator will create a new version of `mb-get` which will collect all the results of each page and return the concatenated list of `[:body :data]` Note: `error-logger` can be nil
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close