use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct CatalogSyncsList<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
}
impl<'a> CatalogSyncsList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_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 } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs",
client.baseurl,
encode_path(&account_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: "catalog_syncs_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 CatalogSyncsCreate<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
forwarded: Result<::std::string::String, String>,
body: Result<types::builder::McnCreateCatalogSyncRequest, String>,
}
impl<'a> CatalogSyncsCreate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
forwarded: Err("forwarded 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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn forwarded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.forwarded = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for forwarded failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCreateCatalogSyncRequest>,
<V as std::convert::TryInto<types::McnCreateCatalogSyncRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnCreateCatalogSyncRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnCreateCatalogSyncRequest,
) -> types::builder::McnCreateCatalogSyncRequest,
{
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,
forwarded,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let forwarded = forwarded.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::McnCreateCatalogSyncRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append("forwarded", forwarded.to_string().try_into()?);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "catalog_syncs_create",
};
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() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct CatalogSyncsRead<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
sync_id: Result<types::McnCatalogSyncId, String>,
}
impl<'a> CatalogSyncsRead<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
sync_id: Err("sync_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn sync_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncId>,
{
self.sync_id = value
.try_into()
.map_err(|_| "conversion to `McnCatalogSyncId` for sync_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,
sync_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let sync_id = sync_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&sync_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: "catalog_syncs_read",
};
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 CatalogSyncsUpdate<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
sync_id: Result<types::McnCatalogSyncId, String>,
body: Result<types::builder::McnUpdateCatalogSyncRequest, String>,
}
impl<'a> CatalogSyncsUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
sync_id: Err("sync_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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn sync_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncId>,
{
self.sync_id = value
.try_into()
.map_err(|_| "conversion to `McnCatalogSyncId` for sync_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateCatalogSyncRequest>,
<V as std::convert::TryInto<types::McnUpdateCatalogSyncRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateCatalogSyncRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateCatalogSyncRequest,
) -> types::builder::McnUpdateCatalogSyncRequest,
{
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,
sync_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let sync_id = sync_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::McnUpdateCatalogSyncRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&sync_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: "catalog_syncs_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 CatalogSyncsDelete<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
sync_id: Result<types::McnCatalogSyncId, String>,
delete_destination: Result<bool, String>,
}
impl<'a> CatalogSyncsDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
sync_id: Err("sync_id was not initialized".to_string()),
delete_destination: Err("delete_destination was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn sync_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncId>,
{
self.sync_id = value
.try_into()
.map_err(|_| "conversion to `McnCatalogSyncId` for sync_id failed".to_string());
self
}
pub fn delete_destination<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.delete_destination = value
.try_into()
.map_err(|_| "conversion to `bool` for delete_destination 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,
sync_id,
delete_destination,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let sync_id = sync_id.map_err(Error::InvalidRequest)?;
let delete_destination = delete_destination.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&sync_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"),
)
.query(&progenitor_client::QueryParam::new(
"delete_destination",
&delete_destination,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "catalog_syncs_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 CatalogSyncsPatch<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
sync_id: Result<types::McnCatalogSyncId, String>,
body: Result<types::builder::McnUpdateCatalogSyncRequest, String>,
}
impl<'a> CatalogSyncsPatch<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
sync_id: Err("sync_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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn sync_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncId>,
{
self.sync_id = value
.try_into()
.map_err(|_| "conversion to `McnCatalogSyncId` for sync_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateCatalogSyncRequest>,
<V as std::convert::TryInto<types::McnUpdateCatalogSyncRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateCatalogSyncRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateCatalogSyncRequest,
) -> types::builder::McnUpdateCatalogSyncRequest,
{
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,
sync_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let sync_id = sync_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::McnUpdateCatalogSyncRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&sync_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: "catalog_syncs_patch",
};
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 CatalogSyncsRefresh<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
sync_id: Result<types::McnCatalogSyncId, String>,
}
impl<'a> CatalogSyncsRefresh<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
sync_id: Err("sync_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn sync_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncId>,
{
self.sync_id = value
.try_into()
.map_err(|_| "conversion to `McnCatalogSyncId` for sync_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,
sync_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let sync_id = sync_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/{}/refresh",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&sync_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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "catalog_syncs_refresh",
};
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 CatalogSyncsPrebuiltPoliciesList<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
destination_type: Result<types::McnCatalogSyncDestinationType, String>,
}
impl<'a> CatalogSyncsPrebuiltPoliciesList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
destination_type: Err("destination_type was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn destination_type<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCatalogSyncDestinationType>,
{
self.destination_type = value.try_into().map_err(|_| {
"conversion to `McnCatalogSyncDestinationType` for destination_type 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,
destination_type,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let destination_type = destination_type.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/catalog-syncs/prebuilt-policies",
client.baseurl,
encode_path(&account_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(
"destination_type",
&destination_type,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "catalog_syncs_prebuilt_policies_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)),
}
}
}