Struct mz_metabase::Client
source · pub struct Client {
pub(crate) inner: Client,
pub(crate) url: Url,
pub(crate) session_id: Option<String>,
}
Expand description
A Metabase API client.
Fields§
§inner: Client
§url: Url
§session_id: Option<String>
Implementations§
source§impl Client
impl Client
sourcepub fn new<U>(url: U) -> Result<Self, Error>where
U: IntoUrl,
pub fn new<U>(url: U) -> Result<Self, Error>where
U: IntoUrl,
Constructs a new Client
that will target a Metabase instance at url
.
url
must not contain a path nor be a cannot-be-a-base URL.
sourcepub fn set_session_id(&mut self, session_id: String)
pub fn set_session_id(&mut self, session_id: String)
Sets the session ID to include in future requests made by this client.
sourcepub async fn session_properties(
&self,
) -> Result<SessionPropertiesResponse, Error>
pub async fn session_properties( &self, ) -> Result<SessionPropertiesResponse, Error>
Fetches public, global properties.
The underlying API call is GET /api/session/properties
.
sourcepub async fn login(
&self,
request: &LoginRequest,
) -> Result<LoginResponse, Error>
pub async fn login( &self, request: &LoginRequest, ) -> Result<LoginResponse, Error>
Requests a session ID for the username and password named in request
.
Note that usernames are typically email addresses. To authenticate
future requests with the returned session ID, call set_session_id
.
The underlying API call is POST /api/session
.
sourcepub async fn setup(
&self,
request: &SetupRequest,
) -> Result<LoginResponse, Error>
pub async fn setup( &self, request: &SetupRequest, ) -> Result<LoginResponse, Error>
Creates a user and database connection if the Metabase instance has not yet been set up.
The request must include the setup_token
from a
SessionPropertiesResponse
. If the setup token returned by
Client::session_properties
is None
, the cluster is already set up,
and this request will fail.
The underlying API call is POST /api/setup
.
sourcepub async fn databases(&self) -> Result<Vec<Database>, Error>
pub async fn databases(&self) -> Result<Vec<Database>, Error>
Fetches the list of databases known to Metabase.
The underlying API call is GET /database
.
sourcepub async fn database_metadata(
&self,
id: usize,
) -> Result<DatabaseMetadata, Error>
pub async fn database_metadata( &self, id: usize, ) -> Result<DatabaseMetadata, Error>
Fetches metadata about a particular database.
The underlying API call is GET /database/:id/metadata
.