use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct QueuesDelete<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
}
impl<'a> QueuesDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_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,
queue_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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: "queues_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 QueuesUpdatePartial<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::builder::MqQueue, String>,
}
impl<'a> QueuesUpdatePartial<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqQueue>,
<V as std::convert::TryInto<types::MqQueue>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `MqQueue` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::MqQueue) -> types::builder::MqQueue,
{
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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MqQueue::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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: "queues_update_partial",
};
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 QueuesListConsumers<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
}
impl<'a> QueuesListConsumers<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_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,
queue_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/consumers",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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: "queues_list_consumers",
};
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 QueuesCreateConsumer<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::MqConsumerRequest, String>,
}
impl<'a> QueuesCreateConsumer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqConsumerRequest>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MqConsumerRequest` 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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/consumers",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_create_consumer",
};
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 QueuesGetConsumer<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
consumer_id: Result<types::MqIdentifier, String>,
}
impl<'a> QueuesGetConsumer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
consumer_id: Err("consumer_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn consumer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.consumer_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for consumer_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,
queue_id,
consumer_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let consumer_id = consumer_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/consumers/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_id.to_string()),
encode_path(&consumer_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: "queues_get_consumer",
};
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 QueuesUpdateConsumer<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
consumer_id: Result<types::MqIdentifier, String>,
body: Result<types::MqConsumerRequest, String>,
}
impl<'a> QueuesUpdateConsumer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
consumer_id: Err("consumer_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<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn consumer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.consumer_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for consumer_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqConsumerRequest>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MqConsumerRequest` 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,
queue_id,
consumer_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let consumer_id = consumer_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/consumers/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_id.to_string()),
encode_path(&consumer_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: "queues_update_consumer",
};
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 QueuesDeleteConsumer<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
consumer_id: Result<types::MqIdentifier, String>,
}
impl<'a> QueuesDeleteConsumer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
consumer_id: Err("consumer_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn consumer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.consumer_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for consumer_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,
queue_id,
consumer_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let consumer_id = consumer_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/consumers/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_id.to_string()),
encode_path(&consumer_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: "queues_delete_consumer",
};
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 QueuesPushMessage<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::MqQueueMessage, String>,
}
impl<'a> QueuesPushMessage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqQueueMessage>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MqQueueMessage` 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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/messages",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_push_message",
};
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 QueuesAckMessages<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::builder::QueuesAckMessagesBody, String>,
}
impl<'a> QueuesAckMessages<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::QueuesAckMessagesBody>,
<V as std::convert::TryInto<types::QueuesAckMessagesBody>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `QueuesAckMessagesBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::QueuesAckMessagesBody,
) -> types::builder::QueuesAckMessagesBody,
{
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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::QueuesAckMessagesBody::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/messages/ack",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_ack_messages",
};
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 QueuesPushMessages<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::builder::MqQueueBatch, String>,
}
impl<'a> QueuesPushMessages<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqQueueBatch>,
<V as std::convert::TryInto<types::MqQueueBatch>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `MqQueueBatch` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::MqQueueBatch) -> types::builder::MqQueueBatch,
{
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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MqQueueBatch::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/messages/batch",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_push_messages",
};
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 QueuesPullMessages<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::builder::QueuesPullMessagesBody, String>,
}
impl<'a> QueuesPullMessages<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::QueuesPullMessagesBody>,
<V as std::convert::TryInto<types::QueuesPullMessagesBody>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `QueuesPullMessagesBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::QueuesPullMessagesBody,
) -> types::builder::QueuesPullMessagesBody,
{
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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::QueuesPullMessagesBody::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/messages/pull",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_pull_messages",
};
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 QueuesPurgeGet<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
}
impl<'a> QueuesPurgeGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_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,
queue_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/purge",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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: "queues_purge_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 QueuesPurge<'a> {
client: &'a crate::Client,
account_id: Result<types::MqIdentifier, String>,
queue_id: Result<types::MqIdentifier, String>,
body: Result<types::builder::QueuesPurgeBody, String>,
}
impl<'a> QueuesPurge<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_id: Err("queue_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::MqIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for account_id failed".to_string());
self
}
pub fn queue_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MqIdentifier>,
{
self.queue_id = value
.try_into()
.map_err(|_| "conversion to `MqIdentifier` for queue_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::QueuesPurgeBody>,
<V as std::convert::TryInto<types::QueuesPurgeBody>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `QueuesPurgeBody` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::QueuesPurgeBody) -> types::builder::QueuesPurgeBody,
{
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,
queue_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_id = queue_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::QueuesPurgeBody::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/queues/{}/purge",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&queue_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "queues_purge",
};
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)),
}
}
}