use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct MconnConnectorFetch<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<types::MconnUuid, String>,
}
impl<'a> MconnConnectorFetch<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnUuid>,
{
self.connector_id = value
.try_into()
.map_err(|_| "conversion to `MconnUuid` for connector_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_fetch",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorReplace<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<types::MconnUuid, String>,
body: Result<types::builder::MconnCustomerConnectorUpdateRequest, String>,
}
impl<'a> MconnConnectorReplace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnUuid>,
{
self.connector_id = value
.try_into()
.map_err(|_| "conversion to `MconnUuid` for connector_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnCustomerConnectorUpdateRequest>,
<V as std::convert::TryInto<types::MconnCustomerConnectorUpdateRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MconnCustomerConnectorUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MconnCustomerConnectorUpdateRequest,
) -> types::builder::MconnCustomerConnectorUpdateRequest,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MconnCustomerConnectorUpdateRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_replace",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorDelete<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<types::MconnUuid, String>,
}
impl<'a> MconnConnectorDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnUuid>,
{
self.connector_id = value
.try_into()
.map_err(|_| "conversion to `MconnUuid` for connector_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_delete",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorUpdate<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<types::MconnUuid, String>,
body: Result<types::builder::MconnCustomerConnectorUpdateRequest, String>,
}
impl<'a> MconnConnectorUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnUuid>,
{
self.connector_id = value
.try_into()
.map_err(|_| "conversion to `MconnUuid` for connector_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnCustomerConnectorUpdateRequest>,
<V as std::convert::TryInto<types::MconnCustomerConnectorUpdateRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MconnCustomerConnectorUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MconnCustomerConnectorUpdateRequest,
) -> types::builder::MconnCustomerConnectorUpdateRequest,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MconnCustomerConnectorUpdateRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_update",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetryEventsList<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
cursor: Result<::std::string::String, String>,
from: Result<f64, String>,
k: Result<::std::string::String, String>,
limit: Result<f64, String>,
to: Result<f64, String>,
}
impl<'a> MconnConnectorTelemetryEventsList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
cursor: Err("cursor was not initialized".to_string()),
from: Err("from was not initialized".to_string()),
k: Err("k was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
to: Err("to was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub fn cursor<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cursor = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cursor failed".to_string()
});
self
}
pub fn from<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.from = value
.try_into()
.map_err(|_| "conversion to `f64` for from failed".to_string());
self
}
pub fn k<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.k = value
.try_into()
.map_err(|_| "conversion to `:: std :: string :: String` for k failed".to_string());
self
}
pub fn limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `f64` for limit failed".to_string());
self
}
pub fn to<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.to = value
.try_into()
.map_err(|_| "conversion to `f64` for to failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
cursor,
from,
k,
limit,
to,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let cursor = cursor.map_err(Error::InvalidRequest)?;
let from = from.map_err(Error::InvalidRequest)?;
let k = k.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let to = to.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/events",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("cursor", &cursor))
.query(&progenitor_client::QueryParam::new("from", &from))
.query(&progenitor_client::QueryParam::new("k", &k))
.query(&progenitor_client::QueryParam::new("limit", &limit))
.query(&progenitor_client::QueryParam::new("to", &to))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_events_list",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetryEventsGet<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
event_t: Result<f64, String>,
event_n: Result<f64, String>,
}
impl<'a> MconnConnectorTelemetryEventsGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
event_t: Err("event_t was not initialized".to_string()),
event_n: Err("event_n was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub fn event_t<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.event_t = value
.try_into()
.map_err(|_| "conversion to `f64` for event_t failed".to_string());
self
}
pub fn event_n<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.event_n = value
.try_into()
.map_err(|_| "conversion to `f64` for event_n failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
event_t,
event_n,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let event_t = event_t.map_err(Error::InvalidRequest)?;
let event_n = event_n.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/events/{}.{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
encode_path(&event_t.to_string()),
encode_path(&event_n.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_events_get",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetryEventsListLatest<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
}
impl<'a> MconnConnectorTelemetryEventsListLatest<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/events/latest",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_events_list_latest",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetrySnapshotsList<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
cursor: Result<::std::string::String, String>,
from: Result<f64, String>,
limit: Result<f64, String>,
to: Result<f64, String>,
}
impl<'a> MconnConnectorTelemetrySnapshotsList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
cursor: Err("cursor was not initialized".to_string()),
from: Err("from was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
to: Err("to was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub fn cursor<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cursor = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cursor failed".to_string()
});
self
}
pub fn from<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.from = value
.try_into()
.map_err(|_| "conversion to `f64` for from failed".to_string());
self
}
pub fn limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `f64` for limit failed".to_string());
self
}
pub fn to<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.to = value
.try_into()
.map_err(|_| "conversion to `f64` for to failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
cursor,
from,
limit,
to,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let cursor = cursor.map_err(Error::InvalidRequest)?;
let from = from.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let to = to.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/snapshots",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("cursor", &cursor))
.query(&progenitor_client::QueryParam::new("from", &from))
.query(&progenitor_client::QueryParam::new("limit", &limit))
.query(&progenitor_client::QueryParam::new("to", &to))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_snapshots_list",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetrySnapshotsGet<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
snapshot_t: Result<f64, String>,
}
impl<'a> MconnConnectorTelemetrySnapshotsGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
snapshot_t: Err("snapshot_t was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub fn snapshot_t<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.snapshot_t = value
.try_into()
.map_err(|_| "conversion to `f64` for snapshot_t failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
snapshot_t,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let snapshot_t = snapshot_t.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/snapshots/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
encode_path(&snapshot_t.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_snapshots_get",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MconnConnectorTelemetrySnapshotsListLatest<'a> {
client: &'a crate::Client,
account_id: Result<types::MconnAccountId, String>,
connector_id: Result<::std::string::String, String>,
}
impl<'a> MconnConnectorTelemetrySnapshotsListLatest<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
connector_id: Err("connector_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MconnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MconnAccountId` for account_id failed".to_string());
self
}
pub fn connector_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.connector_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for connector_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
connector_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let connector_id = connector_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/connectors/{}/telemetry/snapshots/latest",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&connector_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "mconn_connector_telemetry_snapshots_list_latest",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}