tustvold commented on code in PR #3436:
URL: https://github.com/apache/arrow-rs/pull/3436#discussion_r1061361389


##########
object_store/src/aws/mod.rs:
##########
@@ -379,6 +383,170 @@ pub struct AmazonS3Builder {
     client_options: ClientOptions,
 }
 
+/// Configuration keys for [`AmazonS3Builder`]
+#[derive(PartialEq, Eq, Hash, Clone, Debug, Copy)]
+pub enum AmazonS3ConfigKey {
+    /// AWS Access Key
+    ///
+    /// See [`AmazonS3Builder::with_access_key_id`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_access_key_id`
+    /// - `access_key_id`
+    AccessKeyId,
+
+    /// Secret Access Key
+    ///
+    /// See [`AmazonS3Builder::with_secret_access_key`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_secret_access_key`
+    /// - `secret_access_key`
+    SecretAccessKey,
+
+    /// Region
+    ///
+    /// See [`AmazonS3Builder::with_region`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_region`
+    /// - `region`
+    Region,
+
+    /// Default region
+    ///
+    /// See [`AmazonS3Builder::with_region`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_default_region`
+    /// - `default_region`
+    DefaultRegion,
+
+    /// Bucket name
+    ///
+    /// See [`AmazonS3Builder::with_bucket_name`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_bucket`
+    /// - `aws_bucket_name`
+    /// - `bucket`
+    /// - `bucket_name`
+    Bucket,
+
+    /// Sets custom endpoint for communicating with AWS S3.
+    ///
+    /// See [`AmazonS3Builder::with_endpoint`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_endpoint`
+    /// - `aws_endpoint_url`
+    /// - `endpoint`
+    /// - `endpoint_url`
+    Endpoint,
+
+    /// Token to use for requests (passed to underlying provider)
+    ///
+    /// See [`AmazonS3Builder::with_token`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_session_token`
+    /// - `aws_token`
+    /// - `session_token`
+    /// - `token`
+    Token,
+
+    /// Fall back to ImdsV1
+    ///
+    /// See [`AmazonS3Builder::with_imdsv1_fallback`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_imdsv1_fallback`
+    /// - `imdsv1_fallback`
+    ImdsV1Fallback,
+
+    /// If virtual hosted style request has to be used
+    ///
+    /// See [`AmazonS3Builder::with_virtual_hosted_style_request`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_virtual_hosted_style_request`
+    /// - `virtual_hosted_style_request`
+    VirtualHostedStyleRequest,
+
+    /// Set the instance metadata endpoint
+    ///
+    /// See [`AmazonS3Builder::with_metadata_endpoint`] for details.
+    ///
+    /// Supported keys:
+    /// - `aws_metadata_endpoint`
+    /// - `metadata_endpoint`
+    MetadataEndpoint,
+
+    /// AWS profile name
+    ///
+    /// Supported keys:
+    /// - `aws_profile`
+    /// - `profile`
+    Profile,
+}
+
+impl From<AmazonS3ConfigKey> for String {
+    fn from(value: AmazonS3ConfigKey) -> Self {
+        match value {
+            AmazonS3ConfigKey::AccessKeyId => Self::from("aws_access_key_id"),
+            AmazonS3ConfigKey::SecretAccessKey => 
Self::from("aws_secret_access_key"),
+            AmazonS3ConfigKey::Region => Self::from("aws_region"),
+            AmazonS3ConfigKey::Bucket => Self::from("aws_bucket"),
+            AmazonS3ConfigKey::Endpoint => Self::from("aws_endpoint"),
+            AmazonS3ConfigKey::Token => Self::from("aws_session_token"),
+            AmazonS3ConfigKey::ImdsV1Fallback => 
Self::from("aws_imdsv1_fallback"),
+            AmazonS3ConfigKey::VirtualHostedStyleRequest => {
+                Self::from("aws_virtual_hosted_style_request")
+            }
+            AmazonS3ConfigKey::DefaultRegion => 
Self::from("aws_default_region"),
+            AmazonS3ConfigKey::MetadataEndpoint => 
Self::from("aws_metadata_endpoint"),
+            AmazonS3ConfigKey::Profile => Self::from("aws_profile"),
+        }
+    }
+}
+
+impl TryFrom<&str> for AmazonS3ConfigKey {

Review Comment:
   `FromStr` is the more idiomatic trait to use here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to