Skip to content

[Storage] get_account_info for all clients, set/get_tags for BlobClient #2661

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
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_231754d877",
"Tag": "rust/azure_storage_blob_3efb7d4663",
"TagPrefix": "rust/azure_storage_blob"
}
67 changes: 57 additions & 10 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

use crate::serialize::serialize_blob_tags;
use crate::{
generated::clients::BlobClient as GeneratedBlobClient,
generated::models::{
BlobClientDownloadResult, BlobClientGetPropertiesResult,
BlockBlobClientCommitBlockListResult, BlockBlobClientStageBlockResult,
BlockBlobClientUploadResult,
},
models::{
AccessTier, BlobClientDeleteOptions, BlobClientDownloadOptions,
BlobClientGetPropertiesOptions, BlobClientSetMetadataOptions,
BlobClientSetPropertiesOptions, BlobClientSetTierOptions,
BlockBlobClientCommitBlockListOptions, BlockBlobClientUploadOptions, BlockList,
BlockListType, BlockLookupList,
AccessTier, BlobClientDeleteOptions, BlobClientDownloadOptions, BlobClientDownloadResult,
BlobClientGetAccountInfoOptions, BlobClientGetAccountInfoResult,
BlobClientGetPropertiesOptions, BlobClientGetPropertiesResult, BlobClientGetTagsOptions,
BlobClientSetMetadataOptions, BlobClientSetPropertiesOptions, BlobClientSetTagsOptions,
BlobClientSetTierOptions, BlobTags, BlockBlobClientCommitBlockListOptions,
BlockBlobClientCommitBlockListResult, BlockBlobClientStageBlockResult,
BlockBlobClientUploadOptions, BlockBlobClientUploadResult, BlockList, BlockListType,
BlockLookupList,
},
pipeline::StorageHeadersPolicy,
BlobClientOptions, BlockBlobClient,
Expand All @@ -26,6 +25,7 @@ use azure_core::{
},
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 @@ -211,4 +211,51 @@ impl BlobClient {
) -> Result<Response<()>> {
self.client.set_tier(tier, 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<()>> {
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<BlobTags>> {
self.client.get_tags(options).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>> {
self.client.get_account_info(options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

use crate::{
generated::clients::BlobContainerClient as GeneratedBlobContainerClient,
generated::models::BlobContainerClientGetPropertiesResult,
models::{
BlobContainerClientCreateOptions, BlobContainerClientDeleteOptions,
BlobContainerClientGetPropertiesOptions, BlobContainerClientListBlobFlatSegmentOptions,
BlobContainerClientSetMetadataOptions, ListBlobsFlatSegmentResponse,
BlobContainerClientGetAccountInfoOptions, BlobContainerClientGetAccountInfoResult,
BlobContainerClientGetPropertiesOptions, BlobContainerClientGetPropertiesResult,
BlobContainerClientListBlobFlatSegmentOptions, BlobContainerClientSetMetadataOptions,
ListBlobsFlatSegmentResponse,
},
pipeline::StorageHeadersPolicy,
BlobClient, BlobContainerClientOptions,
Expand Down Expand Up @@ -157,4 +158,17 @@ impl BlobContainerClient {
) -> Result<Pager<ListBlobsFlatSegmentResponse>> {
self.client.list_blob_flat_segment(options)
}

/// 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>> {
self.client.get_account_info(options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

use crate::{
generated::clients::BlobServiceClient as GeneratedBlobServiceClient,
models::{BlobServiceClientGetPropertiesOptions, StorageServiceProperties},
models::{
BlobServiceClientGetAccountInfoOptions, BlobServiceClientGetAccountInfoResult,
BlobServiceClientGetPropertiesOptions, StorageServiceProperties,
},
pipeline::StorageHeadersPolicy,
BlobContainerClient, BlobServiceClientOptions,
};
Expand Down Expand Up @@ -89,4 +92,17 @@ impl BlobServiceClient {
) -> Result<Response<StorageServiceProperties>> {
self.client.get_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>> {
self.client.get_account_info(options).await
}
}

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.

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