From 2b3d5108e88eb3831324075cafe8370b7fb3ec2a Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 12:30:42 -0800 Subject: [PATCH 1/7] Compiling, but test cases are not updated --- .../src/clients/blob_client.rs | 108 +- .../src/clients/blob_container_client.rs | 48 +- .../src/clients/blob_service_client.rs | 16 +- ...d_blob_client.rs => append_blob_client.rs} | 109 +- .../src/generated/clients/blob_client.rs | 1452 +++++- .../clients/blob_container_client.rs | 396 +- .../generated/clients/blob_service_client.rs | 142 +- ...ck_blob_client.rs => block_blob_client.rs} | 202 +- .../src/generated/clients/internal_models.rs | 5 +- .../src/generated/clients/method_options.rs | 1572 ++++--- .../src/generated/clients/mod.rs | 14 +- ...age_blob_client.rs => page_blob_client.rs} | 272 +- .../azure_storage_blob/src/generated/enums.rs | 45 + .../src/generated/header_traits.rs | 4006 +++++++++++++++++ .../azure_storage_blob/src/generated/mod.rs | 1 + .../src/generated/models.rs | 966 +++- .../src/generated/xml_helpers.rs | 214 +- sdk/storage/azure_storage_blob/src/lib.rs | 76 +- .../azure_storage_blob/tsp-location.yaml | 2 +- 19 files changed, 8562 insertions(+), 1084 deletions(-) rename sdk/storage/azure_storage_blob/src/generated/clients/{blob_append_blob_client.rs => append_blob_client.rs} (82%) rename sdk/storage/azure_storage_blob/src/generated/clients/{blob_block_blob_client.rs => block_blob_client.rs} (79%) rename sdk/storage/azure_storage_blob/src/generated/clients/{blob_page_blob_client.rs => page_blob_client.rs} (73%) create mode 100644 sdk/storage/azure_storage_blob/src/generated/header_traits.rs diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs index ccb083af34..f6c6b70e44 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs @@ -2,11 +2,13 @@ // Licensed under the MIT License. use crate::{ - clients::GeneratedBlobClient, + clients::{BlockBlobClient, GeneratedBlobClient}, models::{ - BlobBlobClientDownloadOptions, BlobBlobClientGetPropertiesOptions, - BlobBlockBlobClientCommitBlockListOptions, BlobBlockBlobClientStageBlockOptions, - BlobBlockBlobClientUploadOptions, BlobProperties, BlockLookupList, + BlobClientDownloadOptions, BlobClientDownloadResult, BlobClientGetPropertiesOptions, + BlobClientGetPropertiesResult, BlockBlobClientCommitBlockListOptions, + BlockBlobClientCommitBlockListResult, BlockBlobClientStageBlockOptions, + BlockBlobClientStageBlockResult, BlockBlobClientUploadOptions, BlockBlobClientUploadResult, + BlockLookupList, }, pipeline::StorageHeadersPolicy, BlobClientOptions, @@ -21,6 +23,7 @@ pub struct BlobClient { endpoint: Url, container_name: String, blob_name: String, + credential: Arc, client: GeneratedBlobClient, } @@ -49,11 +52,19 @@ impl BlobClient { .per_try_policies .push(Arc::new(oauth_token_policy) as Arc); - let client = GeneratedBlobClient::new(endpoint, credential, Some(options))?; + let client = GeneratedBlobClient::new( + endpoint, + credential.clone(), + "2025-05-05".to_string(), + container_name.clone(), + blob_name.clone(), + Some(options), + )?; Ok(Self { endpoint: endpoint.parse()?, container_name, blob_name, + credential, client, }) } @@ -70,29 +81,23 @@ impl BlobClient { &self.blob_name } + pub fn credential(&self) -> Arc { + self.credential.clone() + } + pub async fn get_blob_properties( &self, - options: Option>, - ) -> Result { - let response = self - .client - .get_blob_blob_client(self.container_name.clone(), self.blob_name.clone()) - .get_properties(options) - .await?; - - let blob_properties: BlobProperties = response.headers().get()?; - Ok(blob_properties) + options: Option>, + ) -> Result> { + let response = self.client.get_properties(options).await?; + Ok(response) } pub async fn download_blob( &self, - options: Option>, - ) -> Result { - let response = self - .client - .get_blob_blob_client(self.container_name.clone(), self.blob_name.clone()) - .download(options) - .await?; + options: Option>, + ) -> Result> { + let response = self.client.download(options).await?; Ok(response) } @@ -101,9 +106,9 @@ impl BlobClient { &self, data: RequestContent, overwrite: bool, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let mut options = options.unwrap_or_default(); // Check if they want overwrite, by default overwrite=False @@ -111,9 +116,17 @@ impl BlobClient { options.if_none_match = Some(String::from("*")); } - let response = self - .client - .get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone()) + // Currently there is no way to alter what options you pass to the BlockBlobClient we spin up on-demand + let block_blob_client = BlockBlobClient::new( + self.endpoint().as_str(), + self.credential(), + "2025-05-05".to_string(), + self.container_name().to_string(), + self.blob_name().to_string(), + None, + )?; + + let response = block_blob_client .upload(data, content_length, Some(options)) .await?; Ok(response) @@ -122,27 +135,40 @@ impl BlobClient { pub async fn commit_block_list( &self, blocks: RequestContent, - options: Option>, - ) -> Result> { - let response = self - .client - .get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone()) - .commit_block_list(blocks, options) - .await?; + options: Option>, + ) -> Result> { + // Currently there is no way to alter what options you pass to the BlockBlobClient we spin up on-demand + let block_blob_client = BlockBlobClient::new( + self.endpoint().as_str(), + self.credential(), + "2025-05-05".to_string(), + self.container_name().to_string(), + self.blob_name().to_string(), + None, + )?; + let response = block_blob_client.commit_block_list(blocks, options).await?; Ok(response) } pub async fn stage_block( &self, block_id: &str, - content_length: i64, + content_length: u64, body: RequestContent, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let block_id = base64::encode(block_id); - let response = self - .client - .get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone()) + // Currently there is no way to alter what options you pass to the BlockBlobClient we spin up on-demand + let block_blob_client = BlockBlobClient::new( + self.endpoint().as_str(), + self.credential(), + "2025-05-05".to_string(), + self.container_name().to_string(), + self.blob_name().to_string(), + None, + )?; + + let response = block_blob_client .stage_block(&block_id, content_length, body, options) .await?; Ok(response) diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs index bf75cb64d3..7a5314b4bc 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs @@ -1,13 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -use crate::clients::GeneratedBlobClient; +use crate::clients::BlobContainerClient as GenBlobContainerClient; use crate::models::{ - BlobContainerClientCreateOptions, BlobContainerClientDeleteOptions, - BlobContainerClientGetPropertiesOptions, ContainerProperties, + BlobContainerClientCreateOptions, BlobContainerClientCreateResult, + BlobContainerClientDeleteOptions, BlobContainerClientDeleteResult, + BlobContainerClientGetPropertiesOptions, BlobContainerClientGetPropertiesResult, + ContainerProperties, }; use crate::pipeline::StorageHeadersPolicy; -use crate::BlobClientOptions; +use crate::BlobContainerClientOptions; use azure_core::{ credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url, }; @@ -16,7 +18,7 @@ use std::sync::Arc; pub struct BlobContainerClient { endpoint: Url, container_name: String, - client: GeneratedBlobClient, + client: GenBlobContainerClient, } impl BlobContainerClient { @@ -24,7 +26,7 @@ impl BlobContainerClient { endpoint: &str, container_name: String, credential: Arc, - options: Option, + options: Option, ) -> Result { let mut options = options.unwrap_or_default(); @@ -43,7 +45,12 @@ impl BlobContainerClient { .per_try_policies .push(Arc::new(oauth_token_policy) as Arc); - let client = GeneratedBlobClient::new(endpoint, credential, Some(options))?; + let client = GenBlobContainerClient::new( + endpoint, + credential, + container_name.clone(), + Some(options), + )?; Ok(Self { endpoint: endpoint.parse()?, @@ -63,38 +70,25 @@ impl BlobContainerClient { pub async fn create_container( &self, options: Option>, - ) -> Result> { - let response = self - .client - .get_blob_container_client(self.container_name.clone()) - .create(options) - .await?; + ) -> Result> { + let response = self.client.create(options).await?; Ok(response) } pub async fn delete_container( &self, options: Option>, - ) -> Result> { - let response = self - .client - .get_blob_container_client(self.container_name.clone()) - .delete(options) - .await?; + ) -> Result> { + let response = self.client.delete(options).await?; Ok(response) } pub async fn get_container_properties( &self, options: Option>, - ) -> Result { - let response = self - .client - .get_blob_container_client(self.container_name.clone()) - .get_properties(options) - .await?; + ) -> Result> { + let response = self.client.get_properties(options).await?; - let container_properties: ContainerProperties = response.headers().get()?; - Ok(container_properties) + Ok(response) } } diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs index b8e0e26207..46c768c43e 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs @@ -2,10 +2,10 @@ // Licensed under the MIT License. use crate::{ - clients::GeneratedBlobClient, + clients::BlobServiceClient as GenBlobServiceClient, models::{BlobServiceClientGetPropertiesOptions, StorageServiceProperties}, pipeline::StorageHeadersPolicy, - BlobClientOptions, + BlobClientOptions, BlobServiceClientOptions, }; use azure_core::{ credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url, @@ -14,14 +14,14 @@ use std::sync::Arc; pub struct BlobServiceClient { endpoint: Url, - client: GeneratedBlobClient, + client: GenBlobServiceClient, } impl BlobServiceClient { pub fn new( endpoint: &str, credential: Arc, - options: Option, + options: Option, ) -> Result { let mut options = options.unwrap_or_default(); @@ -40,7 +40,7 @@ impl BlobServiceClient { .per_try_policies .push(Arc::new(oauth_token_policy) as Arc); - let client = GeneratedBlobClient::new(endpoint, credential, Some(options))?; + let client = GenBlobServiceClient::new(endpoint, credential, Some(options))?; Ok(Self { endpoint: endpoint.parse()?, @@ -56,11 +56,7 @@ impl BlobServiceClient { &self, options: Option>, ) -> Result> { - let response = self - .client - .get_blob_service_client() - .get_properties(options) - .await?; + let response = self.client.get_properties(options).await?; Ok(response) } } diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_append_blob_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/append_blob_client.rs similarity index 82% rename from sdk/storage/azure_storage_blob/src/generated/clients/blob_append_blob_client.rs rename to sdk/storage/azure_storage_blob/src/generated/clients/append_blob_client.rs index 75737d4605..200cef893b 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_append_blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/append_blob_client.rs @@ -4,12 +4,19 @@ // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. use crate::generated::clients::method_options::*; -use crate::models::BlobType; +use crate::models::{ + AppendBlobClientAppendBlockFromUrlResult, AppendBlobClientAppendBlockResult, + AppendBlobClientCreateResult, AppendBlobClientSealResult, BlobType, +}; +use azure_core::credentials::TokenCredential; use azure_core::{ - base64, date, Bytes, Context, Method, Pipeline, Request, RequestContent, Response, Result, Url, + base64, date, BearerTokenCredentialPolicy, Bytes, ClientOptions, Context, Method, Pipeline, + Policy, Request, RequestContent, Response, Result, Url, }; +use std::sync::Arc; +use typespec_client_core::fmt::SafeDebug; -pub struct BlobAppendBlobClient { +pub struct AppendBlobClient { pub(crate) blob: String, pub(crate) container_name: String, pub(crate) endpoint: Url, @@ -17,7 +24,60 @@ pub struct BlobAppendBlobClient { pub(crate) version: String, } -impl BlobAppendBlobClient { +/// Options used when creating a [`AppendBlobClient`](crate::AppendBlobClient) +#[derive(Clone, Default, SafeDebug)] +pub struct AppendBlobClientOptions { + pub client_options: ClientOptions, +} + +impl AppendBlobClient { + /// Creates a new AppendBlobClient, using Entra ID authentication. + /// + /// # Arguments + /// + /// * `endpoint` - Service host + /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an + /// Entra ID token to use when authenticating. + /// * `version` - Specifies the version of the operation to use for this request. + /// * `container_name` - The name of the container. + /// * `blob` - The name of the blob. + /// * `options` - Optional configuration for the client. + pub fn new( + endpoint: &str, + credential: Arc, + version: String, + container_name: String, + blob: String, + options: Option, + ) -> Result { + let options = options.unwrap_or_default(); + let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } + endpoint.set_query(None); + let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( + credential, + vec!["https://storage.azure.com/.default"], + )); + Ok(Self { + blob, + container_name, + endpoint, + version, + pipeline: Pipeline::new( + option_env!("CARGO_PKG_NAME"), + option_env!("CARGO_PKG_VERSION"), + options.client_options, + Vec::default(), + vec![auth_policy], + ), + }) + } + /// Returns the Url associated with this client. pub fn endpoint(&self) -> &Url { &self.endpoint @@ -33,13 +93,13 @@ impl BlobAppendBlobClient { pub async fn append_block( &self, body: RequestContent, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -54,7 +114,7 @@ impl BlobAppendBlobClient { if let Some(transactional_content_md5) = options.transactional_content_md5 { request.insert_header("content-md5", transactional_content_md5); } - request.insert_header("content-type", "application/xml"); + request.insert_header("content-type", "application/octet-stream"); if let Some(if_match) = options.if_match { request.insert_header("if-match", if_match); } @@ -128,13 +188,13 @@ impl BlobAppendBlobClient { pub async fn append_block_from_url( &self, source_url: &str, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -214,7 +274,10 @@ impl BlobAppendBlobClient { request.insert_header("x-ms-source-if-match", source_if_match); } if let Some(source_if_modified_since) = options.source_if_modified_since { - request.insert_header("x-ms-source-if-modified-since", source_if_modified_since); + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); } if let Some(source_if_none_match) = options.source_if_none_match { request.insert_header("x-ms-source-if-none-match", source_if_none_match); @@ -222,7 +285,7 @@ impl BlobAppendBlobClient { if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { request.insert_header( "x-ms-source-if-unmodified-since", - source_if_unmodified_since, + date::to_rfc7231(&source_if_unmodified_since), ); } if let Some(source_range) = options.source_range { @@ -240,13 +303,13 @@ impl BlobAppendBlobClient { /// * `options` - Optional parameters for the request. pub async fn create( &self, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -323,7 +386,7 @@ impl BlobAppendBlobClient { if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { request.insert_header( "x-ms-immutability-policy-until-date", - immutability_policy_expiry, + date::to_rfc7231(&immutability_policy_expiry), ); } if let Some(lease_id) = options.lease_id { @@ -352,12 +415,12 @@ impl BlobAppendBlobClient { /// * `options` - Optional parameters for the request. pub async fn seal( &self, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/blob_client.rs index 3e319238ba..c5603fd2a3 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/blob_client.rs @@ -3,28 +3,38 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. -use crate::generated::clients::blob_append_blob_client::BlobAppendBlobClient; -use crate::generated::clients::blob_blob_client::BlobBlobClient; -use crate::generated::clients::blob_block_blob_client::BlobBlockBlobClient; -use crate::generated::clients::blob_container_client::BlobContainerClient; -use crate::generated::clients::blob_page_blob_client::BlobPageBlobClient; -use crate::generated::clients::blob_service_client::BlobServiceClient; +use crate::generated::clients::method_options::*; +use crate::models::{ + AccessTier, BlobClientAbortCopyFromUrlResult, BlobClientAcquireLeaseResult, + BlobClientBreakLeaseResult, BlobClientChangeLeaseResult, BlobClientCopyFromUrlResult, + BlobClientCreateSnapshotResult, BlobClientDeleteImmutabilityPolicyResult, + BlobClientDeleteResult, BlobClientDownloadResult, BlobClientGetAccountInfoResult, + BlobClientGetPropertiesResult, BlobClientReleaseLeaseResult, BlobClientRenewLeaseResult, + BlobClientSetExpiryResult, BlobClientSetHttpHeadersResult, + BlobClientSetImmutabilityPolicyResult, BlobClientSetLegalHoldResult, + BlobClientSetMetadataResult, BlobClientSetTagsResult, BlobClientSetTierResult, + BlobClientStartCopyFromUrlResult, BlobClientUndeleteResult, BlobExpiryOptions, BlobTags, +}; use azure_core::credentials::TokenCredential; -use azure_core::{BearerTokenCredentialPolicy, ClientOptions, Pipeline, Policy, Result, Url}; +use azure_core::{ + base64, date, BearerTokenCredentialPolicy, ClientOptions, Context, Method, Pipeline, Policy, + Request, RequestContent, Response, Result, Url, +}; use std::sync::Arc; use typespec_client_core::fmt::SafeDebug; pub struct BlobClient { - endpoint: Url, - pipeline: Pipeline, - version: String, + pub(crate) blob: String, + pub(crate) container_name: String, + pub(crate) endpoint: Url, + pub(crate) pipeline: Pipeline, + pub(crate) version: String, } /// Options used when creating a [`BlobClient`](crate::BlobClient) -#[derive(Clone, SafeDebug)] +#[derive(Clone, Default, SafeDebug)] pub struct BlobClientOptions { pub client_options: ClientOptions, - pub version: String, } impl BlobClient { @@ -35,22 +45,36 @@ impl BlobClient { /// * `endpoint` - Service host /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an /// Entra ID token to use when authenticating. + /// * `version` - Specifies the version of the operation to use for this request. + /// * `container_name` - The name of the container. + /// * `blob` - The name of the blob. /// * `options` - Optional configuration for the client. pub fn new( endpoint: &str, credential: Arc, + version: String, + container_name: String, + blob: String, options: Option, ) -> Result { let options = options.unwrap_or_default(); let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } endpoint.set_query(None); let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( credential, vec!["https://storage.azure.com/.default"], )); Ok(Self { + blob, + container_name, endpoint, - version: options.version, + version, pipeline: Pipeline::new( option_env!("CARGO_PKG_NAME"), option_env!("CARGO_PKG_VERSION"), @@ -66,111 +90,1375 @@ impl BlobClient { &self.endpoint } - /// Returns a new instance of BlobAppendBlobClient. + /// The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with zero length + /// and full metadata. /// /// # Arguments /// - /// * `container_name` - The name of the container. - /// * `blob` - The name of the blob. - pub fn get_blob_append_blob_client( + /// * `copy_id` - The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + /// * `options` - Optional parameters for the request. + pub async fn abort_copy_from_url( &self, - container_name: String, - blob: String, - ) -> BlobAppendBlobClient { - BlobAppendBlobClient { - blob, - container_name, - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + copy_id: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "copy") + .append_key_only("copyid"); + url.query_pairs_mut().append_pair("copyid", copy_id); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } - /// Returns a new instance of BlobBlobClient. + /// The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or can be + /// infinite. /// /// # Arguments /// - /// * `container_name` - The name of the container. - /// * `blob` - The name of the blob. - pub fn get_blob_blob_client(&self, container_name: String, blob: String) -> BlobBlobClient { - BlobBlobClient { - blob, - container_name, - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + /// * `options` - Optional parameters for the request. + pub async fn acquire_lease( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_key_only("acquire") + .append_pair("comp", "lease"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(duration) = options.duration { + request.insert_header("x-ms-lease-duration", duration.to_string()); + } + if let Some(proposed_lease_id) = options.proposed_lease_id { + request.insert_header("x-ms-proposed-lease-id", proposed_lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } - /// Returns a new instance of BlobBlockBlobClient. + /// The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the current lease + /// period has expired. /// /// # Arguments /// - /// * `container_name` - The name of the container. - /// * `blob` - The name of the blob. - pub fn get_blob_block_blob_client( + /// * `options` - Optional parameters for the request. + pub async fn break_lease( &self, - container_name: String, - blob: String, - ) -> BlobBlockBlobClient { - BlobBlockBlobClient { - blob, - container_name, - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_key_only("break") + .append_pair("comp", "lease"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(break_period) = options.break_period { + request.insert_header("x-ms-lease-break-period", break_period.to_string()); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } - /// Returns a new instance of BlobContainerClient. + /// The Change Lease operation is used to change the ID of an existing lease. /// /// # Arguments /// - /// * `container_name` - The name of the container. - pub fn get_blob_container_client(&self, container_name: String) -> BlobContainerClient { - BlobContainerClient { - container_name, - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + /// * `lease_id` - Required. A lease ID for the source path. If specified, the source path must have an active lease and the + /// lease ID must match. + /// * `options` - Optional parameters for the request. + pub async fn change_lease( + &self, + lease_id: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_key_only("change") + .append_pair("comp", "lease"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + request.insert_header("x-ms-lease-id", lease_id.to_owned()); + if let Some(proposed_lease_id) = options.proposed_lease_id { + request.insert_header("x-ms-proposed-lease-id", proposed_lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } - /// Returns a new instance of BlobPageBlobClient. + /// The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response until the + /// copy is complete. /// /// # Arguments /// - /// * `container_name` - The name of the container. - /// * `blob` - The name of the blob. - pub fn get_blob_page_blob_client( + /// * `copy_source` - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that + /// specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. The source blob must + /// either be public or must be authenticated via a shared access signature. + /// * `options` - Optional parameters for the request. + pub async fn copy_from_url( &self, - container_name: String, - blob: String, - ) -> BlobPageBlobClient { - BlobPageBlobClient { - blob, - container_name, - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + copy_source: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "copy") + .append_key_only("sync"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(tier) = options.tier { + request.insert_header("x-ms-access-tier", tier.to_string()); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-copy-source", copy_source.to_owned()); + if let Some(copy_source_authorization) = options.copy_source_authorization { + request.insert_header("x-ms-copy-source-authorization", copy_source_authorization); + } + if let Some(copy_source_tags) = options.copy_source_tags { + request.insert_header("x-ms-copy-source-tags", copy_source_tags); + } + if let Some(encryption_scope) = options.encryption_scope { + request.insert_header("x-ms-encryption-scope", encryption_scope); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(immutability_policy_mode) = options.immutability_policy_mode { + request.insert_header( + "x-ms-immutability-policy-mode", + immutability_policy_mode.to_string(), + ); + } + if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { + request.insert_header( + "x-ms-immutability-policy-until-date", + date::to_rfc7231(&immutability_policy_expiry), + ); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(legal_hold) = options.legal_hold { + request.insert_header("x-ms-legal-hold", legal_hold.to_string()); + } + if let Some(metadata) = options.metadata { + for (k, v) in &metadata { + request.insert_header(format!("x-ms-meta-{}", k), v); + } + } + if let Some(source_content_md5) = options.source_content_md5 { + request.insert_header("x-ms-source-content-md5", source_content_md5); + } + if let Some(source_if_match) = options.source_if_match { + request.insert_header("x-ms-source-if-match", source_if_match); + } + if let Some(source_if_modified_since) = options.source_if_modified_since { + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); + } + if let Some(source_if_none_match) = options.source_if_none_match { + request.insert_header("x-ms-source-if-none-match", source_if_none_match); + } + if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { + request.insert_header( + "x-ms-source-if-unmodified-since", + date::to_rfc7231(&source_if_unmodified_since), + ); + } + if let Some(blob_tags_string) = options.blob_tags_string { + request.insert_header("x-ms-tags", blob_tags_string); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Create Snapshot operation creates a read-only snapshot of a blob + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn create_snapshot( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "snapshot"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(encryption_algorithm) = options.encryption_algorithm { + request.insert_header( + "x-ms-encryption-algorithm", + encryption_algorithm.to_string(), + ); + } + if let Some(encryption_key) = options.encryption_key { + request.insert_header("x-ms-encryption-key", encryption_key); + } + if let Some(encryption_key_sha256) = options.encryption_key_sha256 { + request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256); + } + if let Some(encryption_scope) = options.encryption_scope { + request.insert_header("x-ms-encryption-scope", encryption_scope); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(metadata) = options.metadata { + for (k, v) in &metadata { + request.insert_header(format!("x-ms-meta-{}", k), v); + } + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed from + /// the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, it is marked + /// for deletion and becomes inaccessible immediately. However, the blob service retains the blob or snapshot for the number + /// of days specified by the DeleteRetentionPolicy section of [Storage service properties] (Set-Blob-Service-Properties.md). + /// After the specified number of days has passed, the blob's data is permanently removed from the storage account. Note that + /// you continue to be charged for the soft-deleted blob's storage until it is permanently removed. Use the List Blobs API + /// and specify the \"include=deleted\" query parameter to discover which blobs and snapshots have been soft deleted. You + /// can then use the Undelete Blob API to restore a soft-deleted blob. All other operations on a soft-deleted blob or snapshot + /// causes the service to return an HTTP status code of 404 (ResourceNotFound). + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn delete( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + if let Some(blob_delete_type) = options.blob_delete_type { + url.query_pairs_mut() + .append_pair("deletetype", blob_delete_type.as_ref()); + } + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Delete); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(delete_snapshots) = options.delete_snapshots { + request.insert_header("x-ms-delete-snapshots", delete_snapshots.to_string()); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } - /// Returns a new instance of BlobServiceClient. - pub fn get_blob_service_client(&self) -> BlobServiceClient { - BlobServiceClient { - endpoint: self.endpoint.clone(), - pipeline: self.pipeline.clone(), - version: self.version.clone(), + /// The Delete Immutability Policy operation deletes the immutability policy on the blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn delete_immutability_policy( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "immutabilityPolicies"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); } + let mut request = Request::new(url, Method::Delete); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } -} -impl Default for BlobClientOptions { - fn default() -> Self { - Self { - client_options: ClientOptions::default(), - version: String::from("2025-01-05"), + /// The Download operation reads or downloads a blob from the system, including its metadata and properties. You can also + /// call Download to read a snapshot. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn download( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/octet-stream"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(encryption_algorithm) = options.encryption_algorithm { + request.insert_header( + "x-ms-encryption-algorithm", + encryption_algorithm.to_string(), + ); + } + if let Some(encryption_key) = options.encryption_key { + request.insert_header("x-ms-encryption-key", encryption_key); + } + if let Some(encryption_key_sha256) = options.encryption_key_sha256 { + request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(range) = options.range { + request.insert_header("x-ms-range", range); + } + if let Some(range_get_content_crc64) = options.range_get_content_crc64 { + request.insert_header( + "x-ms-range-get-content-crc64", + range_get_content_crc64.to_string(), + ); + } + if let Some(range_get_content_md5) = options.range_get_content_md5 { + request.insert_header( + "x-ms-range-get-content-md5", + range_get_content_md5.to_string(), + ); + } + if let Some(structured_body_type) = options.structured_body_type { + request.insert_header("x-ms-structured-body", structured_body_type); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// Returns the sku name and account kind + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn get_account_info( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_key_only("blob") + .append_pair("comp", "properties") + .append_pair("restype", "account"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties for the + /// blob. It does not return the content of the blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn get_properties( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Head); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/octet-stream"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(encryption_algorithm) = options.encryption_algorithm { + request.insert_header( + "x-ms-encryption-algorithm", + encryption_algorithm.to_string(), + ); + } + if let Some(encryption_key) = options.encryption_key { + request.insert_header("x-ms-encryption-key", encryption_key); + } + if let Some(encryption_key_sha256) = options.encryption_key_sha256 { + request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Get Blob Tags operation enables users to get tags on a blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn get_tags( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "tags"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately acquire a + /// lease against the blob. + /// + /// # Arguments + /// + /// * `lease_id` - Required. A lease ID for the source path. If specified, the source path must have an active lease and the + /// lease ID must match. + /// * `options` - Optional parameters for the request. + pub async fn release_lease( + &self, + lease_id: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "lease") + .append_key_only("release"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + request.insert_header("x-ms-lease-id", lease_id.to_owned()); + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Renew Lease operation renews an existing lease. + /// + /// # Arguments + /// + /// * `lease_id` - Required. A lease ID for the source path. If specified, the source path must have an active lease and the + /// lease ID must match. + /// * `options` - Optional parameters for the request. + pub async fn renew_lease( + &self, + lease_id: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "lease") + .append_key_only("renew"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + request.insert_header("x-ms-lease-id", lease_id.to_owned()); + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// Set the expiration time of a blob + /// + /// # Arguments + /// + /// * `expiry_options` - Required. Indicates mode of the expiry time + /// * `options` - Optional parameters for the request. + pub async fn set_expiry( + &self, + expiry_options: BlobExpiryOptions, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "expiry"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-expiry-option", expiry_options.to_string()); + if let Some(expires_on) = options.expires_on { + request.insert_header("x-ms-expiry-time", date::to_rfc7231(&expires_on)); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Set HTTP Headers operation sets system properties on the blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn set_http_headers( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_key_only("SetHTTPHeaders") + .append_pair("comp", "properties"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(blob_cache_control) = options.blob_cache_control { + request.insert_header("x-ms-blob-cache-control", blob_cache_control); + } + if let Some(blob_content_disposition) = options.blob_content_disposition { + request.insert_header("x-ms-blob-content-disposition", blob_content_disposition); + } + if let Some(blob_content_encoding) = options.blob_content_encoding { + request.insert_header("x-ms-blob-content-encoding", blob_content_encoding); + } + if let Some(blob_content_language) = options.blob_content_language { + request.insert_header("x-ms-blob-content-language", blob_content_language); + } + if let Some(blob_content_md5) = options.blob_content_md5 { + request.insert_header("x-ms-blob-content-md5", base64::encode(blob_content_md5)); + } + if let Some(blob_content_type) = options.blob_content_type { + request.insert_header("x-ms-blob-content-type", blob_content_type); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// Set the immutability policy of a blob + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn set_immutability_policy( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "immutabilityPolicies"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(immutability_policy_mode) = options.immutability_policy_mode { + request.insert_header( + "x-ms-immutability-policy-mode", + immutability_policy_mode.to_string(), + ); + } + if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { + request.insert_header( + "x-ms-immutability-policy-until-date", + date::to_rfc7231(&immutability_policy_expiry), + ); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Set Legal Hold operation sets a legal hold on the blob. + /// + /// # Arguments + /// + /// * `legal_hold` - Required. Specifies the legal hold status to set on the blob. + /// * `options` - Optional parameters for the request. + pub async fn set_legal_hold( + &self, + legal_hold: bool, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "legalhold"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-legal-hold", legal_hold.to_string()); + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn set_metadata( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "metadata"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(encryption_algorithm) = options.encryption_algorithm { + request.insert_header( + "x-ms-encryption-algorithm", + encryption_algorithm.to_string(), + ); + } + if let Some(encryption_key) = options.encryption_key { + request.insert_header("x-ms-encryption-key", encryption_key); + } + if let Some(encryption_key_sha256) = options.encryption_key_sha256 { + request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256); + } + if let Some(encryption_scope) = options.encryption_scope { + request.insert_header("x-ms-encryption-scope", encryption_scope); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(metadata) = options.metadata { + for (k, v) in &metadata { + request.insert_header(format!("x-ms-meta-{}", k), v); + } + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Set Tags operation enables users to set tags on a blob. + /// + /// # Arguments + /// + /// * `tags` - The blob tags. + /// * `options` - Optional parameters for the request. + pub async fn set_tags( + &self, + tags: RequestContent, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "tags"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + if let Some(transactional_content_md5) = options.transactional_content_md5 { + request.insert_header("content-md5", transactional_content_md5); + } + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(transactional_content_crc64) = options.transactional_content_crc64 { + request.insert_header("x-ms-content-crc64", transactional_content_crc64); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + request.set_body(tags); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but not on + /// an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's + /// ETag. + /// + /// # Arguments + /// + /// * `tier` - Indicates the tier to be set on the blob. + /// * `options` - Optional parameters for the request. + pub async fn set_tier( + &self, + tier: AccessTier, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "tier"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + if let Some(version_id) = options.version_id { + url.query_pairs_mut().append_pair("versionid", &version_id); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + request.insert_header("x-ms-access-tier", tier.to_string()); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(rehydrate_priority) = options.rehydrate_priority { + request.insert_header("x-ms-rehydrate-priority", rehydrate_priority.to_string()); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Start Copy From URL operation copies a blob or an internet resource to a new blob. + /// + /// # Arguments + /// + /// * `copy_source` - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that + /// specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. The source blob must + /// either be public or must be authenticated via a shared access signature. + /// * `options` - Optional parameters for the request. + pub async fn start_copy_from_url( + &self, + copy_source: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "copy"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(tier) = options.tier { + request.insert_header("x-ms-access-tier", tier.to_string()); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-copy-source", copy_source.to_owned()); + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(immutability_policy_mode) = options.immutability_policy_mode { + request.insert_header( + "x-ms-immutability-policy-mode", + immutability_policy_mode.to_string(), + ); + } + if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { + request.insert_header( + "x-ms-immutability-policy-until-date", + date::to_rfc7231(&immutability_policy_expiry), + ); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(legal_hold) = options.legal_hold { + request.insert_header("x-ms-legal-hold", legal_hold.to_string()); + } + if let Some(metadata) = options.metadata { + for (k, v) in &metadata { + request.insert_header(format!("x-ms-meta-{}", k), v); + } + } + if let Some(rehydrate_priority) = options.rehydrate_priority { + request.insert_header("x-ms-rehydrate-priority", rehydrate_priority.to_string()); + } + if let Some(seal_blob) = options.seal_blob { + request.insert_header("x-ms-seal-blob", seal_blob.to_string()); + } + if let Some(source_if_match) = options.source_if_match { + request.insert_header("x-ms-source-if-match", source_if_match); + } + if let Some(source_if_modified_since) = options.source_if_modified_since { + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); + } + if let Some(source_if_none_match) = options.source_if_none_match { + request.insert_header("x-ms-source-if-none-match", source_if_none_match); + } + if let Some(source_if_tags) = options.source_if_tags { + request.insert_header("x-ms-source-if-tags", source_if_tags); + } + if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { + request.insert_header( + "x-ms-source-if-unmodified-since", + date::to_rfc7231(&source_if_unmodified_since), + ); + } + if let Some(blob_tags_string) = options.blob_tags_string { + request.insert_header("x-ms-tags", blob_tags_string); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// Undelete a blob that was previously soft deleted + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn undelete( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "undelete"); + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Put); + request.insert_header("accept", "application/json"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await } } diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_container_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/blob_container_client.rs index 3bc36fff42..bd232ebb43 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_container_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/blob_container_client.rs @@ -3,11 +3,28 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. +use crate::generated::clients::append_blob_client::AppendBlobClient; +use crate::generated::clients::blob_client::BlobClient; +use crate::generated::clients::block_blob_client::BlockBlobClient; use crate::generated::clients::method_options::*; -use crate::models::{FilterBlobSegment, SignedIdentifier}; +use crate::generated::clients::page_blob_client::PageBlobClient; +use crate::models::{ + BlobContainerClientAcquireLeaseResult, BlobContainerClientBreakLeaseResult, + BlobContainerClientChangeLeaseResult, BlobContainerClientCreateResult, + BlobContainerClientDeleteResult, BlobContainerClientGetAccountInfoResult, + BlobContainerClientGetPropertiesResult, BlobContainerClientReleaseLeaseResult, + BlobContainerClientRenameResult, BlobContainerClientRenewLeaseResult, + BlobContainerClientRestoreResult, BlobContainerClientSetAccessPolicyResult, + BlobContainerClientSetMetadataResult, BlobContainerClientSubmitBatchResult, FilterBlobSegment, + ListBlobsFlatSegmentResponse, ListBlobsHierarchySegmentResponse, SignedIdentifier, +}; +use azure_core::credentials::TokenCredential; use azure_core::{ - Bytes, Context, Method, Pipeline, Request, RequestContent, Response, Result, Url, + date, BearerTokenCredentialPolicy, Bytes, ClientOptions, Context, Method, Pipeline, Policy, + Request, RequestContent, Response, Result, Url, }; +use std::sync::Arc; +use typespec_client_core::fmt::SafeDebug; pub struct BlobContainerClient { pub(crate) container_name: String, @@ -16,7 +33,56 @@ pub struct BlobContainerClient { pub(crate) version: String, } +/// Options used when creating a [`BlobContainerClient`](crate::BlobContainerClient) +#[derive(Clone, SafeDebug)] +pub struct BlobContainerClientOptions { + pub client_options: ClientOptions, + pub version: String, +} + impl BlobContainerClient { + /// Creates a new BlobContainerClient, using Entra ID authentication. + /// + /// # Arguments + /// + /// * `endpoint` - Service host + /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an + /// Entra ID token to use when authenticating. + /// * `container_name` - The name of the container. + /// * `options` - Optional configuration for the client. + pub fn new( + endpoint: &str, + credential: Arc, + container_name: String, + options: Option, + ) -> Result { + let options = options.unwrap_or_default(); + let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } + endpoint.set_query(None); + let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( + credential, + vec!["https://storage.azure.com/.default"], + )); + Ok(Self { + container_name, + endpoint, + version: options.version, + pipeline: Pipeline::new( + option_env!("CARGO_PKG_NAME"), + option_env!("CARGO_PKG_VERSION"), + options.client_options, + Vec::default(), + vec![auth_policy], + ), + }) + } + /// Returns the Url associated with this client. pub fn endpoint(&self) -> &Url { &self.endpoint @@ -31,11 +97,13 @@ impl BlobContainerClient { pub async fn acquire_lease( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_key_only("acquire") .append_pair("comp", "lease") @@ -48,10 +116,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -75,11 +146,13 @@ impl BlobContainerClient { pub async fn break_lease( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_key_only("break") .append_pair("comp", "lease") @@ -92,10 +165,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -120,11 +196,13 @@ impl BlobContainerClient { lease_id: &str, proposed_lease_id: &str, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_key_only("change") .append_pair("comp", "lease") @@ -137,10 +215,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -160,11 +241,13 @@ impl BlobContainerClient { pub async fn create( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut().append_pair("restype", "container"); if let Some(timeout) = options.timeout { url.query_pairs_mut() @@ -206,11 +289,13 @@ impl BlobContainerClient { pub async fn delete( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut().append_pair("restype", "container"); if let Some(timeout) = options.timeout { url.query_pairs_mut() @@ -220,10 +305,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -248,7 +336,9 @@ impl BlobContainerClient { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "blobs") .append_pair("restype", "container"); @@ -298,7 +388,9 @@ impl BlobContainerClient { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "acl") .append_pair("restype", "container"); @@ -327,11 +419,13 @@ impl BlobContainerClient { pub async fn get_account_info( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "properties") .append_pair("restype", "account"); @@ -349,6 +443,66 @@ impl BlobContainerClient { self.pipeline.send(&ctx, &mut request).await } + /// Returns a new instance of AppendBlobClient. + /// + /// # Arguments + /// + /// * `blob` - The name of the blob. + pub fn get_append_blob_client(&self, blob: String) -> AppendBlobClient { + AppendBlobClient { + blob, + container_name: self.container_name.clone(), + endpoint: self.endpoint.clone(), + pipeline: self.pipeline.clone(), + version: self.version.clone(), + } + } + + /// Returns a new instance of BlobClient. + /// + /// # Arguments + /// + /// * `blob` - The name of the blob. + pub fn get_blob_client(&self, blob: String) -> BlobClient { + BlobClient { + blob, + container_name: self.container_name.clone(), + endpoint: self.endpoint.clone(), + pipeline: self.pipeline.clone(), + version: self.version.clone(), + } + } + + /// Returns a new instance of BlockBlobClient. + /// + /// # Arguments + /// + /// * `blob` - The name of the blob. + pub fn get_block_blob_client(&self, blob: String) -> BlockBlobClient { + BlockBlobClient { + blob, + container_name: self.container_name.clone(), + endpoint: self.endpoint.clone(), + pipeline: self.pipeline.clone(), + version: self.version.clone(), + } + } + + /// Returns a new instance of PageBlobClient. + /// + /// # Arguments + /// + /// * `blob` - The name of the blob. + pub fn get_page_blob_client(&self, blob: String) -> PageBlobClient { + PageBlobClient { + blob, + container_name: self.container_name.clone(), + endpoint: self.endpoint.clone(), + pipeline: self.pipeline.clone(), + version: self.version.clone(), + } + } + /// returns all user-defined metadata and system properties for the specified container. The data returned does not include /// the container's list of blobs /// @@ -358,11 +512,13 @@ impl BlobContainerClient { pub async fn get_properties( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut().append_pair("restype", "container"); if let Some(timeout) = options.timeout { url.query_pairs_mut() @@ -381,6 +537,118 @@ impl BlobContainerClient { self.pipeline.send(&ctx, &mut request).await } + /// The List Blobs operation returns a list of the blobs under the specified container. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn list_blob_flat_segment( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "list") + .append_key_only("flat") + .append_pair("restype", "container"); + if let Some(include) = options.include { + url.query_pairs_mut().append_pair( + "include", + &include + .iter() + .map(|i| i.to_string()) + .collect::>() + .join(","), + ); + } + if let Some(marker) = options.marker { + url.query_pairs_mut().append_pair("marker", &marker); + } + if let Some(maxresults) = options.maxresults { + url.query_pairs_mut() + .append_pair("maxresults", &maxresults.to_string()); + } + if let Some(prefix) = options.prefix { + url.query_pairs_mut().append_pair("prefix", &prefix); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to traverse + /// a virtual hierarchy of blobs as though it were a file system. + /// + /// # Arguments + /// + /// * `delimiter` - When the request includes this parameter, the operation returns a BlobPrefix element in the response body + /// that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter + /// character. The delimiter may be a single character or a string. + /// * `options` - Optional parameters for the request. + pub async fn list_blob_hierarchy_segment( + &self, + delimiter: &str, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "list") + .append_key_only("hierarchy") + .append_pair("restype", "container"); + url.query_pairs_mut().append_pair("delimiter", delimiter); + if let Some(include) = options.include { + url.query_pairs_mut().append_pair( + "include", + &include + .iter() + .map(|i| i.to_string()) + .collect::>() + .join(","), + ); + } + if let Some(marker) = options.marker { + url.query_pairs_mut().append_pair("marker", &marker); + } + if let Some(maxresults) = options.maxresults { + url.query_pairs_mut() + .append_pair("maxresults", &maxresults.to_string()); + } + if let Some(prefix) = options.prefix { + url.query_pairs_mut().append_pair("prefix", &prefix); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + /// The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately acquire a /// lease against the container. /// @@ -393,11 +661,13 @@ impl BlobContainerClient { &self, lease_id: &str, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "lease") .append_key_only("release") @@ -410,10 +680,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -433,11 +706,13 @@ impl BlobContainerClient { &self, source_container_name: &str, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "rename") .append_pair("restype", "container"); @@ -473,11 +748,13 @@ impl BlobContainerClient { &self, lease_id: &str, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "lease") .append_key_only("renew") @@ -490,10 +767,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -511,11 +791,13 @@ impl BlobContainerClient { pub async fn restore( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "undelete") .append_pair("restype", "container"); @@ -550,11 +832,13 @@ impl BlobContainerClient { &self, container_acl: RequestContent>, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "acl") .append_pair("restype", "container"); @@ -566,10 +850,13 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(if_unmodified_since) = options.if_unmodified_since { - request.insert_header("if-unmodified-since", if_unmodified_since); + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); } if let Some(access) = options.access { request.insert_header("x-ms-blob-public-access", access.to_string()); @@ -593,11 +880,13 @@ impl BlobContainerClient { pub async fn set_metadata( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "metadata") .append_pair("restype", "container"); @@ -609,7 +898,7 @@ impl BlobContainerClient { request.insert_header("accept", "application/json"); request.insert_header("content-type", "application/xml"); if let Some(if_modified_since) = options.if_modified_since { - request.insert_header("if-modified-since", if_modified_since); + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); } if let Some(client_request_id) = options.client_request_id { request.insert_header("x-ms-client-request-id", client_request_id); @@ -636,13 +925,15 @@ impl BlobContainerClient { pub async fn submit_batch( &self, body: RequestContent, - content_length: i64, + content_length: u64, options: Option>, - ) -> Result { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - url = url.join(&self.container_name)?; + let mut path = String::from("{containerName}/"); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; url.query_pairs_mut() .append_pair("comp", "batch") .append_pair("restype", "container"); @@ -662,3 +953,12 @@ impl BlobContainerClient { self.pipeline.send(&ctx, &mut request).await } } + +impl Default for BlobContainerClientOptions { + fn default() -> Self { + Self { + client_options: ClientOptions::default(), + version: String::from("2025-01-05"), + } + } +} diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_service_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/blob_service_client.rs index d9ed90f16c..355169ee74 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_service_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/blob_service_client.rs @@ -4,21 +4,74 @@ // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. use super::internal_models::{GetUserDelegationKeyRequest, SetPropertiesRequest}; +use crate::generated::clients::blob_container_client::BlobContainerClient; use crate::generated::clients::method_options::*; use crate::models::{ - FilterBlobSegment, StorageServiceProperties, StorageServiceStats, UserDelegationKey, + BlobServiceClientGetAccountInfoResult, BlobServiceClientSetPropertiesResult, + BlobServiceClientSubmitBatchResult, FilterBlobSegment, ListContainersSegmentResponse, + StorageServiceProperties, StorageServiceStats, UserDelegationKey, }; +use azure_core::credentials::TokenCredential; use azure_core::{ - Bytes, Context, Method, Pipeline, Request, RequestContent, Response, Result, Url, + BearerTokenCredentialPolicy, Bytes, ClientOptions, Context, Method, Pipeline, Policy, Request, + RequestContent, Response, Result, Url, }; +use std::sync::Arc; +use typespec_client_core::fmt::SafeDebug; pub struct BlobServiceClient { - pub(crate) endpoint: Url, - pub(crate) pipeline: Pipeline, - pub(crate) version: String, + endpoint: Url, + pipeline: Pipeline, + version: String, +} + +/// Options used when creating a [`BlobServiceClient`](crate::BlobServiceClient) +#[derive(Clone, SafeDebug)] +pub struct BlobServiceClientOptions { + pub client_options: ClientOptions, + pub version: String, } impl BlobServiceClient { + /// Creates a new BlobServiceClient, using Entra ID authentication. + /// + /// # Arguments + /// + /// * `endpoint` - Service host + /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an + /// Entra ID token to use when authenticating. + /// * `options` - Optional configuration for the client. + pub fn new( + endpoint: &str, + credential: Arc, + options: Option, + ) -> Result { + let options = options.unwrap_or_default(); + let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } + endpoint.set_query(None); + let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( + credential, + vec!["https://storage.azure.com/.default"], + )); + Ok(Self { + endpoint, + version: options.version, + pipeline: Pipeline::new( + option_env!("CARGO_PKG_NAME"), + option_env!("CARGO_PKG_VERSION"), + options.client_options, + Vec::default(), + vec![auth_policy], + ), + }) + } + /// Returns the Url associated with this client. pub fn endpoint(&self) -> &Url { &self.endpoint @@ -80,7 +133,7 @@ impl BlobServiceClient { pub async fn get_account_info( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); @@ -102,6 +155,20 @@ impl BlobServiceClient { self.pipeline.send(&ctx, &mut request).await } + /// Returns a new instance of BlobContainerClient. + /// + /// # Arguments + /// + /// * `container_name` - The name of the container. + pub fn get_blob_container_client(&self, container_name: String) -> BlobContainerClient { + BlobContainerClient { + container_name, + endpoint: self.endpoint.clone(), + pipeline: self.pipeline.clone(), + version: self.version.clone(), + } + } + /// Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS (Cross-Origin /// Resource Sharing) rules. /// @@ -204,6 +271,54 @@ impl BlobServiceClient { self.pipeline.send(&ctx, &mut request).await } + /// The List Containers Segment operation returns a list of the containers under the specified account + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn list_containers_segment( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + url = url.join("")?; + url.query_pairs_mut().append_pair("comp", "list"); + if let Some(include) = options.include { + url.query_pairs_mut().append_pair( + "include", + &include + .iter() + .map(|i| i.to_string()) + .collect::>() + .join(","), + ); + } + if let Some(marker) = options.marker { + url.query_pairs_mut().append_pair("marker", &marker); + } + if let Some(maxresults) = options.maxresults { + url.query_pairs_mut() + .append_pair("maxresults", &maxresults.to_string()); + } + if let Some(prefix) = options.prefix { + url.query_pairs_mut().append_pair("prefix", &prefix); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + /// Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and CORS (Cross-Origin /// Resource Sharing) rules /// @@ -213,7 +328,7 @@ impl BlobServiceClient { pub async fn set_properties( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); @@ -255,10 +370,10 @@ impl BlobServiceClient { /// * `options` - Optional parameters for the request. pub async fn submit_batch( &self, - content_length: i64, + content_length: u64, body: RequestContent, options: Option>, - ) -> Result { + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); @@ -280,3 +395,12 @@ impl BlobServiceClient { self.pipeline.send(&ctx, &mut request).await } } + +impl Default for BlobServiceClientOptions { + fn default() -> Self { + Self { + client_options: ClientOptions::default(), + version: String::from("2025-01-05"), + } + } +} diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_block_blob_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs similarity index 79% rename from sdk/storage/azure_storage_blob/src/generated/clients/blob_block_blob_client.rs rename to sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs index 3a08f10cf6..af9eb49d46 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_block_blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs @@ -4,12 +4,21 @@ // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. use crate::generated::clients::method_options::*; -use crate::models::{BlobType, BlockListType, BlockLookupList}; +use crate::models::{ + BlobType, BlockBlobClientCommitBlockListResult, BlockBlobClientPutBlobFromUrlResult, + BlockBlobClientQueryResult, BlockBlobClientStageBlockFromUrlResult, + BlockBlobClientStageBlockResult, BlockBlobClientUploadResult, BlockList, BlockListType, + BlockLookupList, QueryRequest, +}; +use azure_core::credentials::TokenCredential; use azure_core::{ - base64, date, Bytes, Context, Method, Pipeline, Request, RequestContent, Response, Result, Url, + base64, date, BearerTokenCredentialPolicy, Bytes, ClientOptions, Context, Method, Pipeline, + Policy, Request, RequestContent, Response, Result, Url, }; +use std::sync::Arc; +use typespec_client_core::fmt::SafeDebug; -pub struct BlobBlockBlobClient { +pub struct BlockBlobClient { pub(crate) blob: String, pub(crate) container_name: String, pub(crate) endpoint: Url, @@ -17,7 +26,60 @@ pub struct BlobBlockBlobClient { pub(crate) version: String, } -impl BlobBlockBlobClient { +/// Options used when creating a [`BlockBlobClient`](crate::BlockBlobClient) +#[derive(Clone, Default, SafeDebug)] +pub struct BlockBlobClientOptions { + pub client_options: ClientOptions, +} + +impl BlockBlobClient { + /// Creates a new BlockBlobClient, using Entra ID authentication. + /// + /// # Arguments + /// + /// * `endpoint` - Service host + /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an + /// Entra ID token to use when authenticating. + /// * `version` - Specifies the version of the operation to use for this request. + /// * `container_name` - The name of the container. + /// * `blob` - The name of the blob. + /// * `options` - Optional configuration for the client. + pub fn new( + endpoint: &str, + credential: Arc, + version: String, + container_name: String, + blob: String, + options: Option, + ) -> Result { + let options = options.unwrap_or_default(); + let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } + endpoint.set_query(None); + let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( + credential, + vec!["https://storage.azure.com/.default"], + )); + Ok(Self { + blob, + container_name, + endpoint, + version, + pipeline: Pipeline::new( + option_env!("CARGO_PKG_NAME"), + option_env!("CARGO_PKG_VERSION"), + options.client_options, + Vec::default(), + vec![auth_policy], + ), + }) + } + /// Returns the Url associated with this client. pub fn endpoint(&self) -> &Url { &self.endpoint @@ -37,12 +99,12 @@ impl BlobBlockBlobClient { pub async fn commit_block_list( &self, blocks: RequestContent, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -126,7 +188,7 @@ impl BlobBlockBlobClient { if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { request.insert_header( "x-ms-immutability-policy-until-date", - immutability_policy_expiry, + date::to_rfc7231(&immutability_policy_expiry), ); } if let Some(lease_id) = options.lease_id { @@ -158,12 +220,12 @@ impl BlobBlockBlobClient { pub async fn get_block_list( &self, list_type: BlockListType, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -207,14 +269,14 @@ impl BlobBlockBlobClient { /// * `options` - Optional parameters for the request. pub async fn put_blob_from_url( &self, - content_length: i64, + content_length: u64, copy_source: &str, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -318,7 +380,10 @@ impl BlobBlockBlobClient { request.insert_header("x-ms-source-if-match", source_if_match); } if let Some(source_if_modified_since) = options.source_if_modified_since { - request.insert_header("x-ms-source-if-modified-since", source_if_modified_since); + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); } if let Some(source_if_none_match) = options.source_if_none_match { request.insert_header("x-ms-source-if-none-match", source_if_none_match); @@ -329,7 +394,7 @@ impl BlobBlockBlobClient { if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { request.insert_header( "x-ms-source-if-unmodified-since", - source_if_unmodified_since, + date::to_rfc7231(&source_if_unmodified_since), ); } if let Some(blob_tags_string) = options.blob_tags_string { @@ -339,6 +404,76 @@ impl BlobBlockBlobClient { self.pipeline.send(&ctx, &mut request).await } + /// The Query operation enables users to select/project on blob data by providing simple query expressions. + /// + /// # Arguments + /// + /// * `query_request` - The query request + /// * `options` - Optional parameters for the request. + pub async fn query( + &self, + query_request: RequestContent, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "query"); + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Post); + request.insert_header("accept", "application/octet-stream"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(encryption_algorithm) = options.encryption_algorithm { + request.insert_header( + "x-ms-encryption-algorithm", + encryption_algorithm.to_string(), + ); + } + if let Some(encryption_key) = options.encryption_key { + request.insert_header("x-ms-encryption-key", encryption_key); + } + if let Some(encryption_key_sha256) = options.encryption_key_sha256 { + request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + request.insert_header("x-ms-version", &self.version); + request.set_body(query_request); + self.pipeline.send(&ctx, &mut request).await + } + /// The Stage Block operation creates a new block to be committed as part of a blob /// /// # Arguments @@ -352,14 +487,14 @@ impl BlobBlockBlobClient { pub async fn stage_block( &self, block_id: &str, - content_length: i64, + content_length: u64, body: RequestContent, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -428,14 +563,14 @@ impl BlobBlockBlobClient { pub async fn stage_block_from_url( &self, block_id: &str, - content_length: i64, + content_length: u64, source_url: &str, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -489,7 +624,10 @@ impl BlobBlockBlobClient { request.insert_header("x-ms-source-if-match", source_if_match); } if let Some(source_if_modified_since) = options.source_if_modified_since { - request.insert_header("x-ms-source-if-modified-since", source_if_modified_since); + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); } if let Some(source_if_none_match) = options.source_if_none_match { request.insert_header("x-ms-source-if-none-match", source_if_none_match); @@ -497,7 +635,7 @@ impl BlobBlockBlobClient { if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { request.insert_header( "x-ms-source-if-unmodified-since", - source_if_unmodified_since, + date::to_rfc7231(&source_if_unmodified_since), ); } if let Some(source_range) = options.source_range { @@ -520,13 +658,13 @@ impl BlobBlockBlobClient { pub async fn upload( &self, body: RequestContent, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -612,7 +750,7 @@ impl BlobBlockBlobClient { if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { request.insert_header( "x-ms-immutability-policy-until-date", - immutability_policy_expiry, + date::to_rfc7231(&immutability_policy_expiry), ); } if let Some(lease_id) = options.lease_id { diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/internal_models.rs b/sdk/storage/azure_storage_blob/src/generated/clients/internal_models.rs index 670df9b70b..ff1c7c62b6 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/internal_models.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/internal_models.rs @@ -30,10 +30,9 @@ pub struct SetPropertiesRequest { default, deserialize_with = "CorsCorsRule::unwrap", rename = "Cors", - serialize_with = "CorsCorsRule::wrap", - skip_serializing_if = "Option::is_none" + serialize_with = "CorsCorsRule::wrap" )] - pub cors: Option>, + pub cors: Vec, /// The default service version. #[serde( diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/method_options.rs b/sdk/storage/azure_storage_blob/src/generated/clients/method_options.rs index bbe36dc4d9..c362243478 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/method_options.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/method_options.rs @@ -5,17 +5,18 @@ use crate::models::{ AccessTier, BlobDeleteType, BlobImmutabilityPolicyMode, CorsRule, DeleteSnapshotsOptionType, - EncryptionAlgorithmType, FilterBlobsIncludeItem, Logging, Metrics, PremiumPageBlobAccessTier, - PublicAccessType, RehydratePriority, RetentionPolicy, StaticWebsite, + EncryptionAlgorithmType, FilterBlobsIncludeItem, ListBlobsIncludeItem, + ListContainersIncludeType, Logging, Metrics, PremiumPageBlobAccessTier, PublicAccessType, + RehydratePriority, RetentionPolicy, StaticWebsite, }; use azure_core::ClientMethodOptions; use std::collections::HashMap; use time::OffsetDateTime; use typespec_client_core::fmt::SafeDebug; -/// Options to be passed to [`BlobAppendBlobClient::append_block()`](crate::clients::BlobAppendBlobClient::append_block()) +/// Options to be passed to [`AppendBlobClient::append_block()`](crate::AppendBlobClient::append_block()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobAppendBlobClientAppendBlockOptions<'a> { +pub struct AppendBlobClientAppendBlockOptions<'a> { /// Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. /// Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with /// the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). @@ -72,7 +73,7 @@ pub struct BlobAppendBlobClientAppendBlockOptions<'a> { /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message /// body. Will always be smaller than Content-Length. - pub structured_content_length: Option, + pub structured_content_length: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, @@ -85,9 +86,9 @@ pub struct BlobAppendBlobClientAppendBlockOptions<'a> { pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobAppendBlobClient::append_block_from_url()`](crate::clients::BlobAppendBlobClient::append_block_from_url()) +/// Options to be passed to [`AppendBlobClient::append_block_from_url()`](crate::AppendBlobClient::append_block_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobAppendBlobClientAppendBlockFromUrlOptions<'a> { +pub struct AppendBlobClientAppendBlockFromUrlOptions<'a> { /// Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. /// Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with /// the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). @@ -152,13 +153,13 @@ pub struct BlobAppendBlobClientAppendBlockFromUrlOptions<'a> { pub source_if_match: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, + pub source_if_modified_since: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. pub source_if_none_match: Option, /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, + pub source_if_unmodified_since: Option, /// Bytes of source data in the specified range. pub source_range: Option, @@ -171,9 +172,9 @@ pub struct BlobAppendBlobClientAppendBlockFromUrlOptions<'a> { pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobAppendBlobClient::create()`](crate::clients::BlobAppendBlobClient::create()) +/// Options to be passed to [`AppendBlobClient::create()`](crate::AppendBlobClient::create()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobAppendBlobClientCreateOptions<'a> { +pub struct AppendBlobClientCreateOptions<'a> { /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read /// request. pub blob_cache_control: Option, @@ -236,7 +237,7 @@ pub struct BlobAppendBlobClientCreateOptions<'a> { pub if_unmodified_since: Option, /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + pub immutability_policy_expiry: Option, /// Specifies the immutability policy mode to set on the blob. pub immutability_policy_mode: Option, @@ -257,9 +258,9 @@ pub struct BlobAppendBlobClientCreateOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobAppendBlobClient::seal()`](crate::clients::BlobAppendBlobClient::seal()) +/// Options to be passed to [`AppendBlobClient::seal()`](crate::AppendBlobClient::seal()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobAppendBlobClientSealOptions<'a> { +pub struct AppendBlobClientSealOptions<'a> { /// Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. /// Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with /// the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). @@ -290,9 +291,9 @@ pub struct BlobAppendBlobClientSealOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::abort_copy_from_url()`](crate::clients::BlobBlobClient::abort_copy_from_url()) +/// Options to be passed to [`BlobClient::abort_copy_from_url()`](crate::BlobClient::abort_copy_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientAbortCopyFromUrlOptions<'a> { +pub struct BlobClientAbortCopyFromUrlOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -306,9 +307,9 @@ pub struct BlobBlobClientAbortCopyFromUrlOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::acquire_lease()`](crate::clients::BlobBlobClient::acquire_lease()) +/// Options to be passed to [`BlobClient::acquire_lease()`](crate::BlobClient::acquire_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientAcquireLeaseOptions<'a> { +pub struct BlobClientAcquireLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -341,9 +342,9 @@ pub struct BlobBlobClientAcquireLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::break_lease()`](crate::clients::BlobBlobClient::break_lease()) +/// Options to be passed to [`BlobClient::break_lease()`](crate::BlobClient::break_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientBreakLeaseOptions<'a> { +pub struct BlobClientBreakLeaseOptions<'a> { /// For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. /// This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on /// the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for @@ -376,9 +377,9 @@ pub struct BlobBlobClientBreakLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::change_lease()`](crate::clients::BlobBlobClient::change_lease()) +/// Options to be passed to [`BlobClient::change_lease()`](crate::BlobClient::change_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientChangeLeaseOptions<'a> { +pub struct BlobClientChangeLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -407,9 +408,9 @@ pub struct BlobBlobClientChangeLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::copy_from_url()`](crate::clients::BlobBlobClient::copy_from_url()) +/// Options to be passed to [`BlobClient::copy_from_url()`](crate::BlobClient::copy_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientCopyFromUrlOptions<'a> { +pub struct BlobClientCopyFromUrlOptions<'a> { /// Optional. Used to set blob tags in various blob operations. pub blob_tags_string: Option, @@ -442,7 +443,7 @@ pub struct BlobBlobClientCopyFromUrlOptions<'a> { pub if_unmodified_since: Option, /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + pub immutability_policy_expiry: Option, /// Specifies the immutability policy mode to set on the blob. pub immutability_policy_mode: Option, @@ -466,13 +467,13 @@ pub struct BlobBlobClientCopyFromUrlOptions<'a> { pub source_if_match: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, + pub source_if_modified_since: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. pub source_if_none_match: Option, /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, + pub source_if_unmodified_since: Option, /// The tier to be set on the blob. pub tier: Option, @@ -481,9 +482,9 @@ pub struct BlobBlobClientCopyFromUrlOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::create_snapshot()`](crate::clients::BlobBlobClient::create_snapshot()) +/// Options to be passed to [`BlobClient::create_snapshot()`](crate::BlobClient::create_snapshot()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientCreateSnapshotOptions<'a> { +pub struct BlobClientCreateSnapshotOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -532,9 +533,9 @@ pub struct BlobBlobClientCreateSnapshotOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::delete()`](crate::clients::BlobBlobClient::delete()) +/// Options to be passed to [`BlobClient::delete()`](crate::BlobClient::delete()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientDeleteOptions<'a> { +pub struct BlobClientDeleteOptions<'a> { /// Optional. Only possible value is 'permanent', which specifies to permanently delete a blob if blob soft delete is enabled. pub blob_delete_type: Option, @@ -578,9 +579,9 @@ pub struct BlobBlobClientDeleteOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::delete_immutability_policy()`](crate::clients::BlobBlobClient::delete_immutability_policy()) +/// Options to be passed to [`BlobClient::delete_immutability_policy()`](crate::BlobClient::delete_immutability_policy()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientDeleteImmutabilityPolicyOptions<'a> { +pub struct BlobClientDeleteImmutabilityPolicyOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -599,9 +600,9 @@ pub struct BlobBlobClientDeleteImmutabilityPolicyOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::download()`](crate::clients::BlobBlobClient::download()) +/// Options to be passed to [`BlobClient::download()`](crate::BlobClient::download()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientDownloadOptions<'a> { +pub struct BlobClientDownloadOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -666,9 +667,9 @@ pub struct BlobBlobClientDownloadOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::get_account_info()`](crate::clients::BlobBlobClient::get_account_info()) +/// Options to be passed to [`BlobClient::get_account_info()`](crate::BlobClient::get_account_info()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientGetAccountInfoOptions<'a> { +pub struct BlobClientGetAccountInfoOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -679,9 +680,9 @@ pub struct BlobBlobClientGetAccountInfoOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::get_properties()`](crate::clients::BlobBlobClient::get_properties()) +/// Options to be passed to [`BlobClient::get_properties()`](crate::BlobClient::get_properties()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientGetPropertiesOptions<'a> { +pub struct BlobClientGetPropertiesOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -731,9 +732,9 @@ pub struct BlobBlobClientGetPropertiesOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::get_tags()`](crate::clients::BlobBlobClient::get_tags()) +/// Options to be passed to [`BlobClient::get_tags()`](crate::BlobClient::get_tags()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientGetTagsOptions<'a> { +pub struct BlobClientGetTagsOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -758,57 +759,9 @@ pub struct BlobBlobClientGetTagsOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::query()`](crate::clients::BlobBlobClient::query()) +/// Options to be passed to [`BlobClient::release_lease()`](crate::BlobClient::release_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientQueryOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, - - /// The request should only proceed if an entity matches this string. - pub if_match: Option, - - /// The request should only proceed if the entity was modified after this time. - pub if_modified_since: Option, - - /// The request should only proceed if no entity matches this string. - pub if_none_match: Option, - - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub if_tags: Option, - - /// The request should only proceed if the entity was not modified after this time. - pub if_unmodified_since: Option, - - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more - /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) - pub snapshot: Option, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobBlobClient::release_lease()`](crate::clients::BlobBlobClient::release_lease()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientReleaseLeaseOptions<'a> { +pub struct BlobClientReleaseLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -834,9 +787,9 @@ pub struct BlobBlobClientReleaseLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::renew_lease()`](crate::clients::BlobBlobClient::renew_lease()) +/// Options to be passed to [`BlobClient::renew_lease()`](crate::BlobClient::renew_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientRenewLeaseOptions<'a> { +pub struct BlobClientRenewLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -862,14 +815,14 @@ pub struct BlobBlobClientRenewLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::set_expiry()`](crate::clients::BlobBlobClient::set_expiry()) +/// Options to be passed to [`BlobClient::set_expiry()`](crate::BlobClient::set_expiry()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetExpiryOptions<'a> { +pub struct BlobClientSetExpiryOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, /// The time this blob will expire. - pub expires_on: Option, + pub expires_on: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, @@ -878,9 +831,9 @@ pub struct BlobBlobClientSetExpiryOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::set_http_headers()`](crate::clients::BlobBlobClient::set_http_headers()) +/// Options to be passed to [`BlobClient::set_http_headers()`](crate::BlobClient::set_http_headers()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetHttpHeadersOptions<'a> { +pub struct BlobClientSetHttpHeadersOptions<'a> { /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read /// request. pub blob_cache_control: Option, @@ -932,17 +885,17 @@ pub struct BlobBlobClientSetHttpHeadersOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::set_immutability_policy()`](crate::clients::BlobBlobClient::set_immutability_policy()) +/// Options to be passed to [`BlobClient::set_immutability_policy()`](crate::BlobClient::set_immutability_policy()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetImmutabilityPolicyOptions<'a> { +pub struct BlobClientSetImmutabilityPolicyOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + pub if_unmodified_since: Option, /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + pub immutability_policy_expiry: Option, /// Specifies the immutability policy mode to set on the blob. pub immutability_policy_mode: Option, @@ -962,9 +915,9 @@ pub struct BlobBlobClientSetImmutabilityPolicyOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::set_legal_hold()`](crate::clients::BlobBlobClient::set_legal_hold()) +/// Options to be passed to [`BlobClient::set_legal_hold()`](crate::BlobClient::set_legal_hold()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetLegalHoldOptions<'a> { +pub struct BlobClientSetLegalHoldOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -983,9 +936,9 @@ pub struct BlobBlobClientSetLegalHoldOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::set_metadata()`](crate::clients::BlobBlobClient::set_metadata()) +/// Options to be passed to [`BlobClient::set_metadata()`](crate::BlobClient::set_metadata()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetMetadataOptions<'a> { +pub struct BlobClientSetMetadataOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1034,9 +987,9 @@ pub struct BlobBlobClientSetMetadataOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::set_tags()`](crate::clients::BlobBlobClient::set_tags()) +/// Options to be passed to [`BlobClient::set_tags()`](crate::BlobClient::set_tags()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetTagsOptions<'a> { +pub struct BlobClientSetTagsOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1064,9 +1017,9 @@ pub struct BlobBlobClientSetTagsOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::set_tier()`](crate::clients::BlobBlobClient::set_tier()) +/// Options to be passed to [`BlobClient::set_tier()`](crate::BlobClient::set_tier()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientSetTierOptions<'a> { +pub struct BlobClientSetTierOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1095,9 +1048,9 @@ pub struct BlobBlobClientSetTierOptions<'a> { pub version_id: Option, } -/// Options to be passed to [`BlobBlobClient::start_copy_from_url()`](crate::clients::BlobBlobClient::start_copy_from_url()) +/// Options to be passed to [`BlobClient::start_copy_from_url()`](crate::BlobClient::start_copy_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientStartCopyFromUrlOptions<'a> { +pub struct BlobClientStartCopyFromUrlOptions<'a> { /// Optional. Used to set blob tags in various blob operations. pub blob_tags_string: Option, @@ -1120,7 +1073,7 @@ pub struct BlobBlobClientStartCopyFromUrlOptions<'a> { pub if_unmodified_since: Option, /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + pub immutability_policy_expiry: Option, /// Specifies the immutability policy mode to set on the blob. pub immutability_policy_mode: Option, @@ -1148,7 +1101,7 @@ pub struct BlobBlobClientStartCopyFromUrlOptions<'a> { pub source_if_match: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, + pub source_if_modified_since: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. pub source_if_none_match: Option, @@ -1157,7 +1110,7 @@ pub struct BlobBlobClientStartCopyFromUrlOptions<'a> { pub source_if_tags: Option, /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, + pub source_if_unmodified_since: Option, /// The tier to be set on the blob. pub tier: Option, @@ -1166,9 +1119,9 @@ pub struct BlobBlobClientStartCopyFromUrlOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlobClient::undelete()`](crate::clients::BlobBlobClient::undelete()) +/// Options to be passed to [`BlobClient::undelete()`](crate::BlobClient::undelete()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlobClientUndeleteOptions<'a> { +pub struct BlobClientUndeleteOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1179,81 +1132,89 @@ pub struct BlobBlobClientUndeleteOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobBlockBlobClient::commit_block_list()`](crate::clients::BlobBlockBlobClient::commit_block_list()) +/// Options to be passed to [`BlobContainerClient::acquire_lease()`](crate::BlobContainerClient::acquire_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientCommitBlockListOptions<'a> { - /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_cache_control: Option, +pub struct BlobContainerClientAcquireLeaseOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, - /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a - /// read request. - pub blob_content_disposition: Option, + /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease + /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. + pub duration: Option, - /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_encoding: Option, + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. + pub if_modified_since: Option, - /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_language: Option, + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. + pub if_unmodified_since: Option, - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub blob_content_md5: Option>, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. - pub blob_content_type: Option, + /// Optional. The proposed lease ID for the container. + pub proposed_lease_id: Option, - /// Optional. Used to set blob tags in various blob operations. - pub blob_tags_string: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobContainerClient::break_lease()`](crate::BlobContainerClient::break_lease()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientBreakLeaseOptions<'a> { + /// For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. + /// This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on + /// the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for + /// longer than the break period. If this header does not appear with a break operation, a fixed-duration lease breaks after + /// the remaining lease period elapses, and an infinite lease breaks immediately. + pub break_period: Option, /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. + pub if_modified_since: Option, - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. + pub if_unmodified_since: Option, - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_scope: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} - /// The request should only proceed if an entity matches this string. - pub if_match: Option, +/// Options to be passed to [`BlobContainerClient::change_lease()`](crate::BlobContainerClient::change_lease()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientChangeLeaseOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, - /// The request should only proceed if the entity was modified after this time. + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. pub if_modified_since: Option, - /// The request should only proceed if no entity matches this string. - pub if_none_match: Option, - - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub if_tags: Option, - - /// The request should only proceed if the entity was not modified after this time. + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. pub if_unmodified_since: Option, - /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Specifies the immutability policy mode to set on the blob. - pub immutability_policy_mode: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, +/// Options to be passed to [`BlobContainerClient::create()`](crate::BlobContainerClient::create()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientCreateOptions<'a> { + /// The public access setting for the container. + pub access: Option, - /// Specified if a legal hold should be set on the blob. - pub legal_hold: Option, + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the default encryption scope to set on the container and use for all + /// future writes. + pub default_encryption_scope: Option, /// The metadata headers. pub metadata: Option>, @@ -1261,28 +1222,25 @@ pub struct BlobBlockBlobClientCommitBlockListOptions<'a> { /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// The tier to be set on the blob. - pub tier: Option, + /// If a blob has a lease and the lease is of infinite duration then the value of this header is set to true, otherwise it + /// is set to false. + pub prevent_encryption_scope_override: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, - - /// Specify the transactional crc64 for the body, to be validated by the service. - pub transactional_content_crc64: Option, - - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobBlockBlobClient::get_block_list()`](crate::clients::BlobBlockBlobClient::get_block_list()) +/// Options to be passed to [`BlobContainerClient::delete()`](crate::BlobContainerClient::delete()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientGetBlockListOptions<'a> { +pub struct BlobContainerClientDeleteOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub if_tags: Option, + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. + pub if_modified_since: Option, + + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. + pub if_unmodified_since: Option, /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, @@ -1290,376 +1248,188 @@ pub struct BlobBlockBlobClientGetBlockListOptions<'a> { /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more - /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) - pub snapshot: Option, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobBlockBlobClient::put_blob_from_url()`](crate::clients::BlobBlockBlobClient::put_blob_from_url()) +/// Options to be passed to [`BlobContainerClient::filter_blobs()`](crate::BlobContainerClient::filter_blobs()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientPutBlobFromUrlOptions<'a> { - /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_cache_control: Option, +pub struct BlobContainerClientFilterBlobsOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, - /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a - /// read request. - pub blob_content_disposition: Option, + /// Include this parameter to specify one or more datasets to include in the response. + pub include: Option>, - /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_encoding: Option, + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, - /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_language: Option, + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub blob_content_md5: Option>, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. - pub blob_content_type: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, - /// Optional. Used to set blob tags in various blob operations. - pub blob_tags_string: Option, + /// Filters the results to return only to return only blobs whose tags match the specified expression. + pub where_param: Option, +} +/// Options to be passed to [`BlobContainerClient::get_access_policy()`](crate::BlobContainerClient::get_access_policy()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientGetAccessPolicyOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. - pub copy_source_authorization: Option, + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, - /// Optional, default is true. Indicates if properties from the source blob should be copied. - pub copy_source_blob_properties: Option, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Optional, default 'replace'. Indicates if source tags should be copied or replaced with the tags specified by x-ms-tags. - pub copy_source_tags: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, +/// Options to be passed to [`BlobContainerClient::get_account_info()`](crate::BlobContainerClient::get_account_info()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientGetAccountInfoOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} - /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_scope: Option, - - /// The request should only proceed if an entity matches this string. - pub if_match: Option, - - /// The request should only proceed if the entity was modified after this time. - pub if_modified_since: Option, - - /// The request should only proceed if no entity matches this string. - pub if_none_match: Option, - - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub if_tags: Option, - - /// The request should only proceed if the entity was not modified after this time. - pub if_unmodified_since: Option, +/// Options to be passed to [`BlobContainerClient::get_properties()`](crate::BlobContainerClient::get_properties()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobContainerClientGetPropertiesOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, - /// The metadata headers. - pub metadata: Option>, - /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// Specify the md5 calculated for the range of bytes that must be read from the copy source. - pub source_content_md5: Option, - - /// Specify an ETag value to operate only on blobs with a matching value. - pub source_if_match: Option, - - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, - - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_none_match: Option, - - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub source_if_tags: Option, - - /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, - - /// The tier to be set on the blob. - pub tier: Option, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, - - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobBlockBlobClient::stage_block()`](crate::clients::BlobBlockBlobClient::stage_block()) +/// Options to be passed to [`BlobContainerClient::list_blob_flat_segment()`](crate::BlobContainerClient::list_blob_flat_segment()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientStageBlockOptions<'a> { +pub struct BlobContainerClientListBlobFlatSegmentOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, + /// Include this parameter to specify one or more datasets to include in the response. + pub include: Option>, - /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_scope: Option, + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// Required if the request body is a structured message. Specifies the message schema version and properties. - pub structured_body_type: Option, - - /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message - /// body. Will always be smaller than Content-Length. - pub structured_content_length: Option, + /// Filters the results to return only containers whose name begins with the specified prefix. + pub prefix: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, - - /// Specify the transactional crc64 for the body, to be validated by the service. - pub transactional_content_crc64: Option, - - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobBlockBlobClient::stage_block_from_url()`](crate::clients::BlobBlockBlobClient::stage_block_from_url()) +/// Options to be passed to [`BlobContainerClient::list_blob_hierarchy_segment()`](crate::BlobContainerClient::list_blob_hierarchy_segment()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientStageBlockFromUrlOptions<'a> { +pub struct BlobContainerClientListBlobHierarchySegmentOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. - pub copy_source_authorization: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, + /// Include this parameter to specify one or more datasets to include in the response. + pub include: Option>, - /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_scope: Option, + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// Specify the crc64 calculated for the range of bytes that must be read from the copy source. - pub source_content_crc64: Option>, - - /// Specify the md5 calculated for the range of bytes that must be read from the copy source. - pub source_content_md5: Option, - - /// Specify an ETag value to operate only on blobs with a matching value. - pub source_if_match: Option, - - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, - - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_none_match: Option, - - /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, - - /// Bytes of source data in the specified range. - pub source_range: Option, + /// Filters the results to return only containers whose name begins with the specified prefix. + pub prefix: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobBlockBlobClient::upload()`](crate::clients::BlobBlockBlobClient::upload()) +/// Options to be passed to [`BlobContainerClient::release_lease()`](crate::BlobContainerClient::release_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobBlockBlobClientUploadOptions<'a> { - /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_cache_control: Option, - - /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a - /// read request. - pub blob_content_disposition: Option, - - /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_encoding: Option, - - /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read - /// request. - pub blob_content_language: Option, - - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub blob_content_md5: Option>, - - /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. - pub blob_content_type: Option, - - /// Optional. Used to set blob tags in various blob operations. - pub blob_tags_string: Option, - +pub struct BlobContainerClientReleaseLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is - /// AES256. - pub encryption_algorithm: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_key: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided - /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated - /// with a client token, this header should be specified using the SHA256 hash of the encryption key. - pub encryption_key_sha256: Option, - - /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. - /// If not specified, the request will be encrypted with the root account key. - pub encryption_scope: Option, - - /// The request should only proceed if an entity matches this string. - pub if_match: Option, - - /// The request should only proceed if the entity was modified after this time. + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. pub if_modified_since: Option, - /// The request should only proceed if no entity matches this string. - pub if_none_match: Option, - - /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - pub if_tags: Option, - - /// The request should only proceed if the entity was not modified after this time. + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. pub if_unmodified_since: Option, - /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, - - /// Specifies the immutability policy mode to set on the blob. - pub immutability_policy_mode: Option, - - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, - - /// Specified if a legal hold should be set on the blob. - pub legal_hold: Option, - - /// The metadata headers. - pub metadata: Option>, - /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// Required if the request body is a structured message. Specifies the message schema version and properties. - pub structured_body_type: Option, - - /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message - /// body. Will always be smaller than Content-Length. - pub structured_content_length: Option, - - /// The tier to be set on the blob. - pub tier: Option, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, - - /// Specify the transactional crc64 for the body, to be validated by the service. - pub transactional_content_crc64: Option, - - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks - /// were validated when each was uploaded. - pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobContainerClient::acquire_lease()`](crate::clients::BlobContainerClient::acquire_lease()) +/// Options to be passed to [`BlobContainerClient::rename()`](crate::BlobContainerClient::rename()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientAcquireLeaseOptions<'a> { +pub struct BlobContainerClientRenameOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease - /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. - pub duration: Option, - - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, - - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, - /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// Optional. The proposed lease ID for the container. - pub proposed_lease_id: Option, + /// A lease ID for the source path. If specified, the source path must have an active lease and the lease ID must match. + pub source_lease_id: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::break_lease()`](crate::clients::BlobContainerClient::break_lease()) +/// Options to be passed to [`BlobContainerClient::renew_lease()`](crate::BlobContainerClient::renew_lease()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientBreakLeaseOptions<'a> { - /// For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. - /// This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on - /// the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for - /// longer than the break period. If this header does not appear with a break operation, a fixed-duration lease breaks after - /// the remaining lease period elapses, and an infinite lease breaks immediately. - pub break_period: Option, - +pub struct BlobContainerClientRenewLeaseOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + pub if_modified_since: Option, /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + pub if_unmodified_since: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, @@ -1668,17 +1438,17 @@ pub struct BlobContainerClientBreakLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::change_lease()`](crate::clients::BlobContainerClient::change_lease()) +/// Options to be passed to [`BlobContainerClient::restore()`](crate::BlobContainerClient::restore()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientChangeLeaseOptions<'a> { +pub struct BlobContainerClientRestoreOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + /// Optional. Version 2019-12-12 and later. Specifies the name of the deleted container to restore. + pub deleted_container_name: Option, - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + /// Optional. Version 2019-12-12 and later. Specifies the version of the deleted container to restore. + pub deleted_container_version: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, @@ -1687,48 +1457,46 @@ pub struct BlobContainerClientChangeLeaseOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::create()`](crate::clients::BlobContainerClient::create()) +/// Options to be passed to [`BlobContainerClient::set_access_policy()`](crate::BlobContainerClient::set_access_policy()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientCreateOptions<'a> { +pub struct BlobContainerClientSetAccessPolicyOptions<'a> { /// The public access setting for the container. pub access: Option, /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Optional. Version 2019-07-07 and later. Specifies the default encryption scope to set on the container and use for all - /// future writes. - pub default_encryption_scope: Option, - - /// The metadata headers. - pub metadata: Option>, + /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. + pub if_modified_since: Option, + + /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. + pub if_unmodified_since: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// If a blob has a lease and the lease is of infinite duration then the value of this header is set to true, otherwise it - /// is set to false. - pub prevent_encryption_scope_override: Option, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::delete()`](crate::clients::BlobContainerClient::delete()) +/// Options to be passed to [`BlobContainerClient::set_metadata()`](crate::BlobContainerClient::set_metadata()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientDeleteOptions<'a> { +pub struct BlobContainerClientSetMetadataOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, - - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + pub if_modified_since: Option, /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, + /// The metadata headers. + pub metadata: Option>, + /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, @@ -1736,9 +1504,22 @@ pub struct BlobContainerClientDeleteOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::filter_blobs()`](crate::clients::BlobContainerClient::filter_blobs()) +/// Options to be passed to [`BlobContainerClient::submit_batch()`](crate::BlobContainerClient::submit_batch()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientFilterBlobsOptions<'a> { +pub struct BlobContainerClientSubmitBatchOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobServiceClient::filter_blobs()`](crate::BlobServiceClient::filter_blobs()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobServiceClientFilterBlobsOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1765,14 +1546,24 @@ pub struct BlobContainerClientFilterBlobsOptions<'a> { pub where_param: Option, } -/// Options to be passed to [`BlobContainerClient::get_access_policy()`](crate::clients::BlobContainerClient::get_access_policy()) +/// Options to be passed to [`BlobServiceClient::get_account_info()`](crate::BlobServiceClient::get_account_info()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientGetAccessPolicyOptions<'a> { +pub struct BlobServiceClientGetAccountInfoOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - pub lease_id: Option, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobServiceClient::get_properties()`](crate::BlobServiceClient::get_properties()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobServiceClientGetPropertiesOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, @@ -1781,9 +1572,9 @@ pub struct BlobContainerClientGetAccessPolicyOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::get_account_info()`](crate::clients::BlobContainerClient::get_account_info()) +/// Options to be passed to [`BlobServiceClient::get_statistics()`](crate::BlobServiceClient::get_statistics()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientGetAccountInfoOptions<'a> { +pub struct BlobServiceClientGetStatisticsOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -1794,158 +1585,583 @@ pub struct BlobContainerClientGetAccountInfoOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::get_properties()`](crate::clients::BlobContainerClient::get_properties()) +/// Options to be passed to [`BlobServiceClient::get_user_delegation_key()`](crate::BlobServiceClient::get_user_delegation_key()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientGetPropertiesOptions<'a> { +pub struct BlobServiceClientGetUserDelegationKeyOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobServiceClient::list_containers_segment()`](crate::BlobServiceClient::list_containers_segment()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobServiceClientListContainersSegmentOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Include this parameter to specify that the container's metadata be returned as part of the response body. + pub include: Option>, + + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, + + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// Filters the results to return only containers whose name begins with the specified prefix. + pub prefix: Option, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobServiceClient::set_properties()`](crate::BlobServiceClient::set_properties()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobServiceClientSetPropertiesOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// The CORS properties. + pub cors: Vec, + + /// The default service version. + pub default_service_version: Option, + + /// The delete retention policy. + pub delete_retention_policy: Option, + + /// The hour metrics properties. + pub hour_metrics: Option, + + /// The logging properties. + pub logging: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// The minute metrics properties. + pub minute_metrics: Option, + + /// The static website properties. + pub static_website: Option, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlobServiceClient::submit_batch()`](crate::BlobServiceClient::submit_batch()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlobServiceClientSubmitBatchOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlockBlobClient::commit_block_list()`](crate::BlockBlobClient::commit_block_list()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlockBlobClientCommitBlockListOptions<'a> { + /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_cache_control: Option, + + /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a + /// read request. + pub blob_content_disposition: Option, + + /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_encoding: Option, + + /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_language: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub blob_content_md5: Option>, + + /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. + pub blob_content_type: Option, + + /// Optional. Used to set blob tags in various blob operations. + pub blob_tags_string: Option, + /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_scope: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, + + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, + + /// Specifies the date time when the blobs immutability policy is set to expire. + pub immutability_policy_expiry: Option, + + /// Specifies the immutability policy mode to set on the blob. + pub immutability_policy_mode: Option, + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, + /// Specified if a legal hold should be set on the blob. + pub legal_hold: Option, + + /// The metadata headers. + pub metadata: Option>, + /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, + /// The tier to be set on the blob. + pub tier: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, + + /// Specify the transactional crc64 for the body, to be validated by the service. + pub transactional_content_crc64: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobContainerClient::release_lease()`](crate::clients::BlobContainerClient::release_lease()) +/// Options to be passed to [`BlockBlobClient::get_block_list()`](crate::BlockBlobClient::get_block_list()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientReleaseLeaseOptions<'a> { +pub struct BlockBlobClientGetBlockListOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more + /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) + pub snapshot: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::rename()`](crate::clients::BlobContainerClient::rename()) +/// Options to be passed to [`BlockBlobClient::put_blob_from_url()`](crate::BlockBlobClient::put_blob_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientRenameOptions<'a> { +pub struct BlockBlobClientPutBlobFromUrlOptions<'a> { + /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_cache_control: Option, + + /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a + /// read request. + pub blob_content_disposition: Option, + + /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_encoding: Option, + + /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_language: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub blob_content_md5: Option>, + + /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. + pub blob_content_type: Option, + + /// Optional. Used to set blob tags in various blob operations. + pub blob_tags_string: Option, + /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, + /// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. + pub copy_source_authorization: Option, + + /// Optional, default is true. Indicates if properties from the source blob should be copied. + pub copy_source_blob_properties: Option, + + /// Optional, default 'replace'. Indicates if source tags should be copied or replaced with the tags specified by x-ms-tags. + pub copy_source_tags: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_scope: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, + + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, + + /// The metadata headers. + pub metadata: Option>, + /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// A lease ID for the source path. If specified, the source path must have an active lease and the lease ID must match. - pub source_lease_id: Option, + /// Specify the md5 calculated for the range of bytes that must be read from the copy source. + pub source_content_md5: Option, + + /// Specify an ETag value to operate only on blobs with a matching value. + pub source_if_match: Option, + + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + pub source_if_modified_since: Option, + + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + pub source_if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub source_if_tags: Option, + + /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. + pub source_if_unmodified_since: Option, + + /// The tier to be set on the blob. + pub tier: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobContainerClient::renew_lease()`](crate::clients::BlobContainerClient::renew_lease()) +/// Options to be passed to [`BlockBlobClient::query()`](crate::BlockBlobClient::query()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientRenewLeaseOptions<'a> { +pub struct BlockBlobClientQueryOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, + + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more + /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) + pub snapshot: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, } -/// Options to be passed to [`BlobContainerClient::restore()`](crate::clients::BlobContainerClient::restore()) +/// Options to be passed to [`BlockBlobClient::stage_block()`](crate::BlockBlobClient::stage_block()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientRestoreOptions<'a> { +pub struct BlockBlobClientStageBlockOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// Optional. Version 2019-12-12 and later. Specifies the name of the deleted container to restore. - pub deleted_container_name: Option, + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, - /// Optional. Version 2019-12-12 and later. Specifies the version of the deleted container to restore. - pub deleted_container_version: Option, + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_scope: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, + /// Required if the request body is a structured message. Specifies the message schema version and properties. + pub structured_body_type: Option, + + /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message + /// body. Will always be smaller than Content-Length. + pub structured_content_length: Option, + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, + + /// Specify the transactional crc64 for the body, to be validated by the service. + pub transactional_content_crc64: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobContainerClient::set_access_policy()`](crate::clients::BlobContainerClient::set_access_policy()) +/// Options to be passed to [`BlockBlobClient::stage_block_from_url()`](crate::BlockBlobClient::stage_block_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientSetAccessPolicyOptions<'a> { - /// The public access setting for the container. - pub access: Option, - +pub struct BlockBlobClientStageBlockFromUrlOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + /// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. + pub copy_source_authorization: Option, - /// A date-time value. A request is made under the condition that the resource has not been modified since the specified date-time. - pub if_unmodified_since: Option, + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_scope: Option, /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// Specify the crc64 calculated for the range of bytes that must be read from the copy source. + pub source_content_crc64: Option>, + + /// Specify the md5 calculated for the range of bytes that must be read from the copy source. + pub source_content_md5: Option, + + /// Specify an ETag value to operate only on blobs with a matching value. + pub source_if_match: Option, + + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + pub source_if_modified_since: Option, + + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + pub source_if_none_match: Option, + + /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. + pub source_if_unmodified_since: Option, + + /// Bytes of source data in the specified range. + pub source_range: Option, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`BlockBlobClient::upload()`](crate::BlockBlobClient::upload()) +#[derive(Clone, Default, SafeDebug)] +pub struct BlockBlobClientUploadOptions<'a> { + /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_cache_control: Option, + + /// Optional. Sets the blob's content disposition. If specified, this property is stored with the blob and returned with a + /// read request. + pub blob_content_disposition: Option, + + /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_encoding: Option, + + /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read + /// request. + pub blob_content_language: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub blob_content_md5: Option>, + + /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. + pub blob_content_type: Option, + + /// Optional. Used to set blob tags in various blob operations. + pub blob_tags_string: Option, + + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. If not specified, the default is + /// AES256. + pub encryption_algorithm: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_key: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption key used to encrypt the data provided + /// in the request. This header is only used for encryption with a customer-provided key. If the request is authenticated + /// with a client token, this header should be specified using the SHA256 hash of the encryption key. + pub encryption_key_sha256: Option, + + /// Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt the data provided in the request. + /// If not specified, the request will be encrypted with the root account key. + pub encryption_scope: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, -/// Options to be passed to [`BlobContainerClient::set_metadata()`](crate::clients::BlobContainerClient::set_metadata()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientSetMetadataOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, + /// Specifies the date time when the blobs immutability policy is set to expire. + pub immutability_policy_expiry: Option, - /// A date-time value. A request is made under the condition that the resource has been modified since the specified date-time. - pub if_modified_since: Option, + /// Specifies the immutability policy mode to set on the blob. + pub immutability_policy_mode: Option, /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. pub lease_id: Option, + /// Specified if a legal hold should be set on the blob. + pub legal_hold: Option, + /// The metadata headers. pub metadata: Option>, /// Allows customization of the method call. pub method_options: ClientMethodOptions<'a>, - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} + /// Required if the request body is a structured message. Specifies the message schema version and properties. + pub structured_body_type: Option, -/// Options to be passed to [`BlobContainerClient::submit_batch()`](crate::clients::BlobContainerClient::submit_batch()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobContainerClientSubmitBatchOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, + /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message + /// body. Will always be smaller than Content-Length. + pub structured_content_length: Option, - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, + /// The tier to be set on the blob. + pub tier: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, + + /// Specify the transactional crc64 for the body, to be validated by the service. + pub transactional_content_crc64: Option, + + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks + /// were validated when each was uploaded. + pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobPageBlobClient::clear_pages()`](crate::clients::BlobPageBlobClient::clear_pages()) +/// Options to be passed to [`PageBlobClient::clear_pages()`](crate::PageBlobClient::clear_pages()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientClearPagesOptions<'a> { +pub struct PageBlobClientClearPagesOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -2003,9 +2219,9 @@ pub struct BlobPageBlobClientClearPagesOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobPageBlobClient::copy_incremental()`](crate::clients::BlobPageBlobClient::copy_incremental()) +/// Options to be passed to [`PageBlobClient::copy_incremental()`](crate::PageBlobClient::copy_incremental()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientCopyIncrementalOptions<'a> { +pub struct PageBlobClientCopyIncrementalOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -2031,9 +2247,9 @@ pub struct BlobPageBlobClientCopyIncrementalOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobPageBlobClient::create()`](crate::clients::BlobPageBlobClient::create()) +/// Options to be passed to [`PageBlobClient::create()`](crate::PageBlobClient::create()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientCreateOptions<'a> { +pub struct PageBlobClientCreateOptions<'a> { /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read /// request. pub blob_cache_control: Option, @@ -2100,7 +2316,7 @@ pub struct BlobPageBlobClientCreateOptions<'a> { pub if_unmodified_since: Option, /// Specifies the date time when the blobs immutability policy is set to expire. - pub immutability_policy_expiry: Option, + pub immutability_policy_expiry: Option, /// Specifies the immutability policy mode to set on the blob. pub immutability_policy_mode: Option, @@ -2124,9 +2340,115 @@ pub struct BlobPageBlobClientCreateOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobPageBlobClient::resize()`](crate::clients::BlobPageBlobClient::resize()) +/// Options to be passed to [`PageBlobClient::get_page_ranges()`](crate::PageBlobClient::get_page_ranges()) +#[derive(Clone, Default, SafeDebug)] +pub struct PageBlobClientGetPageRangesOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, + + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, + + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, + + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// Return only the bytes of the blob in the specified range. + pub range: Option, + + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more + /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) + pub snapshot: Option, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`PageBlobClient::get_page_ranges_diff()`](crate::PageBlobClient::get_page_ranges_diff()) +#[derive(Clone, Default, SafeDebug)] +pub struct PageBlobClientGetPageRangesDiffOptions<'a> { + /// An opaque, globally-unique, client-generated string identifier for the request. + pub client_request_id: Option, + + /// The request should only proceed if an entity matches this string. + pub if_match: Option, + + /// The request should only proceed if the entity was modified after this time. + pub if_modified_since: Option, + + /// The request should only proceed if no entity matches this string. + pub if_none_match: Option, + + /// Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + pub if_tags: Option, + + /// The request should only proceed if the entity was not modified after this time. + pub if_unmodified_since: Option, + + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + pub lease_id: Option, + + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The + /// operation returns the NextMarker value within the response body if the listing operation did not return all containers + /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + /// a subsequent call to request the next page of list items. The marker value is opaque to the client. + pub marker: Option, + + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value + /// greater than 5000, the server will return up to 5000 items. + pub maxresults: Option, + + /// Allows customization of the method call. + pub method_options: ClientMethodOptions<'a>, + + /// Optional. This header is only supported in service versions 2019-04-19 and after and specifies the URL of a previous snapshot + /// of the target blob. The response will only contain pages that were changed between the target blob and its previous snapshot. + pub prev_snapshot_url: Option, + + /// Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that specifies that the response + /// will contain only pages that were changed between target blob and previous snapshot. Changed pages include both updated + /// and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by prevsnapshot is the older of + /// the two. Note that incremental snapshots are currently supported only for blobs created on or after January 1, 2016. + pub prevsnapshot: Option, + + /// Return only the bytes of the blob in the specified range. + pub range: Option, + + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more + /// information on working with blob snapshots, see [Creating a Snapshot of a Blob.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob) + pub snapshot: Option, + + /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) + pub timeout: Option, +} + +/// Options to be passed to [`PageBlobClient::resize()`](crate::PageBlobClient::resize()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientResizeOptions<'a> { +pub struct PageBlobClientResizeOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -2172,9 +2494,9 @@ pub struct BlobPageBlobClientResizeOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobPageBlobClient::update_sequence_number()`](crate::clients::BlobPageBlobClient::update_sequence_number()) +/// Options to be passed to [`PageBlobClient::update_sequence_number()`](crate::PageBlobClient::update_sequence_number()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientUpdateSequenceNumberOptions<'a> { +pub struct PageBlobClientUpdateSequenceNumberOptions<'a> { /// Set for page blobs only. The sequence number is a user-controlled value that you can use to track requests. The value /// of the sequence number must be between 0 and 2^63 - 1. pub blob_sequence_number: Option, @@ -2207,9 +2529,9 @@ pub struct BlobPageBlobClientUpdateSequenceNumberOptions<'a> { pub timeout: Option, } -/// Options to be passed to [`BlobPageBlobClient::upload_pages()`](crate::clients::BlobPageBlobClient::upload_pages()) +/// Options to be passed to [`PageBlobClient::upload_pages()`](crate::PageBlobClient::upload_pages()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientUploadPagesOptions<'a> { +pub struct PageBlobClientUploadPagesOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -2268,7 +2590,7 @@ pub struct BlobPageBlobClientUploadPagesOptions<'a> { /// Required if the request body is a structured message. Specifies the length of the blob/file content inside the message /// body. Will always be smaller than Content-Length. - pub structured_content_length: Option, + pub structured_content_length: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, @@ -2281,9 +2603,9 @@ pub struct BlobPageBlobClientUploadPagesOptions<'a> { pub transactional_content_md5: Option, } -/// Options to be passed to [`BlobPageBlobClient::upload_pages_from_url()`](crate::clients::BlobPageBlobClient::upload_pages_from_url()) +/// Options to be passed to [`PageBlobClient::upload_pages_from_url()`](crate::PageBlobClient::upload_pages_from_url()) #[derive(Clone, Default, SafeDebug)] -pub struct BlobPageBlobClientUploadPagesFromUrlOptions<'a> { +pub struct PageBlobClientUploadPagesFromUrlOptions<'a> { /// An opaque, globally-unique, client-generated string identifier for the request. pub client_request_id: Option, @@ -2347,141 +2669,13 @@ pub struct BlobPageBlobClientUploadPagesFromUrlOptions<'a> { pub source_if_match: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - pub source_if_modified_since: Option, + pub source_if_modified_since: Option, /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. pub source_if_none_match: Option, /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - pub source_if_unmodified_since: Option, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::filter_blobs()`](crate::clients::BlobServiceClient::filter_blobs()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientFilterBlobsOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Include this parameter to specify one or more datasets to include in the response. - pub include: Option>, - - /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The - /// operation returns the NextMarker value within the response body if the listing operation did not return all containers - /// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in - /// a subsequent call to request the next page of list items. The marker value is opaque to the client. - pub marker: Option, - - /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value - /// greater than 5000, the server will return up to 5000 items. - pub maxresults: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, - - /// Filters the results to return only to return only blobs whose tags match the specified expression. - pub where_param: Option, -} - -/// Options to be passed to [`BlobServiceClient::get_account_info()`](crate::clients::BlobServiceClient::get_account_info()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientGetAccountInfoOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::get_properties()`](crate::clients::BlobServiceClient::get_properties()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientGetPropertiesOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::get_statistics()`](crate::clients::BlobServiceClient::get_statistics()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientGetStatisticsOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::get_user_delegation_key()`](crate::clients::BlobServiceClient::get_user_delegation_key()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientGetUserDelegationKeyOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::set_properties()`](crate::clients::BlobServiceClient::set_properties()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientSetPropertiesOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// The CORS properties. - pub cors: Option>, - - /// The default service version. - pub default_service_version: Option, - - /// The delete retention policy. - pub delete_retention_policy: Option, - - /// The hour metrics properties. - pub hour_metrics: Option, - - /// The logging properties. - pub logging: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, - - /// The minute metrics properties. - pub minute_metrics: Option, - - /// The static website properties. - pub static_website: Option, - - /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) - pub timeout: Option, -} - -/// Options to be passed to [`BlobServiceClient::submit_batch()`](crate::clients::BlobServiceClient::submit_batch()) -#[derive(Clone, Default, SafeDebug)] -pub struct BlobServiceClientSubmitBatchOptions<'a> { - /// An opaque, globally-unique, client-generated string identifier for the request. - pub client_request_id: Option, - - /// Allows customization of the method call. - pub method_options: ClientMethodOptions<'a>, + pub source_if_unmodified_since: Option, /// The timeout parameter is expressed in seconds. For more information, see [Setting Timeouts for Blob Service Operations.](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations) pub timeout: Option, diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/mod.rs b/sdk/storage/azure_storage_blob/src/generated/clients/mod.rs index b7023b9641..9518dbbb7c 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/mod.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/mod.rs @@ -3,19 +3,17 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. -mod blob_append_blob_client; -mod blob_blob_client; -mod blob_block_blob_client; +mod append_blob_client; mod blob_client; mod blob_container_client; -mod blob_page_blob_client; mod blob_service_client; +mod block_blob_client; mod internal_models; pub(crate) mod method_options; -pub use blob_append_blob_client::*; -pub use blob_blob_client::*; -pub use blob_block_blob_client::*; +mod page_blob_client; +pub use append_blob_client::*; pub use blob_client::*; pub use blob_container_client::*; -pub use blob_page_blob_client::*; pub use blob_service_client::*; +pub use block_blob_client::*; +pub use page_blob_client::*; diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/blob_page_blob_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/page_blob_client.rs similarity index 73% rename from sdk/storage/azure_storage_blob/src/generated/clients/blob_page_blob_client.rs rename to sdk/storage/azure_storage_blob/src/generated/clients/page_blob_client.rs index a6904126d3..3472a41514 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/blob_page_blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/page_blob_client.rs @@ -4,12 +4,21 @@ // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. use crate::generated::clients::method_options::*; -use crate::models::{BlobType, SequenceNumberActionType}; +use crate::models::{ + BlobType, PageBlobClientClearPagesResult, PageBlobClientCopyIncrementalResult, + PageBlobClientCreateResult, PageBlobClientResizeResult, + PageBlobClientUpdateSequenceNumberResult, PageBlobClientUploadPagesFromUrlResult, + PageBlobClientUploadPagesResult, PageList, SequenceNumberActionType, +}; +use azure_core::credentials::TokenCredential; use azure_core::{ - base64, date, Bytes, Context, Method, Pipeline, Request, RequestContent, Response, Result, Url, + base64, date, BearerTokenCredentialPolicy, Bytes, ClientOptions, Context, Method, Pipeline, + Policy, Request, RequestContent, Response, Result, Url, }; +use std::sync::Arc; +use typespec_client_core::fmt::SafeDebug; -pub struct BlobPageBlobClient { +pub struct PageBlobClient { pub(crate) blob: String, pub(crate) container_name: String, pub(crate) endpoint: Url, @@ -17,7 +26,60 @@ pub struct BlobPageBlobClient { pub(crate) version: String, } -impl BlobPageBlobClient { +/// Options used when creating a [`PageBlobClient`](crate::PageBlobClient) +#[derive(Clone, Default, SafeDebug)] +pub struct PageBlobClientOptions { + pub client_options: ClientOptions, +} + +impl PageBlobClient { + /// Creates a new PageBlobClient, using Entra ID authentication. + /// + /// # Arguments + /// + /// * `endpoint` - Service host + /// * `credential` - An implementation of [`TokenCredential`](azure_core::credentials::TokenCredential) that can provide an + /// Entra ID token to use when authenticating. + /// * `version` - Specifies the version of the operation to use for this request. + /// * `container_name` - The name of the container. + /// * `blob` - The name of the blob. + /// * `options` - Optional configuration for the client. + pub fn new( + endpoint: &str, + credential: Arc, + version: String, + container_name: String, + blob: String, + options: Option, + ) -> Result { + let options = options.unwrap_or_default(); + let mut endpoint = Url::parse(endpoint)?; + if !endpoint.scheme().starts_with("http") { + return Err(azure_core::Error::message( + azure_core::error::ErrorKind::Other, + format!("{endpoint} must use http(s)"), + )); + } + endpoint.set_query(None); + let auth_policy: Arc = Arc::new(BearerTokenCredentialPolicy::new( + credential, + vec!["https://storage.azure.com/.default"], + )); + Ok(Self { + blob, + container_name, + endpoint, + version, + pipeline: Pipeline::new( + option_env!("CARGO_PKG_NAME"), + option_env!("CARGO_PKG_VERSION"), + options.client_options, + Vec::default(), + vec![auth_policy], + ), + }) + } + /// Returns the Url associated with this client. pub fn endpoint(&self) -> &Url { &self.endpoint @@ -31,13 +93,13 @@ impl BlobPageBlobClient { /// * `options` - Optional parameters for the request. pub async fn clear_pages( &self, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -132,12 +194,12 @@ impl BlobPageBlobClient { pub async fn copy_incremental( &self, copy_source: &str, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -185,14 +247,14 @@ impl BlobPageBlobClient { /// * `options` - Optional parameters for the request. pub async fn create( &self, - content_length: i64, - blob_content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + blob_content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -279,7 +341,7 @@ impl BlobPageBlobClient { if let Some(immutability_policy_expiry) = options.immutability_policy_expiry { request.insert_header( "x-ms-immutability-policy-until-date", - immutability_policy_expiry, + date::to_rfc7231(&immutability_policy_expiry), ); } if let Some(lease_id) = options.lease_id { @@ -300,6 +362,145 @@ impl BlobPageBlobClient { self.pipeline.send(&ctx, &mut request).await } + /// The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn get_page_ranges( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut().append_pair("comp", "pagelist"); + if let Some(marker) = options.marker { + url.query_pairs_mut().append_pair("marker", &marker); + } + if let Some(maxresults) = options.maxresults { + url.query_pairs_mut() + .append_pair("maxresults", &maxresults.to_string()); + } + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(range) = options.range { + request.insert_header("x-ms-range", range); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + + /// The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + /// + /// # Arguments + /// + /// * `options` - Optional parameters for the request. + pub async fn get_page_ranges_diff( + &self, + options: Option>, + ) -> Result> { + let options = options.unwrap_or_default(); + let ctx = Context::with_context(&options.method_options.context); + let mut url = self.endpoint.clone(); + let mut path = String::from("{containerName}/{blob}/"); + path = path.replace("{blob}", &self.blob); + path = path.replace("{containerName}", &self.container_name); + url = url.join(&path)?; + url.query_pairs_mut() + .append_pair("comp", "pagelist") + .append_key_only("diff"); + if let Some(marker) = options.marker { + url.query_pairs_mut().append_pair("marker", &marker); + } + if let Some(maxresults) = options.maxresults { + url.query_pairs_mut() + .append_pair("maxresults", &maxresults.to_string()); + } + if let Some(prevsnapshot) = options.prevsnapshot { + url.query_pairs_mut() + .append_pair("prevsnapshot", &prevsnapshot); + } + if let Some(snapshot) = options.snapshot { + url.query_pairs_mut().append_pair("snapshot", &snapshot); + } + if let Some(timeout) = options.timeout { + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); + } + let mut request = Request::new(url, Method::Get); + request.insert_header("accept", "application/xml"); + request.insert_header("content-type", "application/xml"); + if let Some(if_match) = options.if_match { + request.insert_header("if-match", if_match); + } + if let Some(if_modified_since) = options.if_modified_since { + request.insert_header("if-modified-since", date::to_rfc7231(&if_modified_since)); + } + if let Some(if_none_match) = options.if_none_match { + request.insert_header("if-none-match", if_none_match); + } + if let Some(if_unmodified_since) = options.if_unmodified_since { + request.insert_header( + "if-unmodified-since", + date::to_rfc7231(&if_unmodified_since), + ); + } + if let Some(client_request_id) = options.client_request_id { + request.insert_header("x-ms-client-request-id", client_request_id); + } + if let Some(if_tags) = options.if_tags { + request.insert_header("x-ms-if-tags", if_tags); + } + if let Some(lease_id) = options.lease_id { + request.insert_header("x-ms-lease-id", lease_id); + } + if let Some(prev_snapshot_url) = options.prev_snapshot_url { + request.insert_header("x-ms-previous-snapshot-url", prev_snapshot_url); + } + if let Some(range) = options.range { + request.insert_header("x-ms-range", range); + } + request.insert_header("x-ms-version", &self.version); + self.pipeline.send(&ctx, &mut request).await + } + /// The Resize operation increases the size of the page blob to the specified size. /// /// # Arguments @@ -309,13 +510,13 @@ impl BlobPageBlobClient { /// * `options` - Optional parameters for the request. pub async fn resize( &self, - blob_content_length: i64, - options: Option>, - ) -> Result> { + blob_content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -384,12 +585,12 @@ impl BlobPageBlobClient { pub async fn update_sequence_number( &self, sequence_number_action: SequenceNumberActionType, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -451,13 +652,13 @@ impl BlobPageBlobClient { pub async fn upload_pages( &self, body: RequestContent, - content_length: i64, - options: Option>, - ) -> Result> { + content_length: u64, + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -569,14 +770,14 @@ impl BlobPageBlobClient { &self, source_url: &str, source_range: &str, - content_length: i64, + content_length: u64, range: &str, - options: Option>, - ) -> Result> { + options: Option>, + ) -> Result> { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}"); + let mut path = String::from("{containerName}/{blob}/"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; @@ -669,7 +870,10 @@ impl BlobPageBlobClient { request.insert_header("x-ms-source-if-match", source_if_match); } if let Some(source_if_modified_since) = options.source_if_modified_since { - request.insert_header("x-ms-source-if-modified-since", source_if_modified_since); + request.insert_header( + "x-ms-source-if-modified-since", + date::to_rfc7231(&source_if_modified_since), + ); } if let Some(source_if_none_match) = options.source_if_none_match { request.insert_header("x-ms-source-if-none-match", source_if_none_match); @@ -677,7 +881,7 @@ impl BlobPageBlobClient { if let Some(source_if_unmodified_since) = options.source_if_unmodified_since { request.insert_header( "x-ms-source-if-unmodified-since", - source_if_unmodified_since, + date::to_rfc7231(&source_if_unmodified_since), ); } request.insert_header("x-ms-source-range", source_range.to_owned()); diff --git a/sdk/storage/azure_storage_blob/src/generated/enums.rs b/sdk/storage/azure_storage_blob/src/generated/enums.rs index 90bbfd6465..491916a575 100644 --- a/sdk/storage/azure_storage_blob/src/generated/enums.rs +++ b/sdk/storage/azure_storage_blob/src/generated/enums.rs @@ -171,6 +171,15 @@ create_extensible_enum!( (Unavailable, "unavailable") ); +create_extensible_enum!( + #[doc = r#"/// The lease duration."#] + LeaseDuration, + #[doc = r#"/// The lease is of fixed duration."#] + (Fixed, "fixed"), + #[doc = r#"/// The lease is of infinite duration."#] + (Infinite, "infinite") +); + create_extensible_enum!( #[doc = r#"/// The lease state."#] LeaseState, @@ -195,6 +204,42 @@ create_extensible_enum!( (Unlocked, "unlocked") ); +create_extensible_enum!( + #[doc = r#"/// The list blob includes parameter values."#] + ListBlobsIncludeItem, + #[doc = r#"/// The include copies."#] + (Copy, "copy"), + #[doc = r#"/// The include deleted blobs."#] + (Deleted, "deleted"), + #[doc = r#"/// The include deleted with versions."#] + (DeletedWithVersions, "deletedwithversions"), + #[doc = r#"/// The include immutable policy."#] + (ImmutabilityPolicy, "immutabilitypolicy"), + #[doc = r#"/// The include legal hold."#] + (LegalHold, "legalhold"), + #[doc = r#"/// The include metadata."#] + (Metadata, "metadata"), + #[doc = r#"/// The include snapshots."#] + (Snapshots, "snapshots"), + #[doc = r#"/// The include tags."#] + (Tags, "tags"), + #[doc = r#"/// The include uncommitted blobs."#] + (UncommittedBlobs, "uncommittedblobs"), + #[doc = r#"/// The include versions."#] + (Versions, "versions") +); + +create_extensible_enum!( + #[doc = r#"/// Include this parameter to specify that the container's metadata be returned as part of the response body."#] + ListContainersIncludeType, + #[doc = r#"/// Include deleted"#] + (Deleted, "deleted"), + #[doc = r#"/// Include metadata"#] + (Metadata, "metadata"), + #[doc = r#"/// Include system"#] + (System, "system") +); + create_extensible_enum!( #[doc = r#"/// The premium page blob access tier types."#] PremiumPageBlobAccessTier, diff --git a/sdk/storage/azure_storage_blob/src/generated/header_traits.rs b/sdk/storage/azure_storage_blob/src/generated/header_traits.rs new file mode 100644 index 0000000000..0952e93a22 --- /dev/null +++ b/sdk/storage/azure_storage_blob/src/generated/header_traits.rs @@ -0,0 +1,4006 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. + +use crate::models::{ + AccessTier, AccountKind, AppendBlobClientAppendBlockFromUrlResult, + AppendBlobClientAppendBlockResult, AppendBlobClientCreateResult, AppendBlobClientSealResult, + ArchiveStatus, BlobClientAbortCopyFromUrlResult, BlobClientAcquireLeaseResult, + BlobClientBreakLeaseResult, BlobClientChangeLeaseResult, BlobClientCopyFromUrlResult, + BlobClientCreateSnapshotResult, BlobClientDeleteImmutabilityPolicyResult, + BlobClientDeleteResult, BlobClientDownloadResult, BlobClientGetAccountInfoResult, + BlobClientGetPropertiesResult, BlobClientReleaseLeaseResult, BlobClientRenewLeaseResult, + BlobClientSetExpiryResult, BlobClientSetHttpHeadersResult, + BlobClientSetImmutabilityPolicyResult, BlobClientSetLegalHoldResult, + BlobClientSetMetadataResult, BlobClientSetTagsResult, BlobClientSetTierResult, + BlobClientStartCopyFromUrlResult, BlobClientUndeleteResult, + BlobContainerClientAcquireLeaseResult, BlobContainerClientBreakLeaseResult, + BlobContainerClientChangeLeaseResult, BlobContainerClientCreateResult, + BlobContainerClientDeleteResult, BlobContainerClientGetAccountInfoResult, + BlobContainerClientGetPropertiesResult, BlobContainerClientReleaseLeaseResult, + BlobContainerClientRenameResult, BlobContainerClientRenewLeaseResult, + BlobContainerClientRestoreResult, BlobContainerClientSetAccessPolicyResult, + BlobContainerClientSetMetadataResult, BlobContainerClientSubmitBatchResult, + BlobImmutabilityPolicyMode, BlobServiceClientGetAccountInfoResult, + BlobServiceClientSetPropertiesResult, BlobServiceClientSubmitBatchResult, BlobTags, BlobType, + BlockBlobClientCommitBlockListResult, BlockBlobClientPutBlobFromUrlResult, + BlockBlobClientQueryResult, BlockBlobClientStageBlockFromUrlResult, + BlockBlobClientStageBlockResult, BlockBlobClientUploadResult, BlockList, CopyStatus, + FilterBlobSegment, LeaseState, LeaseStatus, ListBlobsFlatSegmentResponse, + ListBlobsHierarchySegmentResponse, ListContainersSegmentResponse, + PageBlobClientClearPagesResult, PageBlobClientCopyIncrementalResult, + PageBlobClientCreateResult, PageBlobClientResizeResult, + PageBlobClientUpdateSequenceNumberResult, PageBlobClientUploadPagesFromUrlResult, + PageBlobClientUploadPagesResult, PageList, PublicAccessType, RehydratePriority, + SignedIdentifier, SkuName, StorageServiceProperties, StorageServiceStats, UserDelegationKey, +}; +use azure_core::{base64, date, headers::HeaderName, headers::Headers, Response, Result}; +use std::collections::HashMap; +use time::OffsetDateTime; + +const ACCEPT_RANGES: HeaderName = HeaderName::from_static("accept-ranges"); +const ACCESS_TIER: HeaderName = HeaderName::from_static("x-ms-access-tier"); +const ACCESS_TIER_CHANGE_TIME: HeaderName = HeaderName::from_static("x-ms-access-tier-change-time"); +const ACCESS_TIER_INFERRED: HeaderName = HeaderName::from_static("x-ms-access-tier-inferred"); +const ACCOUNT_KIND: HeaderName = HeaderName::from_static("x-ms-account-kind"); +const ARCHIVE_STATUS: HeaderName = HeaderName::from_static("x-ms-archive-status"); +const BLOB_APPEND_OFFSET: HeaderName = HeaderName::from_static("x-ms-blob-append-offset"); +const BLOB_COMMITTED_BLOCK_COUNT: HeaderName = + HeaderName::from_static("x-ms-blob-committed-block-count"); +const BLOB_CONTENT_LENGTH: HeaderName = HeaderName::from_static("x-ms-blob-content-length"); +const BLOB_CONTENT_MD5: HeaderName = HeaderName::from_static("x-ms-blob-content-md5"); +const BLOB_PUBLIC_ACCESS: HeaderName = HeaderName::from_static("x-ms-blob-public-access"); +const BLOB_SEALED: HeaderName = HeaderName::from_static("x-ms-blob-sealed"); +const BLOB_SEQUENCE_NUMBER: HeaderName = HeaderName::from_static("x-ms-blob-sequence-number"); +const BLOB_TYPE: HeaderName = HeaderName::from_static("x-ms-blob-type"); +const CACHE_CONTROL: HeaderName = HeaderName::from_static("cache-control"); +const CLIENT_REQUEST_ID: HeaderName = HeaderName::from_static("x-ms-client-request-id"); +const CONTENT_CRC64: HeaderName = HeaderName::from_static("x-ms-content-crc64"); +const CONTENT_DISPOSITION: HeaderName = HeaderName::from_static("content-disposition"); +const CONTENT_ENCODING: HeaderName = HeaderName::from_static("content-encoding"); +const CONTENT_LANGUAGE: HeaderName = HeaderName::from_static("content-language"); +const CONTENT_LENGTH: HeaderName = HeaderName::from_static("content-length"); +const CONTENT_MD5: HeaderName = HeaderName::from_static("content-md5"); +const CONTENT_RANGE: HeaderName = HeaderName::from_static("content-range"); +const COPY_COMPLETION_TIME: HeaderName = HeaderName::from_static("x-ms-copy-completion-time"); +const COPY_DESTINATION_SNAPSHOT: HeaderName = + HeaderName::from_static("x-ms-copy-destination-snapshot"); +const COPY_ID: HeaderName = HeaderName::from_static("x-ms-copy-id"); +const COPY_PROGRESS: HeaderName = HeaderName::from_static("x-ms-copy-progress"); +const COPY_SOURCE: HeaderName = HeaderName::from_static("x-ms-copy-source"); +const COPY_STATUS: HeaderName = HeaderName::from_static("x-ms-copy-status"); +const COPY_STATUS_DESCRIPTION: HeaderName = HeaderName::from_static("x-ms-copy-status-description"); +const CREATION_TIME: HeaderName = HeaderName::from_static("x-ms-creation-time"); +const DATE: HeaderName = HeaderName::from_static("date"); +const DEFAULT_ENCRYPTION_SCOPE: HeaderName = + HeaderName::from_static("x-ms-default-encryption-scope"); +const DENY_ENCRYPTION_SCOPE_OVERRIDE: HeaderName = + HeaderName::from_static("x-ms-deny-encryption-scope-override"); +const ENCRYPTION_KEY_SHA256: HeaderName = HeaderName::from_static("x-ms-encryption-key-sha256"); +const ENCRYPTION_SCOPE: HeaderName = HeaderName::from_static("x-ms-encryption-scope"); +const EXPIRY_TIME: HeaderName = HeaderName::from_static("x-ms-expiry-time"); +const E_TAG: HeaderName = HeaderName::from_static("etag"); +const HAS_IMMUTABILITY_POLICY: HeaderName = HeaderName::from_static("x-ms-has-immutability-policy"); +const HAS_LEGAL_HOLD: HeaderName = HeaderName::from_static("x-ms-has-legal-hold"); +const IMMUTABILITY_POLICY_MODE: HeaderName = + HeaderName::from_static("x-ms-immutability-policy-mode"); +const IMMUTABILITY_POLICY_UNTIL_DATE: HeaderName = + HeaderName::from_static("x-ms-immutability-policy-until-date"); +const IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED: HeaderName = + HeaderName::from_static("x-ms-immutable-storage-with-versioning-enabled"); +const INCREMENTAL_COPY: HeaderName = HeaderName::from_static("x-ms-incremental-copy"); +const IS_CURRENT_VERSION: HeaderName = HeaderName::from_static("x-ms-is-current-version"); +const IS_HNS_ENABLED: HeaderName = HeaderName::from_static("x-ms-is-hns-enabled"); +const LAST_ACCESS_TIME: HeaderName = HeaderName::from_static("x-ms-last-access-time"); +const LAST_MODIFIED: HeaderName = HeaderName::from_static("last-modified"); +const LEASE_DURATION: HeaderName = HeaderName::from_static("x-ms-lease-duration"); +const LEASE_ID: HeaderName = HeaderName::from_static("x-ms-lease-id"); +const LEASE_STATE: HeaderName = HeaderName::from_static("x-ms-lease-state"); +const LEASE_STATUS: HeaderName = HeaderName::from_static("x-ms-lease-status"); +const LEASE_TIME: HeaderName = HeaderName::from_static("x-ms-lease-time"); +const LEGAL_HOLD: HeaderName = HeaderName::from_static("x-ms-legal-hold"); +const META: &str = "x-ms-meta-"; +const OR: &str = "x-ms-or-"; +const OR_POLICY_ID: HeaderName = HeaderName::from_static("x-ms-or-policy-id"); +const REHYDRATE_PRIORITY: HeaderName = HeaderName::from_static("x-ms-rehydrate-priority"); +const REQUEST_ID: HeaderName = HeaderName::from_static("x-ms-request-id"); +const REQUEST_SERVER_ENCRYPTED: HeaderName = + HeaderName::from_static("x-ms-request-server-encrypted"); +const SKU_NAME: HeaderName = HeaderName::from_static("x-ms-sku-name"); +const SNAPSHOT: HeaderName = HeaderName::from_static("x-ms-snapshot"); +const STRUCTURED_BODY: HeaderName = HeaderName::from_static("x-ms-structured-body"); +const STRUCTURED_CONTENT_LENGTH: HeaderName = + HeaderName::from_static("x-ms-structured-content-length"); +const TAG_COUNT: HeaderName = HeaderName::from_static("x-ms-tag-count"); +const VERSION_ID: HeaderName = HeaderName::from_static("x-ms-version-id"); + +/// Provides access to typed response headers for [`AppendBlobClient::append_block_from_url()`](crate::clients::AppendBlobClient::append_block_from_url()) +pub trait AppendBlobClientAppendBlockFromUrlResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_append_offset(&self) -> Result>; + fn blob_committed_block_count(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; +} + +impl AppendBlobClientAppendBlockFromUrlResultHeaders + for Response +{ + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// This response header is returned only for append operations. It returns the offset at which the block was committed, in + /// bytes. + fn blob_append_offset(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_APPEND_OFFSET) + } + + /// The number of committed blocks present in the blob. This header is returned only for append blobs. + fn blob_committed_block_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_COMMITTED_BLOCK_COUNT) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } +} + +/// Provides access to typed response headers for [`AppendBlobClient::append_block()`](crate::clients::AppendBlobClient::append_block()) +pub trait AppendBlobClientAppendBlockResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_append_offset(&self) -> Result>; + fn blob_committed_block_count(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn structured_body_type(&self) -> Result>; +} + +impl AppendBlobClientAppendBlockResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// This response header is returned only for append operations. It returns the offset at which the block was committed, in + /// bytes. + fn blob_append_offset(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_APPEND_OFFSET) + } + + /// The number of committed blocks present in the blob. This header is returned only for append blobs. + fn blob_committed_block_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_COMMITTED_BLOCK_COUNT) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Indicates the response body contains a structured message and specifies the message schema version and properties. + fn structured_body_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_BODY) + } +} + +/// Provides access to typed response headers for [`AppendBlobClient::create()`](crate::clients::AppendBlobClient::create()) +pub trait AppendBlobClientCreateResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl AppendBlobClientCreateResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`AppendBlobClient::seal()`](crate::clients::AppendBlobClient::seal()) +pub trait AppendBlobClientSealResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn is_sealed(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl AppendBlobClientSealResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// If this blob has been sealed + fn is_sealed(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEALED) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::abort_copy_from_url()`](crate::clients::BlobClient::abort_copy_from_url()) +pub trait BlobClientAbortCopyFromUrlResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientAbortCopyFromUrlResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::acquire_lease()`](crate::clients::BlobClient::acquire_lease()) +pub trait BlobClientAcquireLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientAcquireLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::break_lease()`](crate::clients::BlobClient::break_lease()) +pub trait BlobClientBreakLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_time(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientBreakLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Approximate time remaining in the lease period, in seconds. + fn lease_time(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_TIME) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::change_lease()`](crate::clients::BlobClient::change_lease()) +pub trait BlobClientChangeLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientChangeLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::copy_from_url()`](crate::clients::BlobClient::copy_from_url()) +pub trait BlobClientCopyFromUrlResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientCopyFromUrlResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::create_snapshot()`](crate::clients::BlobClient::create_snapshot()) +pub trait BlobClientCreateSnapshotResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn snapshot(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientCreateSnapshotResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Uniquely identifies the snapshot and indicates the snapshot version. It may be used in subsequent requests to access the + /// snapshot. + fn snapshot(&self) -> Result> { + Headers::get_optional_as(self.headers(), &SNAPSHOT) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::delete_immutability_policy()`](crate::clients::BlobClient::delete_immutability_policy()) +pub trait BlobClientDeleteImmutabilityPolicyResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientDeleteImmutabilityPolicyResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::delete()`](crate::clients::BlobClient::delete()) +pub trait BlobClientDeleteResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientDeleteResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::download()`](crate::clients::BlobClient::download()) +pub trait BlobClientDownloadResultHeaders: private::Sealed { + fn accept_ranges(&self) -> Result>; + fn cache_control(&self) -> Result>; + fn content_disposition(&self) -> Result>; + fn content_encoding(&self) -> Result>; + fn content_language(&self) -> Result>; + fn content_length(&self) -> Result>; + fn content_md5(&self) -> Result>; + fn content_range(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_committed_block_count(&self) -> Result>; + fn blob_content_md5(&self) -> Result>>; + fn is_sealed(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn blob_type(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn copy_completion_time(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_progress(&self) -> Result>; + fn copy_source(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn copy_status_description(&self) -> Result>; + fn creation_time(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn immutability_policy_mode(&self) -> Result>; + fn immutability_policy_expires_on(&self) -> Result>; + fn is_current_version(&self) -> Result>; + fn last_accessed(&self) -> Result>; + fn duration(&self) -> Result>; + fn lease_state(&self) -> Result>; + fn lease_status(&self) -> Result>; + fn legal_hold(&self) -> Result>; + fn metadata(&self) -> Result>; + fn object_replication_rules(&self) -> Result>; + fn object_replication_policy_id(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn structured_body_type(&self) -> Result>; + fn structured_content_length(&self) -> Result>; + fn tag_count(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientDownloadResultHeaders for Response { + /// Indicates that the service supports requests for partial blob content. + fn accept_ranges(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCEPT_RANGES) + } + + /// This header is returned if it was previously specified for the blob. + fn cache_control(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CACHE_CONTROL) + } + + /// This header returns the value that was specified for the 'x-ms-blob-content-disposition' header. The Content-Disposition + /// response header field conveys additional information about how to process the response payload, and also can be used to + /// attach additional metadata. For example, if set to attachment, it indicates that the user-agent should not display the + /// response, but instead show a Save As dialog with a filename other than the blob name specified. + fn content_disposition(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_DISPOSITION) + } + + /// This header returns the value that was specified for the Content-Encoding request header + fn content_encoding(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_ENCODING) + } + + /// This header returns the value that was specified for the Content-Language request header. + fn content_language(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LANGUAGE) + } + + /// The number of bytes present in the response body. + fn content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LENGTH) + } + + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// Indicates the range of bytes returned in the event that the client requested a subset of the blob by setting the 'Range' + /// request header. + fn content_range(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_RANGE) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The number of committed blocks present in the blob. This header is returned only for append blobs. + fn blob_committed_block_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_COMMITTED_BLOCK_COUNT) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn blob_content_md5(&self) -> Result>> { + Headers::get_optional_with(self.headers(), &BLOB_CONTENT_MD5, |h| { + base64::decode(h.as_str()) + }) + } + + /// If this blob has been sealed + fn is_sealed(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEALED) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// The type of the blob. + fn blob_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_TYPE) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// Conclusion time of the last attempted Copy Blob operation where this blob was the destination blob. This value can specify + /// the time of a completed, aborted, or failed copy attempt. This header does not appear if a copy is pending, if this blob + /// has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy Blob + /// operation using Set Blob Properties, Put Blob, or Put Block List. + fn copy_completion_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), ©_COMPLETION_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy Blob operation where + /// this blob was the destination blob. Can show between 0 and Content-Length bytes copied. This header does not appear if + /// this blob has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded + /// Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_progress(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_PROGRESS) + } + + /// URL up to 2 KB in length that specifies the source blob or file used in the last attempted Copy Blob operation where this + /// blob was the destination blob. This header does not appear if this blob has never been the destination in a Copy Blob + /// operation, or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, + /// or Put Block List. + fn copy_source(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_SOURCE) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last fatal or non-fatal copy operation + /// failure. This header does not appear if this blob has never been the destination in a Copy Blob operation, or if this + /// blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_status_description(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS_DESCRIPTION) + } + + /// Returns the date and time the blob was created. + fn creation_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), &CREATION_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// Indicates the immutability policy mode of the blob. + fn immutability_policy_mode(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IMMUTABILITY_POLICY_MODE) + } + + /// UTC date/time value generated by the service that indicates the time at which the blob immutability policy will expire. + fn immutability_policy_expires_on(&self) -> Result> { + Headers::get_optional_with(self.headers(), &IMMUTABILITY_POLICY_UNTIL_DATE, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The value of this header indicates whether version of this blob is a current version, see also x-ms-version-id header. + fn is_current_version(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IS_CURRENT_VERSION) + } + + /// UTC date/time value generated by the service that indicates the time at which the blob was last read or written to + fn last_accessed(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_ACCESS_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease + /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. + fn duration(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_DURATION) + } + + /// Lease state of the blob. + fn lease_state(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATE) + } + + /// The lease status of the blob. + fn lease_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATUS) + } + + /// Specifies the legal hold status to set on the blob. + fn legal_hold(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEGAL_HOLD) + } + + /// The metadata headers. + fn metadata(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > META.len() && name.starts_with(META) { + values.insert(name[META.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// Optional. Only valid when Object Replication is enabled for the storage container and on the source blob of the replication. + /// When retrieving this header, it will return the header with the policy id and rule id (e.g. x-ms-or-policyid_ruleid), + /// and the value will be the status of the replication (e.g. complete, failed). + fn object_replication_rules(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > OR.len() && name.starts_with(OR) { + values.insert(name[OR.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// Optional. Only valid when Object Replication is enabled for the storage container and on the destination blob of the replication. + fn object_replication_policy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &OR_POLICY_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Indicates the response body contains a structured message and specifies the message schema version and properties. + fn structured_body_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_BODY) + } + + /// The length of the blob/file content inside the message body when the response body is returned as a structured message. + /// Will always be smaller than Content-Length. + fn structured_content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_CONTENT_LENGTH) + } + + /// The number of tags associated with the blob + fn tag_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &TAG_COUNT) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::get_account_info()`](crate::clients::BlobClient::get_account_info()) +pub trait BlobClientGetAccountInfoResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn account_kind(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn is_hierarchical_namespace_enabled(&self) -> Result>; + fn request_id(&self) -> Result>; + fn sku_name(&self) -> Result>; +} + +impl BlobClientGetAccountInfoResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// Identifies the account kind + fn account_kind(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCOUNT_KIND) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Version 2019-07-07 and newer. Indicates if the account has a hierarchical namespace enabled. + fn is_hierarchical_namespace_enabled(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IS_HNS_ENABLED) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// Identifies the sku name of the account + fn sku_name(&self) -> Result> { + Headers::get_optional_as(self.headers(), &SKU_NAME) + } +} + +/// Provides access to typed response headers for [`BlobClient::get_properties()`](crate::clients::BlobClient::get_properties()) +pub trait BlobClientGetPropertiesResultHeaders: private::Sealed { + fn accept_ranges(&self) -> Result>; + fn cache_control(&self) -> Result>; + fn content_disposition(&self) -> Result>; + fn content_encoding(&self) -> Result>; + fn content_language(&self) -> Result>; + fn content_length(&self) -> Result>; + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn tier(&self) -> Result>; + fn access_tier_change_time(&self) -> Result>; + fn access_tier_inferred(&self) -> Result>; + fn archive_status(&self) -> Result>; + fn blob_committed_block_count(&self) -> Result>; + fn is_sealed(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn blob_type(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn copy_completion_time(&self) -> Result>; + fn destination_snapshot(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_progress(&self) -> Result>; + fn copy_source(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn copy_status_description(&self) -> Result>; + fn creation_time(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn expires_on(&self) -> Result>; + fn immutability_policy_mode(&self) -> Result>; + fn immutability_policy_expires_on(&self) -> Result>; + fn is_incremental_copy(&self) -> Result>; + fn is_current_version(&self) -> Result>; + fn last_accessed(&self) -> Result>; + fn duration(&self) -> Result>; + fn lease_state(&self) -> Result>; + fn lease_status(&self) -> Result>; + fn legal_hold(&self) -> Result>; + fn metadata(&self) -> Result>; + fn object_replication_rules(&self) -> Result>; + fn object_replication_policy_id(&self) -> Result>; + fn rehydrate_priority(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn tag_count(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientGetPropertiesResultHeaders for Response { + /// Indicates that the service supports requests for partial blob content. + fn accept_ranges(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCEPT_RANGES) + } + + /// This header is returned if it was previously specified for the blob. + fn cache_control(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CACHE_CONTROL) + } + + /// This header returns the value that was specified for the 'x-ms-blob-content-disposition' header. The Content-Disposition + /// response header field conveys additional information about how to process the response payload, and also can be used to + /// attach additional metadata. For example, if set to attachment, it indicates that the user-agent should not display the + /// response, but instead show a Save As dialog with a filename other than the blob name specified. + fn content_disposition(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_DISPOSITION) + } + + /// This header returns the value that was specified for the Content-Encoding request header + fn content_encoding(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_ENCODING) + } + + /// This header returns the value that was specified for the Content-Language request header. + fn content_language(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LANGUAGE) + } + + /// The number of bytes present in the response body. + fn content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LENGTH) + } + + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The tier to be set on the blob. + fn tier(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCESS_TIER) + } + + /// The time the tier was changed on the object. This is only returned if the tier on the block blob was ever set. + fn access_tier_change_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), &ACCESS_TIER_CHANGE_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// For page blobs on a premium storage account only. If the access tier is not explicitly set on the blob, the tier is inferred + /// based on its content length and this header will be returned with true value. + fn access_tier_inferred(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCESS_TIER_INFERRED) + } + + /// For blob storage LRS accounts, valid values are rehydrate-pending-to-hot/rehydrate-pending-to-cool. If the blob is being + /// rehydrated and is not complete then this header is returned indicating that rehydrate is pending and also tells the destination + /// tier. + fn archive_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ARCHIVE_STATUS) + } + + /// The number of committed blocks present in the blob. This header is returned only for append blobs. + fn blob_committed_block_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_COMMITTED_BLOCK_COUNT) + } + + /// If this blob has been sealed + fn is_sealed(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEALED) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// The type of the blob. + fn blob_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_TYPE) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Conclusion time of the last attempted Copy Blob operation where this blob was the destination blob. This value can specify + /// the time of a completed, aborted, or failed copy attempt. This header does not appear if a copy is pending, if this blob + /// has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy Blob + /// operation using Set Blob Properties, Put Blob, or Put Block List. + fn copy_completion_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), ©_COMPLETION_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// Included if the blob is incremental copy blob or incremental copy snapshot, if x-ms-copy-status is success. Snapshot time + /// of the last successful incremental copy snapshot for this blob. + fn destination_snapshot(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_DESTINATION_SNAPSHOT) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy Blob operation where + /// this blob was the destination blob. Can show between 0 and Content-Length bytes copied. This header does not appear if + /// this blob has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded + /// Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_progress(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_PROGRESS) + } + + /// URL up to 2 KB in length that specifies the source blob or file used in the last attempted Copy Blob operation where this + /// blob was the destination blob. This header does not appear if this blob has never been the destination in a Copy Blob + /// operation, or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, + /// or Put Block List. + fn copy_source(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_SOURCE) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last fatal or non-fatal copy operation + /// failure. This header does not appear if this blob has never been the destination in a Copy Blob operation, or if this + /// blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_status_description(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS_DESCRIPTION) + } + + /// Returns the date and time the blob was created. + fn creation_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), &CREATION_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// The time this blob will expire. + fn expires_on(&self) -> Result> { + Headers::get_optional_with(self.headers(), &EXPIRY_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// Indicates the immutability policy mode of the blob. + fn immutability_policy_mode(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IMMUTABILITY_POLICY_MODE) + } + + /// UTC date/time value generated by the service that indicates the time at which the blob immutability policy will expire. + fn immutability_policy_expires_on(&self) -> Result> { + Headers::get_optional_with(self.headers(), &IMMUTABILITY_POLICY_UNTIL_DATE, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// Included if the blob is incremental copy blob. + fn is_incremental_copy(&self) -> Result> { + Headers::get_optional_as(self.headers(), &INCREMENTAL_COPY) + } + + /// The value of this header indicates whether version of this blob is a current version, see also x-ms-version-id header. + fn is_current_version(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IS_CURRENT_VERSION) + } + + /// UTC date/time value generated by the service that indicates the time at which the blob was last read or written to + fn last_accessed(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_ACCESS_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease + /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. + fn duration(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_DURATION) + } + + /// Lease state of the blob. + fn lease_state(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATE) + } + + /// The lease status of the blob. + fn lease_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATUS) + } + + /// Specifies the legal hold status to set on the blob. + fn legal_hold(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEGAL_HOLD) + } + + /// The metadata headers. + fn metadata(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > META.len() && name.starts_with(META) { + values.insert(name[META.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// Optional. Only valid when Object Replication is enabled for the storage container and on the source blob of the replication. + /// When retrieving this header, it will return the header with the policy id and rule id (e.g. x-ms-or-policyid_ruleid), + /// and the value will be the status of the replication (e.g. complete, failed). + fn object_replication_rules(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > OR.len() && name.starts_with(OR) { + values.insert(name[OR.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// Optional. Only valid when Object Replication is enabled for the storage container and on the destination blob of the replication. + fn object_replication_policy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &OR_POLICY_ID) + } + + /// If an object is in rehydrate pending state then this header is returned with priority of rehydrate. Valid values are High + /// and Standard. + fn rehydrate_priority(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REHYDRATE_PRIORITY) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// The number of tags associated with the blob + fn tag_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &TAG_COUNT) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::release_lease()`](crate::clients::BlobClient::release_lease()) +pub trait BlobClientReleaseLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientReleaseLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::renew_lease()`](crate::clients::BlobClient::renew_lease()) +pub trait BlobClientRenewLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientRenewLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_expiry()`](crate::clients::BlobClient::set_expiry()) +pub trait BlobClientSetExpiryResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetExpiryResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_http_headers()`](crate::clients::BlobClient::set_http_headers()) +pub trait BlobClientSetHttpHeadersResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetHttpHeadersResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_immutability_policy()`](crate::clients::BlobClient::set_immutability_policy()) +pub trait BlobClientSetImmutabilityPolicyResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn immutability_policy_mode(&self) -> Result>; + fn immutability_policy_expires_on(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetImmutabilityPolicyResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Indicates the immutability policy mode of the blob. + fn immutability_policy_mode(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IMMUTABILITY_POLICY_MODE) + } + + /// UTC date/time value generated by the service that indicates the time at which the blob immutability policy will expire. + fn immutability_policy_expires_on(&self) -> Result> { + Headers::get_optional_with(self.headers(), &IMMUTABILITY_POLICY_UNTIL_DATE, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_legal_hold()`](crate::clients::BlobClient::set_legal_hold()) +pub trait BlobClientSetLegalHoldResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn legal_hold(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetLegalHoldResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Specifies the legal hold status to set on the blob. + fn legal_hold(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEGAL_HOLD) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_metadata()`](crate::clients::BlobClient::set_metadata()) +pub trait BlobClientSetMetadataResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientSetMetadataResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_tags()`](crate::clients::BlobClient::set_tags()) +pub trait BlobClientSetTagsResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetTagsResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::set_tier()`](crate::clients::BlobClient::set_tier()) +pub trait BlobClientSetTierResultHeaders: private::Sealed { + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientSetTierResultHeaders for Response { + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::start_copy_from_url()`](crate::clients::BlobClient::start_copy_from_url()) +pub trait BlobClientStartCopyFromUrlResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn request_id(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlobClientStartCopyFromUrlResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::undelete()`](crate::clients::BlobClient::undelete()) +pub trait BlobClientUndeleteResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobClientUndeleteResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::acquire_lease()`](crate::clients::BlobContainerClient::acquire_lease()) +pub trait BlobContainerClientAcquireLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientAcquireLeaseResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::break_lease()`](crate::clients::BlobContainerClient::break_lease()) +pub trait BlobContainerClientBreakLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn lease_time(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientBreakLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// Approximate time remaining in the lease period, in seconds. + fn lease_time(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_TIME) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::change_lease()`](crate::clients::BlobContainerClient::change_lease()) +pub trait BlobContainerClientChangeLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientChangeLeaseResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::create()`](crate::clients::BlobContainerClient::create()) +pub trait BlobContainerClientCreateResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientCreateResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::delete()`](crate::clients::BlobContainerClient::delete()) +pub trait BlobContainerClientDeleteResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientDeleteResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::get_account_info()`](crate::clients::BlobContainerClient::get_account_info()) +pub trait BlobContainerClientGetAccountInfoResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn account_kind(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn is_hierarchical_namespace_enabled(&self) -> Result>; + fn request_id(&self) -> Result>; + fn sku_name(&self) -> Result>; +} + +impl BlobContainerClientGetAccountInfoResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// Identifies the account kind + fn account_kind(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCOUNT_KIND) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Version 2019-07-07 and newer. Indicates if the account has a hierarchical namespace enabled. + fn is_hierarchical_namespace_enabled(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IS_HNS_ENABLED) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// Identifies the sku name of the account + fn sku_name(&self) -> Result> { + Headers::get_optional_as(self.headers(), &SKU_NAME) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::get_properties()`](crate::clients::BlobContainerClient::get_properties()) +pub trait BlobContainerClientGetPropertiesResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn access(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn default_encryption_scope(&self) -> Result>; + fn prevent_encryption_scope_override(&self) -> Result>; + fn has_immutability_policy(&self) -> Result>; + fn has_legal_hold(&self) -> Result>; + fn is_immutable_storage_with_versioning_enabled(&self) -> Result>; + fn duration(&self) -> Result>; + fn lease_state(&self) -> Result>; + fn lease_status(&self) -> Result>; + fn metadata(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientGetPropertiesResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The public access setting for the container. + fn access(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_PUBLIC_ACCESS) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The default encryption scope for the container. + fn default_encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &DEFAULT_ENCRYPTION_SCOPE) + } + + /// If a blob has a lease and the lease is of infinite duration then the value of this header is set to true, otherwise it + /// is set to false. + fn prevent_encryption_scope_override(&self) -> Result> { + Headers::get_optional_as(self.headers(), &DENY_ENCRYPTION_SCOPE_OVERRIDE) + } + + /// Indicates whether the container has an immutability policy set on it. + fn has_immutability_policy(&self) -> Result> { + Headers::get_optional_as(self.headers(), &HAS_IMMUTABILITY_POLICY) + } + + /// Indicates whether the container has a legal hold. + fn has_legal_hold(&self) -> Result> { + Headers::get_optional_as(self.headers(), &HAS_LEGAL_HOLD) + } + + /// Indicates whether version level worm is enabled on a container + fn is_immutable_storage_with_versioning_enabled(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED) + } + + /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease + /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. + fn duration(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_DURATION) + } + + /// Lease state of the blob. + fn lease_state(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATE) + } + + /// The lease status of the blob. + fn lease_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATUS) + } + + /// The metadata headers. + fn metadata(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > META.len() && name.starts_with(META) { + values.insert(name[META.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::release_lease()`](crate::clients::BlobContainerClient::release_lease()) +pub trait BlobContainerClientReleaseLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientReleaseLeaseResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::rename()`](crate::clients::BlobContainerClient::rename()) +pub trait BlobContainerClientRenameResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientRenameResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::renew_lease()`](crate::clients::BlobContainerClient::renew_lease()) +pub trait BlobContainerClientRenewLeaseResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn lease_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientRenewLeaseResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Uniquely identifies a blobs' lease + fn lease_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::restore()`](crate::clients::BlobContainerClient::restore()) +pub trait BlobContainerClientRestoreResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientRestoreResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::set_access_policy()`](crate::clients::BlobContainerClient::set_access_policy()) +pub trait BlobContainerClientSetAccessPolicyResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientSetAccessPolicyResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::set_metadata()`](crate::clients::BlobContainerClient::set_metadata()) +pub trait BlobContainerClientSetMetadataResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientSetMetadataResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::submit_batch()`](crate::clients::BlobContainerClient::submit_batch()) +pub trait BlobContainerClientSubmitBatchResultHeaders: private::Sealed { + fn request_id(&self) -> Result>; +} + +impl BlobContainerClientSubmitBatchResultHeaders + for Response +{ + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::get_account_info()`](crate::clients::BlobServiceClient::get_account_info()) +pub trait BlobServiceClientGetAccountInfoResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn account_kind(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn is_hierarchical_namespace_enabled(&self) -> Result>; + fn request_id(&self) -> Result>; + fn sku_name(&self) -> Result>; +} + +impl BlobServiceClientGetAccountInfoResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// Identifies the account kind + fn account_kind(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCOUNT_KIND) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// Version 2019-07-07 and newer. Indicates if the account has a hierarchical namespace enabled. + fn is_hierarchical_namespace_enabled(&self) -> Result> { + Headers::get_optional_as(self.headers(), &IS_HNS_ENABLED) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// Identifies the sku name of the account + fn sku_name(&self) -> Result> { + Headers::get_optional_as(self.headers(), &SKU_NAME) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::set_properties()`](crate::clients::BlobServiceClient::set_properties()) +pub trait BlobServiceClientSetPropertiesResultHeaders: private::Sealed { + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobServiceClientSetPropertiesResultHeaders + for Response +{ + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::submit_batch()`](crate::clients::BlobServiceClient::submit_batch()) +pub trait BlobServiceClientSubmitBatchResultHeaders: private::Sealed { + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobServiceClientSubmitBatchResultHeaders for Response { + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobClient::get_tags()`](crate::clients::BlobClient::get_tags()) +pub trait BlobTagsHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlobTagsHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::commit_block_list()`](crate::clients::BlockBlobClient::commit_block_list()) +pub trait BlockBlobClientCommitBlockListResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlockBlobClientCommitBlockListResultHeaders + for Response +{ + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::put_blob_from_url()`](crate::clients::BlockBlobClient::put_blob_from_url()) +pub trait BlockBlobClientPutBlobFromUrlResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlockBlobClientPutBlobFromUrlResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::query()`](crate::clients::BlockBlobClient::query()) +pub trait BlockBlobClientQueryResultHeaders: private::Sealed { + fn accept_ranges(&self) -> Result>; + fn cache_control(&self) -> Result>; + fn content_disposition(&self) -> Result>; + fn content_encoding(&self) -> Result>; + fn content_language(&self) -> Result>; + fn content_length(&self) -> Result>; + fn content_md5(&self) -> Result>; + fn content_range(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_committed_block_count(&self) -> Result>; + fn blob_content_md5(&self) -> Result>>; + fn blob_sequence_number(&self) -> Result>; + fn blob_type(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn copy_completion_time(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_progress(&self) -> Result>; + fn copy_source(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn copy_status_description(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn duration(&self) -> Result>; + fn lease_state(&self) -> Result>; + fn lease_status(&self) -> Result>; + fn metadata(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; +} + +impl BlockBlobClientQueryResultHeaders for Response { + /// Indicates that the service supports requests for partial blob content. + fn accept_ranges(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ACCEPT_RANGES) + } + + /// This header is returned if it was previously specified for the blob. + fn cache_control(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CACHE_CONTROL) + } + + /// This header returns the value that was specified for the 'x-ms-blob-content-disposition' header. The Content-Disposition + /// response header field conveys additional information about how to process the response payload, and also can be used to + /// attach additional metadata. For example, if set to attachment, it indicates that the user-agent should not display the + /// response, but instead show a Save As dialog with a filename other than the blob name specified. + fn content_disposition(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_DISPOSITION) + } + + /// This header returns the value that was specified for the Content-Encoding request header + fn content_encoding(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_ENCODING) + } + + /// This header returns the value that was specified for the Content-Language request header. + fn content_language(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LANGUAGE) + } + + /// The number of bytes present in the response body. + fn content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_LENGTH) + } + + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// Indicates the range of bytes returned in the event that the client requested a subset of the blob by setting the 'Range' + /// request header. + fn content_range(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_RANGE) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The number of committed blocks present in the blob. This header is returned only for append blobs. + fn blob_committed_block_count(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_COMMITTED_BLOCK_COUNT) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn blob_content_md5(&self) -> Result>> { + Headers::get_optional_with(self.headers(), &BLOB_CONTENT_MD5, |h| { + base64::decode(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// The type of the blob. + fn blob_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_TYPE) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// Conclusion time of the last attempted Copy Blob operation where this blob was the destination blob. This value can specify + /// the time of a completed, aborted, or failed copy attempt. This header does not appear if a copy is pending, if this blob + /// has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy Blob + /// operation using Set Blob Properties, Put Blob, or Put Block List. + fn copy_completion_time(&self) -> Result> { + Headers::get_optional_with(self.headers(), ©_COMPLETION_TIME, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy Blob operation where + /// this blob was the destination blob. Can show between 0 and Content-Length bytes copied. This header does not appear if + /// this blob has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded + /// Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_progress(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_PROGRESS) + } + + /// URL up to 2 KB in length that specifies the source blob or file used in the last attempted Copy Blob operation where this + /// blob was the destination blob. This header does not appear if this blob has never been the destination in a Copy Blob + /// operation, or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, + /// or Put Block List. + fn copy_source(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_SOURCE) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last fatal or non-fatal copy operation + /// failure. This header does not appear if this blob has never been the destination in a Copy Blob operation, or if this + /// blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, or Put Block List + fn copy_status_description(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS_DESCRIPTION) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease + /// can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. + fn duration(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_DURATION) + } + + /// Lease state of the blob. + fn lease_state(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATE) + } + + /// The lease status of the blob. + fn lease_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), &LEASE_STATUS) + } + + /// The metadata headers. + fn metadata(&self) -> Result> { + let mut values = HashMap::new(); + for h in self.headers().iter() { + let name = h.0.as_str(); + if name.len() > META.len() && name.starts_with(META) { + values.insert(name[META.len()..].to_owned(), h.1.as_str().to_owned()); + } + } + Ok(values) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::stage_block_from_url()`](crate::clients::BlockBlobClient::stage_block_from_url()) +pub trait BlockBlobClientStageBlockFromUrlResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; +} + +impl BlockBlobClientStageBlockFromUrlResultHeaders + for Response +{ + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::stage_block()`](crate::clients::BlockBlobClient::stage_block()) +pub trait BlockBlobClientStageBlockResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn structured_body_type(&self) -> Result>; +} + +impl BlockBlobClientStageBlockResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Indicates the response body contains a structured message and specifies the message schema version and properties. + fn structured_body_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_BODY) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::upload()`](crate::clients::BlockBlobClient::upload()) +pub trait BlockBlobClientUploadResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn structured_body_type(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl BlockBlobClientUploadResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Indicates the response body contains a structured message and specifies the message schema version and properties. + fn structured_body_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_BODY) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`BlockBlobClient::get_block_list()`](crate::clients::BlockBlobClient::get_block_list()) +pub trait BlockListHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_content_length(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl BlockListHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte + /// boundary. + fn blob_content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_CONTENT_LENGTH) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::filter_blobs()`](crate::clients::BlobContainerClient::filter_blobs()) +pub trait FilterBlobSegmentHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl FilterBlobSegmentHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::list_blob_flat_segment()`](crate::clients::BlobContainerClient::list_blob_flat_segment()) +pub trait ListBlobsFlatSegmentResponseHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl ListBlobsFlatSegmentResponseHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::list_blob_hierarchy_segment()`](crate::clients::BlobContainerClient::list_blob_hierarchy_segment()) +pub trait ListBlobsHierarchySegmentResponseHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl ListBlobsHierarchySegmentResponseHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::list_containers_segment()`](crate::clients::BlobServiceClient::list_containers_segment()) +pub trait ListContainersSegmentResponseHeaders: private::Sealed { + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl ListContainersSegmentResponseHeaders for Response { + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::clear_pages()`](crate::clients::PageBlobClient::clear_pages()) +pub trait PageBlobClientClearPagesResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl PageBlobClientClearPagesResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::copy_incremental()`](crate::clients::PageBlobClient::copy_incremental()) +pub trait PageBlobClientCopyIncrementalResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn copy_id(&self) -> Result>; + fn copy_status(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl PageBlobClientCopyIncrementalResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy operation, or + /// pass to Abort Copy Blob to abort a pending copy. + fn copy_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_ID) + } + + /// State of the copy operation identified by x-ms-copy-id. + fn copy_status(&self) -> Result> { + Headers::get_optional_as(self.headers(), ©_STATUS) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::create()`](crate::clients::PageBlobClient::create()) +pub trait PageBlobClientCreateResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn version_id(&self) -> Result>; +} + +impl PageBlobClientCreateResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob + /// version, and may be used in subsequent requests to access this version of the blob. + fn version_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &VERSION_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::resize()`](crate::clients::PageBlobClient::resize()) +pub trait PageBlobClientResizeResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl PageBlobClientResizeResultHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::update_sequence_number()`](crate::clients::PageBlobClient::update_sequence_number()) +pub trait PageBlobClientUpdateSequenceNumberResultHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl PageBlobClientUpdateSequenceNumberResultHeaders + for Response +{ + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::upload_pages_from_url()`](crate::clients::PageBlobClient::upload_pages_from_url()) +pub trait PageBlobClientUploadPagesFromUrlResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; +} + +impl PageBlobClientUploadPagesFromUrlResultHeaders + for Response +{ + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::upload_pages()`](crate::clients::PageBlobClient::upload_pages()) +pub trait PageBlobClientUploadPagesResultHeaders: private::Sealed { + fn content_md5(&self) -> Result>; + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_sequence_number(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn content_crc64(&self) -> Result>; + fn encryption_key_sha256(&self) -> Result>; + fn encryption_scope(&self) -> Result>; + fn request_id(&self) -> Result>; + fn is_server_encrypted(&self) -> Result>; + fn structured_body_type(&self) -> Result>; +} + +impl PageBlobClientUploadPagesResultHeaders for Response { + /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so that the + /// client can check for message content integrity. + fn content_md5(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_MD5) + } + + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs. + fn blob_sequence_number(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_SEQUENCE_NUMBER) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// This response header is returned so that the client can check for the integrity of the copied content. + fn content_crc64(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CONTENT_CRC64) + } + + /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob was encrypted + /// with a customer-provided key. + fn encryption_key_sha256(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_KEY_SHA256) + } + + /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned + /// with the value of the whole blob's MD5 value. This value may or may not be equal to the value returned in Content-MD5 + /// header, with the latter calculated from the requested range + fn encryption_scope(&self) -> Result> { + Headers::get_optional_as(self.headers(), &ENCRYPTION_SCOPE) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } + + /// The value of this header is set to true if the contents of the request are successfully encrypted using the specified + /// algorithm, and false otherwise. + fn is_server_encrypted(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_SERVER_ENCRYPTED) + } + + /// Indicates the response body contains a structured message and specifies the message schema version and properties. + fn structured_body_type(&self) -> Result> { + Headers::get_optional_as(self.headers(), &STRUCTURED_BODY) + } +} + +/// Provides access to typed response headers for [`PageBlobClient::get_page_ranges()`](crate::clients::PageBlobClient::get_page_ranges()) +pub trait PageListHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn blob_content_length(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl PageListHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte + /// boundary. + fn blob_content_length(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_CONTENT_LENGTH) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::get_properties()`](crate::clients::BlobServiceClient::get_properties()) +pub trait StorageServicePropertiesHeaders: private::Sealed { + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl StorageServicePropertiesHeaders for Response { + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::get_statistics()`](crate::clients::BlobServiceClient::get_statistics()) +pub trait StorageServiceStatsHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl StorageServiceStatsHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobServiceClient::get_user_delegation_key()`](crate::clients::BlobServiceClient::get_user_delegation_key()) +pub trait UserDelegationKeyHeaders: private::Sealed { + fn date(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl UserDelegationKeyHeaders for Response { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +/// Provides access to typed response headers for [`BlobContainerClient::get_access_policy()`](crate::clients::BlobContainerClient::get_access_policy()) +pub trait VecSignedIdentifierHeaders: private::Sealed { + fn date(&self) -> Result>; + fn e_tag(&self) -> Result>; + fn last_modified(&self) -> Result>; + fn access(&self) -> Result>; + fn client_request_id(&self) -> Result>; + fn request_id(&self) -> Result>; +} + +impl VecSignedIdentifierHeaders for Response> { + /// UTC date/time value generated by the service that indicates the time at which the response was initiated + fn date(&self) -> Result> { + Headers::get_optional_with(self.headers(), &DATE, |h| date::parse_rfc7231(h.as_str())) + } + + /// The ETag contains a value that you can use to perform operations conditionally. + fn e_tag(&self) -> Result> { + Headers::get_optional_as(self.headers(), &E_TAG) + } + + /// The date/time that the container was last modified. + fn last_modified(&self) -> Result> { + Headers::get_optional_with(self.headers(), &LAST_MODIFIED, |h| { + date::parse_rfc7231(h.as_str()) + }) + } + + /// The public access setting for the container. + fn access(&self) -> Result> { + Headers::get_optional_as(self.headers(), &BLOB_PUBLIC_ACCESS) + } + + /// An opaque, globally-unique, client-generated string identifier for the request. + fn client_request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &CLIENT_REQUEST_ID) + } + + /// An opaque, globally-unique, server-generated string identifier for the request. + fn request_id(&self) -> Result> { + Headers::get_optional_as(self.headers(), &REQUEST_ID) + } +} + +mod private { + use crate::models::{ + AppendBlobClientAppendBlockFromUrlResult, AppendBlobClientAppendBlockResult, + AppendBlobClientCreateResult, AppendBlobClientSealResult, BlobClientAbortCopyFromUrlResult, + BlobClientAcquireLeaseResult, BlobClientBreakLeaseResult, BlobClientChangeLeaseResult, + BlobClientCopyFromUrlResult, BlobClientCreateSnapshotResult, + BlobClientDeleteImmutabilityPolicyResult, BlobClientDeleteResult, BlobClientDownloadResult, + BlobClientGetAccountInfoResult, BlobClientGetPropertiesResult, + BlobClientReleaseLeaseResult, BlobClientRenewLeaseResult, BlobClientSetExpiryResult, + BlobClientSetHttpHeadersResult, BlobClientSetImmutabilityPolicyResult, + BlobClientSetLegalHoldResult, BlobClientSetMetadataResult, BlobClientSetTagsResult, + BlobClientSetTierResult, BlobClientStartCopyFromUrlResult, BlobClientUndeleteResult, + BlobContainerClientAcquireLeaseResult, BlobContainerClientBreakLeaseResult, + BlobContainerClientChangeLeaseResult, BlobContainerClientCreateResult, + BlobContainerClientDeleteResult, BlobContainerClientGetAccountInfoResult, + BlobContainerClientGetPropertiesResult, BlobContainerClientReleaseLeaseResult, + BlobContainerClientRenameResult, BlobContainerClientRenewLeaseResult, + BlobContainerClientRestoreResult, BlobContainerClientSetAccessPolicyResult, + BlobContainerClientSetMetadataResult, BlobContainerClientSubmitBatchResult, + BlobServiceClientGetAccountInfoResult, BlobServiceClientSetPropertiesResult, + BlobServiceClientSubmitBatchResult, BlobTags, BlockBlobClientCommitBlockListResult, + BlockBlobClientPutBlobFromUrlResult, BlockBlobClientQueryResult, + BlockBlobClientStageBlockFromUrlResult, BlockBlobClientStageBlockResult, + BlockBlobClientUploadResult, BlockList, FilterBlobSegment, ListBlobsFlatSegmentResponse, + ListBlobsHierarchySegmentResponse, ListContainersSegmentResponse, + PageBlobClientClearPagesResult, PageBlobClientCopyIncrementalResult, + PageBlobClientCreateResult, PageBlobClientResizeResult, + PageBlobClientUpdateSequenceNumberResult, PageBlobClientUploadPagesFromUrlResult, + PageBlobClientUploadPagesResult, PageList, SignedIdentifier, StorageServiceProperties, + StorageServiceStats, UserDelegationKey, + }; + use azure_core::Response; + + pub trait Sealed {} + + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response {} + impl Sealed for Response> {} +} diff --git a/sdk/storage/azure_storage_blob/src/generated/mod.rs b/sdk/storage/azure_storage_blob/src/generated/mod.rs index 7661c41829..d02172de99 100644 --- a/sdk/storage/azure_storage_blob/src/generated/mod.rs +++ b/sdk/storage/azure_storage_blob/src/generated/mod.rs @@ -5,6 +5,7 @@ pub(crate) mod clients; pub(crate) mod enums; +pub(crate) mod header_traits; pub(crate) mod models; pub(crate) mod models_serde; mod xml_helpers; diff --git a/sdk/storage/azure_storage_blob/src/generated/models.rs b/sdk/storage/azure_storage_blob/src/generated/models.rs index 15964cdc4a..e4f8fd1c9e 100644 --- a/sdk/storage/azure_storage_blob/src/generated/models.rs +++ b/sdk/storage/azure_storage_blob/src/generated/models.rs @@ -3,12 +3,23 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT. -use crate::models::{GeoReplicationStatusType, QueryRequestType, QueryType}; +use crate::models::{ + AccessTier, ArchiveStatus, BlobImmutabilityPolicyMode, BlobType, CopyStatus, + GeoReplicationStatusType, LeaseDuration, LeaseState, LeaseStatus, PublicAccessType, + QueryRequestType, QueryType, RehydratePriority, +}; use crate::{ - generated::xml_helpers::Blob_tag_setBlobTag, generated::xml_helpers::BlobsFilterBlobItem, - generated::xml_helpers::CorsCorsRule, generated::xml_helpers::SchemaArrowField, + generated::xml_helpers::Blob_itemsBlobItemInternal, + generated::xml_helpers::Blob_prefixesBlobPrefix, generated::xml_helpers::Blob_tag_setBlobTag, + generated::xml_helpers::BlobsFilterBlobItem, generated::xml_helpers::Clear_rangeClearRange, + generated::xml_helpers::Committed_blocksBlock, + generated::xml_helpers::Container_itemsContainerItem, generated::xml_helpers::CorsCorsRule, + generated::xml_helpers::Page_rangePageRange, generated::xml_helpers::SchemaArrowField, + generated::xml_helpers::Uncommitted_blocksBlock, }; +use azure_core::base64; use serde::{Deserialize, Serialize}; +use std::collections::HashMap; use time::OffsetDateTime; use typespec_client_core::fmt::SafeDebug; @@ -39,6 +50,22 @@ pub struct AccessPolicy { pub start: Option, } +/// Contains results for [`AppendBlobClient::append_block_from_url()`](crate::AppendBlobClient::append_block_from_url()) +#[derive(SafeDebug)] +pub struct AppendBlobClientAppendBlockFromUrlResult; + +/// Contains results for [`AppendBlobClient::append_block()`](crate::AppendBlobClient::append_block()) +#[derive(SafeDebug)] +pub struct AppendBlobClientAppendBlockResult; + +/// Contains results for [`AppendBlobClient::create()`](crate::AppendBlobClient::create()) +#[derive(SafeDebug)] +pub struct AppendBlobClientCreateResult; + +/// Contains results for [`AppendBlobClient::seal()`](crate::AppendBlobClient::seal()) +#[derive(SafeDebug)] +pub struct AppendBlobClientSealResult; + /// Represents the Apache Arrow configuration. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] #[typespec(format = "xml")] @@ -48,10 +75,9 @@ pub struct ArrowConfiguration { default, deserialize_with = "SchemaArrowField::unwrap", rename = "Schema", - serialize_with = "SchemaArrowField::wrap", - skip_serializing_if = "Option::is_none" + serialize_with = "SchemaArrowField::wrap" )] - pub schema: Option>, + pub schema: Vec, } /// Represents an Apache Arrow field. @@ -76,6 +102,521 @@ pub struct ArrowField { pub type_prop: Option, } +/// Contains results for [`BlobClient::abort_copy_from_url()`](crate::BlobClient::abort_copy_from_url()) +#[derive(SafeDebug)] +pub struct BlobClientAbortCopyFromUrlResult; + +/// Contains results for [`BlobClient::acquire_lease()`](crate::BlobClient::acquire_lease()) +#[derive(SafeDebug)] +pub struct BlobClientAcquireLeaseResult; + +/// Contains results for [`BlobClient::break_lease()`](crate::BlobClient::break_lease()) +#[derive(SafeDebug)] +pub struct BlobClientBreakLeaseResult; + +/// Contains results for [`BlobClient::change_lease()`](crate::BlobClient::change_lease()) +#[derive(SafeDebug)] +pub struct BlobClientChangeLeaseResult; + +/// Contains results for [`BlobClient::copy_from_url()`](crate::BlobClient::copy_from_url()) +#[derive(SafeDebug)] +pub struct BlobClientCopyFromUrlResult; + +/// Contains results for [`BlobClient::create_snapshot()`](crate::BlobClient::create_snapshot()) +#[derive(SafeDebug)] +pub struct BlobClientCreateSnapshotResult; + +/// Contains results for [`BlobClient::delete_immutability_policy()`](crate::BlobClient::delete_immutability_policy()) +#[derive(SafeDebug)] +pub struct BlobClientDeleteImmutabilityPolicyResult; + +/// Contains results for [`BlobClient::delete()`](crate::BlobClient::delete()) +#[derive(SafeDebug)] +pub struct BlobClientDeleteResult; + +/// Contains results for [`BlobClient::download()`](crate::BlobClient::download()) +#[derive(SafeDebug)] +pub struct BlobClientDownloadResult; + +/// Contains results for [`BlobClient::get_account_info()`](crate::BlobClient::get_account_info()) +#[derive(SafeDebug)] +pub struct BlobClientGetAccountInfoResult; + +/// Contains results for [`BlobClient::get_properties()`](crate::BlobClient::get_properties()) +#[derive(SafeDebug)] +pub struct BlobClientGetPropertiesResult; + +/// Contains results for [`BlobClient::release_lease()`](crate::BlobClient::release_lease()) +#[derive(SafeDebug)] +pub struct BlobClientReleaseLeaseResult; + +/// Contains results for [`BlobClient::renew_lease()`](crate::BlobClient::renew_lease()) +#[derive(SafeDebug)] +pub struct BlobClientRenewLeaseResult; + +/// Contains results for [`BlobClient::set_expiry()`](crate::BlobClient::set_expiry()) +#[derive(SafeDebug)] +pub struct BlobClientSetExpiryResult; + +/// Contains results for [`BlobClient::set_http_headers()`](crate::BlobClient::set_http_headers()) +#[derive(SafeDebug)] +pub struct BlobClientSetHttpHeadersResult; + +/// Contains results for [`BlobClient::set_immutability_policy()`](crate::BlobClient::set_immutability_policy()) +#[derive(SafeDebug)] +pub struct BlobClientSetImmutabilityPolicyResult; + +/// Contains results for [`BlobClient::set_legal_hold()`](crate::BlobClient::set_legal_hold()) +#[derive(SafeDebug)] +pub struct BlobClientSetLegalHoldResult; + +/// Contains results for [`BlobClient::set_metadata()`](crate::BlobClient::set_metadata()) +#[derive(SafeDebug)] +pub struct BlobClientSetMetadataResult; + +/// Contains results for [`BlobClient::set_tags()`](crate::BlobClient::set_tags()) +#[derive(SafeDebug)] +pub struct BlobClientSetTagsResult; + +/// Contains results for [`BlobClient::set_tier()`](crate::BlobClient::set_tier()) +#[derive(SafeDebug)] +pub struct BlobClientSetTierResult; + +/// Contains results for [`BlobClient::start_copy_from_url()`](crate::BlobClient::start_copy_from_url()) +#[derive(SafeDebug)] +pub struct BlobClientStartCopyFromUrlResult; + +/// Contains results for [`BlobClient::undelete()`](crate::BlobClient::undelete()) +#[derive(SafeDebug)] +pub struct BlobClientUndeleteResult; + +/// Contains results for [`BlobContainerClient::acquire_lease()`](crate::BlobContainerClient::acquire_lease()) +#[derive(SafeDebug)] +pub struct BlobContainerClientAcquireLeaseResult; + +/// Contains results for [`BlobContainerClient::break_lease()`](crate::BlobContainerClient::break_lease()) +#[derive(SafeDebug)] +pub struct BlobContainerClientBreakLeaseResult; + +/// Contains results for [`BlobContainerClient::change_lease()`](crate::BlobContainerClient::change_lease()) +#[derive(SafeDebug)] +pub struct BlobContainerClientChangeLeaseResult; + +/// Contains results for [`BlobContainerClient::create()`](crate::BlobContainerClient::create()) +#[derive(SafeDebug)] +pub struct BlobContainerClientCreateResult; + +/// Contains results for [`BlobContainerClient::delete()`](crate::BlobContainerClient::delete()) +#[derive(SafeDebug)] +pub struct BlobContainerClientDeleteResult; + +/// Contains results for [`BlobContainerClient::get_account_info()`](crate::BlobContainerClient::get_account_info()) +#[derive(SafeDebug)] +pub struct BlobContainerClientGetAccountInfoResult; + +/// Contains results for [`BlobContainerClient::get_properties()`](crate::BlobContainerClient::get_properties()) +#[derive(SafeDebug)] +pub struct BlobContainerClientGetPropertiesResult; + +/// Contains results for [`BlobContainerClient::release_lease()`](crate::BlobContainerClient::release_lease()) +#[derive(SafeDebug)] +pub struct BlobContainerClientReleaseLeaseResult; + +/// Contains results for [`BlobContainerClient::rename()`](crate::BlobContainerClient::rename()) +#[derive(SafeDebug)] +pub struct BlobContainerClientRenameResult; + +/// Contains results for [`BlobContainerClient::renew_lease()`](crate::BlobContainerClient::renew_lease()) +#[derive(SafeDebug)] +pub struct BlobContainerClientRenewLeaseResult; + +/// Contains results for [`BlobContainerClient::restore()`](crate::BlobContainerClient::restore()) +#[derive(SafeDebug)] +pub struct BlobContainerClientRestoreResult; + +/// Contains results for [`BlobContainerClient::set_access_policy()`](crate::BlobContainerClient::set_access_policy()) +#[derive(SafeDebug)] +pub struct BlobContainerClientSetAccessPolicyResult; + +/// Contains results for [`BlobContainerClient::set_metadata()`](crate::BlobContainerClient::set_metadata()) +#[derive(SafeDebug)] +pub struct BlobContainerClientSetMetadataResult; + +/// Contains results for [`BlobContainerClient::submit_batch()`](crate::BlobContainerClient::submit_batch()) +#[derive(SafeDebug)] +pub struct BlobContainerClientSubmitBatchResult; + +/// The blob flat list segment. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "Blobs")] +#[typespec(format = "xml")] +pub struct BlobFlatListSegment { + /// The blob items. + #[serde( + default, + deserialize_with = "Blob_itemsBlobItemInternal::unwrap", + rename = "BlobItems", + serialize_with = "Blob_itemsBlobItemInternal::wrap" + )] + pub blob_items: Vec, +} + +/// Represents an array of blobs. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "Blobs")] +#[typespec(format = "xml")] +pub struct BlobHierarchyListSegment { + /// The blob items + #[serde( + default, + deserialize_with = "Blob_itemsBlobItemInternal::unwrap", + rename = "BlobItems", + serialize_with = "Blob_itemsBlobItemInternal::wrap" + )] + pub blob_items: Vec, + + /// The blob prefixes. + #[serde( + default, + deserialize_with = "Blob_prefixesBlobPrefix::unwrap", + rename = "BlobPrefixes", + serialize_with = "Blob_prefixesBlobPrefix::wrap" + )] + pub blob_prefixes: Vec, +} + +/// An Azure Storage Blob +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "Blob")] +#[typespec(format = "xml")] +pub struct BlobItemInternal { + /// The tags of the blob. + #[serde(rename = "BlobTags", skip_serializing_if = "Option::is_none")] + pub blob_tags: Option, + + /// Whether the blob is deleted. + #[serde(rename = "Deleted", skip_serializing_if = "Option::is_none")] + pub deleted: Option, + + /// Whether the blog has versions only. + #[serde(rename = "HasVersionsOnly", skip_serializing_if = "Option::is_none")] + pub has_versions_only: Option, + + /// Whether the blob is the current version. + #[serde(rename = "IsCurrentVersion", skip_serializing_if = "Option::is_none")] + pub is_current_version: Option, + + /// The metadata of the blob. + #[serde(rename = "Metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option, + + /// The name of the blob. + #[serde(rename = "Name", skip_serializing_if = "Option::is_none")] + pub name: Option, + + /// The object replication metadata of the blob. + #[serde( + rename = "ObjectReplicationMetadata", + skip_serializing_if = "Option::is_none" + )] + pub object_replication_metadata: Option, + + /// The properties of the blob. + #[serde(rename = "Properties", skip_serializing_if = "Option::is_none")] + pub properties: Option, + + /// The snapshot of the blob. + #[serde(rename = "Snapshot", skip_serializing_if = "Option::is_none")] + pub snapshot: Option, + + /// The version id of the blob. + #[serde(rename = "VersionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, +} + +/// The blob metadata. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct BlobMetadata { + /// Whether the blob metadata is encrypted. + #[serde(rename = "@Encrypted", skip_serializing_if = "Option::is_none")] + pub encrypted: Option, +} + +/// Represents a blob name. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct BlobName { + /// The blob name. + #[serde(rename = "$text", skip_serializing_if = "Option::is_none")] + pub content: Option, + + /// Whether the blob name is encoded. + #[serde(rename = "@Encoded", skip_serializing_if = "Option::is_none")] + pub encoded: Option, +} + +/// Represents a blob prefix. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct BlobPrefix { + /// The blob name. + #[serde(rename = "Name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +/// The properties of a blob. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "Properties")] +#[typespec(format = "xml")] +pub struct BlobPropertiesInternal { + /// The access tier of the blob. + #[serde(rename = "AccessTier", skip_serializing_if = "Option::is_none")] + pub access_tier: Option, + + /// The access tier change time of the blob. + #[serde( + default, + rename = "AccessTierChangeTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub access_tier_change_time: Option, + + /// Whether the access tier is inferred. + #[serde(rename = "AccessTierInferred", skip_serializing_if = "Option::is_none")] + pub access_tier_inferred: Option, + + /// The archive status of the blob. + #[serde(rename = "ArchiveStatus", skip_serializing_if = "Option::is_none")] + pub archive_status: Option, + + /// The sequence number of the blob. + #[serde( + rename = "x-ms-blob-sequence-number", + skip_serializing_if = "Option::is_none" + )] + pub blob_sequence_number: Option, + + /// The blob type. + #[serde(rename = "BlobType", skip_serializing_if = "Option::is_none")] + pub blob_type: Option, + + /// The cache control of the blob. + #[serde(rename = "Cache-Control", skip_serializing_if = "Option::is_none")] + pub cache_control: Option, + + /// The content disposition of the blob. + #[serde( + rename = "Content-Disposition", + skip_serializing_if = "Option::is_none" + )] + pub content_disposition: Option, + + /// The content encoding of the blob. + #[serde(rename = "Content-Encoding", skip_serializing_if = "Option::is_none")] + pub content_encoding: Option, + + /// The content language of the blob. + #[serde(rename = "Content-Language", skip_serializing_if = "Option::is_none")] + pub content_language: Option, + + /// The content length of the blob. + #[serde(rename = "Content-Length", skip_serializing_if = "Option::is_none")] + pub content_length: Option, + + /// The content MD5 of the blob. + #[serde( + default, + deserialize_with = "base64::deserialize", + rename = "Content-MD5", + serialize_with = "base64::serialize", + skip_serializing_if = "Option::is_none" + )] + pub content_md5: Option>, + + /// The content type of the blob. + #[serde(rename = "Content-Type", skip_serializing_if = "Option::is_none")] + pub content_type: Option, + + /// The copy completion time of the blob. + #[serde( + default, + rename = "CopyCompletionTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub copy_completion_time: Option, + + /// The copy ID of the blob. + #[serde(rename = "CopyId", skip_serializing_if = "Option::is_none")] + pub copy_id: Option, + + /// The copy progress of the blob. + #[serde(rename = "CopyProgress", skip_serializing_if = "Option::is_none")] + pub copy_progress: Option, + + /// The copy source of the blob. + #[serde(rename = "CopySource", skip_serializing_if = "Option::is_none")] + pub copy_source: Option, + + /// The copy status of the blob. + #[serde(rename = "CopyStatus", skip_serializing_if = "Option::is_none")] + pub copy_status: Option, + + /// The copy status description of the blob. + #[serde( + rename = "CopyStatusDescription", + skip_serializing_if = "Option::is_none" + )] + pub copy_status_description: Option, + + /// The date-time the blob was created in RFC1123 format. + #[serde( + default, + rename = "Creation-Time", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub creation_time: Option, + + /// Customer provided key sha256 + #[serde( + rename = "CustomerProvidedKeySha256", + skip_serializing_if = "Option::is_none" + )] + pub customer_provided_key_sha256: Option, + + /// The time the blob was deleted. + #[serde( + default, + rename = "DeletedTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub deleted_time: Option, + + /// The name of the destination snapshot. + #[serde( + rename = "DestinationSnapshot", + skip_serializing_if = "Option::is_none" + )] + pub destination_snapshot: Option, + + /// The blog ETag. + #[serde(rename = "ETag", skip_serializing_if = "Option::is_none")] + pub e_tag: Option, + + /// The encryption scope of the blob. + #[serde(rename = "EncryptionScope", skip_serializing_if = "Option::is_none")] + pub encryption_scope: Option, + + /// The expire time of the blob. + #[serde( + default, + rename = "Expiry-Time", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub expires_on: Option, + + /// The immutability policy until time of the blob. + #[serde( + default, + rename = "ImmutabilityPolicyUntilDate", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub immutability_policy_expires_on: Option, + + /// The immutability policy mode of the blob. + #[serde( + rename = "ImmutabilityPolicyMode", + skip_serializing_if = "Option::is_none" + )] + pub immutability_policy_mode: Option, + + /// Whether the blog is incremental copy. + #[serde(rename = "IncrementalCopy", skip_serializing_if = "Option::is_none")] + pub incremental_copy: Option, + + /// Whether the blob is sealed. + #[serde(rename = "Sealed", skip_serializing_if = "Option::is_none")] + pub is_sealed: Option, + + /// The last access time of the blob. + #[serde( + default, + rename = "LastAccessTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub last_accessed_on: Option, + + /// The date-time the blob was last modified in RFC1123 format. + #[serde( + default, + rename = "Last-Modified", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub last_modified: Option, + + /// The lease duration of the blob. + #[serde(rename = "LeaseDuration", skip_serializing_if = "Option::is_none")] + pub lease_duration: Option, + + /// The lease state of the blob. + #[serde(rename = "LeaseState", skip_serializing_if = "Option::is_none")] + pub lease_state: Option, + + /// The lease status of the blob. + #[serde(rename = "LeaseStatus", skip_serializing_if = "Option::is_none")] + pub lease_status: Option, + + /// Whether the blob is under legal hold. + #[serde(rename = "LegalHold", skip_serializing_if = "Option::is_none")] + pub legal_hold: Option, + + /// The rehydrate priority of the blob. + #[serde(rename = "RehydratePriority", skip_serializing_if = "Option::is_none")] + pub rehydrate_priority: Option, + + /// The remaining retention days of the blob. + #[serde( + rename = "RemainingRetentionDays", + skip_serializing_if = "Option::is_none" + )] + pub remaining_retention_days: Option, + + /// Whether the blog is encrypted on the server. + #[serde(rename = "ServerEncrypted", skip_serializing_if = "Option::is_none")] + pub server_encrypted: Option, + + /// The number of tags for the blob. + #[serde(rename = "TagCount", skip_serializing_if = "Option::is_none")] + pub tag_count: Option, +} + +/// Contains results for [`BlobServiceClient::get_account_info()`](crate::BlobServiceClient::get_account_info()) +#[derive(SafeDebug)] +pub struct BlobServiceClientGetAccountInfoResult; + +/// Contains results for [`BlobServiceClient::set_properties()`](crate::BlobServiceClient::set_properties()) +#[derive(SafeDebug)] +pub struct BlobServiceClientSetPropertiesResult; + +/// Contains results for [`BlobServiceClient::submit_batch()`](crate::BlobServiceClient::submit_batch()) +#[derive(SafeDebug)] +pub struct BlobServiceClientSubmitBatchResult; + /// The blob tags. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] #[serde(rename = "Tag")] @@ -100,10 +641,71 @@ pub struct BlobTags { default, deserialize_with = "Blob_tag_setBlobTag::unwrap", rename = "TagSet", - serialize_with = "Blob_tag_setBlobTag::wrap", - skip_serializing_if = "Option::is_none" + serialize_with = "Blob_tag_setBlobTag::wrap" + )] + pub blob_tag_set: Vec, +} + +/// Represents a single block in a block blob. It describes the block's ID and size. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct Block { + /// The base64 encoded block ID. + #[serde(rename = "Name", skip_serializing_if = "Option::is_none")] + pub name: Option, + + /// The block size in bytes. + #[serde(rename = "Size", skip_serializing_if = "Option::is_none")] + pub size: Option, +} + +/// Contains results for [`BlockBlobClient::commit_block_list()`](crate::BlockBlobClient::commit_block_list()) +#[derive(SafeDebug)] +pub struct BlockBlobClientCommitBlockListResult; + +/// Contains results for [`BlockBlobClient::put_blob_from_url()`](crate::BlockBlobClient::put_blob_from_url()) +#[derive(SafeDebug)] +pub struct BlockBlobClientPutBlobFromUrlResult; + +/// Contains results for [`BlockBlobClient::query()`](crate::BlockBlobClient::query()) +#[derive(SafeDebug)] +pub struct BlockBlobClientQueryResult; + +/// Contains results for [`BlockBlobClient::stage_block_from_url()`](crate::BlockBlobClient::stage_block_from_url()) +#[derive(SafeDebug)] +pub struct BlockBlobClientStageBlockFromUrlResult; + +/// Contains results for [`BlockBlobClient::stage_block()`](crate::BlockBlobClient::stage_block()) +#[derive(SafeDebug)] +pub struct BlockBlobClientStageBlockResult; + +/// Contains results for [`BlockBlobClient::upload()`](crate::BlockBlobClient::upload()) +#[derive(SafeDebug)] +pub struct BlockBlobClientUploadResult; + +/// Contains the committed and uncommitted blocks in a block blob. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct BlockList { + /// The list of committed blocks. + #[serde( + default, + deserialize_with = "Committed_blocksBlock::unwrap", + rename = "CommittedBlocks", + serialize_with = "Committed_blocksBlock::wrap" + )] + pub committed_blocks: Vec, + + /// The list of uncommitted blocks. + #[serde( + default, + deserialize_with = "Uncommitted_blocksBlock::unwrap", + rename = "UncommittedBlocks", + serialize_with = "Uncommitted_blocksBlock::wrap" )] - pub blob_tag_set: Option>, + pub uncommitted_blocks: Vec, } /// The Block lookup list. @@ -112,16 +714,144 @@ pub struct BlobTags { #[typespec(format = "xml")] pub struct BlockLookupList { /// The committed blocks - #[serde(rename = "Committed", skip_serializing_if = "Option::is_none")] - pub committed: Option>, + #[serde(default, rename = "Committed")] + pub committed: Vec, /// The latest blocks - #[serde(rename = "Latest", skip_serializing_if = "Option::is_none")] - pub latest: Option>, + #[serde(default, rename = "Latest")] + pub latest: Vec, /// The uncommitted blocks - #[serde(rename = "Uncommitted", skip_serializing_if = "Option::is_none")] - pub uncommitted: Option>, + #[serde(default, rename = "Uncommitted")] + pub uncommitted: Vec, +} + +/// The clear range. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct ClearRange { + /// The end of the byte range. + #[serde(rename = "End", skip_serializing_if = "Option::is_none")] + pub end: Option, + + /// The start of the byte range. + #[serde(rename = "Start", skip_serializing_if = "Option::is_none")] + pub start: Option, +} + +/// An Azure Storage container. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "Container")] +#[typespec(format = "xml")] +pub struct ContainerItem { + /// Whether the container is deleted. + #[serde(rename = "Deleted", skip_serializing_if = "Option::is_none")] + pub delete: Option, + + /// The metadata of the container. + #[serde( + default, + rename = "Metadata", + skip_serializing_if = "HashMap::is_empty" + )] + pub metadata: HashMap, + + /// The name of the container. + #[serde(rename = "Name", skip_serializing_if = "Option::is_none")] + pub name: Option, + + /// The properties of the container. + #[serde(rename = "Properties", skip_serializing_if = "Option::is_none")] + pub properties: Option, + + /// The version of the container. + #[serde(rename = "Version", skip_serializing_if = "Option::is_none")] + pub version: Option, +} + +/// The properties of a container. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct ContainerProperties { + /// The default encryption scope of the container. + #[serde( + rename = "DefaultEncryptionScope", + skip_serializing_if = "Option::is_none" + )] + pub default_encryption_scope: Option, + + /// The deleted time of the container. + #[serde( + default, + rename = "DeletedTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub deleted_time: Option, + + /// The ETag of the container. + #[serde(rename = "ETag", skip_serializing_if = "Option::is_none")] + pub e_tag: Option, + + /// Whether it has an immutability policy. + #[serde( + rename = "HasImmutabilityPolicy", + skip_serializing_if = "Option::is_none" + )] + pub has_immutability_policy: Option, + + /// The has legal hold status of the container. + #[serde(rename = "HasLegalHold", skip_serializing_if = "Option::is_none")] + pub has_legal_hold: Option, + + /// Whether immutable storage with versioning is enabled. + #[serde( + rename = "ImmutableStorageWithVersioningEnabled", + skip_serializing_if = "Option::is_none" + )] + pub is_immutable_storage_with_versioning_enabled: Option, + + /// The date-time the container was last modified in RFC1123 format. + #[serde( + default, + rename = "Last-Modified", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub last_modified: Option, + + /// The lease duration of the container. + #[serde(rename = "LeaseDuration", skip_serializing_if = "Option::is_none")] + pub lease_duration: Option, + + /// The lease state of the container. + #[serde(rename = "LeaseState", skip_serializing_if = "Option::is_none")] + pub lease_state: Option, + + /// The lease status of the container. + #[serde(rename = "LeaseStatus", skip_serializing_if = "Option::is_none")] + pub lease_status: Option, + + /// Whether to prevent encryption scope override. + #[serde( + rename = "DenyEncryptionScopeOverride", + skip_serializing_if = "Option::is_none" + )] + pub prevent_encryption_scope_override: Option, + + /// The public access type of the container. + #[serde(rename = "PublicAccess", skip_serializing_if = "Option::is_none")] + pub public_access: Option, + + /// The remaining retention days of the container. + #[serde( + rename = "RemainingRetentionDays", + skip_serializing_if = "Option::is_none" + )] + pub remaining_retention_days: Option, } /// CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. @@ -214,10 +944,9 @@ pub struct FilterBlobSegment { default, deserialize_with = "BlobsFilterBlobItem::unwrap", rename = "Blobs", - serialize_with = "BlobsFilterBlobItem::wrap", - skip_serializing_if = "Option::is_none" + serialize_with = "BlobsFilterBlobItem::wrap" )] - pub blobs: Option>, + pub blobs: Vec, /// The next marker of the blobs. #[serde(rename = "NextMarker", skip_serializing_if = "Option::is_none")] @@ -239,8 +968,13 @@ pub struct FilterBlobSegment { pub struct GeoReplication { /// A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available for read /// operations at the secondary. Primary writes after this point in time may or may not be available for reads. - #[serde(rename = "LastSyncTime", skip_serializing_if = "Option::is_none")] - pub last_sync_time: Option, + #[serde( + default, + rename = "LastSyncTime", + skip_serializing_if = "Option::is_none", + with = "azure_core::date::rfc7231::option" + )] + pub last_sync_time: Option, /// The status of the secondary location #[serde(rename = "Status", skip_serializing_if = "Option::is_none")] @@ -256,6 +990,116 @@ pub struct JsonTextConfiguration { pub record_separator: Option, } +/// An enumeration of blobs. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "EnumerationResults")] +#[typespec(format = "xml")] +pub struct ListBlobsFlatSegmentResponse { + /// The container name. + #[serde(rename = "@ContainerName", skip_serializing_if = "Option::is_none")] + pub container_name: Option, + + /// The marker of the blobs. + #[serde(rename = "Marker", skip_serializing_if = "Option::is_none")] + pub marker: Option, + + /// The max results of the blobs. + #[serde(rename = "MaxResults", skip_serializing_if = "Option::is_none")] + pub max_results: Option, + + /// The next marker of the blobs. + #[serde(rename = "NextMarker", skip_serializing_if = "Option::is_none")] + pub next_marker: Option, + + /// The prefix of the blobs. + #[serde(rename = "Prefix", skip_serializing_if = "Option::is_none")] + pub prefix: Option, + + /// The blob segment. + #[serde(skip_serializing_if = "Option::is_none")] + pub segment: Option, + + /// The service endpoint. + #[serde(rename = "@ServiceEndpoint", skip_serializing_if = "Option::is_none")] + pub service_endpoint: Option, +} + +/// An enumeration of blobs +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "EnumerationResults")] +#[typespec(format = "xml")] +pub struct ListBlobsHierarchySegmentResponse { + /// The container name. + #[serde(rename = "@ContainerName", skip_serializing_if = "Option::is_none")] + pub container_name: Option, + + /// The delimiter of the blobs. + #[serde(rename = "Delimiter", skip_serializing_if = "Option::is_none")] + pub delimiter: Option, + + /// The marker of the blobs. + #[serde(rename = "Marker", skip_serializing_if = "Option::is_none")] + pub marker: Option, + + /// The max results of the blobs. + #[serde(rename = "MaxResults", skip_serializing_if = "Option::is_none")] + pub max_results: Option, + + /// The next marker of the blobs. + #[serde(rename = "NextMarker", skip_serializing_if = "Option::is_none")] + pub next_marker: Option, + + /// The prefix of the blobs. + #[serde(rename = "Prefix", skip_serializing_if = "Option::is_none")] + pub prefix: Option, + + /// The blob segment. + #[serde(skip_serializing_if = "Option::is_none")] + pub segment: Option, + + /// The service endpoint. + #[serde(rename = "@ServiceEndpoint", skip_serializing_if = "Option::is_none")] + pub service_endpoint: Option, +} + +/// The list container segment response +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "EnumerationResults")] +#[typespec(format = "xml")] +pub struct ListContainersSegmentResponse { + /// The container segment. + #[serde( + default, + deserialize_with = "Container_itemsContainerItem::unwrap", + rename = "Containers", + serialize_with = "Container_itemsContainerItem::wrap" + )] + pub container_items: Vec, + + /// The marker of the containers. + #[serde(rename = "Marker", skip_serializing_if = "Option::is_none")] + pub marker: Option, + + /// The max results of the containers. + #[serde(rename = "MaxResults", skip_serializing_if = "Option::is_none")] + pub max_results: Option, + + /// The next marker of the containers. + #[serde(rename = "NextMarker", skip_serializing_if = "Option::is_none")] + pub next_marker: Option, + + /// The prefix of the containers. + #[serde(rename = "Prefix", skip_serializing_if = "Option::is_none")] + pub prefix: Option, + + /// The service endpoint. + #[serde(rename = "@ServiceEndpoint", skip_serializing_if = "Option::is_none")] + pub service_endpoint: Option, +} + /// Azure Analytics Logging settings. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] #[typespec(format = "xml")] @@ -302,6 +1146,83 @@ pub struct Metrics { pub version: Option, } +/// The object replication metadata. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[serde(rename = "OrMetadata")] +#[typespec(format = "xml")] +pub struct ObjectReplicationMetadata {} + +/// Contains results for [`PageBlobClient::clear_pages()`](crate::PageBlobClient::clear_pages()) +#[derive(SafeDebug)] +pub struct PageBlobClientClearPagesResult; + +/// Contains results for [`PageBlobClient::copy_incremental()`](crate::PageBlobClient::copy_incremental()) +#[derive(SafeDebug)] +pub struct PageBlobClientCopyIncrementalResult; + +/// Contains results for [`PageBlobClient::create()`](crate::PageBlobClient::create()) +#[derive(SafeDebug)] +pub struct PageBlobClientCreateResult; + +/// Contains results for [`PageBlobClient::resize()`](crate::PageBlobClient::resize()) +#[derive(SafeDebug)] +pub struct PageBlobClientResizeResult; + +/// Contains results for [`PageBlobClient::update_sequence_number()`](crate::PageBlobClient::update_sequence_number()) +#[derive(SafeDebug)] +pub struct PageBlobClientUpdateSequenceNumberResult; + +/// Contains results for [`PageBlobClient::upload_pages_from_url()`](crate::PageBlobClient::upload_pages_from_url()) +#[derive(SafeDebug)] +pub struct PageBlobClientUploadPagesFromUrlResult; + +/// Contains results for [`PageBlobClient::upload_pages()`](crate::PageBlobClient::upload_pages()) +#[derive(SafeDebug)] +pub struct PageBlobClientUploadPagesResult; + +/// Represents a page list. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct PageList { + /// The clear ranges. + #[serde( + default, + deserialize_with = "Clear_rangeClearRange::unwrap", + rename = "ClearRange", + serialize_with = "Clear_rangeClearRange::wrap" + )] + pub clear_range: Vec, + + /// The next marker. + #[serde(rename = "NextMarker", skip_serializing_if = "Option::is_none")] + pub next_marker: Option, + + /// The page ranges. + #[serde( + default, + deserialize_with = "Page_rangePageRange::unwrap", + rename = "PageRange", + serialize_with = "Page_rangePageRange::wrap" + )] + pub page_range: Vec, +} + +/// The page range. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] +#[non_exhaustive] +#[typespec(format = "xml")] +pub struct PageRange { + /// The end of the byte range. + #[serde(rename = "End", skip_serializing_if = "Option::is_none")] + pub end: Option, + + /// The start of the byte range. + #[serde(rename = "Start", skip_serializing_if = "Option::is_none")] + pub start: Option, +} + /// Represents the Parquet configuration. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize, azure_core::Model)] #[typespec(format = "xml")] @@ -445,10 +1366,9 @@ pub struct StorageServiceProperties { default, deserialize_with = "CorsCorsRule::unwrap", rename = "Cors", - serialize_with = "CorsCorsRule::wrap", - skip_serializing_if = "Option::is_none" + serialize_with = "CorsCorsRule::wrap" )] - pub cors: Option>, + pub cors: Vec, /// The default service version. #[serde( diff --git a/sdk/storage/azure_storage_blob/src/generated/xml_helpers.rs b/sdk/storage/azure_storage_blob/src/generated/xml_helpers.rs index 53de379545..9afec0cf2c 100644 --- a/sdk/storage/azure_storage_blob/src/generated/xml_helpers.rs +++ b/sdk/storage/azure_storage_blob/src/generated/xml_helpers.rs @@ -6,25 +6,80 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -use crate::models::{ArrowField, BlobTag, CorsRule, FilterBlobItem}; +use crate::models::{ + ArrowField, BlobItemInternal, BlobPrefix, BlobTag, Block, ClearRange, ContainerItem, CorsRule, + FilterBlobItem, PageRange, +}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +#[derive(Deserialize, Serialize)] +#[serde(rename = "BlobItems")] +pub struct Blob_itemsBlobItemInternal { + #[serde(default)] + BlobItemInternal: Vec, +} + +impl Blob_itemsBlobItemInternal { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Blob_itemsBlobItemInternal::deserialize(deserializer)?.BlobItemInternal) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Blob_itemsBlobItemInternal { + BlobItemInternal: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + +#[derive(Deserialize, Serialize)] +#[serde(rename = "BlobPrefixes")] +pub struct Blob_prefixesBlobPrefix { + #[serde(default)] + BlobPrefix: Vec, +} + +impl Blob_prefixesBlobPrefix { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Blob_prefixesBlobPrefix::deserialize(deserializer)?.BlobPrefix) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Blob_prefixesBlobPrefix { + BlobPrefix: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + #[derive(Deserialize, Serialize)] #[serde(rename = "TagSet")] pub struct Blob_tag_setBlobTag { #[serde(default)] - BlobTag: Option>, + BlobTag: Vec, } impl Blob_tag_setBlobTag { - pub fn unwrap<'de, D>(deserializer: D) -> Result>, D::Error> + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { Ok(Blob_tag_setBlobTag::deserialize(deserializer)?.BlobTag) } - pub fn wrap(to_serialize: &Option>, serializer: S) -> Result + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result where S: Serializer, { @@ -39,21 +94,18 @@ impl Blob_tag_setBlobTag { #[serde(rename = "Blobs")] pub struct BlobsFilterBlobItem { #[serde(default)] - FilterBlobItem: Option>, + FilterBlobItem: Vec, } impl BlobsFilterBlobItem { - pub fn unwrap<'de, D>(deserializer: D) -> Result>, D::Error> + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { Ok(BlobsFilterBlobItem::deserialize(deserializer)?.FilterBlobItem) } - pub fn wrap( - to_serialize: &Option>, - serializer: S, - ) -> Result + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result where S: Serializer, { @@ -64,22 +116,100 @@ impl BlobsFilterBlobItem { } } +#[derive(Deserialize, Serialize)] +#[serde(rename = "ClearRange")] +pub struct Clear_rangeClearRange { + #[serde(default)] + ClearRange: Vec, +} + +impl Clear_rangeClearRange { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Clear_rangeClearRange::deserialize(deserializer)?.ClearRange) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Clear_rangeClearRange { + ClearRange: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + +#[derive(Deserialize, Serialize)] +#[serde(rename = "CommittedBlocks")] +pub struct Committed_blocksBlock { + #[serde(default)] + Block: Vec, +} + +impl Committed_blocksBlock { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Committed_blocksBlock::deserialize(deserializer)?.Block) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Committed_blocksBlock { + Block: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + +#[derive(Deserialize, Serialize)] +#[serde(rename = "Containers")] +pub struct Container_itemsContainerItem { + #[serde(default)] + ContainerItem: Vec, +} + +impl Container_itemsContainerItem { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Container_itemsContainerItem::deserialize(deserializer)?.ContainerItem) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Container_itemsContainerItem { + ContainerItem: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + #[derive(Deserialize, Serialize)] #[serde(rename = "Cors")] pub struct CorsCorsRule { #[serde(default)] - CorsRule: Option>, + CorsRule: Vec, } impl CorsCorsRule { - pub fn unwrap<'de, D>(deserializer: D) -> Result>, D::Error> + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { Ok(CorsCorsRule::deserialize(deserializer)?.CorsRule) } - pub fn wrap(to_serialize: &Option>, serializer: S) -> Result + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result where S: Serializer, { @@ -90,22 +220,48 @@ impl CorsCorsRule { } } +#[derive(Deserialize, Serialize)] +#[serde(rename = "PageRange")] +pub struct Page_rangePageRange { + #[serde(default)] + PageRange: Vec, +} + +impl Page_rangePageRange { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Page_rangePageRange::deserialize(deserializer)?.PageRange) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Page_rangePageRange { + PageRange: to_serialize.to_owned(), + } + .serialize(serializer) + } +} + #[derive(Deserialize, Serialize)] #[serde(rename = "Schema")] pub struct SchemaArrowField { #[serde(default)] - ArrowField: Option>, + ArrowField: Vec, } impl SchemaArrowField { - pub fn unwrap<'de, D>(deserializer: D) -> Result>, D::Error> + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { Ok(SchemaArrowField::deserialize(deserializer)?.ArrowField) } - pub fn wrap(to_serialize: &Option>, serializer: S) -> Result + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result where S: Serializer, { @@ -115,3 +271,29 @@ impl SchemaArrowField { .serialize(serializer) } } + +#[derive(Deserialize, Serialize)] +#[serde(rename = "UncommittedBlocks")] +pub struct Uncommitted_blocksBlock { + #[serde(default)] + Block: Vec, +} + +impl Uncommitted_blocksBlock { + pub fn unwrap<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + Ok(Uncommitted_blocksBlock::deserialize(deserializer)?.Block) + } + + pub fn wrap(to_serialize: &Vec, serializer: S) -> Result + where + S: Serializer, + { + Uncommitted_blocksBlock { + Block: to_serialize.to_owned(), + } + .serialize(serializer) + } +} diff --git a/sdk/storage/azure_storage_blob/src/lib.rs b/sdk/storage/azure_storage_blob/src/lib.rs index 59e2293fd3..9bdc537cf8 100644 --- a/sdk/storage/azure_storage_blob/src/lib.rs +++ b/sdk/storage/azure_storage_blob/src/lib.rs @@ -11,66 +11,66 @@ pub mod clients { pub mod blob_container_client; pub mod blob_service_client; + pub use crate::generated::clients::{ + AppendBlobClient, AppendBlobClientOptions, BlobClient as GeneratedBlobClient, + BlobClientOptions, BlobContainerClient, BlobContainerClientOptions, BlobServiceClient, + BlobServiceClientOptions, BlockBlobClient, BlockBlobClientOptions, PageBlobClient, + PageBlobClientOptions, + }; pub use blob_client::BlobClient; pub use blob_container_client::BlobContainerClient as ContainerClient; pub use blob_service_client::BlobServiceClient as ServiceClient; - - pub use crate::generated::clients::{ - BlobAppendBlobClient, BlobBlobClient, BlobBlockBlobClient, - BlobClient as GeneratedBlobClient, BlobClientOptions, BlobContainerClient, - BlobPageBlobClient, BlobServiceClient, - }; } pub mod models { pub use crate::generated::clients::method_options::{ - BlobAppendBlobClientAppendBlockFromUrlOptions, BlobAppendBlobClientAppendBlockOptions, - BlobAppendBlobClientCreateOptions, BlobAppendBlobClientSealOptions, - BlobBlobClientAbortCopyFromUrlOptions, BlobBlobClientAcquireLeaseOptions, - BlobBlobClientBreakLeaseOptions, BlobBlobClientChangeLeaseOptions, - BlobBlobClientCopyFromUrlOptions, BlobBlobClientCreateSnapshotOptions, - BlobBlobClientDeleteImmutabilityPolicyOptions, BlobBlobClientDeleteOptions, - BlobBlobClientDownloadOptions, BlobBlobClientGetAccountInfoOptions, - BlobBlobClientGetPropertiesOptions, BlobBlobClientGetTagsOptions, - BlobBlobClientQueryOptions, BlobBlobClientReleaseLeaseOptions, - BlobBlobClientRenewLeaseOptions, BlobBlobClientSetExpiryOptions, - BlobBlobClientSetHttpHeadersOptions, BlobBlobClientSetImmutabilityPolicyOptions, - BlobBlobClientSetLegalHoldOptions, BlobBlobClientSetMetadataOptions, - BlobBlobClientSetTagsOptions, BlobBlobClientSetTierOptions, - BlobBlobClientStartCopyFromUrlOptions, BlobBlobClientUndeleteOptions, - BlobBlockBlobClientCommitBlockListOptions, BlobBlockBlobClientGetBlockListOptions, - BlobBlockBlobClientPutBlobFromUrlOptions, BlobBlockBlobClientStageBlockFromUrlOptions, - BlobBlockBlobClientStageBlockOptions, BlobBlockBlobClientUploadOptions, + AppendBlobClientAppendBlockFromUrlOptions, AppendBlobClientAppendBlockOptions, + AppendBlobClientCreateOptions, AppendBlobClientSealOptions, + BlobClientAbortCopyFromUrlOptions, BlobClientAcquireLeaseOptions, + BlobClientBreakLeaseOptions, BlobClientChangeLeaseOptions, BlobClientCopyFromUrlOptions, + BlobClientCreateSnapshotOptions, BlobClientDeleteImmutabilityPolicyOptions, + BlobClientDeleteOptions, BlobClientDownloadOptions, BlobClientGetAccountInfoOptions, + BlobClientGetPropertiesOptions, BlobClientGetTagsOptions, BlobClientReleaseLeaseOptions, + BlobClientRenewLeaseOptions, BlobClientSetExpiryOptions, BlobClientSetHttpHeadersOptions, + BlobClientSetImmutabilityPolicyOptions, BlobClientSetLegalHoldOptions, + BlobClientSetMetadataOptions, BlobClientSetTagsOptions, BlobClientSetTierOptions, + BlobClientStartCopyFromUrlOptions, BlobClientUndeleteOptions, BlobContainerClientAcquireLeaseOptions, BlobContainerClientBreakLeaseOptions, BlobContainerClientChangeLeaseOptions, BlobContainerClientCreateOptions, BlobContainerClientDeleteOptions, BlobContainerClientFilterBlobsOptions, BlobContainerClientGetAccessPolicyOptions, BlobContainerClientGetAccountInfoOptions, - BlobContainerClientGetPropertiesOptions, BlobContainerClientReleaseLeaseOptions, + BlobContainerClientGetPropertiesOptions, BlobContainerClientListBlobFlatSegmentOptions, + BlobContainerClientListBlobHierarchySegmentOptions, BlobContainerClientReleaseLeaseOptions, BlobContainerClientRenameOptions, BlobContainerClientRenewLeaseOptions, BlobContainerClientRestoreOptions, BlobContainerClientSetAccessPolicyOptions, BlobContainerClientSetMetadataOptions, BlobContainerClientSubmitBatchOptions, - BlobPageBlobClientClearPagesOptions, BlobPageBlobClientCopyIncrementalOptions, - BlobPageBlobClientCreateOptions, BlobPageBlobClientResizeOptions, - BlobPageBlobClientUpdateSequenceNumberOptions, BlobPageBlobClientUploadPagesFromUrlOptions, - BlobPageBlobClientUploadPagesOptions, BlobServiceClientFilterBlobsOptions, - BlobServiceClientGetAccountInfoOptions, BlobServiceClientGetPropertiesOptions, - BlobServiceClientGetStatisticsOptions, BlobServiceClientGetUserDelegationKeyOptions, - BlobServiceClientSetPropertiesOptions, BlobServiceClientSubmitBatchOptions, + BlobServiceClientFilterBlobsOptions, BlobServiceClientGetAccountInfoOptions, + BlobServiceClientGetPropertiesOptions, BlobServiceClientGetStatisticsOptions, + BlobServiceClientGetUserDelegationKeyOptions, + BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions, + BlobServiceClientSubmitBatchOptions, BlockBlobClientCommitBlockListOptions, + BlockBlobClientGetBlockListOptions, BlockBlobClientPutBlobFromUrlOptions, + BlockBlobClientQueryOptions, BlockBlobClientStageBlockFromUrlOptions, + BlockBlobClientStageBlockOptions, BlockBlobClientUploadOptions, + PageBlobClientClearPagesOptions, PageBlobClientCopyIncrementalOptions, + PageBlobClientCreateOptions, PageBlobClientGetPageRangesDiffOptions, + PageBlobClientGetPageRangesOptions, PageBlobClientResizeOptions, + PageBlobClientUpdateSequenceNumberOptions, PageBlobClientUploadPagesFromUrlOptions, + PageBlobClientUploadPagesOptions, }; pub use crate::generated::enums::*; + pub use crate::generated::header_traits::*; pub use crate::generated::models::*; - mod blob_properties; - pub use blob_properties::BlobProperties; - - mod container_properties; - pub use container_properties::ContainerProperties; - mod blob_block; pub use blob_block::BlobBlock; } -pub use crate::generated::clients::{BlobClient, BlobClientOptions}; +pub use crate::generated::clients::{ + AppendBlobClient, AppendBlobClientOptions, BlobClient, BlobClientOptions, BlobContainerClient, + BlobContainerClientOptions, BlobServiceClient, BlobServiceClientOptions, BlockBlobClient, + BlockBlobClientOptions, PageBlobClient, PageBlobClientOptions, +}; // END GENERATED CODE pub(crate) mod pipeline; diff --git a/sdk/storage/azure_storage_blob/tsp-location.yaml b/sdk/storage/azure_storage_blob/tsp-location.yaml index f8f090e91d..7019852de3 100644 --- a/sdk/storage/azure_storage_blob/tsp-location.yaml +++ b/sdk/storage/azure_storage_blob/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/storage/Microsoft.BlobStorage -commit: 297b89f87399d99e625a4a9bbed4a43b440b036c +commit: 64026697c400e05f19b5ec6ca4f6efaf290113f8 repo: Azure/azure-rest-api-specs additionalDirectories: From 98ede470d0fb0e066026c6189b6934b09834907b Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 12:37:27 -0800 Subject: [PATCH 2/7] nit --- .../src/clients/blob_container_client.rs | 7 +++---- .../azure_storage_blob/src/clients/blob_service_client.rs | 8 ++++---- sdk/storage/azure_storage_blob/src/lib.rs | 7 ++++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs index 7a5314b4bc..c4e6a859fd 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -use crate::clients::BlobContainerClient as GenBlobContainerClient; +use crate::clients::GeneratedBlobContainerClient; use crate::models::{ BlobContainerClientCreateOptions, BlobContainerClientCreateResult, BlobContainerClientDeleteOptions, BlobContainerClientDeleteResult, BlobContainerClientGetPropertiesOptions, BlobContainerClientGetPropertiesResult, - ContainerProperties, }; use crate::pipeline::StorageHeadersPolicy; use crate::BlobContainerClientOptions; @@ -18,7 +17,7 @@ use std::sync::Arc; pub struct BlobContainerClient { endpoint: Url, container_name: String, - client: GenBlobContainerClient, + client: GeneratedBlobContainerClient, } impl BlobContainerClient { @@ -45,7 +44,7 @@ impl BlobContainerClient { .per_try_policies .push(Arc::new(oauth_token_policy) as Arc); - let client = GenBlobContainerClient::new( + let client = GeneratedBlobContainerClient::new( endpoint, credential, container_name.clone(), diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs index 46c768c43e..ba80b02b11 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs @@ -2,10 +2,10 @@ // Licensed under the MIT License. use crate::{ - clients::BlobServiceClient as GenBlobServiceClient, + clients::GeneratedBlobServiceClient, models::{BlobServiceClientGetPropertiesOptions, StorageServiceProperties}, pipeline::StorageHeadersPolicy, - BlobClientOptions, BlobServiceClientOptions, + BlobServiceClientOptions, }; use azure_core::{ credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url, @@ -14,7 +14,7 @@ use std::sync::Arc; pub struct BlobServiceClient { endpoint: Url, - client: GenBlobServiceClient, + client: GeneratedBlobServiceClient, } impl BlobServiceClient { @@ -40,7 +40,7 @@ impl BlobServiceClient { .per_try_policies .push(Arc::new(oauth_token_policy) as Arc); - let client = GenBlobServiceClient::new(endpoint, credential, Some(options))?; + let client = GeneratedBlobServiceClient::new(endpoint, credential, Some(options))?; Ok(Self { endpoint: endpoint.parse()?, diff --git a/sdk/storage/azure_storage_blob/src/lib.rs b/sdk/storage/azure_storage_blob/src/lib.rs index 9bdc537cf8..da2b08db94 100644 --- a/sdk/storage/azure_storage_blob/src/lib.rs +++ b/sdk/storage/azure_storage_blob/src/lib.rs @@ -13,13 +13,14 @@ pub mod clients { pub use crate::generated::clients::{ AppendBlobClient, AppendBlobClientOptions, BlobClient as GeneratedBlobClient, - BlobClientOptions, BlobContainerClient, BlobContainerClientOptions, BlobServiceClient, + BlobClientOptions, BlobContainerClient as GeneratedBlobContainerClient, + BlobContainerClientOptions, BlobServiceClient as GeneratedBlobServiceClient, BlobServiceClientOptions, BlockBlobClient, BlockBlobClientOptions, PageBlobClient, PageBlobClientOptions, }; pub use blob_client::BlobClient; - pub use blob_container_client::BlobContainerClient as ContainerClient; - pub use blob_service_client::BlobServiceClient as ServiceClient; + pub use blob_container_client::BlobContainerClient; + pub use blob_service_client::BlobServiceClient; } pub mod models { From 333ad3627b4b1bd92435ebd245595ada7e7a698f Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 16:40:02 -0800 Subject: [PATCH 3/7] Attempt at bringing fowrard tests, failing peculiarly --- .../src/clients/blob_client.rs | 1 + .../azure_storage_blob/tests/blob_client.rs | 674 ++++++++++-------- .../tests/blob_container_client.rs | 154 ++-- 3 files changed, 440 insertions(+), 389 deletions(-) diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs index f6c6b70e44..d213d7cfcb 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs @@ -129,6 +129,7 @@ impl BlobClient { let response = block_blob_client .upload(data, content_length, Some(options)) .await?; + println!("Resp inside of upload_blob API: {:?}", response); Ok(response) } diff --git a/sdk/storage/azure_storage_blob/tests/blob_client.rs b/sdk/storage/azure_storage_blob/tests/blob_client.rs index 16449b3898..82ab9db293 100644 --- a/sdk/storage/azure_storage_blob/tests/blob_client.rs +++ b/sdk/storage/azure_storage_blob/tests/blob_client.rs @@ -4,13 +4,60 @@ use azure_core::{headers::HeaderName, Bytes, RequestContent, StatusCode}; use azure_core_test::{recorded, TestContext}; use azure_storage_blob::{ - clients::{BlobClient, ContainerClient}, + clients::{BlobClient, BlobContainerClient}, models::{BlobBlock, BlobType, BlockLookupList}, - BlobClientOptions, + BlobClientOptions, BlobContainerClientOptions, }; use azure_storage_blob_test::recorded_test_setup; use std::error::Error; +// #[recorded::test(live)] +// async fn test_get_blob_properties_live() -> Result<(), Box> { +// // Live Resource Setup + +// use azure_identity::DefaultAzureCredentialBuilder; +// let container_name = "testcontainer01".to_string(); +// let blob_name = "testblob001".to_string(); +// let endpoint = format!("https://{}.blob.core.windows.net/", "ruststoragedev"); +// let credential = DefaultAzureCredentialBuilder::default().build()?; + +// // Act +// let container_client = BlobContainerClient::new( +// &endpoint, +// container_name.clone(), +// credential.clone(), +// None, // default options bag +// )?; +// container_client.create_container(None).await?; + +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// credential, +// None, // default options bag +// )?; +// let data = b"hello rusty world"; +// blob_client +// .upload_blob( +// RequestContent::from(data.to_vec()), +// true, +// u64::try_from(data.len())?, +// None, +// ) +// .await?; + +// println!("Made it past upload"); +// let response = blob_client.get_blob_properties(None).await?; + +// // // Assert +// println!("{:?}", response); + +// container_client.delete_container(None).await?; +// Ok(()) +// } +// The way this is currently implemented, yields a recording with only a CONTAINER PUT and DELETE +// For some reason the blob doesn't seem to get created despite upload_blob response returning 'status: Created' #[recorded::test] async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box> { // Recording Setup @@ -23,12 +70,16 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box .random_string::<12>(Some("blob")) .to_ascii_lowercase(); + let container_client_options = BlobContainerClientOptions { + client_options: options.client_options.clone(), + ..Default::default() + }; // Act - let container_client = ContainerClient::new( + let container_client = BlobContainerClient::new( &endpoint, container_name.clone(), recording.credential(), - Some(options.clone()), + Some(container_client_options), )?; container_client.create_container(None).await?; @@ -44,320 +95,319 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box .upload_blob( RequestContent::from(data.to_vec()), true, - i64::try_from(data.len())?, - None, - ) - .await?; - let response = blob_client.get_blob_properties(None).await; - - // Assert - assert!(response.is_ok()); - - let blob_properties = response?; - assert_eq!(blob_properties.blob_type, Some(BlobType::BlockBlob)); - assert_eq!(blob_properties.content_length, Some(17)); - - container_client.delete_container(None).await?; - Ok(()) -} - -#[recorded::test] -async fn test_get_blob_properties_invalid_container( - ctx: TestContext, -) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); - let blob_name = recording - .random_string::<12>(Some("blob")) - .to_ascii_lowercase(); - - // Act - let blob_client = BlobClient::new( - &endpoint, - container_name, - blob_name, - recording.credential(), - Some(options), - )?; - let response = blob_client.get_blob_properties(None).await; - - // Assert - assert_eq!( - String::from("HttpResponse(NotFound, \"ContainerNotFound\")"), - response.unwrap_err().kind().to_string() - ); - - Ok(()) -} - -#[recorded::test] -async fn test_download_blob(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); - let blob_name = recording - .random_string::<12>(Some("blob")) - .to_ascii_lowercase(); - - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name.clone(), - recording.credential(), - Some(options.clone()), - )?; - container_client.create_container(None).await?; - - let blob_client = BlobClient::new( - &endpoint, - container_name, - blob_name, - recording.credential(), - Some(options), - )?; - let data = b"test download content"; - blob_client - .upload_blob( - RequestContent::from(data.to_vec()), - true, - i64::try_from(data.len())?, - None, - ) - .await?; - let response = blob_client.download_blob(None).await?; - - // Assert - let (status_code, headers, response_body) = response.deconstruct(); - assert!(status_code.is_success()); - assert_eq!( - "21", - headers.get_str(&HeaderName::from_static("content-length"))? - ); - assert_eq!(Bytes::from_static(data), response_body.collect().await?); - - container_client.delete_container(None).await?; - Ok(()) -} - -#[recorded::test] -async fn test_upload_blob(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); - let blob_name = recording - .random_string::<12>(Some("blob")) - .to_ascii_lowercase(); - - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name.clone(), - recording.credential(), - Some(options.clone()), - )?; - container_client.create_container(None).await?; - - let blob_client = BlobClient::new( - &endpoint, - container_name, - blob_name, - recording.credential(), - Some(options), - )?; - - let data = b"hello rusty world"; - let response = blob_client - .upload_blob( - RequestContent::from(data.to_vec()), - false, - i64::try_from(data.len())?, - None, - ) - .await?; - - // Assert - assert_eq!(response.status(), StatusCode::Created); - - container_client.delete_container(None).await?; - Ok(()) -} - -#[recorded::test] -async fn test_upload_blob_overwrite(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); - let blob_name = recording - .random_string::<12>(Some("blob")) - .to_ascii_lowercase(); - - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name.clone(), - recording.credential(), - Some(options.clone()), - )?; - container_client.create_container(None).await?; - - let blob_client = BlobClient::new( - &endpoint, - container_name, - blob_name, - recording.credential(), - Some(options), - )?; - - let old_data = b"hello rusty world"; - blob_client - .upload_blob( - RequestContent::from(old_data.to_vec()), - false, - i64::try_from(old_data.len())?, + u64::try_from(data.len())?, None, ) .await?; - let new_data = b"hello overwritten rusty world"; + println!("Made it past upload"); + // Next line will fail for blobNotFound + // let response = blob_client.get_blob_properties(None).await?; - // Error Case (overwrite=false/none) - let error_response = blob_client - .upload_blob( - RequestContent::from(new_data.to_vec()), - false, - i64::try_from(new_data.len())?, - None, - ) - .await; - assert!(error_response.is_err()); + // // Assert + // println!("{:?}", response); - // Working Case (overwrite=true) - let upload_response = blob_client - .upload_blob( - RequestContent::from(new_data.to_vec()), - true, - i64::try_from(new_data.len())?, - None, - ) - .await?; - let response = blob_client.download_blob(None).await?; - - // Assert - assert_eq!(upload_response.status(), StatusCode::Created); - let (status_code, headers, response_body) = response.deconstruct(); - assert!(status_code.is_success()); - assert_eq!( - "29", - headers.get_str(&HeaderName::from_static("content-length"))? - ); - assert_eq!(Bytes::from_static(new_data), response_body.collect().await?); - - container_client.delete_container(None).await?; + // container_client.delete_container(None).await?; Ok(()) } -#[recorded::test] -async fn test_put_block_list(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); - let blob_name = recording - .random_string::<12>(Some("blob")) - .to_ascii_lowercase(); - - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name.clone(), - recording.credential(), - Some(options.clone()), - )?; - container_client.create_container(None).await?; - - let blob_client = BlobClient::new( - &endpoint, - container_name, - blob_name, - recording.credential(), - Some(options), - )?; - - let block_1 = b"AAA"; - let block_2 = b"BBB"; - let block_3 = b"CCC"; - - blob_client - .stage_block( - "1", - i64::try_from(block_1.len())?, - RequestContent::from(block_1.to_vec()), - None, - ) - .await?; - - blob_client - .stage_block( - "2", - i64::try_from(block_2.len())?, - RequestContent::from(block_2.to_vec()), - None, - ) - .await?; - blob_client - .stage_block( - "3", - i64::try_from(block_3.len())?, - RequestContent::from(block_3.to_vec()), - None, - ) - .await?; - - let latest_blocks = BlobBlock::new(vec![ - String::from("1"), - String::from("2"), - String::from("3"), - ]); - - let block_lookup_list = BlockLookupList { - committed: None, - latest: Some(latest_blocks.into()), - uncommitted: None, - }; - - let request_content = RequestContent::try_from(block_lookup_list)?; - - blob_client.commit_block_list(request_content, None).await?; - - let response = blob_client.download_blob(None).await?; - - // Assert - let (status_code, headers, response_body) = response.deconstruct(); - assert!(status_code.is_success()); - assert_eq!( - "9", - headers.get_str(&HeaderName::from_static("content-length"))? - ); - assert_eq!( - Bytes::from_static(b"AAABBBCCC"), - response_body.collect().await? - ); - - container_client.delete_container(None).await?; - Ok(()) -} +// #[recorded::test] +// async fn test_get_blob_properties_invalid_container( +// ctx: TestContext, +// ) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); +// let blob_name = recording +// .random_string::<12>(Some("blob")) +// .to_ascii_lowercase(); + +// // Act +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// recording.credential(), +// Some(options), +// )?; +// let response = blob_client.get_blob_properties(None).await; + +// // Assert +// assert_eq!( +// String::from("HttpResponse(NotFound, \"ContainerNotFound\")"), +// response.unwrap_err().kind().to_string() +// ); + +// Ok(()) +// } + +// #[recorded::test] +// async fn test_download_blob(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); +// let blob_name = recording +// .random_string::<12>(Some("blob")) +// .to_ascii_lowercase(); + +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name.clone(), +// recording.credential(), +// Some(options.clone()), +// )?; +// container_client.create_container(None).await?; + +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// recording.credential(), +// Some(options), +// )?; +// let data = b"test download content"; +// blob_client +// .upload_blob( +// RequestContent::from(data.to_vec()), +// true, +// i64::try_from(data.len())?, +// None, +// ) +// .await?; +// let response = blob_client.download_blob(None).await?; + +// // Assert +// let (status_code, headers, response_body) = response.deconstruct(); +// assert!(status_code.is_success()); +// assert_eq!( +// "21", +// headers.get_str(&HeaderName::from_static("content-length"))? +// ); +// assert_eq!(Bytes::from_static(data), response_body.collect().await?); + +// container_client.delete_container(None).await?; +// Ok(()) +// } + +// #[recorded::test] +// async fn test_upload_blob(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); +// let blob_name = recording +// .random_string::<12>(Some("blob")) +// .to_ascii_lowercase(); + +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name.clone(), +// recording.credential(), +// Some(options.clone()), +// )?; +// container_client.create_container(None).await?; + +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// recording.credential(), +// Some(options), +// )?; + +// let data = b"hello rusty world"; +// let response = blob_client +// .upload_blob( +// RequestContent::from(data.to_vec()), +// false, +// i64::try_from(data.len())?, +// None, +// ) +// .await?; + +// // Assert +// assert_eq!(response.status(), StatusCode::Created); + +// container_client.delete_container(None).await?; +// Ok(()) +// } + +// #[recorded::test] +// async fn test_upload_blob_overwrite(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); +// let blob_name = recording +// .random_string::<12>(Some("blob")) +// .to_ascii_lowercase(); + +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name.clone(), +// recording.credential(), +// Some(options.clone()), +// )?; +// container_client.create_container(None).await?; + +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// recording.credential(), +// Some(options), +// )?; + +// let old_data = b"hello rusty world"; +// blob_client +// .upload_blob( +// RequestContent::from(old_data.to_vec()), +// false, +// i64::try_from(old_data.len())?, +// None, +// ) +// .await?; + +// let new_data = b"hello overwritten rusty world"; + +// // Error Case (overwrite=false/none) +// let error_response = blob_client +// .upload_blob( +// RequestContent::from(new_data.to_vec()), +// false, +// i64::try_from(new_data.len())?, +// None, +// ) +// .await; +// assert!(error_response.is_err()); + +// // Working Case (overwrite=true) +// let upload_response = blob_client +// .upload_blob( +// RequestContent::from(new_data.to_vec()), +// true, +// i64::try_from(new_data.len())?, +// None, +// ) +// .await?; +// let response = blob_client.download_blob(None).await?; + +// // Assert +// assert_eq!(upload_response.status(), StatusCode::Created); +// let (status_code, headers, response_body) = response.deconstruct(); +// assert!(status_code.is_success()); +// assert_eq!( +// "29", +// headers.get_str(&HeaderName::from_static("content-length"))? +// ); +// assert_eq!(Bytes::from_static(new_data), response_body.collect().await?); + +// container_client.delete_container(None).await?; +// Ok(()) +// } + +// #[recorded::test] +// async fn test_put_block_list(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); +// let blob_name = recording +// .random_string::<12>(Some("blob")) +// .to_ascii_lowercase(); + +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name.clone(), +// recording.credential(), +// Some(options.clone()), +// )?; +// container_client.create_container(None).await?; + +// let blob_client = BlobClient::new( +// &endpoint, +// container_name, +// blob_name, +// recording.credential(), +// Some(options), +// )?; + +// let block_1 = b"AAA"; +// let block_2 = b"BBB"; +// let block_3 = b"CCC"; + +// blob_client +// .stage_block( +// "1", +// i64::try_from(block_1.len())?, +// RequestContent::from(block_1.to_vec()), +// None, +// ) +// .await?; + +// blob_client +// .stage_block( +// "2", +// i64::try_from(block_2.len())?, +// RequestContent::from(block_2.to_vec()), +// None, +// ) +// .await?; +// blob_client +// .stage_block( +// "3", +// i64::try_from(block_3.len())?, +// RequestContent::from(block_3.to_vec()), +// None, +// ) +// .await?; + +// let latest_blocks = BlobBlock::new(vec![ +// String::from("1"), +// String::from("2"), +// String::from("3"), +// ]); + +// let block_lookup_list = BlockLookupList { +// committed: None, +// latest: Some(latest_blocks.into()), +// uncommitted: None, +// }; + +// let request_content = RequestContent::try_from(block_lookup_list)?; + +// blob_client.commit_block_list(request_content, None).await?; + +// let response = blob_client.download_blob(None).await?; + +// // Assert +// let (status_code, headers, response_body) = response.deconstruct(); +// assert!(status_code.is_success()); +// assert_eq!( +// "9", +// headers.get_str(&HeaderName::from_static("content-length"))? +// ); +// assert_eq!( +// Bytes::from_static(b"AAABBBCCC"), +// response_body.collect().await? +// ); + +// container_client.delete_container(None).await?; +// Ok(()) +// } diff --git a/sdk/storage/azure_storage_blob/tests/blob_container_client.rs b/sdk/storage/azure_storage_blob/tests/blob_container_client.rs index edc4632724..c343934c01 100644 --- a/sdk/storage/azure_storage_blob/tests/blob_container_client.rs +++ b/sdk/storage/azure_storage_blob/tests/blob_container_client.rs @@ -1,90 +1,90 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. +// // Copyright (c) Microsoft Corporation. All rights reserved. +// // Licensed under the MIT License. -use azure_core::StatusCode; -use azure_core_test::{recorded, TestContext}; -use azure_storage_blob::{clients::ContainerClient, models::LeaseState, BlobClientOptions}; -use azure_storage_blob_test::recorded_test_setup; -use std::error::Error; +// use azure_core::StatusCode; +// use azure_core_test::{recorded, TestContext}; +// use azure_storage_blob::{clients::ContainerClient, models::LeaseState, BlobClientOptions}; +// use azure_storage_blob_test::recorded_test_setup; +// use std::error::Error; -#[recorded::test] -async fn test_create_container(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); +// #[recorded::test] +// async fn test_create_container(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name, - recording.credential(), - Some(options), - )?; +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name, +// recording.credential(), +// Some(options), +// )?; - // Assert - container_client.create_container(None).await?; +// // Assert +// container_client.create_container(None).await?; - container_client.delete_container(None).await?; - Ok(()) -} +// container_client.delete_container(None).await?; +// Ok(()) +// } -#[recorded::test] -async fn test_get_container_properties(ctx: TestContext) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); +// #[recorded::test] +// async fn test_get_container_properties(ctx: TestContext) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name, - recording.credential(), - Some(options), - )?; - container_client.create_container(None).await?; - let container_properties = container_client.get_container_properties(None).await?; +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name, +// recording.credential(), +// Some(options), +// )?; +// container_client.create_container(None).await?; +// let container_properties = container_client.get_container_properties(None).await?; - // Assert - assert_eq!( - container_properties.lease_state, - Some(LeaseState::Available) - ); - assert_eq!(container_properties.has_immutability_policy, Some(false)); +// // Assert +// assert_eq!( +// container_properties.lease_state, +// Some(LeaseState::Available) +// ); +// assert_eq!(container_properties.has_immutability_policy, Some(false)); - container_client.delete_container(None).await?; - Ok(()) -} +// container_client.delete_container(None).await?; +// Ok(()) +// } -#[recorded::test] -async fn test_get_container_properties_invalid_container( - ctx: TestContext, -) -> Result<(), Box> { - // Recording Setup - let recording = ctx.recording(); - let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; - let container_name = recording - .random_string::<17>(Some("container")) - .to_ascii_lowercase(); +// #[recorded::test] +// async fn test_get_container_properties_invalid_container( +// ctx: TestContext, +// ) -> Result<(), Box> { +// // Recording Setup +// let recording = ctx.recording(); +// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await; +// let container_name = recording +// .random_string::<17>(Some("container")) +// .to_ascii_lowercase(); - // Act - let container_client = ContainerClient::new( - &endpoint, - container_name, - recording.credential(), - Some(options), - )?; - let response = container_client.get_container_properties(None).await; +// // Act +// let container_client = ContainerClient::new( +// &endpoint, +// container_name, +// recording.credential(), +// Some(options), +// )?; +// let response = container_client.get_container_properties(None).await; - // Assert - assert!(response.is_err()); - let error = response.unwrap_err().http_status(); - assert_eq!(Some(StatusCode::NotFound), error); +// // Assert +// assert!(response.is_err()); +// let error = response.unwrap_err().http_status(); +// assert_eq!(Some(StatusCode::NotFound), error); - Ok(()) -} +// Ok(()) +// } From e7d6a27cf3ffc1b0347ceb6bcf6340df69ea3391 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 17:06:40 -0800 Subject: [PATCH 4/7] Found source of weird block blob upload --- .../src/clients/blob_client.rs | 1 + .../generated/clients/block_blob_client.rs | 4 +- .../azure_storage_blob/tests/blob_client.rs | 61 +++---------------- 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs index d213d7cfcb..95d4b5c084 100644 --- a/sdk/storage/azure_storage_blob/src/clients/blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/blob_client.rs @@ -117,6 +117,7 @@ impl BlobClient { } // Currently there is no way to alter what options you pass to the BlockBlobClient we spin up on-demand + // We could inherit the ClientOptions from the current BlobClient to resolve the recording issue let block_blob_client = BlockBlobClient::new( self.endpoint().as_str(), self.credential(), diff --git a/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs b/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs index af9eb49d46..0fba9862a5 100644 --- a/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/generated/clients/block_blob_client.rs @@ -664,7 +664,9 @@ impl BlockBlobClient { let options = options.unwrap_or_default(); let ctx = Context::with_context(&options.method_options.context); let mut url = self.endpoint.clone(); - let mut path = String::from("{containerName}/{blob}/"); + + // This path has an extra '/' character + let mut path = String::from("{containerName}/{blob}"); path = path.replace("{blob}", &self.blob); path = path.replace("{containerName}", &self.container_name); url = url.join(&path)?; diff --git a/sdk/storage/azure_storage_blob/tests/blob_client.rs b/sdk/storage/azure_storage_blob/tests/blob_client.rs index 82ab9db293..ff09ffc286 100644 --- a/sdk/storage/azure_storage_blob/tests/blob_client.rs +++ b/sdk/storage/azure_storage_blob/tests/blob_client.rs @@ -11,53 +11,6 @@ use azure_storage_blob::{ use azure_storage_blob_test::recorded_test_setup; use std::error::Error; -// #[recorded::test(live)] -// async fn test_get_blob_properties_live() -> Result<(), Box> { -// // Live Resource Setup - -// use azure_identity::DefaultAzureCredentialBuilder; -// let container_name = "testcontainer01".to_string(); -// let blob_name = "testblob001".to_string(); -// let endpoint = format!("https://{}.blob.core.windows.net/", "ruststoragedev"); -// let credential = DefaultAzureCredentialBuilder::default().build()?; - -// // Act -// let container_client = BlobContainerClient::new( -// &endpoint, -// container_name.clone(), -// credential.clone(), -// None, // default options bag -// )?; -// container_client.create_container(None).await?; - -// let blob_client = BlobClient::new( -// &endpoint, -// container_name, -// blob_name, -// credential, -// None, // default options bag -// )?; -// let data = b"hello rusty world"; -// blob_client -// .upload_blob( -// RequestContent::from(data.to_vec()), -// true, -// u64::try_from(data.len())?, -// None, -// ) -// .await?; - -// println!("Made it past upload"); -// let response = blob_client.get_blob_properties(None).await?; - -// // // Assert -// println!("{:?}", response); - -// container_client.delete_container(None).await?; -// Ok(()) -// } -// The way this is currently implemented, yields a recording with only a CONTAINER PUT and DELETE -// For some reason the blob doesn't seem to get created despite upload_blob response returning 'status: Created' #[recorded::test] async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box> { // Recording Setup @@ -70,6 +23,7 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box .random_string::<12>(Some("blob")) .to_ascii_lowercase(); + // This is to shove the modified pipeline policy into the container client options let container_client_options = BlobContainerClientOptions { client_options: options.client_options.clone(), ..Default::default() @@ -91,6 +45,9 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box Some(options), )?; let data = b"hello rusty world"; + + // This is completely absent from the recording due to the fact that this spins up a BlockBlobClient w/ default options (thus no recording policy) + // I didn't inherit from the base BlobClient and haven't introduced a knob for these options, only the API-specific options bag blob_client .upload_blob( RequestContent::from(data.to_vec()), @@ -100,12 +57,10 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box ) .await?; - println!("Made it past upload"); - // Next line will fail for blobNotFound - // let response = blob_client.get_blob_properties(None).await?; - - // // Assert - // println!("{:?}", response); + // Not really sure how to read this + let response = blob_client.get_blob_properties(None).await?; + println!("{:?}", response); + // Assert // container_client.delete_container(None).await?; Ok(()) From f1926493eec6f1bf0d66f9530a6f31bdc72937a6 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 17:17:36 -0800 Subject: [PATCH 5/7] Successfully access a field from BlobProperties, need to fix Intellisense --- sdk/storage/azure_storage_blob/tests/blob_client.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure_storage_blob/tests/blob_client.rs b/sdk/storage/azure_storage_blob/tests/blob_client.rs index ff09ffc286..51ecf8c67c 100644 --- a/sdk/storage/azure_storage_blob/tests/blob_client.rs +++ b/sdk/storage/azure_storage_blob/tests/blob_client.rs @@ -5,7 +5,9 @@ use azure_core::{headers::HeaderName, Bytes, RequestContent, StatusCode}; use azure_core_test::{recorded, TestContext}; use azure_storage_blob::{ clients::{BlobClient, BlobContainerClient}, - models::{BlobBlock, BlobType, BlockLookupList}, + models::{ + BlobBlock, BlobClientGetPropertiesResultHeaders, BlobType, BlockLookupList, LeaseState, + }, BlobClientOptions, BlobContainerClientOptions, }; use azure_storage_blob_test::recorded_test_setup; @@ -57,8 +59,10 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box ) .await?; - // Not really sure how to read this + // Where's my Intellisense!!! let response = blob_client.get_blob_properties(None).await?; + let field = response.lease_state()?; + assert_eq!(field, Some(LeaseState::Available)); println!("{:?}", response); // Assert From d4a68d233bc18eb366393d6c0d87f14ce4f3e970 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 5 Mar 2025 17:23:07 -0800 Subject: [PATCH 6/7] Remove channel from toolchain #2280 in main --- rust-toolchain.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b8f83b4088..4430b9d081 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,4 @@ [toolchain] -channel = "1.80.0" components = [ "rustc", "rustfmt", From db85f54f11de8103385835091b90c22fed8a45b4 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Thu, 6 Mar 2025 18:11:11 -0800 Subject: [PATCH 7/7] Remove unneeded from model response --- .../azure_storage_blob/src/generated/header_traits.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azure_storage_blob/src/generated/header_traits.rs b/sdk/storage/azure_storage_blob/src/generated/header_traits.rs index 0952e93a22..8b8edf8de3 100644 --- a/sdk/storage/azure_storage_blob/src/generated/header_traits.rs +++ b/sdk/storage/azure_storage_blob/src/generated/header_traits.rs @@ -1125,14 +1125,14 @@ impl BlobClientGetAccountInfoResultHeaders for Response Result>; + // fn accept_ranges(&self) -> Result>; fn cache_control(&self) -> Result>; fn content_disposition(&self) -> Result>; fn content_encoding(&self) -> Result>; fn content_language(&self) -> Result>; fn content_length(&self) -> Result>; fn content_md5(&self) -> Result>; - fn date(&self) -> Result>; + // fn date(&self) -> Result>; fn e_tag(&self) -> Result>; fn last_modified(&self) -> Result>; fn tier(&self) -> Result>; @@ -1143,7 +1143,7 @@ pub trait BlobClientGetPropertiesResultHeaders: private::Sealed { fn is_sealed(&self) -> Result>; fn blob_sequence_number(&self) -> Result>; fn blob_type(&self) -> Result>; - fn client_request_id(&self) -> Result>; + // fn client_request_id(&self) -> Result>; fn copy_completion_time(&self) -> Result>; fn destination_snapshot(&self) -> Result>; fn copy_id(&self) -> Result>; @@ -1168,7 +1168,7 @@ pub trait BlobClientGetPropertiesResultHeaders: private::Sealed { fn object_replication_rules(&self) -> Result>; fn object_replication_policy_id(&self) -> Result>; fn rehydrate_priority(&self) -> Result>; - fn request_id(&self) -> Result>; + // fn request_id(&self) -> Result>; fn is_server_encrypted(&self) -> Result>; fn tag_count(&self) -> Result>; fn version_id(&self) -> Result>;