Skip to main content

redis_cloud/
data_integration.rs

1//! Redis Data Integration workspace operations.
2//!
3//! The Redis Cloud API exposes Data Integration as an opaque JSON workspace
4//! service. The published schema intentionally models request and response
5//! bodies as arbitrary JSON, so this handler provides structured routing while
6//! preserving payloads as [`serde_json::Value`].
7
8use crate::{CloudClient, Result};
9use serde_json::Value;
10
11/// Handler for Data Integration workspace and proxy operations.
12pub struct DataIntegrationHandler {
13    client: CloudClient,
14}
15
16impl DataIntegrationHandler {
17    /// Create a Data Integration handler.
18    #[must_use]
19    pub fn new(client: CloudClient) -> Self {
20        Self { client }
21    }
22
23    /// List Data Integration workspaces visible to the account.
24    pub async fn list_workspaces(&self) -> Result<Value> {
25        self.client.get_raw("/data-integration-workspaces").await
26    }
27
28    /// Get the root Data Integration workspace document for a subscription.
29    pub async fn get_workspace(&self, subscription_id: i32) -> Result<Value> {
30        self.client
31            .get_raw(&format!(
32                "/subscriptions/{subscription_id}/data-integration-workspace"
33            ))
34            .await
35    }
36
37    /// POST an opaque JSON document to a subscription's workspace root.
38    pub async fn post_workspace(&self, subscription_id: i32, body: Value) -> Result<Value> {
39        self.client
40            .post_raw(
41                &format!("/subscriptions/{subscription_id}/data-integration-workspace"),
42                body,
43            )
44            .await
45    }
46
47    /// Replace a subscription's workspace root with an opaque JSON document.
48    pub async fn put_workspace(&self, subscription_id: i32, body: Value) -> Result<Value> {
49        self.client
50            .put_raw(
51                &format!("/subscriptions/{subscription_id}/data-integration-workspace"),
52                body,
53            )
54            .await
55    }
56
57    /// Patch a subscription's workspace root with an opaque JSON document.
58    pub async fn patch_workspace(&self, subscription_id: i32, body: Value) -> Result<Value> {
59        self.client
60            .patch_raw(
61                &format!("/subscriptions/{subscription_id}/data-integration-workspace"),
62                body,
63            )
64            .await
65    }
66
67    /// DELETE a subscription's workspace root with an opaque JSON document.
68    pub async fn delete_workspace(&self, subscription_id: i32, body: Value) -> Result<Value> {
69        self.client
70            .delete_with_body(
71                &format!("/subscriptions/{subscription_id}/data-integration-workspace"),
72                body,
73            )
74            .await
75    }
76
77    /// GET an arbitrary path below a subscription's Data Integration workspace.
78    pub async fn get_workspace_path(
79        &self,
80        subscription_id: i32,
81        workspace_path: &str,
82    ) -> Result<Value> {
83        let workspace_path = workspace_path.trim_matches('/');
84        self.client
85            .get_raw(&format!(
86                "/subscriptions/{subscription_id}/data-integration-workspace/{workspace_path}"
87            ))
88            .await
89    }
90
91    /// POST an opaque JSON document to an arbitrary workspace path.
92    pub async fn post_workspace_path(
93        &self,
94        subscription_id: i32,
95        workspace_path: &str,
96        body: Value,
97    ) -> Result<Value> {
98        let workspace_path = workspace_path.trim_matches('/');
99        self.client
100            .post_raw(
101                &format!(
102                    "/subscriptions/{subscription_id}/data-integration-workspace/{workspace_path}"
103                ),
104                body,
105            )
106            .await
107    }
108
109    /// PUT an opaque JSON document at an arbitrary workspace path.
110    pub async fn put_workspace_path(
111        &self,
112        subscription_id: i32,
113        workspace_path: &str,
114        body: Value,
115    ) -> Result<Value> {
116        let workspace_path = workspace_path.trim_matches('/');
117        self.client
118            .put_raw(
119                &format!(
120                    "/subscriptions/{subscription_id}/data-integration-workspace/{workspace_path}"
121                ),
122                body,
123            )
124            .await
125    }
126
127    /// PATCH an arbitrary workspace path with an opaque JSON document.
128    pub async fn patch_workspace_path(
129        &self,
130        subscription_id: i32,
131        workspace_path: &str,
132        body: Value,
133    ) -> Result<Value> {
134        let workspace_path = workspace_path.trim_matches('/');
135        self.client
136            .patch_raw(
137                &format!(
138                    "/subscriptions/{subscription_id}/data-integration-workspace/{workspace_path}"
139                ),
140                body,
141            )
142            .await
143    }
144
145    /// DELETE an arbitrary workspace path with an opaque JSON document.
146    pub async fn delete_workspace_path(
147        &self,
148        subscription_id: i32,
149        workspace_path: &str,
150        body: Value,
151    ) -> Result<Value> {
152        let workspace_path = workspace_path.trim_matches('/');
153        self.client
154            .delete_with_body(
155                &format!(
156                    "/subscriptions/{subscription_id}/data-integration-workspace/{workspace_path}"
157                ),
158                body,
159            )
160            .await
161    }
162}