### AWS S3 Client Setup and Usage in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/lib.rs_search=std%3A%3Avec Demonstrates how to initialize and use the AwsS3Fs client for AWS S3. It shows connecting, getting the working directory, changing directories, and disconnecting. Requires the 'remotefs' and 'remotefs-aws-s3' crates. It uses Tokio for asynchronous operations. ```rust use remotefs::RemoteFs; use remotefs_aws_s3::AwsS3Fs; use std::path::Path; use std::sync::Arc; let mut client = AwsS3Fs::new("test-bucket", &Arc::new(tokio::runtime::Runtime::new().unwrap())) .region("eu-west-1") .profile("default") .access_key("AKIAxxxxxxxxxxxx") .secret_access_key("****************"); // connect assert!(client.connect().is_ok()); // get working directory println!("Wrkdir: {}", client.pwd().ok().unwrap().display()); // change working directory assert!(client.change_dir(Path::new("/tmp")).is_ok()); // disconnect assert!(client.disconnect().is_ok()); ``` -------------------------------- ### Setup Function for AWS S3 CI Tests (No Containers) Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search= This setup function is used for tests running in an AWS S3 CI environment without using containers. It initializes an AwsS3Fs client, connects to S3, creates a temporary directory, and changes the current directory to the temporary one. It asserts that these operations are successful. ```rust #[cfg(all(feature = "with-s3-ci", not(feature = "with-containers")))] fn setup_client() -> Ctx { // Get transfer let bucket = env!("AWS_S3_BUCKET"); let mut client = AwsS3Fs::new(bucket, &Arc::new(Runtime::new().unwrap())); assert!(client.connect().is_ok()); // Create wrkdir let tempdir = PathBuf::from(generate_tempdir()); assert!( client .create_dir(tempdir.as_path(), UnixPex::from(0o775)) .is_ok() ); // Change directory let err = client.change_dir(tempdir.as_path()); if err.is_err() { println!("Error: {:?}", err); } assert!(client.change_dir(tempdir.as_path()).is_ok()); Ctx { client, container: (), } } ``` -------------------------------- ### Setup Client for Containers Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This function sets up an AWS S3 client specifically for containerized environments, likely using Minio. It starts a Minio instance, retrieves its port, and initializes the AwsS3Fs client with the appropriate configuration. It also creates a runtime. ```rust #[cfg(feature = "with-containers")] fn setup_client() -> Ctx { let minio = Minio::start(); let port = minio.port(); // Get transfer let runtime = Arc::new(Runtime::new().expect("Could not create runtime")); ``` -------------------------------- ### List Objects with StartAfter Parameter Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Configures the starting point for listing objects in an S3 bucket. The `start_after` parameter specifies a key after which the listing should begin. Note that this functionality is not supported for directory buckets. ```Rust /// Sets the `start_after` parameter for listing objects. /// /// `start_after` is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. `StartAfter` can be any key in the bucket. /// /// **Note:** This functionality is not supported for directory buckets. /// /// # Arguments /// /// * `impl Into` - The key to start listing after. /// /// # Example /// /// ```rust /// // Assuming `list_objects_builder` is a mutable reference to a ListObjectsV2 builder /// // list_objects_builder.start_after("my_key_prefix"); /// ``` fn start_after(impl Into) { // Implementation details would go here } ``` -------------------------------- ### Configure Bucket for ListObjectsV2 in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec This example shows how to set the bucket for the `ListObjectsV2` operation using the `bucket` or `set_bucket` methods in the Rust SDK. It highlights the required nature of the bucket parameter and special formatting for directory buckets. ```rust * `bucket(impl Into)` / `set_bucket(Option)`: required: **true** ``` -------------------------------- ### Configure Fetch Owner for ListObjectsV2 in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec This example demonstrates how to include the owner's information in the `ListObjectsV2` response by setting the `fetch_owner` parameter to `true` using the Rust SDK. ```rust * `fetch_owner(bool)` / `set_fetch_owner(Option)`: required: **false** The owner field is not present in `ListObjectsV2` by default. If you want to return the owner field with each key in the result, then set the `FetchOwner` field to `true`. ``` -------------------------------- ### Get Bucket Website Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketWebsite` operation to retrieve the website configuration for a specified S3 bucket. ```APIDOC ## GET /buckets/{bucket}/website ### Description Retrieves the website configuration for an S3 bucket. ### Method GET ### Endpoint /buckets/{bucket}/website ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name for which to get the website configuration. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). ### Request Example ```json { "bucket": "your-bucket-name", "expected_bucket_owner": "optional-owner-id" } ``` ### Response #### Success Response (200) - **redirect_all_requests_to** (Option) - Specifies the redirect behavior of all requests to a website endpoint of an Amazon S3 bucket. - **index_document** (Option) - The name of the index document for the website (for example `index.html`). - **error_document** (Option) - The object key name of the website error document to use for 4XX class errors. - **routing_rules** (Option>) #### Response Example ```json { "redirect_all_requests_to": { "host_name": "www.example.com", "protocol": "https" }, "index_document": { "suffix": "index.html" }, "error_document": { "key": "error.html" } } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### Setup Client for CI/Containers Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This function sets up an AWS S3 client for use in CI or containerized environments. It initializes the client, connects to the S3 service, creates a temporary directory, changes the current directory to the temporary one, and returns a context object containing the client. ```rust #[cfg(all(feature = "with-s3-ci", not(feature = "with-containers")))] fn setup_client() -> Ctx { // Get transfer let bucket = env!("AWS_S3_BUCKET"); let mut client = AwsS3Fs::new(bucket, &Arc::new(Runtime::new().unwrap())); assert!(client.connect().is_ok()); // Create wrkdir let tempdir = PathBuf::from(generate_tempdir()); assert!( client .create_dir(tempdir.as_path(), UnixPex::from(0o775)) .is_ok() ); // Change directory let err = client.change_dir(tempdir.as_path()); if err.is_err() { println!("Error: {:?}", err); } assert!(client.change_dir(tempdir.as_path()).is_ok()); Ctx { client, container: (), } } ``` -------------------------------- ### Configure and Use MinIO Client in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/index This Rust code illustrates how to configure and utilize the AwsS3Fs client for MinIO, an S3-compatible object storage. It highlights setting the endpoint, enabling path-style access, and providing credentials. The example includes connecting, retrieving the working directory, changing directories, and disconnecting. ```rust use remotefs::RemoteFs; use remotefs_aws_s3::AwsS3Fs; use std::path::Path; let mut client = AwsS3Fs::new("test-bucket", &Arc::new(tokio::runtime::Runtime::new().unwrap())) .endpoint("http://localhost:9000") .new_path_style(true) // required for MinIO .access_key("minioadmin") .secret_access_key("minioadmin"); // connect assert!(client.connect().is_ok()); // get working directory println!("Wrkdir: {}", client.pwd().ok().unwrap().display()); // change working directory assert!(client.change_dir(Path::new("/tmp")).is_ok()); // disconnect assert!(client.disconnect().is_ok()); ``` -------------------------------- ### GET /bucket/logging Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketLogging` operation to retrieve logging information for a specified S3 bucket. ```APIDOC ## GET /bucket/logging ### Description Retrieves the logging configuration for a specified S3 bucket. This operation allows you to see where logs are stored and the prefix assigned to log objects. ### Method GET ### Endpoint /bucket/logging ### Parameters #### Query Parameters - **bucket** (string) - Required - The name of the bucket for which to get the logging information. - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID does not match the actual owner, the request fails with a 403 Forbidden error. ### Response #### Success Response (200) - **logging_enabled** (object) - Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. #### Response Example ```json { "logging_enabled": { "target_bucket": "my-log-bucket", "target_prefix": "logs/" } } ``` ``` -------------------------------- ### Configure Prefix for ListObjectsV2 in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec This example demonstrates how to filter object keys based on a prefix using the `prefix` parameter in the Rust SDK for the `ListObjectsV2` operation. It also mentions the limitation for directory buckets. ```rust * `prefix(impl Into)` / `set_prefix(Option)`: required: **false** Limits the response to keys that begin with the specified prefix. **Directory buckets** - For directory buckets, only prefixes that end in a delimiter (`/`) are supported. ``` -------------------------------- ### Configure and Use AWS S3 Client in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/index This Rust code demonstrates how to initialize and use the AwsS3Fs client for AWS S3. It covers setting the bucket name, region, profile, access key, and secret access key. It also shows how to connect, get the working directory, change the directory, and disconnect. ```rust use remotefs::RemoteFs; use remotefs_aws_s3::AwsS3Fs; use std::path::Path; let mut client = AwsS3Fs::new("test-bucket", &Arc::new(tokio::runtime::Runtime::new().unwrap())) .region("eu-west-1") .profile("default") .access_key("AKIAxxxxxxxxxxxx") .secret_access_key("****************"); // connect assert!(client.connect().is_ok()); // get working directory println!("Wrkdir: {}", client.pwd().ok().unwrap().display()); // change working directory assert!(client.change_dir(Path::new("/tmp")).is_ok()); // disconnect assert!(client.disconnect().is_ok()); ``` -------------------------------- ### Use S3 Waiter for Operation Completion (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Illustrates the usage of a waiter to asynchronously wait for a specific S3 operation to reach a desired state. This example shows how to configure a waiter with parameters and a timeout duration before initiating the wait. ```rust use std::time::Duration; let result = client.wait_until_thing() .thing_id("someId") .wait(Duration::from_secs(120)) .await; ``` -------------------------------- ### Get Object Torrent Configuration (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the GetObjectTorrent operation in Rust. This builder allows configuration of bucket, key, request payer, and expected bucket owner. It returns a GetObjectTorrentOutput on success or an SdkError on failure. ```rust pub fn get_object_torrent(&self) -> GetObjectTorrentFluentBuilder Constructs a fluent builder for the `GetObjectTorrent` operation. * The fluent builder is configurable: * `bucket(impl Into)` / `set_bucket(Option)`: required: **true** The name of the bucket containing the object for which to get the torrent files. * `key(impl Into)` / `set_key(Option)`: required: **true** The object key for which to get the information. * `request_payer(RequestPayer)` / `set_request_payer(Option)`: required: **false** Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. If either the source or destination S3 bucket has Requester Pays enabled, the requester will pay for corresponding charges to copy the object. For information about downloading objects from Requester Pays buckets, see Downloading Objects in Requester Pays Buckets in the _Amazon S3 User Guide_. This functionality is not supported for directory buckets. * `expected_bucket_owner(impl Into)` / `set_expected_bucket_owner(Option)`: required: **false** The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). * On success, responds with `GetObjectTorrentOutput` with field(s): * `body(ByteStream)`: A Bencoded dictionary as defined by the BitTorrent specification * `request_charged(Option)`: If present, indicates that the requester was successfully charged for the request. For more information, see Using Requester Pays buckets for storage transfers and usage in the _Amazon Simple Storage Service user guide_. This functionality is not supported for directory buckets. * On failure, responds with `SdkError` ``` -------------------------------- ### Create File in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a file with specified metadata and content using the `create_file` method. It takes a path, metadata, and a boxed reader as input. The operation's success is asserted. ```rust let mut metadata = Metadata::default(); metadata.size = file_data.len() as u64; assert!(client.create_file(p, &metadata, Box::new(reader)).is_ok()); ``` -------------------------------- ### GET /bucket-replication Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Retrieves the replication configuration for a specified bucket. This operation is used to get the replication configuration for a bucket. ```APIDOC ## GET /bucket-replication ### Description Retrieves the replication configuration for a specified bucket. This operation is used to get the replication configuration for a bucket. ### Method GET ### Endpoint /bucket-replication ### Parameters #### Query Parameters - **bucket** (string) - Required - The name of the bucket for which to retrieve the replication configuration. - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. ### Request Example ```json { "bucket": "example-bucket", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **replication_configuration** (object) - A container for replication rules. - **rules** (array) - A list of replication rules. - **id** (string) - The ID of the replication rule. - **priority** (integer) - The priority of the replication rule. - **prefix** (string) - The prefix for the replication rule. - **status** (string) - The status of the replication rule (Enabled or Disabled). - **source_selection_criteria** (object) - Specifies the criteria for the source objects to replicate. - **destination** (object) - The destination bucket for the replication. #### Response Example ```json { "replication_configuration": { "rules": [ { "id": "rule1", "priority": 1, "prefix": "logs/", "status": "Enabled", "source_selection_criteria": { "sse_kms_encrypted_objects": { "status": "Enabled" } }, "destination": { "bucket": "arn:aws:s3:::destination-bucket", "account": "123456789012" } } ] } } ``` ``` -------------------------------- ### Open File and Verify Size in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to open an existing file and verify its size. The `open_file` method is used with a path and a buffer. The returned value, representing the file size, is asserted against the expected size. ```rust let buffer: Box = Box::new(Vec::with_capacity(512)); assert_eq!(client.open_file(p, buffer).ok().unwrap(), 10); ``` -------------------------------- ### GET /bucket-policy-status Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Retrieves the policy status for a specified bucket. This operation is used to get the policy status for a bucket. ```APIDOC ## GET /bucket-policy-status ### Description Retrieves the policy status for a specified bucket. This operation is used to get the policy status for a bucket. ### Method GET ### Endpoint /bucket-policy-status ### Parameters #### Query Parameters - **bucket** (string) - Required - The name of the bucket for which to retrieve the policy status. - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. ### Request Example ```json { "bucket": "example-bucket", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **policy_status** (object) - The policy status for the specified bucket. - **is_public** (boolean) - Indicates whether the bucket policy makes the bucket public. - **http_status_code** (integer) - The HTTP status code for the policy status. #### Response Example ```json { "policy_status": { "is_public": true, "http_status_code": 200 } } ``` ``` -------------------------------- ### GET /bucket-policy Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Retrieves the policy of a specified bucket. This operation is used to get the access control list (ACL) that is associated with a bucket. ```APIDOC ## GET /bucket-policy ### Description Retrieves the policy of a specified bucket. This operation is used to get the access control list (ACL) that is associated with a bucket. ### Method GET ### Endpoint /bucket-policy ### Parameters #### Query Parameters - **bucket** (string) - Required - The name of the bucket for which to retrieve the policy. - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. ### Request Example ```json { "bucket": "example-bucket", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **policy** (string) - The bucket policy as a JSON document. #### Response Example ```json { "policy": "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Sid\": \"Example\", \"Effect\": \"Allow\", \"Principal\": {\"AWS\": \"arn:aws:iam::123456789012:root\"}, \"Action\": \"s3:GetObject\", \"Resource\": \"arn:aws:s3:::example-bucket/*\"}]}" } ``` ``` -------------------------------- ### Client Construction Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Demonstrates how to construct an S3 client using `aws-config` to load settings from the environment. It shows both the simplest case and how to customize configuration with service-specific settings. ```APIDOC ## Client Construction ### Description Constructs an S3 client using configuration loaded from the environment. This can be done directly or with custom service-specific settings. ### Method `Client::new(sdk_config: &SdkConfig)` or `Client::from_conf(conf: Config)` ### Parameters #### Request Body N/A ### Request Example ```rust // Simplest case let config = aws_config::load_from_env().await; let client = aws_sdk_s3::Client::new(&config); // With custom settings let sdk_config = ::aws_config::load_from_env().await; let config = aws_sdk_s3::config::Builder::from(&sdk_config) .some_service_specific_setting("value") .build(); let client = aws_sdk_s3::Client::new(&config); ``` ### Response #### Success Response (Client Instance) - **Client** - An initialized S3 client instance. #### Response Example N/A ### Panics Client construction can panic under specific conditions related to retry/timeout configuration, identity caching, or missing `sleep_impl`, `time_source`, `http_connector`, or `behavior_version`. ``` -------------------------------- ### Part Number for Ranged GET Requests in S3 Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Specifies the part number of an object being read, allowing for ranged GET requests. This is a positive integer between 1 and 10,000, useful for downloading specific parts of an object. ```rust /// `part_number(i32)` / `set_part_number(Option)`: /// required: **false** /// /// Part number of the object being read. This is a positive integer between 1 and 10,000. Effectively performs a ‘ranged’ GET request for the part specified. Useful for downloading just a part of an object. ``` -------------------------------- ### Construct S3 Client with Default Config (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Creates a new S3 client by loading configuration from the environment. This is the most common way to initialize the client for general use. It relies on the `aws-config` crate to resolve SDK configuration. ```rust let config = aws_config::load_from_env().await; let client = aws_sdk_s3::Client::new(&config); ``` -------------------------------- ### Get Underlying S3Client Reference (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a method to get an immutable reference to the underlying AWS SDK S3Client. This is useful for direct interaction with the S3 API if needed. It returns an Option<&S3Client> to handle cases where the client might not be initialized. ```rust /// Get a reference to the underlying aws sdk [`S3Client`] struct pub fn client(&self) -> Option<&S3Client> { self.client.as_ref() } ``` -------------------------------- ### Create and Remove Directory in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the creation of a directory with specific permissions using `create_dir`. The test asserts that the directory creation operation is successful. ```rust let mut dir_path = client.pwd().ok().unwrap(); dir_path.push(Path::new("test/")); assert!( client .create_dir(dir_path.as_path(), UnixPex::from(0o775)) .is_ok() ); ``` -------------------------------- ### Get Current Working Directory Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.AwsS3Fs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the current working directory on the remote S3 server. ```rust fn pwd(&mut self) -> RemoteResult ``` -------------------------------- ### GET /websites/rs_remotefs-aws-s3_0_4_3/get_object_retention Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetObjectRetention` operation to retrieve object retention settings. ```APIDOC ## GET /websites/rs_remotefs-aws-s3_0_4_3/get_object_retention ### Description Retrieves the retention settings for a specific object in an S3 bucket. ### Method GET ### Endpoint /websites/rs_remotefs-aws-s3_0_4_3/get_object_retention ### Parameters #### Query Parameters - **bucket** (String) - Required - The bucket name containing the object whose retention settings you want to retrieve. For access points, provide the alias or ARN. - **key** (String) - Required - The key name for the object whose retention settings you want to retrieve. - **version_id** (String) - Optional - The version ID for the object whose retention settings you want to retrieve. - **request_payer** (RequestPayer) - Optional - Confirms that the requester knows that they will be charged for the request. Not supported for directory buckets. - **expected_bucket_owner** (String) - Optional - The account ID of the expected bucket owner. If it doesn't match, the request fails with a 403 error. ### Request Example ```json { "bucket": "your-bucket-name", "key": "your-object-key", "version_id": "your-object-version-id", "request_payer": "requester", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **retention** (ObjectLockRetention) - The container element for an object’s retention settings. #### Response Example ```json { "retention": { "mode": "COMPLIANCE", "retain_until_date": "2024-12-31T23:59:59Z" } } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### AwsS3Fs Client Initialization and Configuration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.AwsS3Fs_search=std%3A%3Avec This section details how to initialize and configure the AwsS3Fs client for connecting to AWS S3 or compatible endpoints. ```APIDOC ## AwsS3Fs remotefs_aws_s3::client ### Description Aws s3 file system client. ### Methods #### `new>(bucket: S, runtime: &Arc) -> Self` Initialize a new `AwsS3Fs` client with the specified bucket and runtime. #### `region>(self, region: S) -> Self` Specify the AWS region to connect to. #### `endpoint>(self, endpoint: S) -> Self` Specify a custom endpoint. This should be used when trying to connect to `minio` or other API compatible endpoints. #### `profile>(self, profile: S) -> Self` Set the AWS profile to use. If unset, the `"default"` profile will be used. #### `new_path_style(self, new_path_style: bool) -> Self` Set whether to use new path style. Required for backends such as MinIO (Default: `False`). #### `access_key>(self, key: S) -> Self` Specify the access key for the AWS connection. If unset, it will be read from the environment variable `AWS_ACCESS_KEY_ID`. #### `secret_access_key>(self, key: S) -> Self` Specify the secret access key for the AWS connection. If unset, it will be read from the environment variable `AWS_SECRET_ACCESS_KEY`. #### `security_token>(self, key: S) -> Self` Specify the security token for the AWS connection. If unset, it will be read from the environment variable `AWS_SECURITY_TOKEN`. #### `session_token>(self, key: S) -> Self` Specify the session token for the AWS connection. If unset, it will be read from the environment variable `AWS_SESSION_TOKEN`. #### `client(&self) -> Option<&S3Client>` Get a reference to the underlying AWS SDK `S3Client` struct. ``` -------------------------------- ### Get File/Directory Metadata Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.AwsS3Fs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves metadata for a file or directory at the specified path on the remote S3 server. ```rust fn stat(&mut self, path: &Path) -> RemoteResult ``` -------------------------------- ### GET /getObjectLockConfiguration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetObjectLockConfiguration` operation to retrieve the Object Lock configuration for a bucket. ```APIDOC ## GET /getObjectLockConfiguration ### Description Retrieves the Object Lock configuration for a specified S3 bucket. ### Method GET ### Endpoint /getObjectLockConfiguration ### Parameters #### Query Parameters - **bucket** (String) - Required - The bucket whose Object Lock configuration you want to retrieve. For access points, provide the alias or ARN. - **expected_bucket_owner** (String) - Optional - The account ID of the expected bucket owner. ### Response #### Success Response (200) - **object_lock_configuration** (ObjectLockConfiguration) - The specified bucket’s Object Lock configuration. #### Response Example ```json { "object_lock_configuration": { "object_lock_enabled": "ENABLED", "rule": { "default_retention": { "mode": "COMPLIANCE", "days": 30 } } } } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### GET /getObjectLegalHold Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetObjectLegalHold` operation to retrieve the legal hold status of an object. ```APIDOC ## GET /getObjectLegalHold ### Description Retrieves the legal hold status for a specified object in an S3 bucket. ### Method GET ### Endpoint /getObjectLegalHold ### Parameters #### Query Parameters - **bucket** (String) - Required - The bucket name containing the object whose legal hold status you want to retrieve. For access points, provide the alias or ARN. - **key** (String) - Required - The key name for the object whose legal hold status you want to retrieve. - **version_id** (String) - Optional - The version ID of the object whose legal hold status you want to retrieve. - **request_payer** (RequestPayer) - Optional - Confirms that the requester knows that they will be charged for the request. This functionality is not supported for directory buckets. - **expected_bucket_owner** (String) - Optional - The account ID of the expected bucket owner. ### Response #### Success Response (200) - **legal_hold** (ObjectLockLegalHold) - The current legal hold status for the specified object. #### Response Example ```json { "legal_hold": { "status": "ON" } } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### Construct ListParts Fluent Builder in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec This code snippet demonstrates how to construct a fluent builder for the `ListParts` operation using the Rust AWS SDK. It shows the basic setup for initiating the builder, which is a prerequisite for configuring and executing the `ListParts` API call. The builder allows for setting various parameters to specify the multipart upload details. ```rust pub fn list_parts(&self) -> ListPartsFluentBuilder ``` -------------------------------- ### GET /bucket/metrics/configuration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketMetricsConfiguration` operation to retrieve the metrics configuration for an S3 bucket. ```APIDOC ## GET /bucket/metrics/configuration ### Description Retrieves the metrics configuration for a specified S3 bucket. This operation allows you to view the metrics configuration, which specifies the metrics that are enabled for the bucket. ### Method GET ### Endpoint /bucket/metrics/configuration ### Parameters #### Query Parameters - **bucket** (string) - Required - The name of the bucket containing the metrics configuration to retrieve. - **id** (string) - Required - The ID used to identify the metrics configuration. The ID has a 64 character limit and can only contain letters, numbers, periods, dashes, and underscores. - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID does not match the actual owner, the request fails with a 403 Forbidden error. ### Response #### Success Response (200) - **metrics_configuration** (object) - Specifies the metrics configuration. #### Response Example ```json { "metrics_configuration": { "id": "my-metrics-id", "prefix": "logs/", "access_point_arn": "arn:aws:s3:us-east-1:123456789012:accesspoint/my-access-point" } } ``` ``` -------------------------------- ### Initialize AWS S3 Filesystem in Rust (With Options) Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes an `AwsS3Fs` instance and configures it with various options like region, access key, secret key, endpoint, and path style. This fluent API allows setting specific AWS credentials and connection details. The test asserts that all provided options are correctly applied to the `AwsS3Fs` instance. ```rust fn should_init_s3_with_options() { let s3 = AwsS3Fs::new("aws-s3-test", &Arc::new(Runtime::new().unwrap())) .region("eu-central-1") .access_key("AKIA0000") .profile("default") .secret_access_key("PASSWORD") .security_token("secret") .session_token("token") .new_path_style(true) .endpoint("omar"); assert_eq!(s3.bucket_name.as_str(), "aws-s3-test"); assert_eq!(s3.region.as_deref().unwrap(), "eu-central-1"); assert_eq!(s3.access_key.as_deref().unwrap(), "AKIA0000"); assert_eq!(s3.secret_key.as_deref().unwrap(), "PASSWORD"); assert_eq!(s3.security_token.as_deref().unwrap(), "secret"); assert_eq!(s3.session_token.as_deref().unwrap(), "token"); assert_eq!(s3.endpoint.as_deref().unwrap(), "omar"); assert_eq!(s3.is_anonymous(), false); assert_eq!(s3.new_path_style, true); } ``` -------------------------------- ### Construct ListBucketMetricsConfigurations Fluent Builder (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec This Rust code snippet demonstrates how to construct a fluent builder for the `ListBucketMetricsConfigurations` operation. The builder allows for configuration of parameters such as `bucket`, `continuation_token`, and `expected_bucket_owner`. The operation retrieves metrics configurations for a specified S3 bucket. ```rust pub fn list_bucket_metrics_configurations(&self) -> ListBucketMetricsConfigurationsFluentBuilder { // Implementation details for constructing the fluent builder unimplemented!() } ``` -------------------------------- ### Get Bucket Location Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketLocation` operation to retrieve the location constraint of an S3 bucket. ```APIDOC ## GET /buckets/{bucket}/location ### Description Retrieves the Region where the specified S3 bucket resides. ### Method GET ### Endpoint `/buckets/{bucket}/location` ### Parameters #### Path Parameters - **bucket** (string) - Required - The name of the bucket for which to get the location. Use the alias of the access point if using an access point. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). ### Request Example ```json { "bucket": "your-bucket-name", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **location_constraint** (BucketLocationConstraint) - Specifies the Region where the bucket resides. #### Response Example ```json { "location_constraint": "us-west-2" } ``` ``` -------------------------------- ### Create Bucket Metadata Configuration (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `CreateBucketMetadataConfiguration` operation. This operation allows for configuring metadata for a specified S3 bucket. It requires the bucket name and metadata configuration, with optional parameters for Content-MD5, checksum algorithm, and expected bucket owner. Success returns `CreateBucketMetadataConfigurationOutput`, while failure returns `SdkError`. ```rust pub fn create_bucket_metadata_configuration(&self) -> CreateBucketMetadataConfigurationFluentBuilder ``` -------------------------------- ### Get S3 Bucket Website Configuration (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketWebsite` operation. This operation retrieves the website configuration for a specified S3 bucket. It requires the bucket name and optionally accepts the expected bucket owner's account ID. On success, it returns website configuration details like `redirect_all_requests_to`, `index_document`, `error_document`, and `routing_rules`; otherwise, it returns an `SdkError`. ```rust pub fn get_bucket_website(&self) -> GetBucketWebsiteFluentBuilder Constructs a fluent builder for the `GetBucketWebsite` operation. * The fluent builder is configurable: * `bucket(impl Into)` / `set_bucket(Option)`: required: **true** The bucket name for which to get the website configuration. * `expected_bucket_owner(impl Into)` / `set_expected_bucket_owner(Option)`: required: **false** The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). * On success, responds with `GetBucketWebsiteOutput` with field(s): * `redirect_all_requests_to(Option)`: Specifies the redirect behavior of all requests to a website endpoint of an Amazon S3 bucket. * `index_document(Option)`: The name of the index document for the website (for example `index.html`). * `error_document(Option)`: The object key name of the website error document to use for 4XX class errors. * `routing_rules(Option>)`: Rules that define when a redirect is applied and the redirect behavior. * On failure, responds with `SdkError` ``` -------------------------------- ### Get Bucket Versioning Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketVersioning` operation to retrieve the versioning status for a specified S3 bucket. ```APIDOC ## GET /buckets/{bucket}/versioning ### Description Retrieves the versioning status for an S3 bucket. ### Method GET ### Endpoint /buckets/{bucket}/versioning ### Parameters #### Path Parameters - **bucket** (string) - Required - The name of the bucket for which to get the versioning information. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). ### Request Example ```json { "bucket": "your-bucket-name", "expected_bucket_owner": "optional-owner-id" } ``` ### Response #### Success Response (200) - **status** (Option) - The versioning state of the bucket. - **mfa_delete** (Option) - Specifies whether MFA delete is enabled in the bucket versioning configuration. #### Response Example ```json { "status": "Enabled", "mfa_delete": "Enabled" } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### Get Bucket Tagging Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketTagging` operation to retrieve the tagging information for a specified S3 bucket. ```APIDOC ## GET /buckets/{bucket}/tagging ### Description Retrieves the tagging information for an S3 bucket. ### Method GET ### Endpoint /buckets/{bucket}/tagging ### Parameters #### Path Parameters - **bucket** (string) - Required - The name of the bucket for which to get the tagging information. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). ### Request Example ```json { "bucket": "your-bucket-name", "expected_bucket_owner": "optional-owner-id" } ``` ### Response #### Success Response (200) - **tag_set** (Vec::) - Contains the tag set. #### Response Example ```json { "tag_set": [ { "key": "Environment", "value": "Production" } ] } ``` #### Error Response - **SdkError** - Indicates an error occurred during the operation. ``` -------------------------------- ### Construct S3 Client with Custom Config (Rust) Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Initializes an S3 client with custom configuration settings by extending the SDK configuration. This allows for service-specific settings or modifications to the default configuration. It uses the `aws-sdk-s3::config::Builder` to apply custom values. ```rust let sdk_config = ::aws_config::load_from_env().await; let config = aws_sdk_s3::config::Builder::from(&sdk_config) .some_service_specific_setting("value") .build(); ``` -------------------------------- ### GET /bucket/metadata/configuration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketMetadataConfiguration` operation to retrieve the metadata configuration for a general purpose S3 bucket. ```APIDOC ## GET /bucket/metadata/configuration ### Description Retrieves the metadata configuration for a general purpose S3 bucket. This operation allows you to get the metadata configuration associated with the bucket. ### Method GET ### Endpoint /bucket/metadata/configuration ### Parameters #### Query Parameters - **bucket** (string) - Required - The general purpose bucket that corresponds to the metadata configuration that you want to retrieve. - **expected_bucket_owner** (string) - Optional - The expected owner of the general purpose bucket. If the account ID does not match the actual owner, the request fails with a 403 Forbidden error. ### Response #### Success Response (200) - **get_bucket_metadata_configuration_result** (object) - The metadata configuration for the general purpose bucket. #### Response Example ```json { "get_bucket_metadata_configuration_result": { "metadata_configuration": { "rule_id": "my-rule-id", "rule_status": "Enabled" } } } ``` ``` -------------------------------- ### Initialize and Connect to AWS S3 Client in Rust Source: https://docs.rs/remotefs-aws-s3/0.4.3/src/remotefs_aws_s3/client.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes an AWS S3 filesystem client with specified endpoint, credentials, and path style. It then connects to the S3 service and asserts the connection is successful. This is typically used for setting up a connection to a local MinIO instance for testing. ```rust let mut client = AwsS3Fs::new("github-ci", &runtime) .endpoint(format!("http://localhost:{port}")) .access_key("minioadmin") .secret_access_key("minioadmin") .new_path_style(true); // connect assert!(client.connect().is_ok()); ``` -------------------------------- ### Get Bucket Lifecycle Configuration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketLifecycleConfiguration` operation to retrieve the lifecycle configuration of an S3 bucket. ```APIDOC ## GET /buckets/{bucket}/lifecycle ### Description Retrieves the lifecycle configuration for a specified S3 bucket. ### Method GET ### Endpoint `/buckets/{bucket}/lifecycle` ### Parameters #### Path Parameters - **bucket** (string) - Required - The name of the bucket for which to get the lifecycle information. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle configurations. ### Request Example ```json { "bucket": "your-bucket-name", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **rules** (array of LifecycleRule) - Container for a lifecycle rule. - **transition_default_minimum_object_size** (TransitionDefaultMinimumObjectSize) - Indicates which default minimum object size behavior is applied to the lifecycle configuration. This parameter applies to general purpose buckets only. #### Response Example ```json { "rules": [ { "id": "my-rule", "filter": { "prefix": "logs/" }, "status": "Enabled", "transitions": [ { "days": 30, "storage_class": "STANDARD_IA" } ], "expiration": { "days": 365 } } ], "transition_default_minimum_object_size": "128KB" } ``` ``` -------------------------------- ### Get Bucket Inventory Configuration Source: https://docs.rs/remotefs-aws-s3/0.4.3/remotefs_aws_s3/client/struct.S3Client_search=std%3A%3Avec Constructs a fluent builder for the `GetBucketInventoryConfiguration` operation to retrieve the inventory configuration of an S3 bucket. ```APIDOC ## GET /buckets/{bucket}/inventoryConfiguration/{id} ### Description Retrieves the inventory configuration for a specified S3 bucket. ### Method GET ### Endpoint `/buckets/{bucket}/inventoryConfiguration/{id}` ### Parameters #### Path Parameters - **bucket** (string) - Required - The name of the bucket containing the inventory configuration to retrieve. - **id** (string) - Required - The ID used to identify the inventory configuration. #### Query Parameters - **expected_bucket_owner** (string) - Optional - The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code `403 Forbidden` (access denied). ### Request Example ```json { "bucket": "your-bucket-name", "id": "your-inventory-id", "expected_bucket_owner": "123456789012" } ``` ### Response #### Success Response (200) - **inventory_configuration** (InventoryConfiguration) - Specifies the inventory configuration. #### Response Example ```json { "inventory_configuration": { "id": "your-inventory-id", "enabled": true, "destination": { "bucket": "your-destination-bucket", "prefix": "inventory/" }, "schedule": { "frequency": "Daily" }, "filter": { "prefix": "logs/" } } } ``` ```