-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add blob service client get properties (#1499)
- Loading branch information
Showing
6 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use azure_storage::prelude::*; | ||
use azure_storage_blobs::prelude::*; | ||
|
||
#[tokio::main] | ||
async fn main() -> azure_core::Result<()> { | ||
env_logger::init(); | ||
// First we retrieve the account name and access key from environment variables. | ||
let account = | ||
std::env::var("STORAGE_ACCOUNT").expect("Set env variable STORAGE_ACCOUNT first!"); | ||
let access_key = | ||
std::env::var("STORAGE_ACCESS_KEY").expect("Set env variable STORAGE_ACCESS_KEY first!"); | ||
|
||
let storage_credentials = StorageCredentials::access_key(account.clone(), access_key); | ||
let service_client = BlobServiceClient::new(account, storage_credentials); | ||
|
||
let properties = service_client.get_properties().await?; | ||
println!("properties: {:#?}", properties); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
pub use super::container::PublicAccess; | ||
pub use crate::options::*; | ||
pub use crate::{ | ||
blob::{Blob, BlobBlockType, BlockList, BlockListType}, | ||
clients::{ | ||
BlobClient, BlobLeaseClient, BlobServiceClient, ClientBuilder, ContainerClient, | ||
ContainerLeaseClient, | ||
}, | ||
container::PublicAccess, | ||
options::*, | ||
}; | ||
pub use azure_storage::{StoredAccessPolicy, StoredAccessPolicyList}; | ||
pub use azure_svc_blobstorage::models::{ | ||
storage_service_properties::Cors, CorsRule, Logging, Metrics, RetentionPolicy, StaticWebsite, | ||
}; |
47 changes: 47 additions & 0 deletions
47
sdk/storage_blobs/src/service/operations/get_blob_service_properties.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::prelude::BlobServiceClient; | ||
use azure_core::headers::Headers; | ||
use azure_core::{Method, Response}; | ||
use azure_storage::headers::CommonStorageResponseHeaders; | ||
use azure_svc_blobstorage::models::StorageServiceProperties; | ||
|
||
operation! { | ||
GetBlobServiceProperties, | ||
client: BlobServiceClient, | ||
} | ||
|
||
impl GetBlobServicePropertiesBuilder { | ||
pub fn into_future(mut self) -> GetBlobServiceProperties { | ||
Box::pin(async move { | ||
let mut url = self.client.url()?; | ||
|
||
url.query_pairs_mut() | ||
.extend_pairs([("restype", "service"), ("comp", "properties")]); | ||
|
||
let mut request = | ||
BlobServiceClient::finalize_request(url, Method::Get, Headers::new(), None)?; | ||
|
||
let response = self.client.send(&mut self.context, &mut request).await?; | ||
|
||
GetBlobServicePropertiesResponse::try_from(response).await | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct GetBlobServicePropertiesResponse { | ||
pub common: CommonStorageResponseHeaders, | ||
pub properties: StorageServiceProperties, | ||
} | ||
|
||
impl GetBlobServicePropertiesResponse { | ||
pub(crate) async fn try_from( | ||
response: Response, | ||
) -> azure_core::Result<GetBlobServicePropertiesResponse> { | ||
let common = CommonStorageResponseHeaders::try_from(response.headers())?; | ||
let body = response.into_body().collect().await?; | ||
println!("body {body:?}"); | ||
let properties = azure_core::xml::read_xml(&body)?; | ||
|
||
Ok(GetBlobServicePropertiesResponse { common, properties }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod find_blobs_by_tags; | ||
mod get_account_information; | ||
mod get_blob_service_properties; | ||
mod get_user_delegation_key; | ||
mod list_containers; | ||
|
||
pub use find_blobs_by_tags::*; | ||
pub use get_account_information::*; | ||
pub use get_blob_service_properties::*; | ||
pub use get_user_delegation_key::*; | ||
pub use list_containers::*; |