fixed incorrect renaming of listen_bucket_notification (#152)

This commit is contained in:
Henk-Jan Lebbink 2025-05-11 20:21:49 +02:00 committed by GitHub
parent 20d8654e34
commit 9495c5dcce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 27 deletions

View File

@ -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::*;

View File

@ -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<Multimap>,
@ -42,7 +42,7 @@ pub struct ListBucketNotification {
events: Option<Vec<String>>,
}
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<dyn Stream<Item = Result<NotificationRecords, Error>> + Unpin + Send>,
);
}
impl ToS3Request for ListBucketNotification {
impl ToS3Request for ListenBucketNotification {
fn to_s3request(self) -> Result<S3Request, Error> {
{
check_bucket_name(&self.bucket, true)?;
if self.client.is_aws_host() {
return Err(Error::UnsupportedApi("ListBucketNotification".into()));
return Err(Error::UnsupportedApi("ListenBucketNotification".into()));
}
}

View File

@ -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;

View File

@ -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<S: Into<String>>(&self, bucket: S) -> ListBucketNotification {
ListBucketNotification::new(self.clone(), bucket.into())
pub fn listen_bucket_notification<S: Into<String>>(
&self,
bucket: S,
) -> ListenBucketNotification {
ListenBucketNotification::new(self.clone(), bucket.into())
}
}

View File

@ -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;

View File

@ -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<dyn Stream<Item = Result<NotificationRecords, Error>> + Unpin + Send>,
)
{
@ -81,7 +81,7 @@ impl FromS3Response
));
Ok((
ListBucketNotificationResponse {
ListenBucketNotificationResponse {
headers,
region: req.inner_region,
bucket: take_bucket(req.bucket)?,

View File

@ -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();