Struct influx_db_client::client::Client
source · pub struct Client { /* private fields */ }
Expand description
The client to influxdb
Implementations§
source§impl Client
impl Client
sourcepub fn new_with_option<T: ToString>(
host: T,
db: T,
tls_option: Option<TLSOption>
) -> Self
pub fn new_with_option<T: ToString>(
host: T,
db: T,
tls_option: Option<TLSOption>
) -> Self
Create a new influxdb client with https
sourcepub fn set_read_timeout(&mut self, timeout: u64)
pub fn set_read_timeout(&mut self, timeout: u64)
Set the read timeout value, unit “s”
sourcepub fn set_write_timeout(&mut self, timeout: u64)
pub fn set_write_timeout(&mut self, timeout: u64)
Set the write timeout value, unit “s”
sourcepub fn switch_database<T>(&mut self, database: T)where
T: ToString,
pub fn switch_database<T>(&mut self, database: T)where
T: ToString,
Change the client’s database
sourcepub fn set_authentication<T>(self, user: T, passwd: T) -> Selfwhere
T: Into<String>,
pub fn set_authentication<T>(self, user: T, passwd: T) -> Selfwhere
T: Into<String>,
Change the client’s user
sourcepub fn set_tls(self, connector: Option<TLSOption>) -> Self
pub fn set_tls(self, connector: Option<TLSOption>) -> Self
Change http to https, but don’t leave the read write timeout setting
sourcepub fn get_version(&self) -> Option<String>
pub fn get_version(&self) -> Option<String>
Query the version of the database and return the version number
sourcepub fn write_point(
&self,
point: Point,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<(), Error>
pub fn write_point(
&self,
point: Point,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<(), Error>
Write a point to the database
sourcepub fn write_points<T: Iterator<Item = Point>>(
&self,
points: T,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<(), Error>
pub fn write_points<T: Iterator<Item = Point>>(
&self,
points: T,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<(), Error>
Write multiple points to the database
sourcepub fn query(
&self,
q: &str,
epoch: Option<Precision>
) -> Result<Option<Vec<Node>>, Error>
pub fn query(
&self,
q: &str,
epoch: Option<Precision>
) -> 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>
) -> Result<ChunkedQuery<'_, SerdeIoRead<Response>>, Error>
pub fn query_chunked(
&self,
q: &str,
epoch: Option<Precision>
) -> Result<ChunkedQuery<'_, SerdeIoRead<Response>>, Error>
Query and return data, the data type is Option<Vec<Node>>
sourcepub fn create_database(&self, dbname: &str) -> Result<(), Error>
pub fn create_database(&self, dbname: &str) -> Result<(), Error>
Create a new database in InfluxDB.
sourcepub fn create_user(
&self,
user: &str,
passwd: &str,
admin: bool
) -> Result<(), Error>
pub fn create_user(
&self,
user: &str,
passwd: &str,
admin: bool
) -> Result<(), Error>
Create a new user in InfluxDB.
sourcepub fn set_user_password(&self, user: &str, passwd: &str) -> Result<(), Error>
pub fn set_user_password(&self, user: &str, passwd: &str) -> Result<(), Error>
Change the password of an existing user.
sourcepub fn grant_admin_privileges(&self, user: &str) -> Result<(), Error>
pub fn grant_admin_privileges(&self, user: &str) -> Result<(), Error>
Grant cluster administration privileges to a user.
sourcepub fn revoke_admin_privileges(&self, user: &str) -> Result<(), Error>
pub fn revoke_admin_privileges(&self, user: &str) -> Result<(), Error>
Revoke cluster administration privileges from a user.
sourcepub fn grant_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> Result<(), Error>
pub fn grant_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> 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
) -> Result<(), Error>
pub fn revoke_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> 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>
) -> Result<(), Error>
pub fn create_retention_policy(
&self,
name: &str,
duration: &str,
replication: &str,
default: bool,
db: Option<&str>
) -> 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.