|
| 1 | +use crate::prelude::BlobServiceClient; |
| 2 | +use azure_core::headers::Headers; |
| 3 | +use azure_core::{Method, Response}; |
| 4 | +use azure_storage::headers::CommonStorageResponseHeaders; |
| 5 | +use azure_svc_blobstorage::models::StorageServiceProperties; |
| 6 | + |
| 7 | +operation! { |
| 8 | + GetBlobServiceProperties, |
| 9 | + client: BlobServiceClient, |
| 10 | +} |
| 11 | + |
| 12 | +impl GetBlobServicePropertiesBuilder { |
| 13 | + pub fn into_future(mut self) -> GetBlobServiceProperties { |
| 14 | + Box::pin(async move { |
| 15 | + let mut url = self.client.url()?; |
| 16 | + |
| 17 | + url.query_pairs_mut() |
| 18 | + .extend_pairs([("restype", "service"), ("comp", "properties")]); |
| 19 | + |
| 20 | + let mut request = |
| 21 | + BlobServiceClient::finalize_request(url, Method::Get, Headers::new(), None)?; |
| 22 | + |
| 23 | + let response = self.client.send(&mut self.context, &mut request).await?; |
| 24 | + |
| 25 | + GetBlobServicePropertiesResponse::try_from(response).await |
| 26 | + }) |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +#[derive(Debug, Clone)] |
| 31 | +pub struct GetBlobServicePropertiesResponse { |
| 32 | + pub common: CommonStorageResponseHeaders, |
| 33 | + pub properties: StorageServiceProperties, |
| 34 | +} |
| 35 | + |
| 36 | +impl GetBlobServicePropertiesResponse { |
| 37 | + pub(crate) async fn try_from( |
| 38 | + response: Response, |
| 39 | + ) -> azure_core::Result<GetBlobServicePropertiesResponse> { |
| 40 | + let common = CommonStorageResponseHeaders::try_from(response.headers())?; |
| 41 | + let body = response.into_body().collect().await?; |
| 42 | + println!("body {body:?}"); |
| 43 | + let properties = azure_core::xml::read_xml(&body)?; |
| 44 | + |
| 45 | + Ok(GetBlobServicePropertiesResponse { common, properties }) |
| 46 | + } |
| 47 | +} |
0 commit comments