airbyte_client/apis/
internal_api.rs

1/*
2 * Airbyte Configuration API
3 *
4 * Airbyte Configuration API [https://airbyte.io](https://airbyte.io).  The Configuration API is an internal Airbyte API that is designed for communications between different Airbyte components. * Its main purpose is to enable the Airbyte Engineering team to configure the internal state of [Airbyte Cloud](https://airbyte.com/airbyte-cloud) * It is also sometimes used by OSS users to configure their own Self-Hosted Airbyte deployment (internal state, etc)  WARNING * Airbyte does NOT have active commitments to support this API long-term. * OSS users can utilize the Configuration API, but at their own risk. * This API is utilized internally by the Airbyte Engineering team and may be modified in the future if the need arises. * Modifications by the Airbyte Engineering team could create breaking changes and OSS users would need to update their code to catch up to any backwards incompatible changes in the API.  This API is a collection of HTTP RPC-style methods. While it is not a REST API, those familiar with REST should find the conventions of this API recognizable.  Here are some conventions that this API follows: * All endpoints are http POST methods. * All endpoints accept data via `application/json` request bodies. The API does not accept any data via query params. * The naming convention for endpoints is: localhost:8000/api/{VERSION}/{METHOD_FAMILY}/{METHOD_NAME} e.g. `localhost:8000/api/v1/connections/create`. * For all `update` methods, the whole object must be passed in, even the fields that did not change.  Authentication (OSS): * When authenticating to the Configuration API, you must use Basic Authentication by setting the Authentication Header to Basic and base64 encoding the username and password (which are `airbyte` and `password` by default - so base64 encoding `airbyte:password` results in `YWlyYnl0ZTpwYXNzd29yZA==`). So the full header reads `'Authorization': \"Basic YWlyYnl0ZTpwYXNzd29yZA==\"`
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: contact@airbyte.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16/// struct for typed errors of method [`create_or_update_state`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateOrUpdateStateError {
20    Status404(crate::models::NotFoundKnownExceptionInfo),
21    Status422(crate::models::InvalidInputExceptionInfo),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_attempt_normalization_statuses_for_job`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetAttemptNormalizationStatusesForJobError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`save_stats`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum SaveStatsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`save_sync_config`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum SaveSyncConfigError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`set_workflow_in_attempt`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum SetWorkflowInAttemptError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`write_discover_catalog_result`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum WriteDiscoverCatalogResultError {
57    UnknownValue(serde_json::Value),
58}
59
60pub async fn create_or_update_state(
61    configuration: &configuration::Configuration,
62    connection_state_create_or_update: crate::models::ConnectionStateCreateOrUpdate,
63) -> Result<crate::models::ConnectionState, Error<CreateOrUpdateStateError>> {
64    let local_var_configuration = configuration;
65
66    let local_var_client = &local_var_configuration.client;
67
68    let local_var_uri_str = format!(
69        "{}/v1/state/create_or_update",
70        local_var_configuration.base_path
71    );
72    let mut local_var_req_builder =
73        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
74
75    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
76        local_var_req_builder =
77            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
78    }
79    local_var_req_builder = local_var_req_builder.json(&connection_state_create_or_update);
80
81    let local_var_req = local_var_req_builder.build()?;
82    let local_var_resp = local_var_client.execute(local_var_req).await?;
83
84    let local_var_status = local_var_resp.status();
85    let local_var_content = local_var_resp.text().await?;
86
87    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
88        serde_json::from_str(&local_var_content).map_err(Error::from)
89    } else {
90        let local_var_entity: Option<CreateOrUpdateStateError> =
91            serde_json::from_str(&local_var_content).ok();
92        let local_var_error = ResponseContent {
93            status: local_var_status,
94            content: local_var_content,
95            entity: local_var_entity,
96        };
97        Err(Error::ResponseError(local_var_error))
98    }
99}
100
101pub async fn get_attempt_normalization_statuses_for_job(
102    configuration: &configuration::Configuration,
103    job_id_request_body: Option<crate::models::JobIdRequestBody>,
104) -> Result<
105    crate::models::AttemptNormalizationStatusReadList,
106    Error<GetAttemptNormalizationStatusesForJobError>,
107> {
108    let local_var_configuration = configuration;
109
110    let local_var_client = &local_var_configuration.client;
111
112    let local_var_uri_str = format!(
113        "{}/v1/jobs/get_normalization_status",
114        local_var_configuration.base_path
115    );
116    let mut local_var_req_builder =
117        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
118
119    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
120        local_var_req_builder =
121            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
122    }
123    local_var_req_builder = local_var_req_builder.json(&job_id_request_body);
124
125    let local_var_req = local_var_req_builder.build()?;
126    let local_var_resp = local_var_client.execute(local_var_req).await?;
127
128    let local_var_status = local_var_resp.status();
129    let local_var_content = local_var_resp.text().await?;
130
131    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
132        serde_json::from_str(&local_var_content).map_err(Error::from)
133    } else {
134        let local_var_entity: Option<GetAttemptNormalizationStatusesForJobError> =
135            serde_json::from_str(&local_var_content).ok();
136        let local_var_error = ResponseContent {
137            status: local_var_status,
138            content: local_var_content,
139            entity: local_var_entity,
140        };
141        Err(Error::ResponseError(local_var_error))
142    }
143}
144
145pub async fn save_stats(
146    configuration: &configuration::Configuration,
147    save_stats_request_body: crate::models::SaveStatsRequestBody,
148) -> Result<crate::models::InternalOperationResult, Error<SaveStatsError>> {
149    let local_var_configuration = configuration;
150
151    let local_var_client = &local_var_configuration.client;
152
153    let local_var_uri_str = format!(
154        "{}/v1/attempt/save_stats",
155        local_var_configuration.base_path
156    );
157    let mut local_var_req_builder =
158        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
159
160    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
161        local_var_req_builder =
162            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
163    }
164    local_var_req_builder = local_var_req_builder.json(&save_stats_request_body);
165
166    let local_var_req = local_var_req_builder.build()?;
167    let local_var_resp = local_var_client.execute(local_var_req).await?;
168
169    let local_var_status = local_var_resp.status();
170    let local_var_content = local_var_resp.text().await?;
171
172    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
173        serde_json::from_str(&local_var_content).map_err(Error::from)
174    } else {
175        let local_var_entity: Option<SaveStatsError> =
176            serde_json::from_str(&local_var_content).ok();
177        let local_var_error = ResponseContent {
178            status: local_var_status,
179            content: local_var_content,
180            entity: local_var_entity,
181        };
182        Err(Error::ResponseError(local_var_error))
183    }
184}
185
186pub async fn save_sync_config(
187    configuration: &configuration::Configuration,
188    save_attempt_sync_config_request_body: crate::models::SaveAttemptSyncConfigRequestBody,
189) -> Result<crate::models::InternalOperationResult, Error<SaveSyncConfigError>> {
190    let local_var_configuration = configuration;
191
192    let local_var_client = &local_var_configuration.client;
193
194    let local_var_uri_str = format!(
195        "{}/v1/attempt/save_sync_config",
196        local_var_configuration.base_path
197    );
198    let mut local_var_req_builder =
199        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
200
201    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202        local_var_req_builder =
203            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
204    }
205    local_var_req_builder = local_var_req_builder.json(&save_attempt_sync_config_request_body);
206
207    let local_var_req = local_var_req_builder.build()?;
208    let local_var_resp = local_var_client.execute(local_var_req).await?;
209
210    let local_var_status = local_var_resp.status();
211    let local_var_content = local_var_resp.text().await?;
212
213    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
214        serde_json::from_str(&local_var_content).map_err(Error::from)
215    } else {
216        let local_var_entity: Option<SaveSyncConfigError> =
217            serde_json::from_str(&local_var_content).ok();
218        let local_var_error = ResponseContent {
219            status: local_var_status,
220            content: local_var_content,
221            entity: local_var_entity,
222        };
223        Err(Error::ResponseError(local_var_error))
224    }
225}
226
227pub async fn set_workflow_in_attempt(
228    configuration: &configuration::Configuration,
229    set_workflow_in_attempt_request_body: crate::models::SetWorkflowInAttemptRequestBody,
230) -> Result<crate::models::InternalOperationResult, Error<SetWorkflowInAttemptError>> {
231    let local_var_configuration = configuration;
232
233    let local_var_client = &local_var_configuration.client;
234
235    let local_var_uri_str = format!(
236        "{}/v1/attempt/set_workflow_in_attempt",
237        local_var_configuration.base_path
238    );
239    let mut local_var_req_builder =
240        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
241
242    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
243        local_var_req_builder =
244            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
245    }
246    local_var_req_builder = local_var_req_builder.json(&set_workflow_in_attempt_request_body);
247
248    let local_var_req = local_var_req_builder.build()?;
249    let local_var_resp = local_var_client.execute(local_var_req).await?;
250
251    let local_var_status = local_var_resp.status();
252    let local_var_content = local_var_resp.text().await?;
253
254    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
255        serde_json::from_str(&local_var_content).map_err(Error::from)
256    } else {
257        let local_var_entity: Option<SetWorkflowInAttemptError> =
258            serde_json::from_str(&local_var_content).ok();
259        let local_var_error = ResponseContent {
260            status: local_var_status,
261            content: local_var_content,
262            entity: local_var_entity,
263        };
264        Err(Error::ResponseError(local_var_error))
265    }
266}
267
268pub async fn write_discover_catalog_result(
269    configuration: &configuration::Configuration,
270    source_discover_schema_write_request_body: crate::models::SourceDiscoverSchemaWriteRequestBody,
271) -> Result<crate::models::DiscoverCatalogResult, Error<WriteDiscoverCatalogResultError>> {
272    let local_var_configuration = configuration;
273
274    let local_var_client = &local_var_configuration.client;
275
276    let local_var_uri_str = format!(
277        "{}/v1/sources/write_discover_catalog_result",
278        local_var_configuration.base_path
279    );
280    let mut local_var_req_builder =
281        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
282
283    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
284        local_var_req_builder =
285            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
286    }
287    local_var_req_builder = local_var_req_builder.json(&source_discover_schema_write_request_body);
288
289    let local_var_req = local_var_req_builder.build()?;
290    let local_var_resp = local_var_client.execute(local_var_req).await?;
291
292    let local_var_status = local_var_resp.status();
293    let local_var_content = local_var_resp.text().await?;
294
295    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
296        serde_json::from_str(&local_var_content).map_err(Error::from)
297    } else {
298        let local_var_entity: Option<WriteDiscoverCatalogResultError> =
299            serde_json::from_str(&local_var_content).ok();
300        let local_var_error = ResponseContent {
301            status: local_var_status,
302            content: local_var_content,
303            entity: local_var_entity,
304        };
305        Err(Error::ResponseError(local_var_error))
306    }
307}