objectiveai_sdk/filesystem/config/
api.rs1use serde::{Serialize, Deserialize};
2
3#[derive(Debug, Clone, Default, Serialize, Deserialize, schemars::JsonSchema)]
4#[schemars(rename = "filesystem.config.ApiConfig")]
5pub struct ApiConfig {
6 #[serde(default)]
7 pub mode: ApiMode,
8 #[serde(skip_serializing_if = "ApiRemoteConfig::is_none")]
9 #[schemars(extend("omitempty" = true))]
10 pub remote: Option<ApiRemoteConfig>,
11 #[serde(skip_serializing_if = "ApiLocalConfig::is_none")]
12 #[schemars(extend("omitempty" = true))]
13 pub local: Option<ApiLocalConfig>,
14 #[serde(skip_serializing_if = "ApiHeadersConfig::is_none")]
15 #[schemars(extend("omitempty" = true))]
16 pub headers: Option<ApiHeadersConfig>,
17}
18
19impl ApiConfig {
20 pub fn is_empty(&self) -> bool {
21 false
22 }
23
24 pub fn is_none(this: &Option<Self>) -> bool {
25 this.as_ref().is_none_or(|cfg| cfg.is_empty())
26 }
27
28 pub fn remote(&mut self) -> &mut ApiRemoteConfig {
29 self.remote.get_or_insert_with(ApiRemoteConfig::default)
30 }
31
32 pub fn local(&mut self) -> &mut ApiLocalConfig {
33 self.local.get_or_insert_with(ApiLocalConfig::default)
34 }
35
36 pub fn headers(&mut self) -> &mut ApiHeadersConfig {
37 self.headers.get_or_insert_with(ApiHeadersConfig::default)
38 }
39
40 pub fn get_mode(&self) -> ApiMode {
41 self.mode
42 }
43
44 pub fn set_mode(&mut self, mode: ApiMode) {
45 self.mode = mode;
46 }
47
48 pub fn jq(&self, filter: &str) -> Result<Vec<serde_json::Value>, super::super::Error> {
49 super::super::run_jq(self, filter)
50 }
51}
52
53#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, schemars::JsonSchema)]
54#[schemars(rename = "filesystem.config.ApiMode")]
55#[serde(rename_all = "snake_case")]
56pub enum ApiMode {
57 Remote,
58 #[default]
59 Local,
60}
61
62#[derive(Debug, Clone, Default, Serialize, Deserialize, schemars::JsonSchema)]
63#[schemars(rename = "filesystem.config.ApiRemoteConfig")]
64pub struct ApiRemoteConfig {
65 #[serde(skip_serializing_if = "Option::is_none")]
66 #[schemars(extend("omitempty" = true))]
67 pub objectiveai_address: Option<String>,
68}
69
70impl ApiRemoteConfig {
71 pub fn is_empty(&self) -> bool {
72 self.objectiveai_address.is_none()
73 }
74
75 pub fn is_none(this: &Option<Self>) -> bool {
76 this.as_ref().is_none_or(|cfg| cfg.is_empty())
77 }
78
79 pub fn get_objectiveai_address(&self) -> Option<&str> {
80 self.objectiveai_address.as_deref()
81 }
82
83 pub fn set_objectiveai_address(&mut self, value: impl Into<String>) {
84 self.objectiveai_address = Some(value.into());
85 }
86
87 pub fn jq(&self, filter: &str) -> Result<Vec<serde_json::Value>, super::super::Error> {
88 super::super::run_jq(self, filter)
89 }
90}
91
92#[derive(Debug, Clone, Default, Serialize, Deserialize, schemars::JsonSchema)]
93#[schemars(rename = "filesystem.config.ApiLocalConfig")]
94pub struct ApiLocalConfig {
95 #[serde(skip_serializing_if = "Option::is_none")]
96 #[schemars(extend("omitempty" = true))]
97 pub claude_agent_sdk: Option<bool>,
98}
99
100impl ApiLocalConfig {
101 pub fn is_empty(&self) -> bool {
102 self.claude_agent_sdk.is_none()
103 }
104
105 pub fn is_none(this: &Option<Self>) -> bool {
106 this.as_ref().is_none_or(|cfg| cfg.is_empty())
107 }
108
109 pub fn get_claude_agent_sdk(&self) -> Option<bool> {
110 self.claude_agent_sdk
111 }
112
113 pub fn set_claude_agent_sdk(&mut self, value: bool) {
114 self.claude_agent_sdk = Some(value);
115 }
116
117 pub fn jq(&self, filter: &str) -> Result<Vec<serde_json::Value>, super::super::Error> {
118 super::super::run_jq(self, filter)
119 }
120}
121
122#[derive(Debug, Clone, Default, Serialize, Deserialize, schemars::JsonSchema)]
123#[schemars(rename = "filesystem.config.ApiHeadersConfig")]
124pub struct ApiHeadersConfig {
125 #[serde(skip_serializing_if = "Option::is_none")]
126 #[schemars(extend("omitempty" = true))]
127 pub x_objectiveai_authorization: Option<String>,
128 #[serde(skip_serializing_if = "Option::is_none")]
129 #[schemars(extend("omitempty" = true))]
130 pub x_openrouter_authorization: Option<String>,
131 #[serde(skip_serializing_if = "Option::is_none")]
132 #[schemars(extend("omitempty" = true))]
133 pub x_github_authorization: Option<String>,
134 #[serde(skip_serializing_if = "Option::is_none")]
135 #[schemars(extend("omitempty" = true))]
136 pub x_mcp_authorization: Option<indexmap::IndexMap<String, String>>,
137 #[serde(skip_serializing_if = "Option::is_none")]
138 #[schemars(extend("omitempty" = true))]
139 pub x_viewer_signature: Option<String>,
140 #[serde(skip_serializing_if = "Option::is_none")]
141 #[schemars(extend("omitempty" = true))]
142 pub x_viewer_address: Option<String>,
143 #[serde(skip_serializing_if = "Option::is_none")]
144 #[schemars(extend("omitempty" = true))]
145 pub user_agent: Option<String>,
146 #[serde(skip_serializing_if = "Option::is_none")]
147 #[schemars(extend("omitempty" = true))]
148 pub http_referer: Option<String>,
149 #[serde(skip_serializing_if = "Option::is_none")]
150 #[schemars(extend("omitempty" = true))]
151 pub x_title: Option<String>,
152 #[serde(skip_serializing_if = "Option::is_none")]
153 #[schemars(extend("omitempty" = true))]
154 pub x_commit_author_name: Option<String>,
155 #[serde(skip_serializing_if = "Option::is_none")]
156 #[schemars(extend("omitempty" = true))]
157 pub x_commit_author_email: Option<String>,
158}
159
160impl ApiHeadersConfig {
161 pub fn is_empty(&self) -> bool {
162 self.x_objectiveai_authorization.is_none()
163 && self.x_openrouter_authorization.is_none()
164 && self.x_github_authorization.is_none()
165 && self.x_mcp_authorization.as_ref().is_none_or(|m| m.is_empty())
166 && self.x_viewer_signature.is_none()
167 && self.x_viewer_address.is_none()
168 && self.user_agent.is_none()
169 && self.http_referer.is_none()
170 && self.x_title.is_none()
171 && self.x_commit_author_name.is_none()
172 && self.x_commit_author_email.is_none()
173 }
174
175 pub fn is_none(this: &Option<Self>) -> bool {
176 this.as_ref().is_none_or(|cfg| cfg.is_empty())
177 }
178
179 pub fn get_x_objectiveai_authorization(&self) -> Option<&str> { self.x_objectiveai_authorization.as_deref() }
180 pub fn set_x_objectiveai_authorization(&mut self, value: impl Into<String>) { self.x_objectiveai_authorization = Some(value.into()); }
181
182 pub fn get_x_openrouter_authorization(&self) -> Option<&str> { self.x_openrouter_authorization.as_deref() }
183 pub fn set_x_openrouter_authorization(&mut self, value: impl Into<String>) { self.x_openrouter_authorization = Some(value.into()); }
184
185 pub fn get_x_github_authorization(&self) -> Option<&str> { self.x_github_authorization.as_deref() }
186 pub fn set_x_github_authorization(&mut self, value: impl Into<String>) { self.x_github_authorization = Some(value.into()); }
187
188 pub fn get_x_mcp_authorization(&self) -> Option<&indexmap::IndexMap<String, String>> { self.x_mcp_authorization.as_ref() }
189 pub fn add_x_mcp_authorization(&mut self, key: impl Into<String>, value: impl Into<String>) { self.x_mcp_authorization.get_or_insert_with(indexmap::IndexMap::new).insert(key.into(), value.into()); }
190 pub fn del_x_mcp_authorization(&mut self, key: &str) { if let Some(mcp) = &mut self.x_mcp_authorization { mcp.shift_remove(key); } }
191
192 pub fn get_x_viewer_signature(&self) -> Option<&str> { self.x_viewer_signature.as_deref() }
193 pub fn set_x_viewer_signature(&mut self, value: impl Into<String>) { self.x_viewer_signature = Some(value.into()); }
194
195 pub fn get_x_viewer_address(&self) -> Option<&str> { self.x_viewer_address.as_deref() }
196 pub fn set_x_viewer_address(&mut self, value: impl Into<String>) { self.x_viewer_address = Some(value.into()); }
197
198 pub fn get_user_agent(&self) -> Option<&str> { self.user_agent.as_deref() }
199 pub fn set_user_agent(&mut self, value: impl Into<String>) { self.user_agent = Some(value.into()); }
200
201 pub fn get_http_referer(&self) -> Option<&str> { self.http_referer.as_deref() }
202 pub fn set_http_referer(&mut self, value: impl Into<String>) { self.http_referer = Some(value.into()); }
203
204 pub fn get_x_title(&self) -> Option<&str> { self.x_title.as_deref() }
205 pub fn set_x_title(&mut self, value: impl Into<String>) { self.x_title = Some(value.into()); }
206
207 pub fn get_x_commit_author_name(&self) -> Option<&str> { self.x_commit_author_name.as_deref() }
208 pub fn set_x_commit_author_name(&mut self, value: impl Into<String>) { self.x_commit_author_name = Some(value.into()); }
209
210 pub fn get_x_commit_author_email(&self) -> Option<&str> { self.x_commit_author_email.as_deref() }
211 pub fn set_x_commit_author_email(&mut self, value: impl Into<String>) { self.x_commit_author_email = Some(value.into()); }
212
213 pub fn jq(&self, filter: &str) -> Result<Vec<serde_json::Value>, super::super::Error> {
214 super::super::run_jq(self, filter)
215 }
216}