Liking cljdoc? Tell your friends :D

lambdaisland.embedkit


bar-chartclj

(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.
sourceraw docstring

connectclj

(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.
sourceraw docstring

create-one!clj

(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.
sourceraw docstring

dashboardclj

(dashboard {:keys [name cards]})

Data definition of a Dashboard entity.

Data definition of a Dashboard entity.
sourceraw docstring

dashboard-cardclj

(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
sourceraw docstring

default-pagination-sizeclj

source

embed-payload-urlclj

(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.
sourceraw docstring

embed-urlclj

(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.
sourceraw docstring

embedkit-keysclj

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. 
sourceraw docstring

fetch-all-groupsclj

(fetch-all-groups client)

Get groups. Always does a request.

Get groups. Always does a request.
sourceraw docstring

fetch-all-usersclj

(fetch-all-users client)

Get users. Always does a request.

Get users. Always does a request.
sourceraw docstring

fetch-database-fieldsclj

(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.
sourceraw docstring

fetch-usersclj

(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.
sourceraw docstring

field-idclj

(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.
sourceraw docstring

find-databaseclj

(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.
sourceraw docstring

find-or-create!clj

(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.
sourceraw docstring

group-idclj

(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.
sourceraw docstring

IConnectioncljprotocol

conn-cacheclj

(conn-cache _)

path-urlclj

(path-url _ p)

requestclj

(request _ method url opts)

secret-keyclj

(secret-key _)
source

mb-deleteclj

(mb-delete conn path & [opts])

Perform a DELETE request to the Metabase API

Perform a DELETE request to the Metabase API
sourceraw docstring

mb-getclj

(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])
sourceraw docstring

mb-postclj

(mb-post conn path & [opts])

Perform a POST request to the Metabase API

Perform a POST request to the Metabase API
sourceraw docstring

mb-putclj

(mb-put conn path & [opts])

Perform a PUT request to the Metabase API

Perform a PUT request to the Metabase API
sourceraw docstring

mb-requestclj

(mb-request verb conn path opts)
source

native-cardclj

(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 map
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 map
sourceraw docstring

populate-cacheclj

(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.
sourceraw docstring

resource-pathclj

(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.
sourceraw docstring

table-idclj

(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.
sourceraw docstring

trigger-db-fn!clj

(trigger-db-fn! conn db-name db-fn-link)

When success, return ...

When success, return ... 
sourceraw docstring

user-idclj

(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.
sourceraw docstring

viz-settingsclj

(viz-settings card settings)

Set a card's visualization settings, takes nested maps.

Set a card's visualization settings, takes nested maps.
sourceraw docstring

with-cachecljmacro

(with-cache conn path & body)
source

with-refresh-authcljmacro

(with-refresh-auth conn & body)
source

wrap-paginateclj

(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
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close