Skip to main content

box_open_sdk/managers/
query.rs

1// Code generated by box-gantry. DO NOT EDIT.
2
3use crate::runtime::{self, Error};
4
5/// Operations for the "query" API area.
6pub struct QueryManager {
7    session: std::sync::Arc<runtime::Client>,
8}
9
10impl QueryManager {
11    pub(crate) fn new(session: std::sync::Arc<runtime::Client>) -> Self {
12        Self { session }
13    }
14
15    pub async fn query(
16        &self,
17        body: crate::models::schemas::QueryRequestBody,
18    ) -> Result<crate::models::schemas::QueryResults, Error> {
19        let mut url = self.session.base_url("api");
20        url.push_str("/query");
21        let mut req = self.session.new_request("POST", &url);
22        req = runtime::with_header(req, "box-version", "2026.0");
23        let payload = serde_json::to_vec(&body)?;
24        req = runtime::with_json_body(req, &payload);
25        let resp = self.session.fetch(req).await?;
26        let data = runtime::response_bytes(&resp)?;
27        Ok(serde_json::from_slice(&data)?)
28    }
29
30    pub async fn query_insights(
31        &self,
32        body: crate::models::schemas::QueryInsightsRequestBody,
33    ) -> Result<crate::models::schemas::QueryInsights, Error> {
34        let mut url = self.session.base_url("api");
35        url.push_str("/query_insights");
36        let mut req = self.session.new_request("POST", &url);
37        req = runtime::with_header(req, "box-version", "2026.0");
38        let payload = serde_json::to_vec(&body)?;
39        req = runtime::with_json_body(req, &payload);
40        let resp = self.session.fetch(req).await?;
41        let data = runtime::response_bytes(&resp)?;
42        Ok(serde_json::from_slice(&data)?)
43    }
44}