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 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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_f12afa9550",
"Tag": "rust/azure_storage_blob_c561afee00",
"TagPrefix": "rust/azure_storage_blob"
}
84 changes: 76 additions & 8 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ use crate::{
generated::clients::BlobClient as GeneratedBlobClient,
generated::models::{
BlobClientAcquireLeaseResult, BlobClientBreakLeaseResult, BlobClientChangeLeaseResult,
BlobClientDownloadResult, BlobClientGetPropertiesResult, BlobClientReleaseLeaseResult,
BlobClientRenewLeaseResult, BlockBlobClientCommitBlockListResult,
BlockBlobClientStageBlockResult, BlockBlobClientUploadResult,
BlobClientDownloadResult, BlobClientGetAccountInfoResult, BlobClientGetPropertiesResult,
BlobClientReleaseLeaseResult, BlobClientRenewLeaseResult, BlobClientStartCopyFromUrlResult,
BlockBlobClientCommitBlockListResult, BlockBlobClientStageBlockResult,
BlockBlobClientUploadResult,
},
models::{
AccessTier, BlobClientAcquireLeaseOptions, BlobClientBreakLeaseOptions,
BlobClientChangeLeaseOptions, BlobClientDeleteOptions, BlobClientDownloadOptions,
BlobClientGetPropertiesOptions, BlobClientReleaseLeaseOptions, BlobClientRenewLeaseOptions,
BlobClientSetMetadataOptions, BlobClientSetPropertiesOptions, BlobClientSetTierOptions,
BlockBlobClientCommitBlockListOptions, BlockBlobClientUploadOptions, BlockList,
BlockListType, BlockLookupList,
BlobClientGetAccountInfoOptions, BlobClientGetPropertiesOptions, BlobClientGetTagsOptions,
BlobClientReleaseLeaseOptions, BlobClientRenewLeaseOptions, BlobClientSetMetadataOptions,
BlobClientSetPropertiesOptions, BlobClientSetTagsOptions, BlobClientSetTierOptions,
BlobClientStartCopyFromUrlOptions, BlobTags, BlockBlobClientCommitBlockListOptions,
BlockBlobClientUploadOptions, BlockList, BlockListType, BlockLookupList,
},
pipeline::StorageHeadersPolicy,
AppendBlobClient, BlobClientOptions, BlockBlobClient, PageBlobClient,
serialize_blob_tags, AppendBlobClient, BlobClientOptions, BlockBlobClient, PageBlobClient,
};
use azure_core::{
credentials::TokenCredential,
Expand All @@ -28,6 +30,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 @@ -313,4 +316,69 @@ impl BlobClient {
) -> Result<Response<BlobClientRenewLeaseResult, NoFormat>> {
self.client.renew_lease(lease_id, options).await
}

/// Copies a blob or an internet resource to a new blob.
///
/// # Arguments
///
/// * `copy_source` - A URL of up to 2 KB in length that specifies a file or blob.
/// The value should be URL-encoded as it would appear in a request URI.
/// If the source is in another account, the source must either be public
/// or must be authenticated via a shared access signature. If the source
/// is public, no authentication is required.
/// * `options` - Optional configuration for the request.
pub async fn start_copy_from_url(
&self,
copy_source: String,
options: Option<BlobClientStartCopyFromUrlOptions<'_>>,
) -> Result<Response<BlobClientStartCopyFromUrlResult, NoFormat>> {
self.client.start_copy_from_url(copy_source, 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<BlobTags, XmlFormat>> {
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, 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 @@ -242,4 +243,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 @@ -104,4 +106,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>,
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
}
}

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
Loading