use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct SlurperGetJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> SlurperGetJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_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,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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: "slurper_get_job",
};
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 SlurperAbortJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> SlurperAbortJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_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,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}/abort",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_abort_job",
};
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 SlurperGetJobLogs<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
limit: Result<i64, String>,
offset: Result<i64, String>,
}
impl<'a> SlurperGetJobLogs<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
offset: Err("offset was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_id failed".to_string()
});
self
}
pub fn limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `i64` for limit failed".to_string());
self
}
pub fn offset<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.offset = value
.try_into()
.map_err(|_| "conversion to `i64` for offset 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,
job_id,
limit,
offset,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let offset = offset.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}/logs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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("limit", &limit))
.query(&progenitor_client::QueryParam::new("offset", &offset))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_get_job_logs",
};
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 SlurperPauseJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> SlurperPauseJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_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,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}/pause",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_pause_job",
};
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 SlurperGetJobProgress<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> SlurperGetJobProgress<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_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,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}/progress",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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: "slurper_get_job_progress",
};
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 SlurperResumeJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> SlurperResumeJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_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,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/jobs/{}/resume",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&job_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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_resume_job",
};
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 SlurperAbortAllJobs<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> SlurperAbortAllJobs<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` 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/{}/slurper/jobs/abortAll",
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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_abort_all_jobs",
};
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 SlurperCheckSourceConnectivity<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
body: Result<types::R2SlurperSourceJobSchema, String>,
}
impl<'a> SlurperCheckSourceConnectivity<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::R2SlurperSourceJobSchema>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `R2SlurperSourceJobSchema` for body 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,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/source/connectivity-precheck",
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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_check_source_connectivity",
};
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 SlurperCheckTargetConnectivity<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
body: Result<types::builder::R2SlurperR2TargetSchema, String>,
}
impl<'a> SlurperCheckTargetConnectivity<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::R2SlurperR2TargetSchema>,
<V as std::convert::TryInto<types::R2SlurperR2TargetSchema>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `R2SlurperR2TargetSchema` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::R2SlurperR2TargetSchema,
) -> types::builder::R2SlurperR2TargetSchema,
{
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,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::R2SlurperR2TargetSchema::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/slurper/target/connectivity-precheck",
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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "slurper_check_target_connectivity",
};
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)),
}
}
}