azure_storage_blobs/container/operations/
get_properties.rs1use crate::{container::Container, prelude::*};
2use azure_core::{date, Method};
3use azure_core::{
4 headers::{self, Headers},
5 prelude::*,
6 RequestId,
7};
8use time::OffsetDateTime;
9
10operation! {
11 GetProperties,
12 client: ContainerClient,
13 ?lease_id: LeaseId
14}
15
16impl GetPropertiesBuilder {
17 pub fn into_future(mut self) -> GetProperties {
18 Box::pin(async move {
19 let mut url = self.client.url()?;
20
21 url.query_pairs_mut().append_pair("restype", "container");
22
23 let mut headers = Headers::new();
24 headers.add(self.lease_id);
25
26 let mut request = ContainerClient::finalize_request(url, Method::Head, headers, None)?;
27
28 let response = self.client.send(&mut self.context, &mut request).await?;
29
30 (self.client.container_name(), response.headers()).try_into()
31 })
32 }
33}
34
35#[derive(Debug, Clone)]
36pub struct GetPropertiesResponse {
37 pub container: Container,
38 pub request_id: RequestId,
39 pub date: OffsetDateTime,
40}
41
42impl TryFrom<(&str, &Headers)> for GetPropertiesResponse {
43 type Error = azure_core::Error;
44
45 fn try_from((body, header_map): (&str, &Headers)) -> azure_core::Result<Self> {
46 GetPropertiesResponse::from_response(body, header_map)
47 }
48}
49
50impl GetPropertiesResponse {
51 pub(crate) fn from_response(
52 container_name: &str,
53 headers: &Headers,
54 ) -> azure_core::Result<GetPropertiesResponse> {
55 let request_id = headers.get_as(&headers::REQUEST_ID)?;
56
57 let date = date::parse_rfc1123(headers.get_str(&headers::DATE)?)?;
58
59 let container = Container::from_response(container_name, headers)?;
60
61 Ok(GetPropertiesResponse {
62 container,
63 request_id,
64 date,
65 })
66 }
67}