Skip to content

[Storage] get_account_info all clients, set/get_tags for BlobClient, set_properties for BlobServiceClient #2795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b5bed2e
start_copy_from_url, set_properties
vincenttran-msft Jul 15, 2025
7e7f9a9
get_account_info, set/get tags
vincenttran-msft Jul 15, 2025
2c40e86
Regenerate against .tsp
vincenttran-msft Jul 15, 2025
d133283
Test recordings
vincenttran-msft Jul 15, 2025
c47b704
Resolve rustdoc error bare-urls
vincenttran-msft Jul 15, 2025
4fc6dba
Recordings update
vincenttran-msft Jul 15, 2025
6e36e3a
nit
vincenttran-msft Jul 18, 2025
b8a375b
Regen after omitting start_copy_from_url
vincenttran-msft Jul 21, 2025
2633e4d
Refactor that any cx facing is HashMap
vincenttran-msft Jul 21, 2025
3c3d716
nit
vincenttran-msft Jul 21, 2025
b7ca0f6
Moved asset file
vincenttran-msft Jul 23, 2025
e67a13c
nit
vincenttran-msft Jul 23, 2025
0715c07
Merge branch 'main' into vincenttran/post_v3_pr
vincenttran-msft Jul 29, 2025
7fc3b5c
Merge branch 'main' into vincenttran/post_v3_pr
vincenttran-msft Jul 30, 2025
1c1a166
Use BTree for fixed-ordering, re-record
vincenttran-msft Jul 30, 2025
87e9d4e
nit
vincenttran-msft Jul 30, 2025
1085fe0
Merge branch 'main' into vincenttran/post_v3_pr
vincenttran-msft Aug 4, 2025
f24aaed
Refactor to new azure-core code, now hitting error case
vincenttran-msft Aug 4, 2025
ab7e12b
Merge branch 'main' into vincenttran/post_v3_pr
vincenttran-msft Aug 5, 2025
9fa4395
Refactor for v20 emitter changes
vincenttran-msft Aug 5, 2025
8c390ef
Added TryFrom BlobTags -> HashMap
vincenttran-msft Aug 14, 2025
c30c1b3
Merge branch 'main' into vincenttran/post_v3_pr
vincenttran-msft Aug 14, 2025
aa92db4
Re-record tests, add commutativity
vincenttran-msft Aug 14, 2025
61def99
nit
vincenttran-msft Aug 14, 2025
790e3fa
Regen against new feature/blob-tsp-rust
vincenttran-msft Aug 15, 2025
010c18b
Regen against feature/blob-tsp-rust
vincenttran-msft Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "rust",
"Tag": "rust/azure_storage_blob_f12afa9550",
"Tag": "rust/azure_storage_blob_49079e88a1",
"TagPrefix": "rust/azure_storage_blob"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl AppendBlobClient {

let client = GeneratedAppendBlobClient::new(
endpoint,
credential.clone(),
container_name.clone(),
blob_name.clone(),
credential,
container_name,
blob_name,
Some(options),
)?;
Ok(Self {
Expand Down
74 changes: 63 additions & 11 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@
// Licensed under the MIT License.

use crate::{
deserialize_blob_tags,
generated::clients::BlobClient as GeneratedBlobClient,
generated::models::{
BlobClientAcquireLeaseResult, BlobClientBreakLeaseResult, BlobClientChangeLeaseResult,
BlobClientDownloadResult, BlobClientGetPropertiesResult, BlobClientReleaseLeaseResult,
BlobClientRenewLeaseResult, BlockBlobClientCommitBlockListResult,
BlockBlobClientStageBlockResult, BlockBlobClientUploadResult,
BlobClientDownloadResult, BlobClientGetAccountInfoResult, BlobClientGetPropertiesResult,
BlobClientReleaseLeaseResult, BlobClientRenewLeaseResult,
BlockBlobClientCommitBlockListResult, BlockBlobClientStageBlockResult,
BlockBlobClientUploadResult,
},
models::{
AccessTier, BlobClientAcquireLeaseOptions, BlobClientBreakLeaseOptions,
BlobClientChangeLeaseOptions, BlobClientDeleteOptions, BlobClientDownloadOptions,
BlobClientGetPropertiesOptions, BlobClientReleaseLeaseOptions, BlobClientRenewLeaseOptions,
BlobClientSetMetadataOptions, BlobClientSetPropertiesOptions, BlobClientSetTierOptions,
BlockBlobClientCommitBlockListOptions, BlockBlobClientUploadOptions, BlockList,
BlobClientGetAccountInfoOptions, BlobClientGetPropertiesOptions, BlobClientGetTagsOptions,
BlobClientReleaseLeaseOptions, BlobClientRenewLeaseOptions, BlobClientSetMetadataOptions,
BlobClientSetPropertiesOptions, BlobClientSetTagsOptions, BlobClientSetTierOptions,
BlobTags, BlockBlobClientCommitBlockListOptions, BlockBlobClientUploadOptions, BlockList,
BlockListType, BlockLookupList,
},
pipeline::StorageHeadersPolicy,
AppendBlobClient, BlobClientOptions, BlockBlobClient, PageBlobClient,
serialize_blob_tags, AppendBlobClient, BlobClientOptions, BlockBlobClient, PageBlobClient,
};
use azure_core::{
credentials::TokenCredential,
http::{
policies::{BearerTokenCredentialPolicy, Policy},
NoFormat, RequestContent, Response, Url, XmlFormat,
JsonFormat, NoFormat, RequestContent, Response, Url, XmlFormat,
},
Bytes, Result,
};
use std::collections::HashMap;
use std::sync::Arc;

/// A client to interact with a specific Azure storage blob, although that blob may not yet exist.
Expand Down Expand Up @@ -63,9 +67,9 @@ impl BlobClient {

let client = GeneratedBlobClient::new(
endpoint,
credential.clone(),
container_name.clone(),
blob_name.clone(),
credential,
container_name,
blob_name,
Some(options),
)?;
Ok(Self {
Expand Down Expand Up @@ -304,4 +308,52 @@ impl BlobClient {
) -> Result<Response<BlobClientRenewLeaseResult, NoFormat>> {
self.client.renew_lease(lease_id, options).await
}

/// Sets tags on a blob. Note that each call to this operation replaces all existing tags. To remove
/// all tags from the blob, call this operation with no tags specified.
///
/// # Arguments
///
/// * `tags` - Name-value pairs associated with the blob as tag. Tags are case-sensitive.
/// The tag set may contain at most 10 tags. Tag keys must be between 1 and 128 characters,
/// and tag values must be between 0 and 256 characters.
/// Valid tag key and value characters include: lowercase and uppercase letters, digits (0-9),
/// space (' '), plus (+), minus (-), period (.), solidus (/), colon (:), equals (=), underscore (_)
/// * `options` - Optional configuration for the request.
pub async fn set_tags(
&self,
tags: HashMap<String, String>,
options: Option<BlobClientSetTagsOptions<'_>>,
) -> Result<Response<(), NoFormat>> {
let blob_tags = serialize_blob_tags(tags);
self.client
.set_tags(RequestContent::try_from(blob_tags)?, options)
.await
}

/// Gets the tags on a blob.
///
/// # Arguments
///
/// * `options` - Optional configuration for the request.
pub async fn get_tags(
&self,
options: Option<BlobClientGetTagsOptions<'_>>,
) -> Result<Response<HashMap<String, String>, JsonFormat>> {
let response = self.client.get_tags(options).await?;
deserialize_blob_tags(response).await
}

/// Gets information related to the Storage account in which the blob resides.
/// This includes the `sku_name` and `account_kind`.
///
/// # Arguments
///
/// * `options` - Optional configuration for the request.
pub async fn get_account_info(
&self,
options: Option<BlobClientGetAccountInfoOptions<'_>>,
) -> Result<Response<BlobClientGetAccountInfoResult, NoFormat>> {
self.client.get_account_info(options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ use crate::{
generated::clients::BlobContainerClient as GeneratedBlobContainerClient,
generated::models::{
BlobContainerClientAcquireLeaseResult, BlobContainerClientBreakLeaseResult,
BlobContainerClientChangeLeaseResult, BlobContainerClientGetPropertiesResult,
BlobContainerClientReleaseLeaseResult, BlobContainerClientRenewLeaseResult,
BlobContainerClientChangeLeaseResult, BlobContainerClientGetAccountInfoResult,
BlobContainerClientGetPropertiesResult, BlobContainerClientReleaseLeaseResult,
BlobContainerClientRenewLeaseResult,
},
models::{
BlobContainerClientAcquireLeaseOptions, BlobContainerClientBreakLeaseOptions,
BlobContainerClientChangeLeaseOptions, BlobContainerClientCreateOptions,
BlobContainerClientDeleteOptions, BlobContainerClientGetPropertiesOptions,
BlobContainerClientListBlobFlatSegmentOptions, BlobContainerClientReleaseLeaseOptions,
BlobContainerClientRenewLeaseOptions, BlobContainerClientSetMetadataOptions,
ListBlobsFlatSegmentResponse,
BlobContainerClientDeleteOptions, BlobContainerClientGetAccountInfoOptions,
BlobContainerClientGetPropertiesOptions, BlobContainerClientListBlobFlatSegmentOptions,
BlobContainerClientReleaseLeaseOptions, BlobContainerClientRenewLeaseOptions,
BlobContainerClientSetMetadataOptions, ListBlobsFlatSegmentResponse,
},
pipeline::StorageHeadersPolicy,
BlobClient, BlobContainerClientOptions,
Expand Down Expand Up @@ -233,4 +234,17 @@ impl BlobContainerClient {
) -> Result<Response<BlobContainerClientRenewLeaseResult, NoFormat>> {
self.client.renew_lease(lease_id, options).await
}

/// Gets information related to the Storage account in which the container resides.
/// This includes the `sku_name` and `account_kind`.
///
/// # Arguments
///
/// * `options` - Optional configuration for the request.
pub async fn get_account_info(
&self,
options: Option<BlobContainerClientGetAccountInfoOptions<'_>>,
) -> Result<Response<BlobContainerClientGetAccountInfoResult, NoFormat>> {
self.client.get_account_info(options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use crate::{
generated::clients::BlobServiceClient as GeneratedBlobServiceClient,
generated::models::BlobServiceClientGetAccountInfoResult,
models::{
BlobServiceClientGetPropertiesOptions, BlobServiceClientListContainersSegmentOptions,
BlobServiceClientGetAccountInfoOptions, BlobServiceClientGetPropertiesOptions,
BlobServiceClientListContainersSegmentOptions, BlobServiceClientSetPropertiesOptions,
ListContainersSegmentResponse, StorageServiceProperties,
},
pipeline::StorageHeadersPolicy,
Expand All @@ -14,7 +16,7 @@ use azure_core::{
credentials::TokenCredential,
http::{
policies::{BearerTokenCredentialPolicy, Policy},
PageIterator, Response, Url, XmlFormat,
NoFormat, PageIterator, RequestContent, Response, Url, XmlFormat,
},
Result,
};
Expand Down Expand Up @@ -95,4 +97,33 @@ impl BlobServiceClient {
) -> Result<PageIterator<Response<ListContainersSegmentResponse, XmlFormat>>> {
self.client.list_containers_segment(options)
}

/// Sets properties for a Storage account's Blob service endpoint, including properties for Storage Analytics and CORS rules.
///
/// # Arguments
///
/// * `storage_service_properties` - The Storage service properties to set.
/// * `options` - Optional configuration for the request.
pub async fn set_properties(
&self,
storage_service_properties: RequestContent<StorageServiceProperties, XmlFormat>,
options: Option<BlobServiceClientSetPropertiesOptions<'_>>,
) -> Result<Response<(), NoFormat>> {
self.client
.set_properties(storage_service_properties, options)
.await
}

/// Gets information related to the Storage account.
/// This includes the `sku_name` and `account_kind`.
///
/// # Arguments
///
/// * `options` - Optional configuration for the request.
pub async fn get_account_info(
&self,
options: Option<BlobServiceClientGetAccountInfoOptions<'_>>,
) -> Result<Response<BlobServiceClientGetAccountInfoResult, NoFormat>> {
self.client.get_account_info(options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ impl BlockBlobClient {

let client = GeneratedBlockBlobClient::new(
endpoint,
credential.clone(),
container_name.clone(),
blob_name.clone(),
credential,
container_name,
blob_name,
Some(options),
)?;
Ok(Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl PageBlobClient {

let client = GeneratedPageBlobClient::new(
endpoint,
credential.clone(),
container_name.clone(),
blob_name.clone(),
credential,
container_name,
blob_name,
Some(options),
)?;
Ok(Self {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading