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 28df7c45f22..f7b4604ee51 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 @@ -28,7 +28,7 @@ use azure_core::{ }, Result, }; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; /// A client to interact with a specified Azure storage container. pub struct BlobContainerClient { @@ -112,12 +112,14 @@ impl BlobContainerClient { /// /// # Arguments /// + /// * `metadata` - The metadata headers. /// * `options` - Optional configuration for the request. pub async fn set_metadata( &self, + metadata: HashMap, options: Option>, ) -> Result> { - self.client.set_metadata(options).await + self.client.set_metadata(metadata, options).await } /// Marks the specified container for deletion. The container and any blobs contained within are later deleted during garbage collection. 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 401081e6f1f..2ea26a7d41d 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 @@ -7,7 +7,7 @@ use crate::{ models::{ BlobServiceClientGetAccountInfoOptions, BlobServiceClientGetPropertiesOptions, BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions, - ListContainersSegmentResponse, StorageServiceProperties, + BlobServiceProperties, ListContainersSegmentResponse, }, pipeline::StorageHeadersPolicy, BlobContainerClient, BlobServiceClientOptions, @@ -82,7 +82,7 @@ impl BlobServiceClient { pub async fn get_properties( &self, options: Option>, - ) -> Result> { + ) -> Result> { self.client.get_properties(options).await } @@ -106,7 +106,7 @@ impl BlobServiceClient { /// * `options` - Optional configuration for the request. pub async fn set_properties( &self, - storage_service_properties: RequestContent, + storage_service_properties: RequestContent, options: Option>, ) -> Result> { self.client diff --git a/sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs b/sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs index 1b15fd1d7b3..9bb2808f1ba 100644 --- a/sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs +++ b/sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs @@ -13,7 +13,7 @@ use crate::{ BlobClientSetMetadataOptions, BlobClientSetPropertiesOptions, BlobClientSetTierOptions, BlockBlobClientCommitBlockListOptions, BlockBlobClientGetBlockListOptions, BlockBlobClientStageBlockOptions, BlockBlobClientUploadOptions, BlockList, BlockListType, - BlockLookupList, StorageServiceProperties, + BlockLookupList, }, pipeline::StorageHeadersPolicy, BlobClientOptions, BlockBlobClientOptions, 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 0871c272cd3..baef9259e19 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 @@ -36,7 +36,7 @@ use azure_core::{ time::to_rfc7231, tracing, xml, Error, Result, }; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; #[tracing::client] pub struct BlobContainerClient { @@ -1043,10 +1043,12 @@ impl BlobContainerClient { /// /// # Arguments /// + /// * `metadata` - The metadata headers. /// * `options` - Optional parameters for the request. #[tracing::function("Storage.Blob.Container.setMetadata")] pub async fn set_metadata( &self, + metadata: HashMap, options: Option>, ) -> Result> { let options = options.unwrap_or_default(); @@ -1072,10 +1074,8 @@ impl BlobContainerClient { 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); - } + for (k, v) in &metadata { + request.insert_header(format!("x-ms-meta-{k}"), v); } request.insert_header("x-ms-version", &self.version); let rsp = self.pipeline.send(&ctx, &mut request).await?; 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 1cfd4fc4d1d..6d16e35c919 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 @@ -10,7 +10,7 @@ use crate::generated::{ BlobServiceClientGetAccountInfoResult, BlobServiceClientGetPropertiesOptions, BlobServiceClientGetStatisticsOptions, BlobServiceClientGetUserDelegationKeyOptions, BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions, - FilterBlobSegment, KeyInfo, ListContainersSegmentResponse, StorageServiceProperties, + BlobServiceProperties, FilterBlobSegment, KeyInfo, ListContainersSegmentResponse, StorageServiceStats, UserDelegationKey, }, }; @@ -212,7 +212,7 @@ impl BlobServiceClient { 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(); @@ -423,12 +423,12 @@ impl BlobServiceClient { /// /// # Arguments /// - /// * `storage_service_properties` - The storage service properties to set. + /// * `blob_service_properties` - The storage service properties to set. /// * `options` - Optional parameters for the request. #[tracing::function("Storage.Blob.setProperties")] pub async fn set_properties( &self, - storage_service_properties: RequestContent, + blob_service_properties: RequestContent, options: Option>, ) -> Result> { let options = options.unwrap_or_default(); @@ -448,7 +448,7 @@ impl BlobServiceClient { request.insert_header("x-ms-client-request-id", client_request_id); } request.insert_header("x-ms-version", &self.version); - request.set_body(storage_service_properties); + request.set_body(blob_service_properties); let rsp = self.pipeline.send(&ctx, &mut request).await?; if !rsp.status().is_success() { let status = rsp.status(); diff --git a/sdk/storage/azure_storage_blob/src/generated/models/method_options.rs b/sdk/storage/azure_storage_blob/src/generated/models/method_options.rs index ab4a82a1187..8ece63fced1 100644 --- a/sdk/storage/azure_storage_blob/src/generated/models/method_options.rs +++ b/sdk/storage/azure_storage_blob/src/generated/models/method_options.rs @@ -1519,9 +1519,6 @@ pub struct BlobContainerClientSetMetadataOptions<'a> { /// 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>, diff --git a/sdk/storage/azure_storage_blob/src/generated/models/models_impl.rs b/sdk/storage/azure_storage_blob/src/generated/models/models_impl.rs index 3621ba90d9d..d8f349ac0bf 100644 --- a/sdk/storage/azure_storage_blob/src/generated/models/models_impl.rs +++ b/sdk/storage/azure_storage_blob/src/generated/models/models_impl.rs @@ -3,13 +3,20 @@ // 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 super::{BlobTags, BlockLookupList, KeyInfo, QueryRequest, StorageServiceProperties}; +use super::{BlobServiceProperties, BlobTags, BlockLookupList, KeyInfo, QueryRequest}; use azure_core::{ http::{RequestContent, XmlFormat}, xml::to_xml, Result, }; +impl TryFrom for RequestContent { + type Error = azure_core::Error; + fn try_from(value: BlobServiceProperties) -> Result { + RequestContent::try_from(to_xml(&value)?) + } +} + impl TryFrom for RequestContent { type Error = azure_core::Error; fn try_from(value: BlobTags) -> Result { @@ -37,10 +44,3 @@ impl TryFrom for RequestContent { RequestContent::try_from(to_xml(&value)?) } } - -impl TryFrom for RequestContent { - type Error = azure_core::Error; - fn try_from(value: StorageServiceProperties) -> Result { - RequestContent::try_from(to_xml(&value)?) - } -} diff --git a/sdk/storage/azure_storage_blob/src/generated/models/pub_models.rs b/sdk/storage/azure_storage_blob/src/generated/models/pub_models.rs index 3dc5ff48e68..7dfce93f70a 100644 --- a/sdk/storage/azure_storage_blob/src/generated/models/pub_models.rs +++ b/sdk/storage/azure_storage_blob/src/generated/models/pub_models.rs @@ -545,6 +545,51 @@ pub struct BlobPropertiesInternal { #[derive(SafeDebug)] pub struct BlobServiceClientGetAccountInfoResult; +/// The service properties. +#[derive(Clone, Default, Deserialize, SafeDebug, Serialize)] +#[serde(rename = "StorageServiceProperties")] +pub struct BlobServiceProperties { + /// The CORS properties. + #[serde( + default, + deserialize_with = "CorsCorsRule::unwrap", + rename = "Cors", + serialize_with = "CorsCorsRule::wrap", + skip_serializing_if = "Option::is_none" + )] + pub cors: Option>, + + /// The default service version. + #[serde( + rename = "DefaultServiceVersion", + skip_serializing_if = "Option::is_none" + )] + pub default_service_version: Option, + + /// The delete retention policy. + #[serde( + rename = "DeleteRetentionPolicy", + skip_serializing_if = "Option::is_none" + )] + pub delete_retention_policy: Option, + + /// The hour metrics properties. + #[serde(rename = "HourMetrics", skip_serializing_if = "Option::is_none")] + pub hour_metrics: Option, + + /// The logging properties. + #[serde(rename = "Logging", skip_serializing_if = "Option::is_none")] + pub logging: Option, + + /// The minute metrics properties. + #[serde(rename = "MinuteMetrics", skip_serializing_if = "Option::is_none")] + pub minute_metrics: Option, + + /// The static website properties. + #[serde(rename = "StaticWebsite", skip_serializing_if = "Option::is_none")] + pub static_website: Option, +} + /// The blob tags. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize)] #[serde(rename = "Tag")] @@ -1278,50 +1323,6 @@ pub struct StaticWebsite { pub index_document: Option, } -/// The service properties. -#[derive(Clone, Default, Deserialize, SafeDebug, Serialize)] -pub struct StorageServiceProperties { - /// The CORS properties. - #[serde( - default, - deserialize_with = "CorsCorsRule::unwrap", - rename = "Cors", - serialize_with = "CorsCorsRule::wrap", - skip_serializing_if = "Option::is_none" - )] - pub cors: Option>, - - /// The default service version. - #[serde( - rename = "DefaultServiceVersion", - skip_serializing_if = "Option::is_none" - )] - pub default_service_version: Option, - - /// The delete retention policy. - #[serde( - rename = "DeleteRetentionPolicy", - skip_serializing_if = "Option::is_none" - )] - pub delete_retention_policy: Option, - - /// The hour metrics properties. - #[serde(rename = "HourMetrics", skip_serializing_if = "Option::is_none")] - pub hour_metrics: Option, - - /// The logging properties. - #[serde(rename = "Logging", skip_serializing_if = "Option::is_none")] - pub logging: Option, - - /// The minute metrics properties. - #[serde(rename = "MinuteMetrics", skip_serializing_if = "Option::is_none")] - pub minute_metrics: Option, - - /// The static website properties. - #[serde(rename = "StaticWebsite", skip_serializing_if = "Option::is_none")] - pub static_website: Option, -} - /// Stats for the storage service. #[derive(Clone, Default, Deserialize, SafeDebug, Serialize)] #[non_exhaustive] diff --git a/sdk/storage/azure_storage_blob/src/models/mod.rs b/sdk/storage/azure_storage_blob/src/models/mod.rs index 81dd27b297b..08dcd719e7f 100644 --- a/sdk/storage/azure_storage_blob/src/models/mod.rs +++ b/sdk/storage/azure_storage_blob/src/models/mod.rs @@ -36,16 +36,17 @@ pub use crate::generated::models::{ BlobItemInternal, BlobMetadata, BlobName, BlobPropertiesInternal, BlobServiceClientGetAccountInfoOptions, BlobServiceClientGetAccountInfoResult, BlobServiceClientGetAccountInfoResultHeaders, BlobServiceClientGetPropertiesOptions, - BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions, BlobTag, - BlobTags, BlobType, Block, BlockBlobClientCommitBlockListOptions, - BlockBlobClientCommitBlockListResult, BlockBlobClientCommitBlockListResultHeaders, - BlockBlobClientGetBlockListOptions, BlockBlobClientStageBlockOptions, - BlockBlobClientStageBlockResult, BlockBlobClientStageBlockResultHeaders, - BlockBlobClientUploadOptions, BlockBlobClientUploadResult, BlockBlobClientUploadResultHeaders, - BlockList, BlockListType, BlockLookupList, ContainerItem, CopyStatus, CorsRule, LeaseDuration, - LeaseState, LeaseStatus, ListBlobsFlatSegmentResponse, ListBlobsIncludeItem, - ListContainersIncludeType, ListContainersSegmentResponse, Logging, Metrics, - ObjectReplicationMetadata, PageBlobClientClearPagesOptions, PageBlobClientClearPagesResult, + BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions, + BlobServiceProperties, BlobTag, BlobTags, BlobType, Block, + BlockBlobClientCommitBlockListOptions, BlockBlobClientCommitBlockListResult, + BlockBlobClientCommitBlockListResultHeaders, BlockBlobClientGetBlockListOptions, + BlockBlobClientStageBlockOptions, BlockBlobClientStageBlockResult, + BlockBlobClientStageBlockResultHeaders, BlockBlobClientUploadOptions, + BlockBlobClientUploadResult, BlockBlobClientUploadResultHeaders, BlockList, BlockListType, + BlockLookupList, ContainerItem, CopyStatus, CorsRule, LeaseDuration, LeaseState, LeaseStatus, + ListBlobsFlatSegmentResponse, ListBlobsIncludeItem, ListContainersIncludeType, + ListContainersSegmentResponse, Logging, Metrics, ObjectReplicationMetadata, + PageBlobClientClearPagesOptions, PageBlobClientClearPagesResult, PageBlobClientClearPagesResultHeaders, PageBlobClientCreateOptions, PageBlobClientCreateResult, PageBlobClientCreateResultHeaders, PageBlobClientGetPageRangesOptions, PageBlobClientResizeOptions, PageBlobClientResizeResult, PageBlobClientResizeResultHeaders, @@ -54,6 +55,6 @@ pub use crate::generated::models::{ PageBlobClientUploadPagesFromUrlResult, PageBlobClientUploadPagesOptions, PageBlobClientUploadPagesResult, PageBlobClientUploadPagesResultHeaders, PageList, PremiumPageBlobAccessTier, PublicAccessType, RehydratePriority, RetentionPolicy, - SequenceNumberActionType, StaticWebsite, StorageServiceProperties, + SequenceNumberActionType, StaticWebsite, }; pub use extensions::*; 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 014411894c4..63391461c6f 100644 --- a/sdk/storage/azure_storage_blob/tests/blob_container_client.rs +++ b/sdk/storage/azure_storage_blob/tests/blob_container_client.rs @@ -64,12 +64,8 @@ async fn test_set_container_metadata(ctx: TestContext) -> Result<(), Box Result<(), Box Result<(), Box Result<(), Box Result<(), Box = - storage_service_properties.try_into()?; + let request_content: RequestContent = + blob_service_properties.try_into()?; service_client.set_properties(request_content, None).await?; // Assert let response = service_client.get_properties(None).await?; - let storage_service_properties = response.into_body().await?; - let default_service_version = storage_service_properties.default_service_version; + let blob_service_properties = response.into_body().await?; + let default_service_version = blob_service_properties.default_service_version; assert_eq!("2022-11-02".to_string(), default_service_version.unwrap()); Ok(()) } diff --git a/sdk/storage/azure_storage_blob/tsp-location.yaml b/sdk/storage/azure_storage_blob/tsp-location.yaml index c12649c61b4..55366e1d1ba 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: bafe771a792f70e71926d83bc0b27a925fba3f01 +commit: fcc4cdefee43823ab15e05be6b42228bed96c1b1 repo: Azure/azure-rest-api-specs additionalDirectories: