Trait influx_db_client::InfluxClient
[−]
[src]
pub trait InfluxClient { fn ping(&self) -> bool; fn get_version(&self) -> Option<String>; fn write_point(
&self,
point: Point,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>; fn write_points(
&self,
points: Points,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>; fn query(
&self,
q: &str,
epoch: Option<Precision>
) -> Result<Vec<Value>, Error>; fn drop_measurement(&self, measurement: &str) -> Result<(), Error>; fn create_database(&self, dbname: &str) -> Result<(), Error>; fn drop_database(&self, dbname: &str) -> Result<(), Error>; fn create_user(
&self,
user: &str,
passwd: &str,
admin: bool
) -> Result<(), Error>; fn drop_user(&self, user: &str) -> Result<(), Error>; fn set_user_password(&self, user: &str, passwd: &str) -> Result<(), Error>; fn grant_admin_privileges(&self, user: &str) -> Result<(), Error>; fn revoke_admin_privileges(&self, user: &str) -> Result<(), Error>; fn grant_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> Result<(), Error>; fn revoke_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> Result<(), Error>; fn create_retention_policy(
&self,
name: &str,
duration: &str,
replication: &str,
default: bool,
db: Option<&str>
) -> Result<(), Error>; fn drop_retention_policy(
&self,
name: &str,
db: Option<&str>
) -> Result<(), Error>; }
Required Methods
fn ping(&self) -> bool
Query whether the corresponding database exists, return bool
fn get_version(&self) -> Option<String>
Query the version of the database and return the version number
fn write_point(
&self,
point: Point,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>
&self,
point: Point,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>
Write a point to the database
fn write_points(
&self,
points: Points,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>
&self,
points: Points,
precision: Option<Precision>,
rp: Option<&str>
) -> Result<bool, Error>
Write multiple points to the database
let mut client = InfluxdbClient::new("http://localhost:8086", "test", "root", "root");
client.set_write_timeout(10);
client.set_read_timeout(10);
let mut point = Point::new("test");
point.add_field("somefield", Value::Integer(65));
let mut point1 = Point::new("test2");
point1.add_field("somefield", Value::Float(12.2));
point1.add_tag("sometag", Value::Boolean(false));
let mut points = Points::new(point);
points.push(point1);
if Precision is None, the default is second
Multiple write
let res = client.write_points(points, Some(Precision::Microseconds), None).unwrap();
fn query(&self, q: &str, epoch: Option<Precision>) -> Result<Vec<Value>, Error>
Query and return data, the data type is Vec<serde_json::Value>
, such as "show, select"
let client = InfluxdbClient::new("http://localhost:8086", "test", "root", "root");
let res = client.query("select * from test", None).unwrap();
println!("{:?}", res[0].get("series").unwrap()[0].get("values"));
fn drop_measurement(&self, measurement: &str) -> Result<(), Error>
fn create_database(&self, dbname: &str) -> Result<(), Error>
Create a new database in InfluxDB.
fn drop_database(&self, dbname: &str) -> Result<(), Error>
Drop a database from InfluxDB.
fn create_user(
&self,
user: &str,
passwd: &str,
admin: bool
) -> Result<(), Error>
&self,
user: &str,
passwd: &str,
admin: bool
) -> Result<(), Error>
Create a new user in InfluxDB.
fn drop_user(&self, user: &str) -> Result<(), Error>
Drop a user from InfluxDB.
fn set_user_password(&self, user: &str, passwd: &str) -> Result<(), Error>
Change the password of an existing user.
fn grant_admin_privileges(&self, user: &str) -> Result<(), Error>
Grant cluster administration privileges to a user.
fn revoke_admin_privileges(&self, user: &str) -> Result<(), Error>
Revoke cluster administration privileges from a user.
fn grant_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> Result<(), Error>
&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
fn revoke_privilege(
&self,
user: &str,
db: &str,
privilege: &str
) -> Result<(), Error>
&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
fn create_retention_policy(
&self,
name: &str,
duration: &str,
replication: &str,
default: bool,
db: Option<&str>
) -> Result<(), Error>
&self,
name: &str,
duration: &str,
replication: &str,
default: bool,
db: Option<&str>
) -> Result<(), Error>
Create a retention policy for a database.
fn drop_retention_policy(
&self,
name: &str,
db: Option<&str>
) -> Result<(), Error>
&self,
name: &str,
db: Option<&str>
) -> Result<(), Error>
Drop an existing retention policy for a database.
Implementors
impl<'a> InfluxClient for InfluxdbClient<'a>