├── .github ├── comprehensive-release.yml ├── release.yml └── workflows │ ├── label-checker.yaml │ ├── lint.yml │ ├── rust-clippy.yml │ └── rust.yml ├── .gitignore ├── .rustfmt.toml ├── .travis.yml ├── Cargo.toml ├── LICENSE ├── README.md ├── benches ├── README.md ├── bench_check_bucket_name.rs └── s3 │ ├── api_benchmarks.rs │ ├── bench_bucket_exists.rs │ ├── bench_bucket_lifecycle.rs │ ├── bench_bucket_notification.rs │ ├── bench_bucket_policy.rs │ ├── bench_bucket_replication.rs │ ├── bench_bucket_tagging.rs │ ├── bench_bucket_versioning.rs │ ├── bench_list_bucket.rs │ ├── bench_object_append.rs │ ├── bench_object_copy.rs │ ├── bench_object_legal_hold.rs │ ├── bench_object_lock_config.rs │ ├── bench_object_put.rs │ ├── bench_object_retention.rs │ ├── bench_object_tagging.rs │ └── common_benches.rs ├── common ├── Cargo.toml └── src │ ├── cleanup_guard.rs │ ├── example.rs │ ├── lib.rs │ ├── rand_reader.rs │ ├── rand_src.rs │ ├── test_context.rs │ └── utils.rs ├── deploy-docs.sh ├── examples ├── append_object.rs ├── bucket_encryption.rs ├── bucket_lifecycle.rs ├── bucket_versioning.rs ├── cat.png ├── common.rs ├── file_downloader.rs ├── file_uploader.rs ├── object_prompt.rs └── put_object.rs ├── rust-toolchain.toml ├── src ├── lib.rs └── s3 │ ├── builders.rs │ ├── builders │ ├── append_object.rs │ ├── bucket_common.rs │ ├── bucket_exists.rs │ ├── copy_object.rs │ ├── create_bucket.rs │ ├── delete_bucket.rs │ ├── delete_bucket_encryption.rs │ ├── delete_bucket_lifecycle.rs │ ├── delete_bucket_notification.rs │ ├── delete_bucket_policy.rs │ ├── delete_bucket_replication.rs │ ├── delete_bucket_tagging.rs │ ├── delete_object_lock_config.rs │ ├── delete_object_tagging.rs │ ├── delete_objects.rs │ ├── get_bucket_encryption.rs │ ├── get_bucket_lifecycle.rs │ ├── get_bucket_notification.rs │ ├── get_bucket_policy.rs │ ├── get_bucket_replication.rs │ ├── get_bucket_tagging.rs │ ├── get_bucket_versioning.rs │ ├── get_object.rs │ ├── get_object_legal_hold.rs │ ├── get_object_lock_config.rs │ ├── get_object_prompt.rs │ ├── get_object_retention.rs │ ├── get_object_tagging.rs │ ├── get_presigned_object_url.rs │ ├── get_presigned_policy_form_data.rs │ ├── get_region.rs │ ├── list_buckets.rs │ ├── list_objects.rs │ ├── listen_bucket_notification.rs │ ├── put_bucket_encryption.rs │ ├── put_bucket_lifecycle.rs │ ├── put_bucket_notification.rs │ ├── put_bucket_policy.rs │ ├── put_bucket_replication.rs │ ├── put_bucket_tagging.rs │ ├── put_bucket_versioning.rs │ ├── put_object.rs │ ├── put_object_legal_hold.rs │ ├── put_object_lock_config.rs │ ├── put_object_retention.rs │ ├── put_object_tagging.rs │ ├── select_object_content.rs │ └── stat_object.rs │ ├── client.rs │ ├── client │ ├── append_object.rs │ ├── bucket_exists.rs │ ├── copy_object.rs │ ├── create_bucket.rs │ ├── delete_bucket.rs │ ├── delete_bucket_encryption.rs │ ├── delete_bucket_lifecycle.rs │ ├── delete_bucket_notification.rs │ ├── delete_bucket_policy.rs │ ├── delete_bucket_replication.rs │ ├── delete_bucket_tagging.rs │ ├── delete_object_lock_config.rs │ ├── delete_object_tagging.rs │ ├── delete_objects.rs │ ├── get_bucket_encryption.rs │ ├── get_bucket_lifecycle.rs │ ├── get_bucket_notification.rs │ ├── get_bucket_policy.rs │ ├── get_bucket_replication.rs │ ├── get_bucket_tagging.rs │ ├── get_bucket_versioning.rs │ ├── get_object.rs │ ├── get_object_legal_hold.rs │ ├── get_object_lock_config.rs │ ├── get_object_prompt.rs │ ├── get_object_retention.rs │ ├── get_object_tagging.rs │ ├── get_presigned_object_url.rs │ ├── get_presigned_post_form_data.rs │ ├── get_region.rs │ ├── list_buckets.rs │ ├── list_objects.rs │ ├── listen_bucket_notification.rs │ ├── put_bucket_encryption.rs │ ├── put_bucket_lifecycle.rs │ ├── put_bucket_notification.rs │ ├── put_bucket_policy.rs │ ├── put_bucket_replication.rs │ ├── put_bucket_tagging.rs │ ├── put_bucket_versioning.rs │ ├── put_object.rs │ ├── put_object_legal_hold.rs │ ├── put_object_lock_config.rs │ ├── put_object_retention.rs │ ├── put_object_tagging.rs │ ├── select_object_content.rs │ └── stat_object.rs │ ├── creds.rs │ ├── error.rs │ ├── http.rs │ ├── lifecycle_config.rs │ ├── mod.rs │ ├── multimap.rs │ ├── object_content.rs │ ├── response.rs │ ├── response │ ├── append_object.rs │ ├── bucket_exists.rs │ ├── copy_object.rs │ ├── create_bucket.rs │ ├── delete_bucket.rs │ ├── delete_bucket_encryption.rs │ ├── delete_bucket_lifecycle.rs │ ├── delete_bucket_notification.rs │ ├── delete_bucket_policy.rs │ ├── delete_bucket_replication.rs │ ├── delete_bucket_tagging.rs │ ├── delete_object.rs │ ├── delete_object_lock_config.rs │ ├── delete_object_tagging.rs │ ├── get_bucket_encryption.rs │ ├── get_bucket_lifecycle.rs │ ├── get_bucket_notification.rs │ ├── get_bucket_policy.rs │ ├── get_bucket_replication.rs │ ├── get_bucket_tagging.rs │ ├── get_bucket_versioning.rs │ ├── get_object.rs │ ├── get_object_legal_hold.rs │ ├── get_object_lock_config.rs │ ├── get_object_prompt.rs │ ├── get_object_retention.rs │ ├── get_object_tagging.rs │ ├── get_presigned_object_url.rs │ ├── get_region.rs │ ├── list_buckets.rs │ ├── list_objects.rs │ ├── listen_bucket_notification.rs │ ├── put_bucket_encryption.rs │ ├── put_bucket_lifecycle.rs │ ├── put_bucket_notification.rs │ ├── put_bucket_policy.rs │ ├── put_bucket_replication.rs │ ├── put_bucket_tagging.rs │ ├── put_bucket_versioning.rs │ ├── put_object.rs │ ├── put_object_legal_hold.rs │ ├── put_object_lock_config.rs │ ├── put_object_retention.rs │ ├── put_object_tagging.rs │ ├── select_object_content.rs │ └── stat_object.rs │ ├── segmented_bytes.rs │ ├── signer.rs │ ├── sse.rs │ ├── types.rs │ └── utils.rs └── tests ├── private.key ├── public.crt ├── run-tests-windows.ps1 ├── start-server.sh ├── test_append_object.rs ├── test_bucket_create_delete.rs ├── test_bucket_encryption.rs ├── test_bucket_exists.rs ├── test_bucket_lifecycle.rs ├── test_bucket_notification.rs ├── test_bucket_policy.rs ├── test_bucket_replication.rs ├── test_bucket_tags.rs ├── test_bucket_versioning.rs ├── test_get_object.rs ├── test_get_presigned_object_url.rs ├── test_get_presigned_post_form_data.rs ├── test_list_buckets.rs ├── test_list_objects.rs ├── test_listen_bucket_notification.rs ├── test_object_compose.rs ├── test_object_copy.rs ├── test_object_legal_hold.rs ├── test_object_lock_config.rs ├── test_object_put.rs ├── test_object_remove.rs ├── test_object_retention.rs ├── test_object_tags.rs ├── test_put_object.rs ├── test_select_object_content.rs └── test_upload_download_object.rs /.github/comprehensive-release.yml: -------------------------------------------------------------------------------- 1 | # Generate release notes using a standard format 2 | 3 | changelog: 4 | categories: 5 | - title: Highlighted Changes 6 | labels: 7 | - highlight 8 | - title: Breaking Changes 9 | labels: 10 | - breaking-change 11 | - title: Security Fixes 12 | labels: 13 | - security-fix 14 | - title: Misc. Fixes and Improvements 15 | labels: 16 | - "*" -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | # Generate release notes using a standard format 2 | 3 | changelog: 4 | categories: 5 | - title: Highlighted Changes 6 | labels: 7 | - highlight 8 | - title: Breaking Changes 9 | labels: 10 | - breaking-change 11 | - title: Security Fixes 12 | labels: 13 | - security-fix -------------------------------------------------------------------------------- /.github/workflows/label-checker.yaml: -------------------------------------------------------------------------------- 1 | name: Label Checker 2 | on: 3 | pull_request: 4 | types: 5 | - opened 6 | - synchronize 7 | - labeled 8 | - unlabeled 9 | 10 | jobs: 11 | 12 | check_labels: 13 | name: Check for labels 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: docker://agilepathway/pull-request-label-checker:latest 17 | with: 18 | one_of: highlight,breaking-change,security-fix,enhancement,bug 19 | repo_token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Rust Linters 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | pull_request: 7 | branches: ["main"] 8 | 9 | # This ensures that previous jobs for the PR are canceled when the PR is 10 | # updated. 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.head_ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | fmt: 17 | name: rustfmt 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: dtolnay/rust-toolchain@stable 22 | with: 23 | components: rustfmt 24 | - run: cargo fmt --all --check 25 | -------------------------------------------------------------------------------- /.github/workflows/rust-clippy.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # rust-clippy is a tool that runs a bunch of lints to catch common 6 | # mistakes in your Rust code and help improve your Rust code. 7 | # More details at https://github.com/rust-lang/rust-clippy 8 | # and https://rust-lang.github.io/rust-clippy/ 9 | 10 | name: rust-clippy analyze 11 | 12 | on: 13 | push: 14 | branches: [ "main" ] 15 | pull_request: 16 | # The branches below must be a subset of the branches above 17 | branches: [ "main" ] 18 | schedule: 19 | - cron: '41 23 * * 1' 20 | 21 | jobs: 22 | rust-clippy-analyze: 23 | name: Run rust-clippy analyzing 24 | runs-on: ubuntu-latest 25 | permissions: 26 | contents: read 27 | security-events: write 28 | actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status 29 | steps: 30 | - name: Checkout code 31 | uses: actions/checkout@v4 32 | 33 | - name: Install Rust toolchain 34 | uses: actions-rs/toolchain@v1 35 | with: 36 | profile: minimal 37 | toolchain: stable 38 | components: clippy 39 | override: true 40 | 41 | - name: Install required cargo 42 | run: cargo install clippy-sarif sarif-fmt 43 | 44 | - name: Run rust-clippy 45 | run: 46 | cargo clippy 47 | --all-features 48 | --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt 49 | continue-on-error: true 50 | 51 | - name: Upload analysis results to GitHub 52 | uses: github/codeql-action/upload-sarif@v3 53 | with: 54 | sarif_file: rust-clippy-results.sarif 55 | wait-for-processing: true 56 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: MinIO Rust Library 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | timeout-minutes: 5 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Build 21 | run: | 22 | cargo --version 23 | cargo fmt --all -- --check 24 | cargo clippy --all-targets --all-features 25 | cargo build --bins --examples --tests --benches --verbose 26 | 27 | - name: Run tests 28 | run: | 29 | ./tests/start-server.sh 30 | export SERVER_ENDPOINT=localhost:9000 31 | export ACCESS_KEY=minioadmin 32 | export SECRET_KEY=minioadmin 33 | export ENABLE_HTTPS=1 34 | export SSL_CERT_FILE=./tests/public.crt 35 | cargo test --verbose -- --nocapture 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | .idea 5 | *.env 6 | .cargo 7 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # rustfmt doc - https://rust-lang.github.io/rustfmt/ 2 | 3 | hard_tabs = false 4 | edition = "2024" 5 | 6 | max_width = 100 7 | array_width = 60 # default is 60 8 | attr_fn_like_width = 70 # default is 70 9 | chain_width = 60 # default is 60 10 | 11 | reorder_imports = true -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: rust 3 | rust: 4 | - stable 5 | - beta 6 | - nightly 7 | matrix: 8 | allow_failures: 9 | - rust: nightly 10 | os: 11 | - linux 12 | 13 | install: 14 | - (rustup component add rustfmt || true) 15 | - PATH=$PATH:/home/travis/.cargo/bin 16 | 17 | env: 18 | global: 19 | - RUST_BACKTRACE=1 20 | 21 | script: 22 | - cargo fmt --all -- --check 23 | - cargo build --verbose --all 24 | - cargo test --verbose --all 25 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minio" 3 | version = "0.3.0" 4 | edition = "2024" 5 | authors = ["MinIO Dev Team "] 6 | description = "MinIO SDK for Amazon S3 compatible object storage access" 7 | license = "Apache-2.0" 8 | repository = "https://github.com/minio/minio-rs" 9 | readme = "README.md" 10 | keywords = ["object-storage", "minio", "s3"] 11 | categories = ["api-bindings", "web-programming::http-client"] 12 | 13 | [dependencies.reqwest] 14 | version = "0.12.18" 15 | default-features = false 16 | features = ["stream"] 17 | 18 | [features] 19 | default = ["default-tls", "dep:hmac", "dep:sha2"] 20 | default-tls = ["reqwest/default-tls"] 21 | native-tls = ["reqwest/native-tls"] 22 | rustls-tls = ["reqwest/rustls-tls"] 23 | ring = ["dep:ring"] 24 | 25 | [dependencies] 26 | async-recursion = "1.1.1" 27 | async-trait = "0.1.88" 28 | base64 = "0.22.1" 29 | byteorder = "1.5.0" 30 | bytes = "1.10.1" 31 | chrono = "0.4.41" 32 | crc = "3.3.0" 33 | dashmap = "6.1.0" 34 | derivative = "2.2.0" 35 | env_logger = "0.11.8" 36 | futures-util = "0.3.31" 37 | hex = "0.4.3" 38 | hmac = { version = "0.12.1", optional = true } 39 | hyper = { version = "1.6.0", features = ["full"] } 40 | lazy_static = "1.5.0" 41 | log = "0.4.27" 42 | md5 = "0.7.0" 43 | multimap = "0.10.1" 44 | percent-encoding = "2.3.1" 45 | rand = { version = "0.8.5", features = ["small_rng"] } 46 | regex = "1.11.1" 47 | ring = { version = "0.17.14", optional = true, default-features = false, features = ["alloc"] } 48 | serde = { version = "1.0.219", features = ["derive"] } 49 | serde_json = "1.0.140" 50 | sha2 = { version = "0.10.8", optional = true } 51 | tokio = { version = "1.45.1", features = ["full"] } 52 | tokio-stream = "0.1.17" 53 | tokio-util = { version = "0.7.15", features = ["io"] } 54 | urlencoding = "2.1.3" 55 | xmltree = "0.11.0" 56 | futures = "0.3.31" 57 | http = "1.3.1" 58 | 59 | [dev-dependencies] 60 | minio_common = { path = "./common" } 61 | async-std = { version = "1.13.1", features = ["attributes", "tokio1"] } 62 | clap = { version = "4.5.39", features = ["derive"] } 63 | quickcheck = "1.0.3" 64 | criterion = "0.6.0" 65 | 66 | [lib] 67 | name = "minio" 68 | path = "src/lib.rs" 69 | 70 | [[example]] 71 | name = "file_uploader" 72 | 73 | [[example]] 74 | name = "file_downloader" 75 | 76 | [[example]] 77 | name = "object_prompt" 78 | 79 | [[example]] 80 | name = "append_object" 81 | 82 | [[bench]] 83 | name = "s3-api" 84 | path = "benches/s3/api_benchmarks.rs" 85 | harness = false 86 | -------------------------------------------------------------------------------- /benches/README.md: -------------------------------------------------------------------------------- 1 | Benches: 2 | 3 | * Designed for low-level, micro-benchmarks. 4 | * Focuses on measuring specific functions or operations. 5 | * Outputs raw benchmarking results. 6 | 7 | run: `cargo bench --bench s3_api_benchmarks` 8 | 9 | results are in `target\criterion` -------------------------------------------------------------------------------- /benches/bench_check_bucket_name.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use criterion::{Criterion, criterion_group, criterion_main}; 17 | use minio::s3::utils::check_bucket_name; 18 | 19 | fn bench_check_bucket_name(c: &mut Criterion) { 20 | c.bench_function("check_bucket_name true", |b| { 21 | b.iter(|| check_bucket_name("my-example-bucket-name", true)) 22 | }); 23 | 24 | c.bench_function("check_bucket_name false", |b| { 25 | b.iter(|| check_bucket_name("my-example-bucket-name", false)) 26 | }); 27 | } 28 | 29 | criterion_group!(benches, bench_check_bucket_name); 30 | criterion_main!(benches); 31 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_exists.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::BucketExists; 20 | 21 | pub(crate) fn bench_bucket_exists(criterion: &mut Criterion) { 22 | benchmark_s3_api( 23 | "bucket_exists", 24 | criterion, 25 | || async { Ctx2::new().await }, 26 | |ctx| BucketExists::new(ctx.client.clone(), ctx.bucket.clone()), 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{DeleteBucketLifecycle, GetBucketLifecycle, PutBucketLifecycle}; 20 | use minio::s3::types::S3Api; 21 | use minio_common::example::create_bucket_lifecycle_config_examples; 22 | 23 | pub(crate) fn bench_put_bucket_lifecycle(criterion: &mut Criterion) { 24 | benchmark_s3_api( 25 | "put_bucket_lifecycle", 26 | criterion, 27 | || async { Ctx2::new().await }, 28 | |ctx| { 29 | let config = create_bucket_lifecycle_config_examples(); 30 | PutBucketLifecycle::new(ctx.client.clone(), ctx.bucket.clone()) 31 | .life_cycle_config(config) 32 | }, 33 | ) 34 | } 35 | pub(crate) fn bench_get_bucket_lifecycle(criterion: &mut Criterion) { 36 | benchmark_s3_api( 37 | "get_bucket_lifecycle", 38 | criterion, 39 | || async { 40 | let ctx = Ctx2::new().await; 41 | let config = create_bucket_lifecycle_config_examples(); 42 | ctx.client 43 | .put_bucket_lifecycle(&ctx.bucket) 44 | .life_cycle_config(config) 45 | .send() 46 | .await 47 | .unwrap(); 48 | ctx 49 | }, 50 | |ctx| GetBucketLifecycle::new(ctx.client.clone(), ctx.bucket.clone()), 51 | ) 52 | } 53 | pub(crate) fn bench_delete_bucket_lifecycle(criterion: &mut Criterion) { 54 | benchmark_s3_api( 55 | "delete_bucket_lifecycle", 56 | criterion, 57 | || async { Ctx2::new().await }, 58 | |ctx| DeleteBucketLifecycle::new(ctx.client.clone(), ctx.bucket.clone()), 59 | ) 60 | } 61 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{DeleteBucketNotification, GetBucketNotification, PutBucketNotification}; 20 | use minio::s3::types::S3Api; 21 | use minio_common::example::create_bucket_notification_config_example; 22 | 23 | #[allow(dead_code)] 24 | pub(crate) fn bench_put_bucket_notification(criterion: &mut Criterion) { 25 | benchmark_s3_api( 26 | "put_bucket_notification", 27 | criterion, 28 | || async { Ctx2::new().await }, 29 | |ctx| { 30 | let config = create_bucket_notification_config_example(); 31 | PutBucketNotification::new(ctx.client.clone(), ctx.bucket.clone()) 32 | .notification_config(config) 33 | }, 34 | ) 35 | } 36 | #[allow(dead_code)] 37 | pub(crate) fn bench_get_bucket_notification(criterion: &mut Criterion) { 38 | benchmark_s3_api( 39 | "get_bucket_notification", 40 | criterion, 41 | || async { 42 | let ctx = Ctx2::new().await; 43 | let config = create_bucket_notification_config_example(); 44 | ctx.client 45 | .put_bucket_notification(&ctx.bucket) 46 | .notification_config(config) 47 | .send() 48 | .await 49 | .unwrap(); 50 | ctx 51 | }, 52 | |ctx| GetBucketNotification::new(ctx.client.clone(), ctx.bucket.clone()), 53 | ) 54 | } 55 | #[allow(dead_code)] 56 | pub(crate) fn bench_delete_bucket_notification(criterion: &mut Criterion) { 57 | benchmark_s3_api( 58 | "delete_bucket_notification", 59 | criterion, 60 | || async { Ctx2::new().await }, 61 | |ctx| DeleteBucketNotification::new(ctx.client.clone(), ctx.bucket.clone()), 62 | ) 63 | } 64 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{DeleteBucketPolicy, GetBucketPolicy, PutBucketPolicy}; 20 | use minio::s3::types::S3Api; 21 | use minio_common::example::create_bucket_policy_config_example; 22 | 23 | pub(crate) fn bench_put_bucket_policy(criterion: &mut Criterion) { 24 | benchmark_s3_api( 25 | "put_bucket_policy", 26 | criterion, 27 | || async { Ctx2::new().await }, 28 | |ctx| { 29 | let config = create_bucket_policy_config_example(&ctx.bucket); 30 | PutBucketPolicy::new(ctx.client.clone(), ctx.bucket.clone()).config(config) 31 | }, 32 | ) 33 | } 34 | pub(crate) fn bench_get_bucket_policy(criterion: &mut Criterion) { 35 | benchmark_s3_api( 36 | "get_bucket_policy", 37 | criterion, 38 | || async { 39 | let ctx = Ctx2::new().await; 40 | let config = create_bucket_policy_config_example(&ctx.bucket); 41 | PutBucketPolicy::new(ctx.client.clone(), ctx.bucket.clone()) 42 | .config(config) 43 | .send() 44 | .await 45 | .unwrap(); 46 | ctx 47 | }, 48 | |ctx| GetBucketPolicy::new(ctx.client.clone(), ctx.bucket.clone()), 49 | ) 50 | } 51 | pub(crate) fn bench_delete_bucket_policy(criterion: &mut Criterion) { 52 | benchmark_s3_api( 53 | "delete_bucket_policy", 54 | criterion, 55 | || async { Ctx2::new().await }, 56 | |ctx| DeleteBucketPolicy::new(ctx.client.clone(), ctx.bucket.clone()), 57 | ) 58 | } 59 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{DeleteBucketTagging, GetBucketTagging, PutBucketTagging}; 20 | use minio::s3::types::S3Api; 21 | use minio_common::example::create_tags_example; 22 | 23 | pub(crate) fn bench_put_bucket_tagging(criterion: &mut Criterion) { 24 | if skip_express_mode("bench_put_bucket_tagging") { 25 | return; 26 | } 27 | benchmark_s3_api( 28 | "put_bucket_tagging", 29 | criterion, 30 | || async { Ctx2::new().await }, 31 | |ctx| { 32 | PutBucketTagging::new(ctx.client.clone(), ctx.bucket.clone()) 33 | .tags(create_tags_example()) 34 | }, 35 | ) 36 | } 37 | pub(crate) fn bench_get_bucket_tagging(criterion: &mut Criterion) { 38 | if skip_express_mode("bench_get_bucket_tagging") { 39 | return; 40 | } 41 | benchmark_s3_api( 42 | "get_bucket_tagging", 43 | criterion, 44 | || async { 45 | let ctx = Ctx2::new().await; 46 | ctx.client 47 | .put_bucket_tagging(&ctx.bucket) 48 | .tags(create_tags_example()) 49 | .send() 50 | .await 51 | .unwrap(); 52 | ctx 53 | }, 54 | |ctx| GetBucketTagging::new(ctx.client.clone(), ctx.bucket.clone()), 55 | ) 56 | } 57 | pub(crate) fn bench_delete_bucket_tagging(criterion: &mut Criterion) { 58 | if skip_express_mode("bench_delete_bucket_tagging") { 59 | return; 60 | } 61 | benchmark_s3_api( 62 | "delete_bucket_tagging", 63 | criterion, 64 | || async { Ctx2::new().await }, 65 | |ctx| DeleteBucketTagging::new(ctx.client.clone(), ctx.bucket.clone()), 66 | ) 67 | } 68 | -------------------------------------------------------------------------------- /benches/s3/bench_bucket_versioning.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{GetBucketVersioning, PutBucketVersioning, VersioningStatus}; 20 | 21 | pub(crate) fn bench_get_bucket_versioning(criterion: &mut Criterion) { 22 | if skip_express_mode("bench_get_bucket_versioning") { 23 | return; 24 | } 25 | benchmark_s3_api( 26 | "get_bucket_versioning", 27 | criterion, 28 | || async { Ctx2::new().await }, 29 | |ctx| GetBucketVersioning::new(ctx.client.clone(), ctx.bucket.clone()), 30 | ) 31 | } 32 | pub(crate) fn bench_put_bucket_versioning(criterion: &mut Criterion) { 33 | if skip_express_mode("bench_put_bucket_versioning") { 34 | return; 35 | } 36 | benchmark_s3_api( 37 | "put_bucket_versioning", 38 | criterion, 39 | || async { Ctx2::new().await }, 40 | |ctx| { 41 | PutBucketVersioning::new(ctx.client.clone(), ctx.bucket.clone()) 42 | .versioning_status(VersioningStatus::Enabled) 43 | }, 44 | ) 45 | } 46 | -------------------------------------------------------------------------------- /benches/s3/bench_list_bucket.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::ListBuckets; 20 | 21 | pub(crate) fn bench_list_buckets(criterion: &mut Criterion) { 22 | benchmark_s3_api( 23 | "list_buckets", 24 | criterion, 25 | || async { Ctx2::new().await }, 26 | |ctx| ListBuckets::new(ctx.client.clone()), 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /benches/s3/bench_object_append.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::AppendObject; 20 | use minio::s3::response::StatObjectResponse; 21 | use minio::s3::segmented_bytes::SegmentedBytes; 22 | use minio::s3::types::S3Api; 23 | use minio_common::test_context::TestContext; 24 | use tokio::task; 25 | 26 | #[allow(dead_code)] 27 | pub(crate) fn bench_object_append(criterion: &mut Criterion) { 28 | if !TestContext::new_from_env().client.is_minio_express() { 29 | println!("Skipping benchmark because it is NOT running in MinIO Express mode"); 30 | return; 31 | } 32 | benchmark_s3_api( 33 | "object_append", 34 | criterion, 35 | || async { Ctx2::new_with_object(false).await }, 36 | |ctx| { 37 | let content1 = "Hello world 2"; 38 | let data1: SegmentedBytes = SegmentedBytes::from(content1.to_string()); 39 | 40 | let resp: StatObjectResponse = task::block_in_place(|| { 41 | tokio::runtime::Runtime::new()? 42 | .block_on(ctx.client.stat_object(&ctx.bucket, &ctx.object).send()) 43 | }) 44 | .unwrap(); 45 | 46 | let offset_bytes: u64 = resp.size; 47 | AppendObject::new( 48 | ctx.client.clone(), 49 | ctx.bucket.clone(), 50 | ctx.object.clone(), 51 | data1, 52 | offset_bytes, 53 | ) 54 | }, 55 | ) 56 | } 57 | -------------------------------------------------------------------------------- /benches/s3/bench_object_copy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{CopyObjectInternal, CopySource}; 20 | use minio_common::utils::rand_object_name; 21 | 22 | pub(crate) fn bench_object_copy_internal(criterion: &mut Criterion) { 23 | benchmark_s3_api( 24 | "object_copy_internal", 25 | criterion, 26 | || async { Ctx2::new_with_object(false).await }, 27 | |ctx| { 28 | let object_name_src = &ctx.object; 29 | let object_name_dst = rand_object_name(); 30 | CopyObjectInternal::new(ctx.client.clone(), ctx.bucket.clone(), object_name_dst) 31 | .source(CopySource::new(&ctx.bucket, object_name_src).unwrap()) 32 | }, 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /benches/s3/bench_object_legal_hold.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{GetObjectLegalHold, PutObjectLegalHold}; 20 | use minio::s3::types::S3Api; 21 | 22 | pub(crate) fn bench_put_object_legal_hold(criterion: &mut Criterion) { 23 | if skip_express_mode("bench_put_object_legal_hold") { 24 | return; 25 | } 26 | benchmark_s3_api( 27 | "put_object_legal_hold", 28 | criterion, 29 | || async { Ctx2::new_with_object(true).await }, 30 | |ctx| { 31 | PutObjectLegalHold::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()) 32 | .legal_hold(Some(true)) 33 | }, 34 | ) 35 | } 36 | pub(crate) fn bench_get_object_legal_hold(criterion: &mut Criterion) { 37 | if skip_express_mode("bench_get_object_legal_hold") { 38 | return; 39 | } 40 | benchmark_s3_api( 41 | "get_object_legal_hold", 42 | criterion, 43 | || async { 44 | let ctx = Ctx2::new_with_object(true).await; 45 | ctx.client 46 | .get_object_legal_hold(&ctx.bucket, &ctx.object) 47 | .send() 48 | .await 49 | .unwrap(); 50 | ctx 51 | }, 52 | |ctx| GetObjectLegalHold::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()), 53 | ) 54 | } 55 | -------------------------------------------------------------------------------- /benches/s3/bench_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | use criterion::Criterion; 18 | use minio::s3::builders::{DeleteObjectLockConfig, GetObjectLockConfig, PutObjectLockConfig}; 19 | use minio_common::example::create_object_lock_config_example; 20 | 21 | pub(crate) fn bench_put_object_lock_config(criterion: &mut Criterion) { 22 | if skip_express_mode("bench_put_object_lock_config") { 23 | return; 24 | } 25 | benchmark_s3_api( 26 | "put_object_lock_config", 27 | criterion, 28 | || async { Ctx2::new_with_object(true).await }, 29 | |ctx| { 30 | let config = create_object_lock_config_example(); 31 | PutObjectLockConfig::new(ctx.client.clone(), ctx.bucket.clone()).config(config) 32 | }, 33 | ) 34 | } 35 | pub(crate) fn bench_get_object_lock_config(criterion: &mut Criterion) { 36 | if skip_express_mode("bench_get_object_lock_config") { 37 | return; 38 | } 39 | benchmark_s3_api( 40 | "get_object_lock_config", 41 | criterion, 42 | || async { Ctx2::new_with_object(true).await }, 43 | |ctx| GetObjectLockConfig::new(ctx.client.clone(), ctx.bucket.clone()), 44 | ) 45 | } 46 | pub(crate) fn bench_delete_object_lock_config(criterion: &mut Criterion) { 47 | if skip_express_mode("bench_delete_object_lock_config") { 48 | return; 49 | } 50 | benchmark_s3_api( 51 | "delete_object_lock_config", 52 | criterion, 53 | || async { Ctx2::new_with_object(true).await }, 54 | |ctx| DeleteObjectLockConfig::new(ctx.client.clone(), ctx.bucket.clone()), 55 | ) 56 | } 57 | -------------------------------------------------------------------------------- /benches/s3/bench_object_put.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{ObjectContent, PutObject}; 20 | use minio::s3::segmented_bytes::SegmentedBytes; 21 | use minio_common::rand_src::RandSrc; 22 | use minio_common::utils::rand_object_name; 23 | use tokio::task; 24 | 25 | pub(crate) fn bench_object_put(criterion: &mut Criterion) { 26 | benchmark_s3_api( 27 | "object_put", 28 | criterion, 29 | || async { Ctx2::new().await }, 30 | |ctx| { 31 | let object_name: String = rand_object_name(); 32 | let size = 1024 * 1024_u64; // 1MB 33 | let object_content = ObjectContent::new_from_stream(RandSrc::new(size), Some(size)); 34 | 35 | let data: SegmentedBytes = task::block_in_place(|| { 36 | tokio::runtime::Runtime::new()?.block_on(object_content.to_segmented_bytes()) 37 | }) 38 | .unwrap(); 39 | 40 | PutObject::new(ctx.client.clone(), ctx.bucket.clone(), object_name, data) 41 | }, 42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /benches/s3/bench_object_retention.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{GetObjectRetention, PutObjectRetention}; 20 | use minio::s3::response::PutObjectRetentionResponse; 21 | use minio::s3::types::{RetentionMode, S3Api}; 22 | use minio::s3::utils::utc_now; 23 | 24 | pub(crate) fn bench_put_object_retention(criterion: &mut Criterion) { 25 | if skip_express_mode("bench_put_object_retention") { 26 | return; 27 | } 28 | benchmark_s3_api( 29 | "put_object_retention", 30 | criterion, 31 | || async { Ctx2::new_with_object(true).await }, 32 | |ctx| { 33 | PutObjectRetention::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()) 34 | .retention_mode(Some(RetentionMode::GOVERNANCE)) 35 | .retain_until_date(Some(utc_now() + chrono::Duration::days(1))) 36 | }, 37 | ) 38 | } 39 | pub(crate) fn bench_get_object_retention(criterion: &mut Criterion) { 40 | if skip_express_mode("bench_get_object_retention") { 41 | return; 42 | } 43 | benchmark_s3_api( 44 | "get_object_retention", 45 | criterion, 46 | || async { 47 | let ctx = Ctx2::new_with_object(true).await; 48 | let _resp: PutObjectRetentionResponse = 49 | PutObjectRetention::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()) 50 | .retention_mode(Some(RetentionMode::GOVERNANCE)) 51 | .retain_until_date(Some(utc_now() + chrono::Duration::days(1))) 52 | .send() 53 | .await 54 | .unwrap(); 55 | ctx 56 | }, 57 | |ctx| GetObjectRetention::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()), 58 | ) 59 | } 60 | -------------------------------------------------------------------------------- /benches/s3/bench_object_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::common_benches::{Ctx2, benchmark_s3_api, skip_express_mode}; 17 | 18 | use criterion::Criterion; 19 | use minio::s3::builders::{GetObjectTagging, PutObjectTagging}; 20 | use minio::s3::response::PutObjectTaggingResponse; 21 | use minio::s3::types::S3Api; 22 | use minio_common::example::create_tags_example; 23 | 24 | pub(crate) fn bench_put_object_tagging(criterion: &mut Criterion) { 25 | if skip_express_mode("bench_put_object_tagging") { 26 | return; 27 | } 28 | benchmark_s3_api( 29 | "put_object_tagging", 30 | criterion, 31 | || async { Ctx2::new_with_object(false).await }, 32 | |ctx| { 33 | PutObjectTagging::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()) 34 | .tags(create_tags_example()) 35 | }, 36 | ) 37 | } 38 | pub(crate) fn bench_get_object_tagging(criterion: &mut Criterion) { 39 | if skip_express_mode("bench_get_object_tagging") { 40 | return; 41 | } 42 | benchmark_s3_api( 43 | "get_object_tagging", 44 | criterion, 45 | || async { 46 | let ctx = Ctx2::new_with_object(false).await; 47 | 48 | let _resp: PutObjectTaggingResponse = ctx 49 | .client 50 | .put_object_tagging(&ctx.bucket, &ctx.object) 51 | .tags(create_tags_example()) 52 | .send() 53 | .await 54 | .unwrap(); 55 | ctx 56 | }, 57 | |ctx| GetObjectTagging::new(ctx.client.clone(), ctx.bucket.clone(), ctx.object.clone()), 58 | ) 59 | } 60 | -------------------------------------------------------------------------------- /common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minio_common" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | minio = {path = ".." } 8 | tokio = { version = "1.44.1", features = ["full"] } 9 | tokio-stream = "0.1.17" 10 | async-std = "1.13.1" 11 | rand = { version = "0.8.5", features = ["small_rng"] } 12 | bytes = "1.10.1" 13 | log = "0.4.27" 14 | chrono = "0.4.40" 15 | reqwest = "0.12.15" 16 | http = "1.3.1" 17 | 18 | [lib] 19 | name = "minio_common" 20 | path = "src/lib.rs" 21 | 22 | -------------------------------------------------------------------------------- /common/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cleanup_guard; 2 | pub mod example; 3 | pub mod rand_reader; 4 | pub mod rand_src; 5 | pub mod test_context; 6 | pub mod utils; 7 | -------------------------------------------------------------------------------- /common/src/rand_reader.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use std::io; 17 | 18 | pub struct RandReader { 19 | size: u64, 20 | } 21 | 22 | impl RandReader { 23 | #[allow(dead_code)] 24 | pub fn new(size: u64) -> RandReader { 25 | RandReader { size } 26 | } 27 | } 28 | 29 | impl io::Read for RandReader { 30 | fn read(&mut self, buf: &mut [u8]) -> Result { 31 | let bytes_read: usize = match (self.size as usize) > buf.len() { 32 | true => buf.len(), 33 | false => self.size as usize, 34 | }; 35 | 36 | if bytes_read > 0 { 37 | let random: &mut dyn rand::RngCore = &mut rand::thread_rng(); 38 | random.fill_bytes(&mut buf[0..bytes_read]); 39 | } 40 | 41 | self.size -= bytes_read as u64; 42 | 43 | Ok(bytes_read) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/utils.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use http::{Response as HttpResponse, StatusCode}; 17 | use minio::s3::error::Error; 18 | use rand::distributions::{Alphanumeric, DistString}; 19 | 20 | pub fn rand_bucket_name() -> String { 21 | Alphanumeric 22 | .sample_string(&mut rand::thread_rng(), 8) 23 | .to_lowercase() 24 | } 25 | 26 | pub fn rand_object_name() -> String { 27 | Alphanumeric.sample_string(&mut rand::thread_rng(), 20) 28 | } 29 | 30 | pub async fn get_bytes_from_response(v: Result) -> bytes::Bytes { 31 | match v { 32 | Ok(r) => match r.bytes().await { 33 | Ok(b) => b, 34 | Err(e) => panic!("{:?}", e), 35 | }, 36 | Err(e) => panic!("{:?}", e), 37 | } 38 | } 39 | 40 | pub fn get_response_from_bytes(bytes: bytes::Bytes) -> reqwest::Response { 41 | let http_response = HttpResponse::builder() 42 | .status(StatusCode::OK) // You can customize the status if needed 43 | .header("Content-Type", "application/octet-stream") 44 | .body(bytes) 45 | .expect("Failed to build HTTP response"); 46 | 47 | reqwest::Response::try_from(http_response).expect("Failed to convert to reqwest::Response") 48 | } 49 | -------------------------------------------------------------------------------- /deploy-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cargo doc --all --no-deps 4 | rm -rf ./docs 5 | echo "" > target/doc/index.html 6 | git checkout gh-pages 7 | git rm --quiet -r --force --ignore-unmatch ./* 8 | cp -a target/doc ./docs 9 | git add docs/ 10 | 11 | echo "minio-rs.min.io" > CNAME 12 | git add CNAME 13 | 14 | git commit --quiet --all -m "update rustdoc htmls" 15 | git push -u origin gh-pages 16 | -------------------------------------------------------------------------------- /examples/bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | mod common; 17 | 18 | use crate::common::{create_bucket_if_not_exists, create_client_on_play}; 19 | use minio::s3::Client; 20 | use minio::s3::response::{GetBucketEncryptionResponse, PutBucketEncryptionResponse}; 21 | use minio::s3::types::{S3Api, SseConfig}; 22 | 23 | #[tokio::main] 24 | async fn main() -> Result<(), Box> { 25 | env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher 26 | let client: Client = create_client_on_play()?; 27 | 28 | let bucket_name: &str = "encryption-rust-bucket"; 29 | create_bucket_if_not_exists(bucket_name, &client).await?; 30 | 31 | let resp: GetBucketEncryptionResponse = 32 | client.get_bucket_encryption(bucket_name).send().await?; 33 | log::info!("encryption before: config={:?}", resp.config); 34 | 35 | let config = SseConfig::default(); 36 | log::info!("going to set encryption config={:?}", config); 37 | 38 | let _resp: PutBucketEncryptionResponse = client 39 | .put_bucket_encryption(bucket_name) 40 | .sse_config(config.clone()) 41 | .send() 42 | .await?; 43 | 44 | let resp: GetBucketEncryptionResponse = 45 | client.get_bucket_encryption(bucket_name).send().await?; 46 | log::info!("encryption after: config={:?}", resp.config); 47 | 48 | Ok(()) 49 | } 50 | -------------------------------------------------------------------------------- /examples/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minio/minio-rs/7d0fcaa5a41e6f4337e1b79cd15ee6b0024c65ae/examples/cat.png -------------------------------------------------------------------------------- /examples/common.rs: -------------------------------------------------------------------------------- 1 | use minio::s3::creds::StaticProvider; 2 | use minio::s3::http::BaseUrl; 3 | use minio::s3::response::BucketExistsResponse; 4 | use minio::s3::types::S3Api; 5 | use minio::s3::{Client, ClientBuilder}; 6 | 7 | #[allow(dead_code)] 8 | pub fn create_client_on_play() -> Result> { 9 | let base_url = "https://play.min.io".parse::()?; 10 | log::info!("Trying to connect to MinIO at: `{:?}`", base_url); 11 | 12 | let static_provider = StaticProvider::new( 13 | "Q3AM3UQ867SPQQA43P2F", 14 | "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", 15 | None, 16 | ); 17 | 18 | let client = ClientBuilder::new(base_url.clone()) 19 | .provider(Some(Box::new(static_provider))) 20 | .build()?; 21 | Ok(client) 22 | } 23 | 24 | #[allow(dead_code)] 25 | pub fn create_client_on_localhost() -> Result> { 26 | let base_url = "http://localhost:9000/".parse::()?; 27 | log::info!("Trying to connect to MinIO at: `{:?}`", base_url); 28 | 29 | let static_provider = StaticProvider::new("minioadmin", "minioadmin", None); 30 | 31 | let client = ClientBuilder::new(base_url.clone()) 32 | .provider(Some(Box::new(static_provider))) 33 | .build()?; 34 | Ok(client) 35 | } 36 | 37 | pub async fn create_bucket_if_not_exists( 38 | bucket_name: &str, 39 | client: &Client, 40 | ) -> Result<(), Box> { 41 | // Check 'bucket_name' bucket exist or not. 42 | let resp: BucketExistsResponse = client.bucket_exists(bucket_name).send().await?; 43 | 44 | // Make 'bucket_name' bucket if not exist. 45 | if !resp.exists { 46 | client.create_bucket(bucket_name).send().await.unwrap(); 47 | }; 48 | Ok(()) 49 | } 50 | 51 | #[allow(dead_code)] 52 | #[tokio::main] 53 | async fn main() -> Result<(), Box> { 54 | // dummy code just to prevent an error because files in examples need to have a main 55 | Ok(()) 56 | } 57 | -------------------------------------------------------------------------------- /examples/file_downloader.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | mod common; 17 | 18 | use crate::common::{create_bucket_if_not_exists, create_client_on_play}; 19 | use minio::s3::Client; 20 | use minio::s3::builders::ObjectContent; 21 | use minio::s3::types::S3Api; 22 | use std::path::Path; 23 | 24 | #[tokio::main] 25 | async fn main() -> Result<(), Box> { 26 | env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher 27 | let client: Client = create_client_on_play()?; 28 | 29 | let bucket_name: &str = "file-download-rust-bucket"; 30 | let object_name: &str = "cat.png"; 31 | 32 | // File we are going to upload to the bucket 33 | let filename: &Path = Path::new("./examples/cat.png"); 34 | let download_path: &str = &format!("/tmp/downloads/{object_name}"); 35 | 36 | create_bucket_if_not_exists(bucket_name, &client).await?; 37 | 38 | if filename.exists() { 39 | log::info!("File '{}' exists.", &filename.to_str().unwrap()); 40 | } else { 41 | log::error!("File '{}' does not exist.", &filename.to_str().unwrap()); 42 | return Ok(()); 43 | } 44 | 45 | let content = ObjectContent::from(filename); 46 | client 47 | .put_object_content(bucket_name, object_name, content) 48 | .send() 49 | .await?; 50 | 51 | log::info!( 52 | "file '{}' is successfully uploaded as object '{object_name}' to bucket '{bucket_name}'.", 53 | filename.display() 54 | ); 55 | 56 | let get_object = client.get_object(bucket_name, object_name).send().await?; 57 | 58 | get_object.content.to_file(Path::new(download_path)).await?; 59 | 60 | log::info!("Object '{object_name}' is successfully downloaded to file '{download_path}'."); 61 | 62 | Ok(()) 63 | } 64 | -------------------------------------------------------------------------------- /examples/file_uploader.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | mod common; 16 | 17 | use crate::common::{create_bucket_if_not_exists, create_client_on_play}; 18 | use minio::s3::Client; 19 | use minio::s3::builders::ObjectContent; 20 | use std::path::Path; 21 | 22 | #[tokio::main] 23 | async fn main() -> Result<(), Box> { 24 | env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher 25 | let client: Client = create_client_on_play()?; 26 | 27 | let bucket_name: &str = "file-upload-rust-bucket"; 28 | create_bucket_if_not_exists(bucket_name, &client).await?; 29 | 30 | // File we are going to upload to the bucket 31 | let filename: &Path = Path::new("./examples/cat.png"); 32 | 33 | // Name of the object that will be stored in the bucket 34 | let object_name: &str = "cat.png"; 35 | 36 | if filename.exists() { 37 | log::info!("File '{}' exists.", &filename.to_str().unwrap()); 38 | } else { 39 | log::error!("File '{}' does not exist.", &filename.to_str().unwrap()); 40 | return Ok(()); 41 | } 42 | 43 | let content = ObjectContent::from(filename); 44 | client 45 | .put_object_content(bucket_name, object_name, content) 46 | .send() 47 | .await?; 48 | 49 | log::info!( 50 | "file '{}' is successfully uploaded as object '{object_name}' to bucket '{bucket_name}'.", 51 | filename.display() 52 | ); 53 | Ok(()) 54 | } 55 | -------------------------------------------------------------------------------- /examples/put_object.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use clap::Parser; 17 | use log::info; 18 | use minio::s3::response::BucketExistsResponse; 19 | use minio::s3::types::S3Api; 20 | use minio::s3::{Client, builders::ObjectContent, client::ClientBuilder, creds::StaticProvider}; 21 | use std::path::PathBuf; 22 | 23 | /// Upload a file to the given bucket and object path on the MinIO Play server. 24 | #[derive(Parser)] 25 | struct Cli { 26 | /// Bucket to upload the file to (will be created if it doesn't exist) 27 | bucket: String, 28 | /// Object path to upload the file to. 29 | object: String, 30 | /// File to upload. 31 | file: PathBuf, 32 | } 33 | 34 | #[tokio::main] 35 | async fn main() -> Result<(), Box> { 36 | let args = Cli::parse(); 37 | 38 | let static_provider = StaticProvider::new( 39 | "Q3AM3UQ867SPQQA43P2F", 40 | "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", 41 | None, 42 | ); 43 | 44 | let client: Client = ClientBuilder::new("https://play.min.io".parse()?) 45 | .provider(Some(Box::new(static_provider))) 46 | .build()?; 47 | 48 | let resp: BucketExistsResponse = client.bucket_exists(&args.bucket).send().await.unwrap(); 49 | 50 | if !resp.exists { 51 | client.create_bucket(&args.bucket).send().await.unwrap(); 52 | } 53 | 54 | let content = ObjectContent::from(args.file.as_path()); 55 | // Put an object 56 | client 57 | .put_object_content(&args.bucket, &args.object, content) 58 | .send() 59 | .await?; 60 | 61 | info!( 62 | "Uploaded file at {:?} to {}/{}", 63 | args.file, args.bucket, args.object 64 | ); 65 | 66 | Ok(()) 67 | } 68 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.86.0" 3 | components = ["clippy", "rustfmt"] 4 | #targets = ["x86_64-unknown-linux-musl"] -------------------------------------------------------------------------------- /src/s3/builders/bucket_common.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use std::marker::PhantomData; 17 | 18 | use crate::s3::client::Client; 19 | use crate::s3::multimap::Multimap; 20 | 21 | /// Common parameters for bucket operations 22 | /// 23 | /// See [Amazon S3 Buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html) for more information. 24 | #[derive(Clone, Debug, Default)] 25 | pub struct BucketCommon { 26 | pub(crate) client: Client, 27 | 28 | pub(crate) extra_headers: Option, 29 | pub(crate) extra_query_params: Option, 30 | pub(crate) region: Option, 31 | pub(crate) bucket: String, 32 | 33 | _operation: PhantomData, 34 | } 35 | 36 | impl BucketCommon { 37 | pub fn new(client: Client, bucket: String) -> BucketCommon { 38 | BucketCommon { 39 | client, 40 | bucket, 41 | ..Default::default() 42 | } 43 | } 44 | 45 | /// Sets extra headers for the request 46 | pub fn extra_headers(mut self, extra_headers: Option) -> Self { 47 | self.extra_headers = extra_headers; 48 | self 49 | } 50 | 51 | /// Sets extra query parameters for the request 52 | pub fn extra_query_params(mut self, extra_query_params: Option) -> Self { 53 | self.extra_query_params = extra_query_params; 54 | self 55 | } 56 | 57 | /// Sets the region for the request 58 | pub fn region(mut self, region: Option) -> Self { 59 | self.region = region; 60 | self 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/s3/builders/bucket_exists.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::BucketExistsResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::check_bucket_name; 21 | use http::Method; 22 | 23 | /// This struct constructs the parameters required for the [`Client::bucket_exists`](crate::s3::client::Client::bucket_exists) method. 24 | /// 25 | /// See [Amazon S3: Working with Buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html) 26 | /// for more information about checking if a bucket exists. 27 | pub type BucketExists = BucketCommon; 28 | 29 | #[doc(hidden)] 30 | #[derive(Clone, Debug, Default)] 31 | pub struct BucketExistsPhantomData; 32 | 33 | impl S3Api for BucketExists { 34 | type S3Response = BucketExistsResponse; 35 | } 36 | 37 | impl ToS3Request for BucketExists { 38 | fn to_s3request(self) -> Result { 39 | check_bucket_name(&self.bucket, true)?; 40 | 41 | Ok(S3Request::new(self.client, Method::HEAD) 42 | .region(self.region) 43 | .bucket(Some(self.bucket)) 44 | .query_params(self.extra_query_params.unwrap_or_default()) 45 | .headers(self.extra_headers.unwrap_or_default())) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::check_bucket_name; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket`](crate::s3::client::Client::delete_bucket) method. 26 | /// See [Amazon S3: Deleting Buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/delete-bucket.html) for more information. 27 | pub type DeleteBucket = BucketCommon; 28 | 29 | #[doc(hidden)] 30 | #[derive(Clone, Debug, Default)] 31 | pub struct DeleteBucketPhantomData; 32 | 33 | impl S3Api for DeleteBucket { 34 | type S3Response = DeleteBucketResponse; 35 | } 36 | 37 | impl ToS3Request for DeleteBucket { 38 | fn to_s3request(self) -> Result { 39 | check_bucket_name(&self.bucket, true)?; 40 | 41 | Ok(S3Request::new(self.client, Method::DELETE) 42 | .region(self.region) 43 | .bucket(Some(self.bucket)) 44 | .query_params(self.extra_query_params.unwrap_or_default()) 45 | .headers(self.extra_headers.unwrap_or_default())) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketEncryptionResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucketEncryption`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket_encryption`](crate::s3::client::Client::delete_bucket_encryption) method. 26 | pub type DeleteBucketEncryption = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteBucketEncryptionPhantomData; 31 | 32 | impl S3Api for DeleteBucketEncryption { 33 | type S3Response = DeleteBucketEncryptionResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteBucketEncryption { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::DELETE) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "encryption")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketLifecycleResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucketLifecycle`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket_lifecycle`](crate::s3::client::Client::delete_bucket_lifecycle) method. 26 | pub type DeleteBucketLifecycle = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteBucketLifecyclePhantomData; 31 | 32 | impl S3Api for DeleteBucketLifecycle { 33 | type S3Response = DeleteBucketLifecycleResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteBucketLifecycle { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::DELETE) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "lifecycle")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketPolicyResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucketPolicy`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketPolicy.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket_policy`](crate::s3::client::Client::delete_bucket_policy) method. 26 | pub type DeleteBucketPolicy = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteBucketPolicyPhantomData; 31 | 32 | impl S3Api for DeleteBucketPolicy { 33 | type S3Response = DeleteBucketPolicyResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteBucketPolicy { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::DELETE) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "policy")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket_replication.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketReplicationResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucketReplication`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketReplication.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket_replication`](crate::s3::client::Client::delete_bucket_replication) method. 26 | pub type DeleteBucketReplication = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteBucketReplicationPhantomData; 31 | 32 | impl S3Api for DeleteBucketReplication { 33 | type S3Response = DeleteBucketReplicationResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteBucketReplication { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::DELETE) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "replication")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/delete_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteBucketTaggingResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`DeleteBucketTagging`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketTagging.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::delete_bucket_tags`](crate::s3::client::Client::delete_bucket_tagging) method. 26 | pub type DeleteBucketTagging = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteBucketTaggingPhantomData; 31 | 32 | impl S3Api for DeleteBucketTagging { 33 | type S3Response = DeleteBucketTaggingResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteBucketTagging { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::DELETE) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "tagging")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/delete_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::DeleteObjectLockConfigResponse; 19 | use crate::s3::segmented_bytes::SegmentedBytes; 20 | use crate::s3::types::{ObjectLockConfig, S3Api, S3Request, ToS3Request}; 21 | use crate::s3::utils::{check_bucket_name, insert}; 22 | use bytes::Bytes; 23 | use http::Method; 24 | 25 | /// This struct constructs the parameters required for the [`Client::delete_object_lock_config`](crate::s3::client::Client::delete_object_lock_config) method. 26 | pub type DeleteObjectLockConfig = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct DeleteObjectLockConfigPhantomData; 31 | 32 | impl S3Api for DeleteObjectLockConfig { 33 | type S3Response = DeleteObjectLockConfigResponse; 34 | } 35 | 36 | impl ToS3Request for DeleteObjectLockConfig { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | let config = ObjectLockConfig { 41 | retention_mode: None, 42 | retention_duration_days: None, 43 | retention_duration_years: None, 44 | }; 45 | let bytes: Bytes = config.to_xml().into(); 46 | let body: Option = Some(SegmentedBytes::from(bytes)); 47 | //TODO consider const body 48 | 49 | Ok(S3Request::new(self.client, Method::PUT) 50 | .region(self.region) 51 | .bucket(Some(self.bucket)) 52 | .query_params(insert(self.extra_query_params, "object-lock")) 53 | .headers(self.extra_headers.unwrap_or_default()) 54 | .body(body)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/s3/builders/get_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetBucketEncryptionResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetBucketEncryption`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_bucket_encryption`](crate::s3::client::Client::get_bucket_encryption) method. 26 | pub type GetBucketEncryption = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct GetBucketEncryptionPhantomData; 31 | 32 | impl S3Api for GetBucketEncryption { 33 | type S3Response = GetBucketEncryptionResponse; 34 | } 35 | 36 | impl ToS3Request for GetBucketEncryption { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "encryption")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/get_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetBucketNotificationResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetBucketNotification`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketNotification.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_bucket_notification`](crate::s3::client::Client::get_bucket_notification) method. 26 | pub type GetBucketNotification = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Default, Debug)] 30 | pub struct GetBucketNotificationPhantomData; 31 | 32 | impl S3Api for GetBucketNotification { 33 | type S3Response = GetBucketNotificationResponse; 34 | } 35 | 36 | impl ToS3Request for GetBucketNotification { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "notification")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/get_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetBucketPolicyResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetBucketPolicy`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicy.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_bucket_policy`](crate::s3::client::Client::get_bucket_policy) method. 26 | pub type GetBucketPolicy = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct GetBucketPolicyPhantomData; 31 | 32 | impl S3Api for GetBucketPolicy { 33 | type S3Response = GetBucketPolicyResponse; 34 | } 35 | 36 | impl ToS3Request for GetBucketPolicy { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "policy")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/get_bucket_replication.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetBucketReplicationResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetBucketReplication`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketReplication.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_bucket_replication`](crate::s3::client::Client::get_bucket_replication) method. 26 | pub type GetBucketReplication = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct GetBucketReplicationPhantomData; 31 | 32 | impl S3Api for GetBucketReplication { 33 | type S3Response = GetBucketReplicationResponse; 34 | } 35 | 36 | impl ToS3Request for GetBucketReplication { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "replication")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/get_bucket_versioning.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetBucketVersioningResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetBucketVersioning`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_bucket_versioning`](crate::s3::client::Client::get_bucket_versioning) method. 26 | pub type GetBucketVersioning = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct GetBucketVersioningPhantomData; 31 | 32 | impl S3Api for GetBucketVersioning { 33 | type S3Response = GetBucketVersioningResponse; 34 | } 35 | 36 | impl ToS3Request for GetBucketVersioning { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "versioning")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/get_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::BucketCommon; 17 | use crate::s3::error::Error; 18 | use crate::s3::response::GetObjectLockConfigResponse; 19 | use crate::s3::types::{S3Api, S3Request, ToS3Request}; 20 | use crate::s3::utils::{check_bucket_name, insert}; 21 | use http::Method; 22 | 23 | /// Argument builder for the [`GetObjectLockConfig`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLockConfiguration.html) S3 API operation. 24 | /// 25 | /// This struct constructs the parameters required for the [`Client::get_object_lock_config`](crate::s3::client::Client::get_object_lock_config) method. 26 | pub type GetObjectLockConfig = BucketCommon; 27 | 28 | #[doc(hidden)] 29 | #[derive(Clone, Debug, Default)] 30 | pub struct GetObjectLockConfigPhantomData; 31 | 32 | impl S3Api for GetObjectLockConfig { 33 | type S3Response = GetObjectLockConfigResponse; 34 | } 35 | 36 | impl ToS3Request for GetObjectLockConfig { 37 | fn to_s3request(self) -> Result { 38 | check_bucket_name(&self.bucket, true)?; 39 | 40 | Ok(S3Request::new(self.client, Method::GET) 41 | .region(self.region) 42 | .bucket(Some(self.bucket)) 43 | .query_params(insert(self.extra_query_params, "object-lock")) 44 | .headers(self.extra_headers.unwrap_or_default())) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/builders/list_buckets.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use http::Method; 17 | 18 | use crate::s3::multimap::Multimap; 19 | use crate::s3::response::ListBucketsResponse; 20 | use crate::s3::{ 21 | Client, 22 | error::Error, 23 | types::{S3Api, S3Request, ToS3Request}, 24 | }; 25 | 26 | /// Argument builder for the [`ListBuckets`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html) S3 API operation. 27 | /// 28 | /// This struct constructs the parameters required for the [`Client::list_buckets`](crate::s3::client::Client::list_buckets) method. 29 | #[derive(Clone, Debug, Default)] 30 | pub struct ListBuckets { 31 | client: Client, 32 | 33 | extra_headers: Option, 34 | extra_query_params: Option, 35 | } 36 | 37 | impl ListBuckets { 38 | pub fn new(client: Client) -> Self { 39 | Self { 40 | client, 41 | ..Default::default() 42 | } 43 | } 44 | 45 | pub fn extra_headers(mut self, extra_headers: Option) -> Self { 46 | self.extra_headers = extra_headers; 47 | self 48 | } 49 | 50 | pub fn extra_query_params(mut self, extra_query_params: Option) -> Self { 51 | self.extra_query_params = extra_query_params; 52 | self 53 | } 54 | } 55 | 56 | impl S3Api for ListBuckets { 57 | type S3Response = ListBucketsResponse; 58 | } 59 | 60 | impl ToS3Request for ListBuckets { 61 | fn to_s3request(self) -> Result { 62 | Ok(S3Request::new(self.client, Method::GET) 63 | .query_params(self.extra_query_params.unwrap_or_default()) 64 | .headers(self.extra_headers.unwrap_or_default())) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/s3/client/bucket_exists.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::BucketExists; 18 | 19 | impl Client { 20 | /// Creates a [`BucketExists`] request builder to check if a bucket exists in S3. 21 | /// 22 | /// To execute the request, call [`BucketExists::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`BucketExistsResponse`](crate::s3::response::BucketExistsResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::BucketExistsResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: BucketExistsResponse = client 36 | /// .bucket_exists("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("bucket '{}' exists: {}", resp.bucket, resp.exists); 39 | /// } 40 | /// ``` 41 | pub fn bucket_exists>(&self, bucket: S) -> BucketExists { 42 | BucketExists::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/create_bucket.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::CreateBucket; 18 | 19 | impl Client { 20 | /// Creates a [`CreateBucket`] request builder. 21 | /// 22 | /// To execute the request, call [`CreateBucket::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`CreateBucketResponse`](crate::s3::response::CreateBucketResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::CreateBucketResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: CreateBucketResponse = client 36 | /// .create_bucket("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("Made bucket '{}' in region '{}'", resp.bucket, resp.region); 39 | /// } 40 | /// ``` 41 | pub fn create_bucket>(&self, bucket: S) -> CreateBucket { 42 | CreateBucket::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketEncryption; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketEncryption`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketEncryption::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`BucketExistsResponse`](crate::s3::response::BucketExistsResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::DeleteBucketEncryptionResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: DeleteBucketEncryptionResponse = client 36 | /// .delete_bucket_encryption("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("bucket '{}' is deleted", resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn delete_bucket_encryption>(&self, bucket: S) -> DeleteBucketEncryption { 42 | DeleteBucketEncryption::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketLifecycle; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketLifecycle`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketLifecycle::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteBucketLifecycleResponse`](crate::s3::response::DeleteBucketLifecycleResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::DeleteBucketLifecycleResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: DeleteBucketLifecycleResponse = client 36 | /// .delete_bucket_lifecycle("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("lifecycle of bucket '{}' is deleted", resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn delete_bucket_lifecycle>(&self, bucket: S) -> DeleteBucketLifecycle { 42 | DeleteBucketLifecycle::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketNotification; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketNotification`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketNotification::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteBucketNotificationResponse`](crate::s3::response::DeleteBucketNotificationResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::DeleteBucketNotificationResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: DeleteBucketNotificationResponse = client 36 | /// .delete_bucket_notification("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("notification of bucket '{}' is deleted", resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn delete_bucket_notification>( 42 | &self, 43 | bucket: S, 44 | ) -> DeleteBucketNotification { 45 | DeleteBucketNotification::new(self.clone(), bucket.into()) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketPolicy; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketPolicy`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketPolicy::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteBucketPolicyResponse`](crate::s3::response::DeleteBucketPolicyResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::DeleteBucketPolicyResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: DeleteBucketPolicyResponse = client 36 | /// .delete_bucket_policy("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("policy of bucket '{}' is deleted", resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn delete_bucket_policy>(&self, bucket: S) -> DeleteBucketPolicy { 42 | DeleteBucketPolicy::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_replication.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketReplication; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketReplication`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketReplication::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteBucketReplicationResponse`](crate::s3::response::DeleteBucketReplicationResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::DeleteBucketReplicationResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: DeleteBucketReplicationResponse = client 38 | /// .delete_bucket_replication("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("replication of bucket '{}' is deleted", resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn delete_bucket_replication>(&self, bucket: S) -> DeleteBucketReplication { 44 | DeleteBucketReplication::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/delete_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteBucketTagging; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteBucketTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteBucketTagging::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteBucketTagsResponse`](crate::s3::response::DeleteBucketTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::DeleteBucketTaggingResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: DeleteBucketTaggingResponse = client 38 | /// .delete_bucket_tagging("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("tags of bucket '{}' are deleted", resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn delete_bucket_tagging>(&self, bucket: S) -> DeleteBucketTagging { 44 | DeleteBucketTagging::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/delete_object_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::DeleteObjectTagging; 18 | 19 | impl Client { 20 | /// Creates a [`DeleteObjectTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`DeleteObjectTagging::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DeleteObjectTagsResponse`](crate::s3::response::DeleteObjectTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::DeleteObjectTaggingResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: DeleteObjectTaggingResponse = client 38 | /// .delete_object_tagging("bucket-name", "object_name") 39 | /// .send().await.unwrap(); 40 | /// println!("legal hold of object '{}' in bucket '{}' is deleted", resp.object, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn delete_object_tagging, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | ) -> DeleteObjectTagging { 48 | DeleteObjectTagging::new(self.clone(), bucket.into(), object.into()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketEncryption; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketEncryption`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketEncryption::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketEncryptionResponse`](crate::s3::response::GetBucketEncryptionResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::GetBucketEncryptionResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: GetBucketEncryptionResponse = client 36 | /// .get_bucket_encryption("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("retrieved SseConfig '{:?}' from bucket '{}'", resp.config, resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn get_bucket_encryption>(&self, bucket: S) -> GetBucketEncryption { 42 | GetBucketEncryption::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketLifecycle; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketLifecycle`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketLifecycle::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketLifecycleResponse`](crate::s3::response::GetBucketLifecycleResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::GetBucketLifecycleResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: GetBucketLifecycleResponse = client 36 | /// .get_bucket_lifecycle("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("retrieved bucket lifecycle config '{:?}' from bucket '{}'", resp.config, resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn get_bucket_lifecycle>(&self, bucket: S) -> GetBucketLifecycle { 42 | GetBucketLifecycle::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketNotification; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketNotification`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketNotification::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketNotificationResponse`](crate::s3::response::GetBucketNotificationResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::GetBucketNotificationResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: GetBucketNotificationResponse = client 36 | /// .get_bucket_notification("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("retrieved bucket notification config '{:?}' from bucket '{}'", resp.config, resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn get_bucket_notification>(&self, bucket: S) -> GetBucketNotification { 42 | GetBucketNotification::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketPolicy; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketPolicy`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketPolicy::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketPolicyResponse`](crate::s3::response::GetBucketPolicyResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::GetBucketPolicyResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: GetBucketPolicyResponse = client 36 | /// .get_bucket_policy("bucket-name") 37 | /// .send().await.unwrap(); 38 | /// println!("retrieved bucket policy config '{:?}' from bucket '{}'", resp.config, resp.bucket); 39 | /// } 40 | /// ``` 41 | pub fn get_bucket_policy>(&self, bucket: S) -> GetBucketPolicy { 42 | GetBucketPolicy::new(self.clone(), bucket.into()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_replication.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketReplication; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketReplication`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketReplication::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketReplicationResponse`](crate::s3::response::GetBucketReplicationResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetBucketReplicationResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetBucketReplicationResponse = client 38 | /// .get_bucket_replication("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved bucket replication config '{:?}' from bucket '{}'", resp.config, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_bucket_replication>(&self, bucket: S) -> GetBucketReplication { 44 | GetBucketReplication::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketTagging; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketTags::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketTagsResponse`](crate::s3::response::GetBucketTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetBucketTaggingResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetBucketTaggingResponse = client 38 | /// .get_bucket_tagging("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved bucket tags '{:?}' from bucket '{}'", resp.tags, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_bucket_tagging>(&self, bucket: S) -> GetBucketTagging { 44 | GetBucketTagging::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/get_bucket_versioning.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetBucketVersioning; 18 | 19 | impl Client { 20 | /// Creates a [`GetBucketVersioning`] request builder. 21 | /// 22 | /// To execute the request, call [`GetBucketVersioning::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetBucketVersioningResponse`](crate::s3::response::GetBucketVersioningResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetBucketVersioningResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetBucketVersioningResponse = client 38 | /// .get_bucket_versioning("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved versioning status '{:?}' from bucket '{}'", resp.status, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_bucket_versioning>(&self, bucket: S) -> GetBucketVersioning { 44 | GetBucketVersioning::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/get_object.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2023 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetObject; 18 | 19 | impl Client { 20 | /// Creates a [`GetObject`] request builder to download an object from a specified S3 bucket. 21 | /// This allows retrieval of the full content and metadata for the object. 22 | /// 23 | /// To execute the request, call [`GetObject::send()`](crate::s3::types::S3Api::send), 24 | /// which returns a [`Result`] containing a [`GetObjectResponse`](crate::s3::response::GetObjectResponse). 25 | /// 26 | /// For more information, refer to the [AWS S3 GetObject API documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html). 27 | /// 28 | /// # Example 29 | /// 30 | /// ```no_run 31 | /// use minio::s3::Client; 32 | /// use minio::s3::response::GetObjectResponse; 33 | /// use minio::s3::types::S3Api; 34 | /// 35 | /// #[tokio::main] 36 | /// async fn main() { 37 | /// let client: Client = Default::default(); // configure your client here 38 | /// let resp: GetObjectResponse = client 39 | /// .get_object("bucket-name", "object-name") 40 | /// .send().await.unwrap(); 41 | /// let content_bytes = resp.content.to_segmented_bytes().await.unwrap().to_bytes(); 42 | /// let content_str = String::from_utf8(content_bytes.to_vec()).unwrap(); 43 | /// println!("retrieved content '{content_str}'"); 44 | /// } 45 | /// ``` 46 | pub fn get_object, S2: Into>( 47 | &self, 48 | bucket: S1, 49 | object: S2, 50 | ) -> GetObject { 51 | GetObject::new(self.clone(), bucket.into(), object.into()) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/s3/client/get_object_legal_hold.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetObjectLegalHold; 18 | 19 | impl Client { 20 | /// Creates a [`GetObjectLegalHold`] request builder. 21 | /// 22 | /// To execute the request, call [`GetObjectLegalHold::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetObjectLegalHoldResponse`](crate::s3::response::GetObjectLegalHoldResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetObjectLegalHoldResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetObjectLegalHoldResponse = client 38 | /// .get_object_legal_hold("bucket-name", "object-name") 39 | /// .send().await.unwrap(); 40 | /// println!("legal hold of object '{}' in bucket '{}' is enabled: {}", resp.object, resp.bucket, resp.enabled); 41 | /// } 42 | /// ``` 43 | pub fn get_object_legal_hold, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | ) -> GetObjectLegalHold { 48 | GetObjectLegalHold::new(self.clone(), bucket.into(), object.into()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/client/get_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetObjectLockConfig; 18 | 19 | impl Client { 20 | /// Creates a [`GetObjectLockConfig`] request builder. 21 | /// 22 | /// To execute the request, call [`GetObjectLockConfig::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetObjectLockConfigResponse`](crate::s3::response::GetObjectLockConfigResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetObjectLockConfigResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetObjectLockConfigResponse = client 38 | /// .get_object_lock_config("bucket-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved object lock config '{:?}' from bucket '{}' is enabled", resp.config, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_object_lock_config>(&self, bucket: S) -> GetObjectLockConfig { 44 | GetObjectLockConfig::new(self.clone(), bucket.into()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/get_object_prompt.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::builders::GetObjectPrompt; 17 | 18 | use super::Client; 19 | 20 | impl Client { 21 | /// Creates a [`GetObjectPrompt`] request builder. Prompt an object using natural language. 22 | /// 23 | /// To execute the request, call [`GetObjectPrompt::send()`](crate::s3::types::S3Api::send), 24 | /// which returns a [`Result`] containing a [`GetObjectPromptResponse`](crate::s3::response::GetObjectPromptResponse). 25 | /// 26 | /// # Example 27 | /// 28 | /// ```no_run 29 | /// use minio::s3::Client; 30 | /// use minio::s3::response::GetObjectPromptResponse; 31 | /// use minio::s3::types::S3Api; 32 | /// 33 | /// #[tokio::main] 34 | /// async fn main() { 35 | /// let client: Client = Default::default(); // configure your client here 36 | /// let resp: GetObjectPromptResponse = client 37 | /// .get_object_prompt("bucket-name", "object-name", "What is it about?") 38 | /// .send().await.unwrap(); 39 | /// println!("the prompt response is: '{}'", resp.prompt_response); 40 | /// } 41 | /// ``` 42 | pub fn get_object_prompt, S2: Into, S3: Into>( 43 | &self, 44 | bucket: S1, 45 | object: S2, 46 | prompt: S3, 47 | ) -> GetObjectPrompt { 48 | GetObjectPrompt::new(self.clone(), bucket.into(), object.into(), prompt.into()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/client/get_object_retention.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetObjectRetention; 18 | 19 | impl Client { 20 | /// Creates a [`GetObjectRetention`] request builder. 21 | /// 22 | /// To execute the request, call [`GetObjectRetention::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetObjectRetentionResponse`](crate::s3::response::GetObjectRetentionResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetObjectRetentionResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetObjectRetentionResponse = client 38 | /// .get_object_retention("bucket-name", "object-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved retention mode '{:?}' until '{:?}' from bucket '{}' is enabled", resp.retention_mode, resp.retain_until_date, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_object_retention, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | ) -> GetObjectRetention { 48 | GetObjectRetention::new(self.clone(), bucket.into(), object.into()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/client/get_object_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::GetObjectTagging; 18 | 19 | impl Client { 20 | /// Creates a [`GetObjectTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`GetObjectTagging::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`GetObjectTaggingResponse`](crate::s3::response::GetObjectTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetObjectTaggingResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetObjectTaggingResponse = client 38 | /// .get_object_tagging("bucket-name", "object-name") 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved object tags '{:?}' from object '{}' in bucket '{}' is enabled", resp.tags, resp.object, resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn get_object_tagging, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | ) -> GetObjectTagging { 48 | GetObjectTagging::new(self.clone(), bucket.into(), object.into()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/client/get_presigned_object_url.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::Client; 17 | use crate::s3::builders::GetPresignedObjectUrl; 18 | use http::Method; 19 | 20 | impl Client { 21 | /// Creates a [`GetPresignedObjectUrl`] request builder. 22 | /// 23 | /// To execute the request, call [`GetPresignedObjectUrl::send()`](crate::s3::types::S3Api::send), 24 | /// which returns a [`Result`] containing a [`GetPresignedObjectUrlResponse`](crate::s3::response::GetPresignedObjectUrlResponse). 25 | /// 26 | /// # Example 27 | /// 28 | /// ```no_run 29 | /// use http::Method; 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::GetPresignedObjectUrlResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: GetPresignedObjectUrlResponse = client 38 | /// .get_presigned_object_url("bucket-name", "object-name", Method::GET) 39 | /// .send().await.unwrap(); 40 | /// println!("the presigned url: '{:?}'", resp.url); 41 | /// } 42 | /// ``` 43 | pub fn get_presigned_object_url, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | method: Method, 48 | ) -> GetPresignedObjectUrl { 49 | GetPresignedObjectUrl::new(self.clone(), bucket.into(), object.into(), method) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/s3/client/list_buckets.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2023 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::ListBuckets; 18 | 19 | impl Client { 20 | /// Creates a [`ListBuckets`] request builder to retrieve the list of all buckets owned by the authenticated sender of the request. 21 | /// 22 | /// To execute the request, call [`ListBuckets::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`ListBucketsResponse`](crate::s3::response::ListBucketsResponse). 24 | /// 25 | /// For more information, refer to the [AWS S3 ListBuckets API documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html). 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::ListBucketsResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: ListBucketsResponse = client 38 | /// .list_buckets() 39 | /// .send().await.unwrap(); 40 | /// println!("retrieved buckets '{:?}'", resp.buckets); 41 | /// } 42 | /// ``` 43 | pub fn list_buckets(&self) -> ListBuckets { 44 | ListBuckets::new(self.clone()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/s3/client/list_objects.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2023 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::ListObjects; 18 | 19 | impl Client { 20 | /// Creates a [`ListObjects`] request builder. 21 | /// 22 | /// List objects with version information optionally. This function handles 23 | /// pagination and returns a stream of results. Each result corresponds to 24 | /// the response of a single listing API call. 25 | /// 26 | /// To execute the request, call [`ListObjects::send()`](crate::s3::types::S3Api::send), 27 | /// which returns a [`Result`] containing a [`ListObjectsResponse`](crate::s3::response::ListObjectsResponse). 28 | /// 29 | /// # Example 30 | /// 31 | /// ```no_run 32 | /// use minio::s3::Client; 33 | /// use minio::s3::types::{ToStream, S3Api}; 34 | /// 35 | /// use futures_util::StreamExt; 36 | /// 37 | /// #[tokio::main] 38 | /// async fn main() { 39 | /// let client: Client = Default::default(); // configure your client here 40 | /// 41 | /// let mut resp = client 42 | /// .list_objects("bucket-name") 43 | /// .recursive(true) 44 | /// .use_api_v1(false) // use v2 45 | /// .include_versions(true) 46 | /// .to_stream().await; 47 | /// 48 | /// while let Some(result) = resp.next().await { 49 | /// match result { 50 | /// Ok(resp) => { 51 | /// for item in resp.contents { 52 | /// println!("{:?}", item); 53 | /// } 54 | /// } 55 | /// Err(e) => println!("Error: {:?}", e), 56 | /// } 57 | /// } 58 | ///} 59 | /// ``` 60 | pub fn list_objects>(&self, bucket: S) -> ListObjects { 61 | ListObjects::new(self.clone(), bucket.into()) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/s3/client/put_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutBucketEncryption; 18 | 19 | impl Client { 20 | /// Creates a [`PutBucketEncryption`] request builder. 21 | /// 22 | /// To execute the request, call [`SetBucketEncryption::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`SetBucketEncryptionResponse`](crate::s3::response::PutBucketEncryptionResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::types::SseConfig; 31 | /// use minio::s3::Client; 32 | /// use minio::s3::response::PutBucketEncryptionResponse; 33 | /// use minio::s3::types::S3Api; 34 | /// 35 | /// #[tokio::main] 36 | /// async fn main() { 37 | /// let client: Client = Default::default(); // configure your client here 38 | /// let config = SseConfig::default(); 39 | /// let resp: PutBucketEncryptionResponse = client 40 | /// .put_bucket_encryption("bucket-name") 41 | /// .sse_config(config) 42 | /// .send().await.unwrap(); 43 | /// println!("set encryption on bucket '{}'", resp.bucket); 44 | /// } 45 | /// ``` 46 | pub fn put_bucket_encryption>(&self, bucket: S) -> PutBucketEncryption { 47 | PutBucketEncryption::new(self.clone(), bucket.into()) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/s3/client/put_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutBucketTagging; 18 | 19 | impl Client { 20 | /// Creates a [`PutBucketTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`PutBucketTagging::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`PutBucketTaggingResponse`](crate::s3::response::PutBucketTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::builders::VersioningStatus; 32 | /// use minio::s3::response::PutBucketTaggingResponse; 33 | /// use minio::s3::types::S3Api; 34 | /// 35 | /// use std::collections::HashMap; 36 | /// 37 | /// #[tokio::main] 38 | /// async fn main() { 39 | /// let client: Client = Default::default(); // configure your client here 40 | /// 41 | /// let mut tags: HashMap = HashMap::new(); 42 | /// tags.insert(String::from("Project"), String::from("Project One")); 43 | /// tags.insert(String::from("User"), String::from("jsmith")); 44 | /// 45 | /// let resp: PutBucketTaggingResponse = client 46 | /// .put_bucket_tagging("bucket-name") 47 | /// .tags(tags) 48 | /// .send().await.unwrap(); 49 | /// println!("set tags on bucket '{}'", resp.bucket); 50 | /// } 51 | /// ``` 52 | pub fn put_bucket_tagging>(&self, bucket: S) -> PutBucketTagging { 53 | PutBucketTagging::new(self.clone(), bucket.into()) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/s3/client/put_bucket_versioning.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutBucketVersioning; 18 | 19 | impl Client { 20 | /// Creates a [`PutBucketVersioning`] request builder. 21 | /// 22 | /// To execute the request, call [`SetBucketVersioning::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`SetBucketVersioningResponse`](crate::s3::response::PutBucketVersioningResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::builders::VersioningStatus; 32 | /// use minio::s3::response::PutBucketVersioningResponse; 33 | /// use minio::s3::types::{S3Api, ObjectLockConfig, RetentionMode}; 34 | /// 35 | /// #[tokio::main] 36 | /// async fn main() { 37 | /// let client: Client = Default::default(); // configure your client here 38 | /// 39 | /// let resp: PutBucketVersioningResponse = client 40 | /// .put_bucket_versioning("bucket-name") 41 | /// .versioning_status(VersioningStatus::Enabled) 42 | /// .send().await.unwrap(); 43 | /// println!("enabled versioning on bucket '{}'", resp.bucket); 44 | /// } 45 | /// ``` 46 | pub fn put_bucket_versioning>(&self, bucket: S) -> PutBucketVersioning { 47 | PutBucketVersioning::new(self.clone(), bucket.into()) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/s3/client/put_object_legal_hold.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutObjectLegalHold; 18 | 19 | impl Client { 20 | /// Creates a [`PutObjectLegalHold`] request builder. 21 | /// 22 | /// To execute the request, call [`DisableObjectLegalHold::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`DisableObjectLegalHoldResponse`](crate::s3::response::PutObjectLegalHoldResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::PutObjectLegalHoldResponse; 32 | /// use minio::s3::types::S3Api; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let resp: PutObjectLegalHoldResponse = client 38 | /// .put_object_legal_hold("bucket-name", "object-name", true) 39 | /// .send().await.unwrap(); 40 | /// println!("legal hold of bucket '{}' is enabled", resp.bucket); 41 | /// } 42 | /// ``` 43 | pub fn put_object_legal_hold, S2: Into>( 44 | &self, 45 | bucket: S1, 46 | object: S2, 47 | legal_hold: bool, 48 | ) -> PutObjectLegalHold { 49 | PutObjectLegalHold::new(self.clone(), bucket.into(), object.into()) 50 | .legal_hold(Some(legal_hold)) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/s3/client/put_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutObjectLockConfig; 18 | 19 | impl Client { 20 | /// Creates a [`PutObjectLockConfig`] request builder. 21 | /// 22 | /// To execute the request, call [`SetObjectLockConfig::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`SetObjectLockConfigResponse`](crate::s3::response::PutObjectLockConfigResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::{CreateBucketResponse, PutObjectLockConfigResponse}; 32 | /// use minio::s3::types::{S3Api, ObjectLockConfig, RetentionMode}; 33 | /// 34 | /// #[tokio::main] 35 | /// async fn main() { 36 | /// let client: Client = Default::default(); // configure your client here 37 | /// let bucket_name = "bucket-name"; 38 | /// 39 | /// let resp: CreateBucketResponse = 40 | /// client.create_bucket(bucket_name).object_lock(true).send().await.unwrap(); 41 | /// println!("created bucket '{}' with object locking enabled", resp.bucket); 42 | /// 43 | /// const DURATION_DAYS: i32 = 7; 44 | /// let config = ObjectLockConfig::new(RetentionMode::GOVERNANCE, Some(DURATION_DAYS), None).unwrap(); 45 | /// 46 | /// let resp: PutObjectLockConfigResponse = 47 | /// client.put_object_lock_config(bucket_name).config(config).send().await.unwrap(); 48 | /// println!("configured object locking for bucket '{}'", resp.bucket); 49 | /// } 50 | /// ``` 51 | pub fn put_object_lock_config>(&self, bucket: S) -> PutObjectLockConfig { 52 | PutObjectLockConfig::new(self.clone(), bucket.into()) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/s3/client/put_object_retention.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutObjectRetention; 18 | 19 | impl Client { 20 | /// Creates a [`PutObjectRetention`] request builder. 21 | /// 22 | /// To execute the request, call [`SetObjectRetention::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`SetObjectRetentionResponse`](crate::s3::response::PutObjectRetentionResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use minio::s3::Client; 31 | /// use minio::s3::response::PutObjectRetentionResponse; 32 | /// use minio::s3::builders::ObjectToDelete; 33 | /// use minio::s3::types::{S3Api, RetentionMode}; 34 | /// use minio::s3::utils::utc_now; 35 | /// 36 | /// #[tokio::main] 37 | /// async fn main() { 38 | /// let client: Client = Default::default(); // configure your client here 39 | /// let retain_until_date = utc_now() + chrono::Duration::days(1); 40 | /// let resp: PutObjectRetentionResponse = client 41 | /// .put_object_retention("bucket-name", "object-name") 42 | /// .retention_mode(Some(RetentionMode::GOVERNANCE)) 43 | /// .retain_until_date(Some(retain_until_date)) 44 | /// .send().await.unwrap(); 45 | /// println!("set the object retention for object '{}'", resp.object); 46 | /// } 47 | /// ``` 48 | pub fn put_object_retention, S2: Into>( 49 | &self, 50 | bucket: S1, 51 | object: S2, 52 | ) -> PutObjectRetention { 53 | PutObjectRetention::new(self.clone(), bucket.into(), object.into()) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/s3/client/put_object_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::PutObjectTagging; 18 | 19 | impl Client { 20 | /// Creates a [`PutObjectTagging`] request builder. 21 | /// 22 | /// To execute the request, call [`SetObjectTags::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`SetObjectTagsResponse`](crate::s3::response::PutObjectTaggingResponse). 24 | /// 25 | /// 🛈 This operation is not supported for express buckets. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```no_run 30 | /// use std::collections::HashMap; 31 | /// use minio::s3::Client; 32 | /// use minio::s3::response::PutObjectTaggingResponse; 33 | /// use minio::s3::types::S3Api; 34 | /// 35 | /// #[tokio::main] 36 | /// async fn main() { 37 | /// let client: Client = Default::default(); // configure your client here 38 | /// let tags = HashMap::from([ 39 | /// (String::from("Project"), String::from("Project One")), 40 | /// (String::from("User"), String::from("jsmith")), 41 | /// ]); 42 | /// let resp: PutObjectTaggingResponse = client 43 | /// .put_object_tagging("bucket-name", "object-name") 44 | /// .tags(tags) 45 | /// .send().await.unwrap(); 46 | /// println!("set the object tags for object '{}'", resp.object); 47 | /// } 48 | /// ``` 49 | pub fn put_object_tagging>(&self, bucket: S, object: S) -> PutObjectTagging { 50 | PutObjectTagging::new(self.clone(), bucket.into(), object.into()) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/s3/client/stat_object.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::Client; 17 | use crate::s3::builders::StatObject; 18 | 19 | impl Client { 20 | /// Creates a [`StatObject`] request builder. Given a bucket and object name, return some statistics. 21 | /// 22 | /// To execute the request, call [`StatObject::send()`](crate::s3::types::S3Api::send), 23 | /// which returns a [`Result`] containing a [`StatObjectResponse`](crate::s3::response::StatObjectResponse). 24 | /// 25 | /// # Example 26 | /// 27 | /// ```no_run 28 | /// use minio::s3::Client; 29 | /// use minio::s3::response::StatObjectResponse; 30 | /// use minio::s3::types::S3Api; 31 | /// 32 | /// #[tokio::main] 33 | /// async fn main() { 34 | /// let client: Client = Default::default(); // configure your client here 35 | /// let resp: StatObjectResponse = 36 | /// client.stat_object("bucket-name", "object-name").send().await.unwrap(); 37 | /// println!("stat of object '{}' are {:#?}", resp.object, resp); 38 | /// } 39 | /// ``` 40 | pub fn stat_object, S2: Into>( 41 | &self, 42 | bucket: S1, 43 | object: S2, 44 | ) -> StatObject { 45 | StatObject::new(self.clone(), bucket.into(), object.into()) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/s3/creds.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Credential providers 17 | 18 | #[derive(Clone, Debug, Default)] 19 | /// Credentials contain access key, secret key and session token optionally 20 | pub struct Credentials { 21 | pub access_key: String, 22 | pub secret_key: String, 23 | pub session_token: Option, 24 | } 25 | 26 | /// Provider trait to fetch credentials 27 | pub trait Provider: std::fmt::Debug { 28 | fn fetch(&self) -> Credentials; 29 | } 30 | 31 | #[derive(Clone, Debug)] 32 | /// Static credential provider 33 | pub struct StaticProvider { 34 | creds: Credentials, 35 | } 36 | 37 | impl StaticProvider { 38 | /// Returns a static provider with given access key, secret key and optional session token 39 | /// 40 | /// # Examples 41 | /// 42 | /// ``` 43 | /// use minio::s3::creds::StaticProvider; 44 | /// let provider = StaticProvider::new("minioadmin", "minio123", None); 45 | /// ``` 46 | pub fn new(access_key: &str, secret_key: &str, session_token: Option<&str>) -> StaticProvider { 47 | StaticProvider { 48 | creds: Credentials { 49 | access_key: access_key.to_string(), 50 | secret_key: secret_key.to_string(), 51 | session_token: session_token.map(|v| v.to_string()), 52 | }, 53 | } 54 | } 55 | } 56 | 57 | impl Provider for StaticProvider { 58 | fn fetch(&self) -> Credentials { 59 | self.creds.clone() 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/s3/mod.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Implementation of Simple Storage Service (aka S3) client 17 | 18 | pub mod builders; 19 | pub mod client; 20 | pub mod creds; 21 | pub mod error; 22 | pub mod http; 23 | pub mod lifecycle_config; 24 | pub mod multimap; 25 | mod object_content; 26 | pub mod response; 27 | pub mod segmented_bytes; 28 | pub mod signer; 29 | pub mod sse; 30 | pub mod types; 31 | pub mod utils; 32 | 33 | pub use client::{Client, ClientBuilder}; 34 | -------------------------------------------------------------------------------- /src/s3/response/create_bucket.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of 24 | /// [create_bucket()](crate::s3::client::Client::create_bucket) 25 | /// API 26 | #[derive(Clone, Debug)] 27 | pub struct CreateBucketResponse { 28 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | pub headers: HeaderMap, 30 | 31 | /// The AWS region where the bucket resides. 32 | pub region: String, 33 | 34 | /// Name of the bucket containing the object. 35 | pub bucket: String, 36 | } 37 | 38 | #[async_trait] 39 | impl FromS3Response for CreateBucketResponse { 40 | async fn from_s3response( 41 | req: S3Request, 42 | resp: Result, 43 | ) -> Result { 44 | let mut req = req; 45 | let bucket: String = take_bucket(req.bucket)?; 46 | req.client.add_bucket_region(&bucket, &req.inner_region); 47 | let mut resp = resp?; 48 | 49 | Ok(Self { 50 | headers: mem::take(resp.headers_mut()), 51 | region: req.inner_region, 52 | bucket, 53 | }) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/s3/response/delete_bucket.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of 24 | /// [delete_bucket()](crate::s3::client::Client::delete_bucket) 25 | /// API 26 | #[derive(Clone, Debug)] 27 | pub struct DeleteBucketResponse { 28 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | pub headers: HeaderMap, 30 | 31 | /// The AWS region where the bucket resides. 32 | pub region: String, 33 | 34 | /// Name of the bucket containing the object. 35 | pub bucket: String, 36 | } 37 | 38 | #[async_trait] 39 | impl FromS3Response for DeleteBucketResponse { 40 | async fn from_s3response( 41 | req: S3Request, 42 | resp: Result, 43 | ) -> Result { 44 | let mut req = req; 45 | let bucket: String = take_bucket(req.bucket)?; 46 | req.client.remove_bucket_region(&bucket); 47 | let mut resp = resp?; 48 | 49 | Ok(Self { 50 | headers: mem::take(resp.headers_mut()), 51 | region: req.inner_region, 52 | bucket, 53 | }) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/s3/response/delete_bucket_encryption.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Represents the response of the [delete_bucket_encryption()](crate::s3::client::Client::delete_bucket_encryption) API call. 24 | /// This struct contains metadata and information about the bucket whose encryption configuration was removed. 25 | /// 26 | /// # Fields 27 | /// 28 | /// * `headers` - HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | /// * `region` - The AWS region where the bucket resides. 30 | /// * `bucket` - Name of the bucket from which the encryption configuration was removed. 31 | #[derive(Clone, Debug)] 32 | pub struct DeleteBucketEncryptionResponse { 33 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 34 | pub headers: HeaderMap, 35 | 36 | /// The AWS region where the bucket resides. 37 | pub region: String, 38 | 39 | /// Name of the bucket from which the Encryption configuration was removed. 40 | pub bucket: String, 41 | } 42 | 43 | #[async_trait] 44 | impl FromS3Response for DeleteBucketEncryptionResponse { 45 | async fn from_s3response( 46 | req: S3Request, 47 | resp: Result, 48 | ) -> Result { 49 | let mut resp = resp?; 50 | 51 | Ok(Self { 52 | headers: mem::take(resp.headers_mut()), 53 | region: req.inner_region, 54 | bucket: take_bucket(req.bucket)?, 55 | }) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/s3/response/delete_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Represents the response of the [delete_bucket_lifecycle()](crate::s3::client::Client::delete_bucket_lifecycle) API call. 24 | /// This struct contains metadata and information about the bucket whose lifecycle configuration was removed. 25 | /// 26 | /// # Fields 27 | /// 28 | /// * `headers` - HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | /// * `region` - The AWS region where the bucket resides. 30 | /// * `bucket` - Name of the bucket from which the Bucket Lifecycle configuration was removed. 31 | #[derive(Clone, Debug)] 32 | pub struct DeleteBucketLifecycleResponse { 33 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 34 | pub headers: HeaderMap, 35 | 36 | /// The AWS region where the bucket resides. 37 | pub region: String, 38 | 39 | /// Name of the bucket from which the Bucket Lifecycle configuration was removed. 40 | pub bucket: String, 41 | } 42 | 43 | #[async_trait] 44 | impl FromS3Response for DeleteBucketLifecycleResponse { 45 | async fn from_s3response( 46 | req: S3Request, 47 | resp: Result, 48 | ) -> Result { 49 | let mut resp = resp?; 50 | 51 | Ok(Self { 52 | headers: mem::take(resp.headers_mut()), 53 | region: req.inner_region, 54 | bucket: take_bucket(req.bucket)?, 55 | }) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/s3/response/delete_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Represents the response of the [delete_bucket_notification()](crate::s3::client::Client::delete_bucket_notification) API call. 24 | /// This struct contains metadata and information about the bucket whose notifications were removed. 25 | /// 26 | /// # Fields 27 | /// 28 | /// * `headers` - HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | /// * `region` - The AWS region where the bucket resides. 30 | /// * `bucket` - Name of the bucket from which the Bucket Notifications were removed. 31 | #[derive(Clone, Debug)] 32 | pub struct DeleteBucketNotificationResponse { 33 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 34 | pub headers: HeaderMap, 35 | 36 | /// The AWS region where the bucket resides. 37 | pub region: String, 38 | 39 | /// Name of the bucket from which the Bucket Notifications were removed. 40 | pub bucket: String, 41 | } 42 | 43 | #[async_trait] 44 | impl FromS3Response for DeleteBucketNotificationResponse { 45 | async fn from_s3response( 46 | req: S3Request, 47 | resp: Result, 48 | ) -> Result { 49 | let mut resp = resp?; 50 | 51 | Ok(Self { 52 | headers: mem::take(resp.headers_mut()), 53 | region: req.inner_region, 54 | bucket: take_bucket(req.bucket)?, 55 | }) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/s3/response/delete_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Represents the response of the [delete_bucket_tagging()](crate::s3::client::Client::delete_bucket_tagging) API call. 24 | /// This struct contains metadata and information about the bucket whose tags were removed. 25 | /// 26 | /// # Fields 27 | /// 28 | /// * `headers` - HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | /// * `region` - The AWS region where the bucket resides. 30 | /// * `bucket` - Name of the bucket from which the tags were removed. 31 | #[derive(Clone, Debug)] 32 | pub struct DeleteBucketTaggingResponse { 33 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 34 | pub headers: HeaderMap, 35 | 36 | /// The AWS region where the bucket resides. 37 | pub region: String, 38 | 39 | /// Name of the bucket from which the tags were removed. 40 | pub bucket: String, 41 | } 42 | 43 | #[async_trait] 44 | impl FromS3Response for DeleteBucketTaggingResponse { 45 | async fn from_s3response( 46 | req: S3Request, 47 | resp: Result, 48 | ) -> Result { 49 | let mut resp = resp?; 50 | 51 | Ok(Self { 52 | headers: mem::take(resp.headers_mut()), 53 | region: req.inner_region, 54 | bucket: take_bucket(req.bucket)?, 55 | }) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/s3/response/delete_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response from the [`delete_object_lock_config`](crate::s3::client::Client::delete_object_lock_config) API call, 24 | /// indicating that the Object Lock configuration has been successfully removed from the specified S3 bucket. 25 | /// 26 | /// Removing the Object Lock configuration disables the default retention settings for new objects added to the bucket. 27 | /// Existing object versions with retention settings or legal holds remain unaffected. 28 | /// 29 | /// For more information, refer to the [AWS S3 DeleteObjectLockConfiguration API documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjectLockConfiguration.html). 30 | #[derive(Clone, Debug)] 31 | pub struct DeleteObjectLockConfigResponse { 32 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 33 | pub headers: HeaderMap, 34 | 35 | /// The AWS region where the bucket resides. 36 | pub region: String, 37 | 38 | /// Name of the bucket from which the Object Lock configuration was removed. 39 | pub bucket: String, 40 | } 41 | 42 | #[async_trait] 43 | impl FromS3Response for DeleteObjectLockConfigResponse { 44 | async fn from_s3response( 45 | req: S3Request, 46 | resp: Result, 47 | ) -> Result { 48 | let mut resp = resp?; 49 | 50 | Ok(Self { 51 | headers: mem::take(resp.headers_mut()), 52 | region: req.inner_region, 53 | bucket: take_bucket(req.bucket)?, 54 | }) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/s3/response/get_object_prompt.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::{take_bucket, take_object}; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | pub struct GetObjectPromptResponse { 24 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 25 | pub headers: HeaderMap, 26 | 27 | /// The AWS region where the bucket resides. 28 | pub region: String, 29 | 30 | /// Name of the bucket containing the object. 31 | pub bucket: String, 32 | 33 | /// Key (path) identifying the object within the bucket. 34 | pub object: String, 35 | 36 | /// The prompt response for the object. 37 | pub prompt_response: String, 38 | } 39 | 40 | #[async_trait] 41 | impl FromS3Response for GetObjectPromptResponse { 42 | async fn from_s3response( 43 | req: S3Request, 44 | resp: Result, 45 | ) -> Result { 46 | let mut resp = resp?; 47 | 48 | let headers: HeaderMap = mem::take(resp.headers_mut()); 49 | let body = resp.bytes().await?; 50 | let prompt_response: String = String::from_utf8(body.to_vec())?; 51 | 52 | Ok(Self { 53 | headers, 54 | region: req.inner_region, 55 | bucket: take_bucket(req.bucket)?, 56 | object: take_object(req.object)?, 57 | prompt_response, 58 | }) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/s3/response/get_presigned_object_url.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Debug)] 2 | /// Response of [get_presigned_object_url()](crate::s3::client::Client::get_presigned_object_url) API 3 | pub struct GetPresignedObjectUrlResponse { 4 | /// The AWS region where the bucket resides. 5 | pub region: String, 6 | 7 | /// Name of the bucket containing the object. 8 | pub bucket: String, 9 | 10 | /// Key (path) identifying the object within the bucket. 11 | pub object: String, 12 | 13 | /// TODO 14 | pub version_id: Option, 15 | 16 | /// The presigned URL for the object. 17 | pub url: String, 18 | } 19 | -------------------------------------------------------------------------------- /src/s3/response/get_region.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::client::DEFAULT_REGION; 17 | use crate::s3::error::Error; 18 | use crate::s3::types::{FromS3Response, S3Request}; 19 | use crate::s3::utils::take_bucket; 20 | use async_trait::async_trait; 21 | use bytes::Buf; 22 | use http::HeaderMap; 23 | use std::mem; 24 | use xmltree::Element; 25 | 26 | /// Response of 27 | /// [get_region()](crate::s3::client::Client::get_region) 28 | /// API 29 | #[derive(Clone, Debug)] 30 | pub struct GetRegionResponse { 31 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 32 | pub headers: HeaderMap, 33 | 34 | /// The AWS region where the bucket resides. 35 | pub region: String, 36 | 37 | /// Name of the bucket containing the object. 38 | pub bucket: String, 39 | 40 | /// The region response for the bucket. 41 | pub region_response: String, 42 | } 43 | 44 | #[async_trait] 45 | impl FromS3Response for GetRegionResponse { 46 | async fn from_s3response( 47 | req: S3Request, 48 | resp: Result, 49 | ) -> Result { 50 | let mut resp = resp?; 51 | 52 | let headers: HeaderMap = mem::take(resp.headers_mut()); 53 | let region_response: String = { 54 | let body = resp.bytes().await?; 55 | let root = Element::parse(body.reader())?; 56 | 57 | let mut location = root.get_text().unwrap_or_default().to_string(); 58 | if location.is_empty() { 59 | location = String::from(DEFAULT_REGION); 60 | } 61 | location 62 | }; 63 | 64 | Ok(Self { 65 | headers, 66 | region: req.inner_region, 67 | bucket: take_bucket(req.bucket)?, 68 | region_response, 69 | }) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/s3/response/list_buckets.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{Bucket, FromS3Response, S3Request}; 18 | use crate::s3::utils::{from_iso8601utc, get_text}; 19 | use async_trait::async_trait; 20 | use bytes::Buf; 21 | use http::HeaderMap; 22 | use std::mem; 23 | use xmltree::Element; 24 | 25 | /// Response of [list_buckets()](crate::s3::client::Client::list_buckets) API 26 | #[derive(Debug, Clone)] 27 | pub struct ListBucketsResponse { 28 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | pub headers: HeaderMap, 30 | 31 | /// the list of buckets that are present in the account. 32 | pub buckets: Vec, 33 | } 34 | 35 | #[async_trait] 36 | impl FromS3Response for ListBucketsResponse { 37 | async fn from_s3response( 38 | _req: S3Request, 39 | resp: Result, 40 | ) -> Result { 41 | let mut resp = resp?; 42 | let headers: HeaderMap = mem::take(resp.headers_mut()); 43 | 44 | let body = resp.bytes().await?; 45 | let mut root = Element::parse(body.reader())?; 46 | let buckets_xml = root 47 | .get_mut_child("Buckets") 48 | .ok_or(Error::XmlError(" tag not found".into()))?; 49 | 50 | let mut buckets: Vec = Vec::new(); 51 | while let Some(b) = buckets_xml.take_child("Bucket") { 52 | let bucket = b; 53 | buckets.push(Bucket { 54 | name: get_text(&bucket, "Name")?, 55 | creation_date: from_iso8601utc(&get_text(&bucket, "CreationDate")?)?, 56 | }) 57 | } 58 | 59 | Ok(Self { headers, buckets }) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_lifecycle.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of [put_bucket_lifecycle()](crate::s3::client::Client::put_bucket_lifecycle) API 24 | #[derive(Debug)] 25 | pub struct PutBucketLifecycleResponse { 26 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 27 | pub headers: HeaderMap, 28 | 29 | /// The AWS region where the bucket resides. 30 | pub region: String, 31 | 32 | /// Name of the bucket containing the object. 33 | pub bucket: String, 34 | } 35 | 36 | #[async_trait] 37 | impl FromS3Response for PutBucketLifecycleResponse { 38 | async fn from_s3response( 39 | req: S3Request, 40 | resp: Result, 41 | ) -> Result { 42 | let mut resp = resp?; 43 | 44 | Ok(Self { 45 | headers: mem::take(resp.headers_mut()), 46 | region: req.inner_region, 47 | bucket: take_bucket(req.bucket)?, 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_notification.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of [put_bucket_notification()](crate::s3::client::Client::put_bucket_notification) API 24 | #[derive(Debug)] 25 | pub struct PutBucketNotificationResponse { 26 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 27 | pub headers: HeaderMap, 28 | 29 | /// The AWS region where the bucket resides. 30 | pub region: String, 31 | 32 | /// Name of the bucket containing the object. 33 | pub bucket: String, 34 | } 35 | 36 | #[async_trait] 37 | impl FromS3Response for PutBucketNotificationResponse { 38 | async fn from_s3response( 39 | req: S3Request, 40 | resp: Result, 41 | ) -> Result { 42 | let mut resp = resp?; 43 | 44 | Ok(Self { 45 | headers: mem::take(resp.headers_mut()), 46 | region: req.inner_region, 47 | bucket: take_bucket(req.bucket)?, 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_policy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of [put_bucket_policy()](crate::s3::client::Client::put_bucket_policy) API 24 | #[derive(Debug)] 25 | pub struct PutBucketPolicyResponse { 26 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 27 | pub headers: HeaderMap, 28 | 29 | /// The AWS region where the bucket resides. 30 | pub region: String, 31 | 32 | /// Name of the bucket containing the object. 33 | pub bucket: String, 34 | } 35 | 36 | #[async_trait] 37 | impl FromS3Response for PutBucketPolicyResponse { 38 | async fn from_s3response( 39 | req: S3Request, 40 | resp: Result, 41 | ) -> Result { 42 | let mut resp = resp?; 43 | 44 | Ok(Self { 45 | headers: mem::take(resp.headers_mut()), 46 | region: req.inner_region, 47 | bucket: take_bucket(req.bucket)?, 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_replication.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of [put_bucket_replication()](crate::s3::client::Client::put_bucket_replication) API 24 | #[derive(Debug)] 25 | pub struct PutBucketReplicationResponse { 26 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 27 | pub headers: HeaderMap, 28 | 29 | /// The AWS region where the bucket resides. 30 | pub region: String, 31 | 32 | /// Name of the bucket containing the object. 33 | pub bucket: String, 34 | } 35 | 36 | #[async_trait] 37 | impl FromS3Response for PutBucketReplicationResponse { 38 | async fn from_s3response( 39 | req: S3Request, 40 | resp: Result, 41 | ) -> Result { 42 | let mut resp = resp?; 43 | 44 | Ok(Self { 45 | headers: mem::take(resp.headers_mut()), 46 | region: req.inner_region, 47 | bucket: take_bucket(req.bucket)?, 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of 24 | /// [put_bucket_tagging()](crate::s3::client::Client::put_bucket_tagging) 25 | /// API 26 | #[derive(Clone, Debug)] 27 | pub struct PutBucketTaggingResponse { 28 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | pub headers: HeaderMap, 30 | 31 | /// The AWS region where the bucket resides. 32 | pub region: String, 33 | 34 | /// Name of the bucket containing the object. 35 | pub bucket: String, 36 | } 37 | 38 | #[async_trait] 39 | impl FromS3Response for PutBucketTaggingResponse { 40 | async fn from_s3response( 41 | req: S3Request, 42 | resp: Result, 43 | ) -> Result { 44 | let mut resp = resp?; 45 | 46 | Ok(Self { 47 | headers: mem::take(resp.headers_mut()), 48 | region: req.inner_region, 49 | bucket: take_bucket(req.bucket)?, 50 | }) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/s3/response/put_bucket_versioning.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of [put_bucket_versioning()](crate::s3::client::Client::put_bucket_versioning) API 24 | #[derive(Debug)] 25 | pub struct PutBucketVersioningResponse { 26 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 27 | pub headers: HeaderMap, 28 | 29 | /// The AWS region where the bucket resides. 30 | pub region: String, 31 | 32 | /// Name of the bucket containing the object. 33 | pub bucket: String, 34 | } 35 | 36 | #[async_trait] 37 | impl FromS3Response for PutBucketVersioningResponse { 38 | async fn from_s3response( 39 | req: S3Request, 40 | resp: Result, 41 | ) -> Result { 42 | let mut resp = resp?; 43 | 44 | Ok(Self { 45 | headers: mem::take(resp.headers_mut()), 46 | region: req.inner_region, 47 | bucket: take_bucket(req.bucket)?, 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/s3/response/put_object_lock_config.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::types::{FromS3Response, S3Request}; 18 | use crate::s3::utils::take_bucket; 19 | use async_trait::async_trait; 20 | use http::HeaderMap; 21 | use std::mem; 22 | 23 | /// Response of 24 | /// [put_object_lock_config()](crate::s3::client::Client::put_object_lock_config) 25 | /// API 26 | #[derive(Clone, Debug)] 27 | pub struct PutObjectLockConfigResponse { 28 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 29 | pub headers: HeaderMap, 30 | 31 | /// The AWS region where the bucket resides. 32 | pub region: String, 33 | 34 | /// Name of the bucket containing the object. 35 | pub bucket: String, 36 | } 37 | 38 | #[async_trait] 39 | impl FromS3Response for PutObjectLockConfigResponse { 40 | async fn from_s3response( 41 | req: S3Request, 42 | resp: Result, 43 | ) -> Result { 44 | let mut resp = resp?; 45 | 46 | Ok(Self { 47 | headers: mem::take(resp.headers_mut()), 48 | region: req.inner_region, 49 | bucket: take_bucket(req.bucket)?, 50 | }) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/s3/response/put_object_retention.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::multimap::MultimapExt; 18 | use crate::s3::types::{FromS3Response, S3Request}; 19 | use crate::s3::utils::{take_bucket, take_object}; 20 | use async_trait::async_trait; 21 | use http::HeaderMap; 22 | use std::mem; 23 | 24 | /// Response of 25 | /// [put_object_retention()](crate::s3::client::Client::put_object_retention) 26 | /// API 27 | #[derive(Clone, Debug)] 28 | pub struct PutObjectRetentionResponse { 29 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 30 | pub headers: HeaderMap, 31 | 32 | /// The AWS region where the bucket resides. 33 | pub region: String, 34 | 35 | /// Name of the bucket containing the object. 36 | pub bucket: String, 37 | 38 | /// Key (path) identifying the object within the bucket. 39 | pub object: String, 40 | 41 | /// Version ID of the object, if versioning is enabled. Value of the `x-amz-version-id` header. 42 | pub version_id: Option, 43 | } 44 | 45 | #[async_trait] 46 | impl FromS3Response for PutObjectRetentionResponse { 47 | async fn from_s3response( 48 | req: S3Request, 49 | resp: Result, 50 | ) -> Result { 51 | let mut resp = resp?; 52 | 53 | Ok(Self { 54 | headers: mem::take(resp.headers_mut()), 55 | region: req.inner_region, 56 | bucket: take_bucket(req.bucket)?, 57 | object: take_object(req.object)?, 58 | version_id: req.query_params.take_version(), 59 | }) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/s3/response/put_object_tagging.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use crate::s3::error::Error; 17 | use crate::s3::multimap::MultimapExt; 18 | use crate::s3::types::{FromS3Response, S3Request}; 19 | use crate::s3::utils::{take_bucket, take_object}; 20 | use async_trait::async_trait; 21 | use http::HeaderMap; 22 | use std::mem; 23 | 24 | /// Response of 25 | /// [put_object_tagging()](crate::s3::client::Client::put_object_tagging) 26 | /// API 27 | #[derive(Clone, Debug)] 28 | pub struct PutObjectTaggingResponse { 29 | /// HTTP headers returned by the server, containing metadata such as `Content-Type`, `ETag`, etc. 30 | pub headers: HeaderMap, 31 | 32 | /// The AWS region where the bucket resides. 33 | pub region: String, 34 | 35 | /// Name of the bucket containing the object. 36 | pub bucket: String, 37 | 38 | /// Key (path) identifying the object within the bucket. 39 | pub object: String, 40 | 41 | /// Version ID of the object, if versioning is enabled. Value of the `x-amz-version-id` header. 42 | pub version_id: Option, 43 | } 44 | 45 | #[async_trait] 46 | impl FromS3Response for PutObjectTaggingResponse { 47 | async fn from_s3response( 48 | req: S3Request, 49 | resp: Result, 50 | ) -> Result { 51 | let mut resp = resp?; 52 | 53 | Ok(Self { 54 | headers: mem::take(resp.headers_mut()), 55 | region: req.inner_region, 56 | bucket: take_bucket(req.bucket)?, 57 | object: take_object(req.object)?, 58 | version_id: req.query_params.take_version(), 59 | }) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/private.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgkZrDqi6YL+RS5xEy 3 | YLMVrCDC9r/F39UYKDPAIS41ulGhRANCAAQgpenErxeS4XVDweO41kcBzeS911/B 4 | cLEDTGmuZF0ZeOHF6JJYtBEMXgxbglUIUPmE+3L21u/6fqR5aztM8GHy 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /tests/public.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIB1TCCAXygAwIBAgIRAP0ihBYxR23zNUlka9xA4TYwCgYIKoZIzj0EAwIwMTEc 3 | MBoGA1UEChMTQ2VydGdlbiBEZXZlbG9wbWVudDERMA8GA1UECwwIYmFsYUBmMzgw 4 | IBcNMjMwODMwMTIzMTQzWhgPMjEyMzA4MDYxMjMxNDNaMDExHDAaBgNVBAoTE0Nl 5 | cnRnZW4gRGV2ZWxvcG1lbnQxETAPBgNVBAsMCGJhbGFAZjM4MFkwEwYHKoZIzj0C 6 | AQYIKoZIzj0DAQcDQgAEIKXpxK8XkuF1Q8HjuNZHAc3kvddfwXCxA0xprmRdGXjh 7 | xeiSWLQRDF4MW4JVCFD5hPty9tbv+n6keWs7TPBh8qNzMHEwDgYDVR0PAQH/BAQD 8 | AgKkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O 9 | BBYEFOI5oRDgCm3lEefkHkKutkW6dzMyMBoGA1UdEQQTMBGCCWxvY2FsaG9zdIcE 10 | fwAAATAKBggqhkjOPQQDAgNHADBEAiAN77OMdOC0OW1eubI6RygpWxv1SOtKqtRJ 11 | CFbdqTLYKgIgVe7mPBqBECShFFjcGvSvRl2ev0f19EN37BEj9E+ZZXI= 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /tests/run-tests-windows.ps1: -------------------------------------------------------------------------------- 1 | # Set environment variables to run tests on play.min.io 2 | $Env:SERVER_ENDPOINT = "http://localhost:9000/" 3 | $Env:ACCESS_KEY = "minioadmin" 4 | $Env:SECRET_KEY = "minioadmin" 5 | $Env:ENABLE_HTTPS = "false" 6 | $Env:SSL_CERT_FILE = "./tests/public.crt" 7 | $Env:IGNORE_CERT_CHECK = "false" 8 | $Env:SERVER_REGION = "" 9 | 10 | # Run tests 11 | cargo test -- --nocapture 12 | 13 | # run one specific test and show stdout 14 | # cargo test --test test_bucket_exists -- --nocapture -------------------------------------------------------------------------------- /tests/start-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | wget --quiet https://dl.min.io/server/minio/release/linux-amd64/minio 7 | chmod +x minio 8 | mkdir -p /tmp/certs 9 | cp ./tests/public.crt ./tests/private.key /tmp/certs/ 10 | 11 | (MINIO_CI_CD=true \ 12 | MINIO_NOTIFY_WEBHOOK_ENABLE_miniojavatest=on \ 13 | MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniojavatest=http://example.org/ \ 14 | ./minio server /tmp/test-xl/{1...4}/ --certs-dir /tmp/certs/ &) 15 | 16 | sleep 10 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/test_bucket_exists.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use minio::s3::client::DEFAULT_REGION; 17 | use minio::s3::response::{BucketExistsResponse, DeleteBucketResponse}; 18 | use minio::s3::types::S3Api; 19 | use minio_common::test_context::TestContext; 20 | 21 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 22 | async fn bucket_exists() { 23 | let ctx = TestContext::new_from_env(); 24 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 25 | 26 | let resp: BucketExistsResponse = ctx.client.bucket_exists(&bucket_name).send().await.unwrap(); 27 | assert!(resp.exists); 28 | assert_eq!(resp.bucket, bucket_name); 29 | assert_eq!(resp.region, DEFAULT_REGION); 30 | 31 | let resp: DeleteBucketResponse = ctx.client.delete_bucket(&bucket_name).send().await.unwrap(); 32 | assert_eq!(resp.bucket, bucket_name); 33 | assert_eq!(resp.region, DEFAULT_REGION); 34 | 35 | let resp: BucketExistsResponse = ctx.client.bucket_exists(&bucket_name).send().await.unwrap(); 36 | assert!(!resp.exists); 37 | assert_eq!(resp.bucket, bucket_name); 38 | assert_eq!(resp.region, ""); 39 | } 40 | -------------------------------------------------------------------------------- /tests/test_get_object.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use bytes::Bytes; 17 | use minio::s3::response::{GetObjectResponse, PutObjectContentResponse}; 18 | use minio::s3::types::S3Api; 19 | use minio_common::test_context::TestContext; 20 | use minio_common::utils::rand_object_name; 21 | 22 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 23 | async fn get_object() { 24 | let ctx = TestContext::new_from_env(); 25 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 26 | let object_name = rand_object_name(); 27 | 28 | let data: Bytes = Bytes::from("hello, world".to_string().into_bytes()); 29 | let resp: PutObjectContentResponse = ctx 30 | .client 31 | .put_object_content(&bucket_name, &object_name, data.clone()) 32 | .send() 33 | .await 34 | .unwrap(); 35 | assert_eq!(resp.bucket, bucket_name); 36 | assert_eq!(resp.object, object_name); 37 | assert_eq!(resp.object_size, data.len() as u64); 38 | 39 | let resp: GetObjectResponse = ctx 40 | .client 41 | .get_object(&bucket_name, &object_name) 42 | .send() 43 | .await 44 | .unwrap(); 45 | assert_eq!(resp.bucket, bucket_name); 46 | assert_eq!(resp.object, object_name); 47 | assert_eq!(resp.object_size, data.len() as u64); 48 | 49 | let got = resp.content.to_segmented_bytes().await.unwrap().to_bytes(); 50 | assert_eq!(got, data); 51 | } 52 | -------------------------------------------------------------------------------- /tests/test_get_presigned_object_url.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use http::Method; 17 | use minio::s3::client::DEFAULT_REGION; 18 | use minio::s3::response::GetPresignedObjectUrlResponse; 19 | use minio_common::test_context::TestContext; 20 | use minio_common::utils::rand_object_name; 21 | 22 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 23 | async fn get_presigned_object_url() { 24 | let ctx = TestContext::new_from_env(); 25 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 26 | 27 | let object_name = rand_object_name(); 28 | let resp: GetPresignedObjectUrlResponse = ctx 29 | .client 30 | .get_presigned_object_url(&bucket_name, &object_name, Method::GET) 31 | .send() 32 | .await 33 | .unwrap(); 34 | assert!(resp.url.contains("X-Amz-Signature=")); 35 | assert_eq!(resp.bucket, bucket_name); 36 | assert_eq!(resp.object, object_name); 37 | assert_eq!(resp.region, DEFAULT_REGION); 38 | } 39 | -------------------------------------------------------------------------------- /tests/test_get_presigned_post_form_data.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use minio::s3::builders::PostPolicy; 17 | use minio_common::example::create_post_policy_example; 18 | use minio_common::test_context::TestContext; 19 | use minio_common::utils::rand_object_name; 20 | use std::collections::HashMap; 21 | 22 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 23 | async fn get_presigned_post_form_data() { 24 | let ctx = TestContext::new_from_env(); 25 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 26 | let object_name = rand_object_name(); 27 | 28 | let policy: PostPolicy = create_post_policy_example(&bucket_name, &object_name); 29 | 30 | let form_data: HashMap = ctx 31 | .client 32 | .get_presigned_post_form_data(policy) 33 | .send() 34 | .await 35 | .unwrap(); 36 | //println!("form_data={:?}", &form_data); 37 | assert!(form_data.contains_key("x-amz-signature")); 38 | assert!(form_data.contains_key("policy")); 39 | assert!(form_data.contains_key("x-amz-date")); 40 | assert!(form_data.contains_key("x-amz-algorithm")); 41 | assert!(form_data.contains_key("x-amz-credential")); 42 | } 43 | -------------------------------------------------------------------------------- /tests/test_list_buckets.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use minio::s3::response::ListBucketsResponse; 17 | use minio::s3::types::S3Api; 18 | use minio_common::cleanup_guard::CleanupGuard; 19 | use minio_common::test_context::TestContext; 20 | 21 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 22 | async fn list_buckets() { 23 | const N_BUCKETS: usize = 3; 24 | let ctx = TestContext::new_from_env(); 25 | 26 | let mut names: Vec = Vec::new(); 27 | let mut guards: Vec = Vec::new(); 28 | for _ in 1..=N_BUCKETS { 29 | let (bucket_name, guard) = ctx.create_bucket_helper().await; 30 | names.push(bucket_name); 31 | guards.push(guard); 32 | } 33 | 34 | assert_eq!(names.len(), N_BUCKETS); 35 | 36 | let mut count = 0; 37 | let resp: ListBucketsResponse = ctx.client.list_buckets().send().await.unwrap(); 38 | 39 | for bucket in resp.buckets.iter() { 40 | if names.contains(&bucket.name) { 41 | count += 1; 42 | } 43 | } 44 | assert_eq!(guards.len(), N_BUCKETS); 45 | assert_eq!(count, N_BUCKETS); 46 | } 47 | -------------------------------------------------------------------------------- /tests/test_object_copy.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use minio::s3::builders::{CopySource, ObjectContent}; 17 | use minio::s3::response::{CopyObjectResponse, PutObjectContentResponse, StatObjectResponse}; 18 | use minio::s3::types::S3Api; 19 | use minio_common::rand_src::RandSrc; 20 | use minio_common::test_context::TestContext; 21 | use minio_common::utils::rand_object_name; 22 | 23 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 24 | async fn copy_object() { 25 | let ctx = TestContext::new_from_env(); 26 | if ctx.client.is_minio_express() { 27 | println!("Skipping test because it is running in MinIO Express mode"); 28 | return; 29 | } 30 | 31 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 32 | let object_name_src: String = rand_object_name(); 33 | let object_name_dst: String = rand_object_name(); 34 | 35 | let size = 16_u64; 36 | let content = ObjectContent::new_from_stream(RandSrc::new(size), Some(size)); 37 | 38 | let resp: PutObjectContentResponse = ctx 39 | .client 40 | .put_object_content(&bucket_name, &object_name_src, content) 41 | .send() 42 | .await 43 | .unwrap(); 44 | assert_eq!(resp.bucket, bucket_name); 45 | 46 | let resp: CopyObjectResponse = ctx 47 | .client 48 | .copy_object(&bucket_name, &object_name_dst) 49 | .source(CopySource::new(&bucket_name, &object_name_src).unwrap()) 50 | .send() 51 | .await 52 | .unwrap(); 53 | assert_eq!(resp.bucket, bucket_name); 54 | assert_eq!(resp.object, object_name_dst); 55 | 56 | let resp: StatObjectResponse = ctx 57 | .client 58 | .stat_object(&bucket_name, &object_name_dst) 59 | .send() 60 | .await 61 | .unwrap(); 62 | assert_eq!(resp.size, size); 63 | assert_eq!(resp.bucket, bucket_name); 64 | } 65 | -------------------------------------------------------------------------------- /tests/test_object_remove.rs: -------------------------------------------------------------------------------- 1 | // MinIO Rust Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2025 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use minio::s3::builders::ObjectToDelete; 17 | use minio::s3::response::PutObjectContentResponse; 18 | use minio::s3::types::ToStream; 19 | use minio_common::test_context::TestContext; 20 | use minio_common::utils::rand_object_name; 21 | use tokio_stream::StreamExt; 22 | 23 | #[tokio::test(flavor = "multi_thread", worker_threads = 10)] 24 | async fn remove_objects() { 25 | let ctx = TestContext::new_from_env(); 26 | let (bucket_name, _cleanup) = ctx.create_bucket_helper().await; 27 | 28 | let mut names: Vec = Vec::new(); 29 | for _ in 1..=3 { 30 | let object_name = rand_object_name(); 31 | let resp: PutObjectContentResponse = ctx 32 | .client 33 | .put_object_content(&bucket_name, &object_name, "") 34 | .send() 35 | .await 36 | .unwrap(); 37 | assert_eq!(resp.bucket, bucket_name); 38 | assert_eq!(resp.object, object_name); 39 | names.push(object_name); 40 | } 41 | let del_items: Vec = names 42 | .iter() 43 | .map(|v| ObjectToDelete::from(v.as_str())) 44 | .collect(); 45 | 46 | let mut resp = ctx 47 | .client 48 | .delete_objects_streaming(&bucket_name, del_items.into_iter()) 49 | .verbose_mode(true) 50 | .to_stream() 51 | .await; 52 | 53 | let mut del_count = 0; 54 | while let Some(item) = resp.next().await { 55 | let res = item.unwrap(); 56 | for obj in res.result.iter() { 57 | assert!(obj.is_deleted()); 58 | } 59 | del_count += res.result.len(); 60 | } 61 | assert_eq!(del_count, 3); 62 | } 63 | --------------------------------------------------------------------------------