pub struct Client { /* private fields */ }
Expand description
The client to influxdb
Implementations§
Source§impl Client
impl Client
Sourcepub fn new_with_client<T>(host: Url, db: T, client: HttpClient) -> Self
pub fn new_with_client<T>(host: Url, db: T, client: HttpClient) -> Self
Create a new influxdb client with custom reqwest’s client.
Sourcepub fn switch_database<T>(&mut self, database: T)
pub fn switch_database<T>(&mut self, database: T)
Change the client’s database
Sourcepub fn set_authentication<T>(self, user: T, passwd: T) -> Self
pub fn set_authentication<T>(self, user: T, passwd: T) -> Self
Change the client’s user
Sourcepub fn set_jwt_token<T>(self, token: T) -> Self
pub fn set_jwt_token<T>(self, token: T) -> Self
Set the client’s jwt token
Sourcepub fn ping(&self) -> impl Future<Output = bool>
pub fn ping(&self) -> impl Future<Output = bool>
Query whether the corresponding database exists, return bool
Sourcepub fn get_version(&self) -> impl Future<Output = Option<String>>
pub fn get_version(&self) -> impl Future<Output = Option<String>>
Query the version of the database and return the version number
Sourcepub fn write_point<'a>(
&self,
point: Point<'a>,
precision: Option<Precision>,
rp: Option<&str>,
) -> impl Future<Output = Result<(), Error>> + 'a
pub fn write_point<'a>( &self, point: Point<'a>, precision: Option<Precision>, rp: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + 'a
Write a point to the database
Sourcepub fn write_points<'a, T: IntoIterator<Item = impl Borrow<Point<'a>>>>(
&self,
points: T,
precision: Option<Precision>,
rp: Option<&str>,
) -> impl Future<Output = Result<(), Error>>
pub fn write_points<'a, T: IntoIterator<Item = impl Borrow<Point<'a>>>>( &self, points: T, precision: Option<Precision>, rp: Option<&str>, ) -> impl Future<Output = Result<(), Error>>
Write multiple points to the database
Sourcepub fn query(
&self,
q: &str,
epoch: Option<Precision>,
) -> impl Future<Output = Result<Option<Vec<Node>>, Error>>
pub fn query( &self, q: &str, epoch: Option<Precision>, ) -> impl Future<Output = Result<Option<Vec<Node>>, Error>>
Query and return data, the data type is Option<Vec<Node>>
Sourcepub fn query_chunked(
&self,
q: &str,
epoch: Option<Precision>,
) -> impl Future<Output = Result<ChunkedQuery<'static, IoRead<Cursor<Bytes>>>, Error>>
pub fn query_chunked( &self, q: &str, epoch: Option<Precision>, ) -> impl Future<Output = Result<ChunkedQuery<'static, IoRead<Cursor<Bytes>>>, Error>>
Query and return data, the data type is Option<Vec<Node>>
Sourcepub fn drop_measurement(
&self,
measurement: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn drop_measurement( &self, measurement: &str, ) -> impl Future<Output = Result<(), Error>>
Drop measurement
Sourcepub fn create_database(
&self,
dbname: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn create_database( &self, dbname: &str, ) -> impl Future<Output = Result<(), Error>>
Create a new database in InfluxDB.
Sourcepub fn drop_database(
&self,
dbname: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn drop_database( &self, dbname: &str, ) -> impl Future<Output = Result<(), Error>>
Drop a database from InfluxDB.
Sourcepub fn create_user(
&self,
user: &str,
passwd: &str,
admin: bool,
) -> impl Future<Output = Result<(), Error>>
pub fn create_user( &self, user: &str, passwd: &str, admin: bool, ) -> impl Future<Output = Result<(), Error>>
Create a new user in InfluxDB.
Sourcepub fn drop_user(&self, user: &str) -> impl Future<Output = Result<(), Error>>
pub fn drop_user(&self, user: &str) -> impl Future<Output = Result<(), Error>>
Drop a user from InfluxDB.
Sourcepub fn set_user_password(
&self,
user: &str,
passwd: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn set_user_password( &self, user: &str, passwd: &str, ) -> impl Future<Output = Result<(), Error>>
Change the password of an existing user.
Sourcepub fn grant_admin_privileges(
&self,
user: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn grant_admin_privileges( &self, user: &str, ) -> impl Future<Output = Result<(), Error>>
Grant cluster administration privileges to a user.
Sourcepub fn revoke_admin_privileges(
&self,
user: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn revoke_admin_privileges( &self, user: &str, ) -> impl Future<Output = Result<(), Error>>
Revoke cluster administration privileges from a user.
Sourcepub fn grant_privilege(
&self,
user: &str,
db: &str,
privilege: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn grant_privilege( &self, user: &str, db: &str, privilege: &str, ) -> impl Future<Output = Result<(), Error>>
Grant a privilege on a database to a user. :param privilege: the privilege to grant, one of ‘read’, ‘write’ or ‘all’. The string is case-insensitive
Sourcepub fn revoke_privilege(
&self,
user: &str,
db: &str,
privilege: &str,
) -> impl Future<Output = Result<(), Error>>
pub fn revoke_privilege( &self, user: &str, db: &str, privilege: &str, ) -> impl Future<Output = Result<(), Error>>
Revoke a privilege on a database from a user. :param privilege: the privilege to grant, one of ‘read’, ‘write’ or ‘all’. The string is case-insensitive
Sourcepub fn create_retention_policy(
&self,
name: &str,
duration: &str,
replication: &str,
default: bool,
db: Option<&str>,
) -> impl Future<Output = Result<(), Error>>
pub fn create_retention_policy( &self, name: &str, duration: &str, replication: &str, default: bool, db: Option<&str>, ) -> impl Future<Output = Result<(), Error>>
Create a retention policy for a database. :param duration: the duration of the new retention policy. Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported and mean 1 hour, 90 minutes, 12 hours, 7 day, and 4 weeks, respectively. For infinite retention – meaning the data will never be deleted – use ‘INF’ for duration. The minimum retention period is 1 hour.