roeap commented on code in PR #3436:
URL: https://github.com/apache/arrow-rs/pull/3436#discussion_r1061589328
##########
object_store/src/aws/mod.rs:
##########
@@ -472,6 +623,50 @@ impl AmazonS3Builder {
self
}
+ /// Set an option on the builder via a key - value pair.
+ pub fn with_option(
+ mut self,
+ key: impl Into<String>,
+ value: impl Into<String>,
+ ) -> Self {
+ match AmazonS3ConfigKey::try_from(key.into()) {
+ Ok(AmazonS3ConfigKey::AccessKeyId) => self.access_key_id =
Some(value.into()),
+ Ok(AmazonS3ConfigKey::SecretAccessKey) => {
+ self.secret_access_key = Some(value.into())
+ }
+ Ok(AmazonS3ConfigKey::Region) => self.region = Some(value.into()),
+ Ok(AmazonS3ConfigKey::Bucket) => self.bucket_name =
Some(value.into()),
+ Ok(AmazonS3ConfigKey::Endpoint) => self.endpoint =
Some(value.into()),
+ Ok(AmazonS3ConfigKey::Token) => self.token = Some(value.into()),
+ Ok(AmazonS3ConfigKey::ImdsV1Fallback) => {
+ self.imdsv1_fallback = str_is_truthy(&value.into())
+ }
+ Ok(AmazonS3ConfigKey::VirtualHostedStyleRequest) => {
+ self.virtual_hosted_style_request =
str_is_truthy(&value.into())
+ }
+ Ok(AmazonS3ConfigKey::DefaultRegion) => {
+ self.region = self.region.or_else(|| Some(value.into()))
+ }
+ Ok(AmazonS3ConfigKey::MetadataEndpoint) => {
+ self.metadata_endpoint = Some(value.into())
+ }
+ Ok(AmazonS3ConfigKey::Profile) => self.profile =
Some(value.into()),
+ Err(_) => (),
+ };
+ self
+ }
+
+ /// Hydrate builder from key value pairs
+ pub fn with_options(
+ mut self,
+ options: &HashMap<impl Into<String> + Clone, String>,
Review Comment:
yes, much nicer :)
--
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]