fix: Remove org_id to query API

Signed-off-by: Aakash Hemadri <aakashhemadri123@gmail.com>
pull/24376/head
Aakash Hemadri 2021-04-05 20:12:01 +05:30
parent 3c99ea2187
commit fcdc5290be
No known key found for this signature in database
GPG Key ID: 16DDD8A27920964C
2 changed files with 5 additions and 18 deletions

View File

@ -11,11 +11,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
client.query_suggestions_name("some-name").await?;
client
.query(
"some-org",
"some-orgID",
Some(Query::new("some-query".to_string())),
)
.query("some-org", Some(Query::new("some-query".to_string())))
.await?;
client

View File

@ -59,19 +59,14 @@ impl Client {
}
/// Query
pub async fn query(
&self,
org: &str,
org_id: &str,
query: Option<Query>,
) -> Result<String, RequestError> {
pub async fn query(&self, org: &str, query: Option<Query>) -> Result<String, RequestError> {
let req_url = format!("{}/api/v2/query", self.url);
let response = self
.request(Method::POST, &req_url)
.header("Accepting-Encoding", "identity")
.header("Content-Type", "application/json")
.query(&[("org", &org), ("orgID", &org_id)])
.query(&[("org", &org)])
.body(serde_json::to_string(&query.unwrap_or_default()).context(Serializing)?)
.send()
.await
@ -191,14 +186,12 @@ mod tests {
async fn query() {
let token = "some-token";
let org = "some-org";
let org_id = "some-org_id";
let query: Option<Query> = Some(Query::new("some-influx-query-string".to_string()));
let mock_server = mock("POST", "/api/v2/query")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Accepting-Encoding", "identity")
.match_header("Content-Type", "application/json")
.match_query(Matcher::UrlEncoded("org".into(), org.into()))
.match_query(Matcher::UrlEncoded("orgID".into(), org_id.into()))
.match_body(
serde_json::to_string(&query.clone().unwrap_or_default())
.unwrap()
@ -208,7 +201,7 @@ mod tests {
let client = Client::new(&mockito::server_url(), token);
let _result = client.query(org, org_id, query).await;
let _result = client.query(org, query).await;
mock_server.assert();
}
@ -217,7 +210,6 @@ mod tests {
async fn query_opt() {
let token = "some-token";
let org = "some-org";
let org_id = "some-org_id";
let query: Option<Query> = None;
let mock_server = mock("POST", "/api/v2/query")
@ -225,7 +217,6 @@ mod tests {
.match_header("Accepting-Encoding", "identity")
.match_header("Content-Type", "application/json")
.match_query(Matcher::UrlEncoded("org".into(), org.into()))
.match_query(Matcher::UrlEncoded("orgID".into(), org_id.into()))
.match_body(
serde_json::to_string(&query.unwrap_or_default())
.unwrap()
@ -235,7 +226,7 @@ mod tests {
let client = Client::new(&mockito::server_url(), token);
let _result = client.query(org, org_id, None).await;
let _result = client.query(org, None).await;
mock_server.assert();
}