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

source

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.

source

pub fn set_session_id(&mut self, session_id: String)

Sets the session ID to include in future requests made by this client.

source

pub async fn session_properties( &self, ) -> Result<SessionPropertiesResponse, Error>

Fetches public, global properties.

The underlying API call is GET /api/session/properties.

source

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.

source

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.

source

pub async fn databases(&self) -> Result<Vec<Database>, Error>

Fetches the list of databases known to Metabase.

The underlying API call is GET /database.

source

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.

source

pub(crate) fn api_url(&self, endpoint: &[&str]) -> Url

source

pub(crate) async fn send_request<T>( &self, req: RequestBuilder, ) -> Result<T, Error>

Trait Implementations§

source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more