use crate::s3::builders::BucketCommon;
use crate::s3::error::Error;
use crate::s3::response::DeleteBucketNotificationResponse;
use crate::s3::segmented_bytes::SegmentedBytes;
use crate::s3::types::{NotificationConfig, S3Api, S3Request, ToS3Request};
use crate::s3::utils::{check_bucket_name, insert};
use bytes::Bytes;
use http::Method;
pub type DeleteBucketNotification = BucketCommon<DeleteBucketNotificationPhantomData>;
#[derive(Clone, Debug, Default)]
pub struct DeleteBucketNotificationPhantomData;
impl S3Api for DeleteBucketNotification {
type S3Response = DeleteBucketNotificationResponse;
}
impl ToS3Request for DeleteBucketNotification {
fn to_s3request(self) -> Result<S3Request, Error> {
check_bucket_name(&self.bucket, true)?;
const CONFIG: NotificationConfig = NotificationConfig {
cloud_func_config_list: None,
queue_config_list: None,
topic_config_list: None,
};
let bytes: Bytes = CONFIG.to_xml().into();
let body: Option<SegmentedBytes> = Some(SegmentedBytes::from(bytes));
Ok(S3Request::new(self.client, Method::PUT)
.region(self.region)
.bucket(Some(self.bucket))
.query_params(insert(self.extra_query_params, "notification"))
.headers(self.extra_headers.unwrap_or_default())
.body(body))
}
}