use object_store::{
Result,
azure::{MicrosoftAzure, MicrosoftAzureBuilder},
};
use super::super::ObjectStorage;
#[derive(Clone, Debug)]
pub struct AzureObjectStorageBuilder {
name: String,
builder: MicrosoftAzureBuilder,
}
impl AzureObjectStorageBuilder {
pub(crate) fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
builder: MicrosoftAzureBuilder::from_env(),
}
}
#[must_use]
pub fn with_account(mut self, account: impl Into<String>) -> Self {
self.builder = self.builder.with_account(account);
self
}
#[must_use]
pub fn with_container_name(mut self, container_name: impl Into<String>) -> Self {
self.builder = self.builder.with_container_name(container_name);
self
}
#[must_use]
pub fn with_access_key(mut self, access_key: impl Into<String>) -> Self {
self.builder = self.builder.with_access_key(access_key);
self
}
#[must_use]
pub fn with_url(mut self, url: impl Into<String>) -> Self {
self.builder = self.builder.with_url(url);
self
}
#[must_use]
pub fn configure_store(
mut self,
configure: impl FnOnce(MicrosoftAzureBuilder) -> MicrosoftAzureBuilder,
) -> Self {
self.builder = configure(self.builder);
self
}
pub fn build(self) -> Result<ObjectStorage<MicrosoftAzure>> {
self.builder
.build()
.map(|store| ObjectStorage::from_store(self.name, store))
}
}