use crate::s3::MinioClient;
use crate::s3::builders::{BucketCommon, BucketCommonBuilder};
use crate::s3::error::ValidationErr;
use crate::s3::response::DeleteBucketNotificationResponse;
use crate::s3::segmented_bytes::SegmentedBytes;
use crate::s3::types::NotificationConfig;
use crate::s3::types::{BucketName, S3Api, S3Request, ToS3Request};
use crate::s3::utils::{check_bucket_name, insert};
use bytes::Bytes;
use http::Method;
use std::sync::Arc;
pub type DeleteBucketNotification = BucketCommon<DeleteBucketNotificationPhantomData>;
#[doc(hidden)]
#[derive(Clone, Debug)]
pub struct DeleteBucketNotificationPhantomData;
impl S3Api for DeleteBucketNotification {
type S3Response = DeleteBucketNotificationResponse;
}
pub type DeleteBucketNotificationBldr = BucketCommonBuilder<
DeleteBucketNotificationPhantomData,
((MinioClient,), (), (), (), (BucketName,), ()),
>;
impl ToS3Request for DeleteBucketNotification {
fn to_s3request(self) -> Result<S3Request, ValidationErr> {
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: Arc<SegmentedBytes> = Arc::new(SegmentedBytes::from(bytes));
Ok(S3Request::builder()
.client(self.client)
.method(Method::PUT)
.region(self.region)
.bucket(self.bucket)
.query_params(insert(self.extra_query_params, "notification"))
.headers(self.extra_headers.unwrap_or_default())
.body(body)
.build())
}
}