roeap commented on code in PR #3436:
URL: https://github.com/apache/arrow-rs/pull/3436#discussion_r1061591165
##########
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(_) => (),
Review Comment:
I made the methods for handling options fallible and renamed them to
`try_with_*`. Was thinking about deferring until build, but I think that would
have limited us in what iterators we can acccept. While different from other
setters, I think this might be acceptable?
--
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]