Struct MetabaseClient

Source
pub struct MetabaseClient { /* private fields */ }
Expand description

The main client for interacting with Metabase API

Implementations§

Source§

impl MetabaseClient

Source

pub fn new(base_url: impl Into<String>) -> Result<Self>

Creates a new MetabaseClient instance

Source

pub fn base_url(&self) -> &str

Gets the base URL of the client

Source

pub fn is_authenticated(&self) -> bool

Checks if the client is authenticated

Source

pub fn is_cache_enabled(&self) -> bool

Checks if cache is enabled (always false when cache feature is disabled)

Source

pub fn set_cache_enabled(&mut self, _enabled: bool)

Sets the cache enabled state (no-op when cache feature is disabled)

Source

pub async fn authenticate(&mut self, credentials: Credentials) -> Result<()>

Authenticates with the Metabase API

Source

pub async fn logout(&mut self) -> Result<()>

Logs out from the Metabase API

Source

pub async fn health_check(&self) -> Result<HealthStatus>

Performs a health check on the Metabase API

Source

pub async fn get_current_user(&self) -> Result<User>

Gets the current authenticated user

Source

pub async fn get_card(&self, id: i64) -> Result<Card>

Gets a card by ID

Source

pub async fn list_cards( &self, params: Option<CardListParams>, ) -> Result<Vec<Card>>

Lists all cards

Source

pub async fn create_card(&self, card: Card) -> Result<Card>

Creates a new card

Source

pub async fn update_card(&self, id: i64, updates: Value) -> Result<Card>

Updates an existing card

Source

pub async fn delete_card(&self, id: i64) -> Result<()>

Deletes a card

Source

pub async fn get_collection(&self, id: MetabaseId) -> Result<Collection>

Gets a collection by ID

Source

pub async fn list_collections(&self) -> Result<Vec<Collection>>

Lists all collections

Source

pub async fn create_collection( &self, collection: Collection, ) -> Result<Collection>

Creates a new collection

Source

pub async fn update_collection( &self, id: MetabaseId, updates: Value, ) -> Result<Collection>

Updates an existing collection

Source

pub async fn archive_collection(&self, id: MetabaseId) -> Result<Collection>

Archives a collection (Metabase doesn’t delete, only archives)

Source

pub async fn get_dashboard(&self, id: MetabaseId) -> Result<Dashboard>

Gets a dashboard by ID

Source

pub async fn list_dashboards( &self, pagination: Option<Pagination>, ) -> Result<Vec<Dashboard>>

Lists all dashboards

Source

pub async fn create_dashboard(&self, dashboard: Dashboard) -> Result<Dashboard>

Creates a new dashboard

Source

pub async fn update_dashboard( &self, id: MetabaseId, updates: Value, ) -> Result<Dashboard>

Updates an existing dashboard

Source

pub async fn delete_dashboard(&self, id: MetabaseId) -> Result<()>

Deletes a dashboard

Source

pub async fn execute_query(&self, query: DatasetQuery) -> Result<QueryResult>

Executes a dataset query

Source

pub async fn execute_native_query( &self, database: MetabaseId, native_query: NativeQuery, ) -> Result<QueryResult>

Executes a native SQL query

Source

pub async fn execute_card_query( &self, card_id: i64, parameters: Option<Value>, ) -> Result<QueryResult>

Execute a card’s query with optional parameters

Source

pub async fn export_card_query( &self, card_id: i64, format: ExportFormat, parameters: Option<Value>, ) -> Result<Vec<u8>>

Export card query results in specified format

Source

pub async fn execute_card_pivot_query( &self, card_id: i64, parameters: Option<Value>, ) -> Result<QueryResult>

Execute a pivot query for a card

Source

pub async fn get_database_metadata( &self, database_id: MetabaseId, ) -> Result<DatabaseMetadata>

Get database metadata including tables and fields

Source

pub async fn sync_database_schema( &self, database_id: MetabaseId, ) -> Result<SyncResult>

Sync database schema

Source

pub async fn get_database_fields( &self, database_id: MetabaseId, ) -> Result<Vec<Field>>

Get all fields for a database

Source

pub async fn get_database_schemas( &self, database_id: MetabaseId, ) -> Result<Vec<String>>

Get all schemas for a database

Source

pub async fn execute_dataset_query(&self, query: Value) -> Result<QueryResult>

Execute a dataset query with advanced options

Source

pub async fn execute_dataset_native(&self, query: Value) -> Result<QueryResult>

Execute a native query through the dataset endpoint

Source

pub async fn execute_dataset_pivot(&self, query: Value) -> Result<QueryResult>

Execute a pivot dataset query

Source

pub async fn export_dataset( &self, format: ExportFormat, query: Value, ) -> Result<Vec<u8>>

Export dataset query results

Source

pub async fn execute_sql( &self, database_id: MetabaseId, sql: &str, ) -> Result<QueryResult>

Execute a simple SQL query

Source

pub async fn execute_sql_with_params( &self, database_id: MetabaseId, sql: &str, params: HashMap<String, Value>, ) -> Result<QueryResult>

Execute a parameterized SQL query

Source

pub async fn export_sql_query( &self, database_id: MetabaseId, sql: &str, format: ExportFormat, ) -> Result<Vec<u8>>

Export SQL query results in specified format

Trait Implementations§

Source§

impl Clone for MetabaseClient

Source§

fn clone(&self) -> MetabaseClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,