Skip to main content

unifly_api/controller/session_queries/
raw.rs

1use crate::controller::Controller;
2use crate::controller::support::require_session;
3use crate::core_error::CoreError;
4
5impl Controller {
6    /// Send a raw GET request to an arbitrary path on the controller.
7    ///
8    /// The `path` is appended to the controller base URL + platform prefix
9    /// (e.g. `/proxy/network/`). The response is returned as raw JSON
10    /// without session envelope unwrapping.
11    pub async fn raw_get(&self, path: &str) -> Result<serde_json::Value, CoreError> {
12        let guard = self.inner.session_client.lock().await;
13        let session = require_session(guard.as_ref())?;
14        Ok(session.raw_get(path).await?)
15    }
16
17    /// Send a raw POST request to an arbitrary path on the controller.
18    pub async fn raw_post(
19        &self,
20        path: &str,
21        body: &serde_json::Value,
22    ) -> Result<serde_json::Value, CoreError> {
23        let guard = self.inner.session_client.lock().await;
24        let session = require_session(guard.as_ref())?;
25        Ok(session.raw_post(path, body).await?)
26    }
27
28    /// Send a raw PUT request to an arbitrary path on the controller.
29    pub async fn raw_put(
30        &self,
31        path: &str,
32        body: &serde_json::Value,
33    ) -> Result<serde_json::Value, CoreError> {
34        let guard = self.inner.session_client.lock().await;
35        let session = require_session(guard.as_ref())?;
36        Ok(session.raw_put(path, body).await?)
37    }
38
39    /// Send a raw PATCH request to an arbitrary path on the controller.
40    pub async fn raw_patch(
41        &self,
42        path: &str,
43        body: &serde_json::Value,
44    ) -> Result<serde_json::Value, CoreError> {
45        let guard = self.inner.session_client.lock().await;
46        let session = require_session(guard.as_ref())?;
47        Ok(session.raw_patch(path, body).await?)
48    }
49
50    /// Send a raw DELETE request to an arbitrary path on the controller.
51    pub async fn raw_delete(&self, path: &str) -> Result<(), CoreError> {
52        let guard = self.inner.session_client.lock().await;
53        let session = require_session(guard.as_ref())?;
54        session.raw_delete(path).await?;
55        Ok(())
56    }
57}