azure_storage_blobs/blob/operations/
get_properties.rs

1use crate::prelude::*;
2use azure_core::{headers::*, prelude::*, RequestId};
3use time::OffsetDateTime;
4
5operation! {
6    GetProperties,
7    client: BlobClient,
8    ?if_modified_since: IfModifiedSinceCondition,
9    ?if_match: IfMatchCondition,
10    ?if_tags: IfTags,
11    ?blob_versioning: BlobVersioning,
12    ?lease_id: LeaseId
13}
14
15impl GetPropertiesBuilder {
16    pub fn into_future(mut self) -> GetProperties {
17        Box::pin(async move {
18            let mut url = self.client.url()?;
19
20            self.blob_versioning.append_to_url_query(&mut url);
21
22            let mut headers = Headers::new();
23            headers.add(self.lease_id);
24            headers.add(self.if_modified_since);
25            headers.add(self.if_match);
26            headers.add(self.if_tags);
27
28            let mut request =
29                BlobClient::finalize_request(url, azure_core::Method::Head, headers, None)?;
30
31            let response = self.client.send(&mut self.context, &mut request).await?;
32            // TODO: Fix this
33            //let blob = Blob::from_headers(&blob_name, &container_name, snapshot_time, &headers)?;
34            let blob = Blob::from_headers(self.client.blob_name(), response.headers())?;
35            GetPropertiesResponse::from_response(response.headers(), blob)
36        })
37    }
38}
39
40#[derive(Debug, Clone)]
41pub struct GetPropertiesResponse {
42    pub blob: Blob,
43    pub request_id: RequestId,
44    pub date: OffsetDateTime,
45}
46
47impl GetPropertiesResponse {
48    pub(crate) fn from_response(
49        headers: &Headers,
50        blob: Blob,
51    ) -> azure_core::Result<GetPropertiesResponse> {
52        let request_id = request_id_from_headers(headers)?;
53        let date = date_from_headers(headers)?;
54
55        Ok(GetPropertiesResponse {
56            blob,
57            request_id,
58            date,
59        })
60    }
61}