airbyte_client/apis/
destination_definition_specification_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 [`get_destination_definition_specification`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetDestinationDefinitionSpecificationError {
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_specification_for_destination_id`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetSpecificationForDestinationIdError {
29    Status404(crate::models::NotFoundKnownExceptionInfo),
30    Status422(crate::models::InvalidInputExceptionInfo),
31    UnknownValue(serde_json::Value),
32}
33
34pub async fn get_destination_definition_specification(
35    configuration: &configuration::Configuration,
36    destination_definition_id_with_workspace_id: crate::models::DestinationDefinitionIdWithWorkspaceId,
37) -> Result<
38    crate::models::DestinationDefinitionSpecificationRead,
39    Error<GetDestinationDefinitionSpecificationError>,
40> {
41    let local_var_configuration = configuration;
42
43    let local_var_client = &local_var_configuration.client;
44
45    let local_var_uri_str = format!(
46        "{}/v1/destination_definition_specifications/get",
47        local_var_configuration.base_path
48    );
49    let mut local_var_req_builder =
50        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
51
52    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
53        local_var_req_builder =
54            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
55    }
56    local_var_req_builder =
57        local_var_req_builder.json(&destination_definition_id_with_workspace_id);
58
59    let local_var_req = local_var_req_builder.build()?;
60    let local_var_resp = local_var_client.execute(local_var_req).await?;
61
62    let local_var_status = local_var_resp.status();
63    let local_var_content = local_var_resp.text().await?;
64
65    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
66        serde_json::from_str(&local_var_content).map_err(Error::from)
67    } else {
68        let local_var_entity: Option<GetDestinationDefinitionSpecificationError> =
69            serde_json::from_str(&local_var_content).ok();
70        let local_var_error = ResponseContent {
71            status: local_var_status,
72            content: local_var_content,
73            entity: local_var_entity,
74        };
75        Err(Error::ResponseError(local_var_error))
76    }
77}
78
79pub async fn get_specification_for_destination_id(
80    configuration: &configuration::Configuration,
81    destination_id_request_body: crate::models::DestinationIdRequestBody,
82) -> Result<
83    crate::models::DestinationDefinitionSpecificationRead,
84    Error<GetSpecificationForDestinationIdError>,
85> {
86    let local_var_configuration = configuration;
87
88    let local_var_client = &local_var_configuration.client;
89
90    let local_var_uri_str = format!(
91        "{}/v1/destination_definition_specifications/get_for_destination",
92        local_var_configuration.base_path
93    );
94    let mut local_var_req_builder =
95        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
96
97    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
98        local_var_req_builder =
99            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101    local_var_req_builder = local_var_req_builder.json(&destination_id_request_body);
102
103    let local_var_req = local_var_req_builder.build()?;
104    let local_var_resp = local_var_client.execute(local_var_req).await?;
105
106    let local_var_status = local_var_resp.status();
107    let local_var_content = local_var_resp.text().await?;
108
109    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
110        serde_json::from_str(&local_var_content).map_err(Error::from)
111    } else {
112        let local_var_entity: Option<GetSpecificationForDestinationIdError> =
113            serde_json::from_str(&local_var_content).ok();
114        let local_var_error = ResponseContent {
115            status: local_var_status,
116            content: local_var_content,
117            entity: local_var_entity,
118        };
119        Err(Error::ResponseError(local_var_error))
120    }
121}