azure_storage_blobs/blob/operations/
change_lease.rs

1use crate::prelude::*;
2use azure_core::{headers::*, prelude::*, RequestId};
3use time::OffsetDateTime;
4
5operation! {
6    ChangeLease,
7    client: BlobLeaseClient,
8    proposed_lease_id: ProposedLeaseId,
9    ?if_modified_since: IfModifiedSinceCondition,
10    ?if_match: IfMatchCondition,
11    ?if_tags: IfTags
12}
13
14impl ChangeLeaseBuilder {
15    pub fn into_future(mut self) -> ChangeLease {
16        Box::pin(async move {
17            let mut url = self.client.url()?;
18
19            url.query_pairs_mut().append_pair("comp", "lease");
20
21            let mut headers = Headers::new();
22            headers.insert(LEASE_ACTION, "change");
23            headers.add(self.client.lease_id());
24            headers.add(self.proposed_lease_id);
25            headers.add(self.if_modified_since);
26            headers.add(self.if_match);
27            headers.add(self.if_tags);
28
29            let mut request =
30                BlobLeaseClient::finalize_request(url, azure_core::Method::Put, headers, None)?;
31
32            let response = self.client.send(&mut self.context, &mut request).await?;
33
34            ChangeLeaseResponse::from_headers(response.headers())
35        })
36    }
37}
38
39azure_storage::response_from_headers!(ChangeLeaseResponse ,
40    etag_from_headers => etag: String,
41    last_modified_from_headers => last_modified: OffsetDateTime,
42    lease_id_from_headers => lease_id: LeaseId,
43    request_id_from_headers => request_id: RequestId,
44    date_from_headers => date: OffsetDateTime
45);