From 9495c5dccef572b12c23365580c728bd6ef9c1b3 Mon Sep 17 00:00:00 2001 From: Henk-Jan Lebbink Date: Sun, 11 May 2025 20:21:49 +0200 Subject: [PATCH] fixed incorrect renaming of listen_bucket_notification (#152) --- src/s3/builders.rs | 4 ++-- ...ation.rs => listen_bucket_notification.rs} | 20 +++++++++---------- src/s3/client.rs | 2 +- ...ation.rs => listen_bucket_notification.rs} | 17 +++++++++------- src/s3/response.rs | 4 ++-- ...ation.rs => listen_bucket_notification.rs} | 8 ++++---- tests/test_listen_bucket_notification.rs | 2 +- 7 files changed, 30 insertions(+), 27 deletions(-) rename src/s3/builders/{list_bucket_notification.rs => listen_bucket_notification.rs} (84%) rename src/s3/client/{list_bucket_notification.rs => listen_bucket_notification.rs} (76%) rename src/s3/response/{list_bucket_notification.rs => listen_bucket_notification.rs} (92%) diff --git a/src/s3/builders.rs b/src/s3/builders.rs index b57562d..8a06fe9 100644 --- a/src/s3/builders.rs +++ b/src/s3/builders.rs @@ -46,9 +46,9 @@ mod get_object_tagging; mod get_presigned_object_url; mod get_presigned_policy_form_data; mod get_region; -mod list_bucket_notification; mod list_buckets; mod list_objects; +mod listen_bucket_notification; mod put_bucket_encryption; mod put_bucket_lifecycle; mod put_bucket_notification; @@ -96,9 +96,9 @@ pub use get_object_tagging::*; pub use get_presigned_object_url::*; pub use get_presigned_policy_form_data::*; pub use get_region::*; -pub use list_bucket_notification::*; pub use list_buckets::*; pub use list_objects::*; +pub use listen_bucket_notification::*; pub use put_bucket_encryption::*; pub use put_bucket_lifecycle::*; pub use put_bucket_notification::*; diff --git a/src/s3/builders/list_bucket_notification.rs b/src/s3/builders/listen_bucket_notification.rs similarity index 84% rename from src/s3/builders/list_bucket_notification.rs rename to src/s3/builders/listen_bucket_notification.rs index f2f81d2..5ba7647 100644 --- a/src/s3/builders/list_bucket_notification.rs +++ b/src/s3/builders/listen_bucket_notification.rs @@ -21,16 +21,16 @@ use crate::s3::multimap::{Multimap, MultimapExt}; use crate::s3::{ client::Client, error::Error, - response::ListBucketNotificationResponse, + response::ListenBucketNotificationResponse, types::{NotificationRecords, S3Api, S3Request, ToS3Request}, utils::check_bucket_name, }; -/// Argument builder for -/// [listen_bucket_notification()](crate::s3::client::Client::list_bucket_notification) -/// API. +/// Argument builder for the [`ListenBucketNotification`](https://min.io/docs/minio/linux/developers/go/API.html#ListenBucketNotification) +/// +/// This struct constructs the parameters required for the [`Client::listen_bucket_notification`](crate::s3::client::Client::listen_bucket_notification) method. #[derive(Clone, Debug, Default)] -pub struct ListBucketNotification { +pub struct ListenBucketNotification { client: Client, extra_headers: Option, @@ -42,7 +42,7 @@ pub struct ListBucketNotification { events: Option>, } -impl ListBucketNotification { +impl ListenBucketNotification { pub fn new(client: Client, bucket: String) -> Self { Self { client, @@ -83,19 +83,19 @@ impl ListBucketNotification { } #[async_trait] -impl S3Api for ListBucketNotification { +impl S3Api for ListenBucketNotification { type S3Response = ( - ListBucketNotificationResponse, + ListenBucketNotificationResponse, Box> + Unpin + Send>, ); } -impl ToS3Request for ListBucketNotification { +impl ToS3Request for ListenBucketNotification { fn to_s3request(self) -> Result { { check_bucket_name(&self.bucket, true)?; if self.client.is_aws_host() { - return Err(Error::UnsupportedApi("ListBucketNotification".into())); + return Err(Error::UnsupportedApi("ListenBucketNotification".into())); } } diff --git a/src/s3/client.rs b/src/s3/client.rs index e793f05..aa09ba9 100644 --- a/src/s3/client.rs +++ b/src/s3/client.rs @@ -70,9 +70,9 @@ mod get_object_tagging; mod get_presigned_object_url; mod get_presigned_post_form_data; mod get_region; -mod list_bucket_notification; mod list_buckets; mod list_objects; +mod listen_bucket_notification; mod put_bucket_encryption; mod put_bucket_lifecycle; mod put_bucket_notification; diff --git a/src/s3/client/list_bucket_notification.rs b/src/s3/client/listen_bucket_notification.rs similarity index 76% rename from src/s3/client/list_bucket_notification.rs rename to src/s3/client/listen_bucket_notification.rs index 749c166..cd210e4 100644 --- a/src/s3/client/list_bucket_notification.rs +++ b/src/s3/client/listen_bucket_notification.rs @@ -16,13 +16,13 @@ //! MinIO Extension API for S3 Buckets: ListenBucketNotification use super::Client; -use crate::s3::builders::ListBucketNotification; +use crate::s3::builders::ListenBucketNotification; impl Client { - /// Creates a [`ListBucketNotification`] request builder. + /// Creates a [`ListenBucketNotification`] request builder. /// - /// To execute the request, call [`ListBucketNotification::send()`](crate::s3::types::S3Api::send), - /// which returns a tuple of [`ListBucketNotificationResponse`](crate::s3::response::ListBucketNotificationResponse) and a + /// To execute the request, call [`ListenBucketNotification::send()`](crate::s3::types::S3Api::send), + /// which returns a tuple of [`ListenBucketNotificationResponse`](crate::s3::response::ListenBucketNotificationResponse) and a /// stream of [`NotificationRecords`](crate::s3::types::NotificationRecords). The former contains the HTTP headers /// returned by the server and the latter is a stream of notification /// records. In normal operation (when there are no errors), the stream @@ -43,7 +43,7 @@ impl Client { /// async fn main() { /// let client: Client = Default::default(); // configure your client here /// let (_resp, mut event_stream) = client - /// .list_bucket_notification("bucket-name") + /// .listen_bucket_notification("bucket-name") /// .send().await .unwrap(); /// /// while let Some(event) = event_stream.next().await { @@ -53,7 +53,10 @@ impl Client { /// } /// } /// ``` - pub fn list_bucket_notification>(&self, bucket: S) -> ListBucketNotification { - ListBucketNotification::new(self.clone(), bucket.into()) + pub fn listen_bucket_notification>( + &self, + bucket: S, + ) -> ListenBucketNotification { + ListenBucketNotification::new(self.clone(), bucket.into()) } } diff --git a/src/s3/response.rs b/src/s3/response.rs index fd9b462..dd259ba 100644 --- a/src/s3/response.rs +++ b/src/s3/response.rs @@ -43,9 +43,9 @@ mod get_object_retention; mod get_object_tagging; mod get_presigned_object_url; mod get_region; -mod list_bucket_notification; mod list_buckets; pub(crate) mod list_objects; +mod listen_bucket_notification; mod put_bucket_encryption; mod put_bucket_lifecycle; mod put_bucket_notification; @@ -90,9 +90,9 @@ pub use get_object_retention::GetObjectRetentionResponse; pub use get_object_tagging::GetObjectTaggingResponse; pub use get_presigned_object_url::GetPresignedObjectUrlResponse; pub use get_region::GetRegionResponse; -pub use list_bucket_notification::ListBucketNotificationResponse; pub use list_buckets::ListBucketsResponse; pub use list_objects::ListObjectsResponse; +pub use listen_bucket_notification::ListenBucketNotificationResponse; pub use put_bucket_encryption::PutBucketEncryptionResponse; pub use put_bucket_lifecycle::PutBucketLifecycleResponse; pub use put_bucket_notification::PutBucketNotificationResponse; diff --git a/src/s3/response/list_bucket_notification.rs b/src/s3/response/listen_bucket_notification.rs similarity index 92% rename from src/s3/response/list_bucket_notification.rs rename to src/s3/response/listen_bucket_notification.rs index 177de0a..f0e96ba 100644 --- a/src/s3/response/list_bucket_notification.rs +++ b/src/s3/response/listen_bucket_notification.rs @@ -26,10 +26,10 @@ use crate::s3::{ }; /// Response of -/// [list_bucket_notification()](crate::s3::client::Client::list_bucket_notification) +/// [listen _bucket_notification()](crate::s3::client::Client::listen_bucket_notification) /// API #[derive(Debug)] -pub struct ListBucketNotificationResponse { +pub struct ListenBucketNotificationResponse { /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. pub headers: HeaderMap, @@ -43,7 +43,7 @@ pub struct ListBucketNotificationResponse { #[async_trait::async_trait] impl FromS3Response for ( - ListBucketNotificationResponse, + ListenBucketNotificationResponse, Box> + Unpin + Send>, ) { @@ -81,7 +81,7 @@ impl FromS3Response )); Ok(( - ListBucketNotificationResponse { + ListenBucketNotificationResponse { headers, region: req.inner_region, bucket: take_bucket(req.bucket)?, diff --git a/tests/test_listen_bucket_notification.rs b/tests/test_listen_bucket_notification.rs index 3d6c864..b948cc0 100644 --- a/tests/test_listen_bucket_notification.rs +++ b/tests/test_listen_bucket_notification.rs @@ -45,7 +45,7 @@ async fn listen_bucket_notification() { let (_resp, mut event_stream) = ctx2 .client - .list_bucket_notification(&bucket_name2) + .listen_bucket_notification(&bucket_name2) .send() .await .unwrap();