Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
5 changes: 3 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions sdk/storage/.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RAGRS
restype
ruleid
secondtag
subsecond
testblob1
testblob2
testblob3
Expand Down
3 changes: 3 additions & 0 deletions sdk/storage/azure_storage_blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added

- Added support for `set_access_policy` to `BlobContainerClient`.
- Added support for `get_access_policy` to `BlobContainerClient`.

### Breaking Changes

### Bugs Fixed
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/azure_storage_blob/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async-trait.workspace = true
azure_core = { workspace = true, features = ["xml"] }
serde.workspace = true
serde_json.workspace = true
time.workspace = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is only needed for this import in generated code:
use time::format_description::well_known::{iso8601, Iso8601};

Given that we usually just use the re-exports from azure_core, would these be something you would consider re-exporting so we don't have to have a time crate dependency?

PR is fine to merge as-is, but we should track the above if we want to go ahead with it to coordinate a fix post-merge.

typespec_client_core = { workspace = true, features = ["derive"] }
url.workspace = true
uuid.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure_storage_blob/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_1e5e3b2c6c",
"Tag": "rust/azure_storage_blob_dd4a0a3a13",
"TagPrefix": "rust/azure_storage_blob"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use crate::{
BlobContainerClientBreakLeaseOptions, BlobContainerClientBreakLeaseResult,
BlobContainerClientChangeLeaseOptions, BlobContainerClientChangeLeaseResult,
BlobContainerClientCreateOptions, BlobContainerClientDeleteOptions,
BlobContainerClientFindBlobsByTagsOptions, BlobContainerClientGetAccountInfoOptions,
BlobContainerClientGetAccountInfoResult, BlobContainerClientGetPropertiesOptions,
BlobContainerClientGetPropertiesResult, BlobContainerClientListBlobFlatSegmentOptions,
BlobContainerClientReleaseLeaseOptions, BlobContainerClientReleaseLeaseResult,
BlobContainerClientRenewLeaseOptions, BlobContainerClientRenewLeaseResult,
BlobContainerClientSetMetadataOptions,
BlobContainerClientFindBlobsByTagsOptions, BlobContainerClientGetAccessPolicyOptions,
BlobContainerClientGetAccountInfoOptions, BlobContainerClientGetAccountInfoResult,
BlobContainerClientGetPropertiesOptions, BlobContainerClientGetPropertiesResult,
BlobContainerClientListBlobFlatSegmentOptions, BlobContainerClientReleaseLeaseOptions,
BlobContainerClientReleaseLeaseResult, BlobContainerClientRenewLeaseOptions,
BlobContainerClientRenewLeaseResult, BlobContainerClientSetAccessPolicyOptions,
BlobContainerClientSetMetadataOptions, SignedIdentifiers,
},
models::{FilterBlobSegment, ListBlobsFlatSegmentResponse, StorageErrorCode},
pipeline::StorageHeadersPolicy,
Expand All @@ -25,7 +26,7 @@ use azure_core::{
error::ErrorKind,
http::{
policies::{BearerTokenAuthorizationPolicy, Policy},
NoFormat, Pager, Pipeline, Response, StatusCode, Url, XmlFormat,
NoFormat, Pager, Pipeline, RequestContent, Response, StatusCode, Url, XmlFormat,
},
tracing, Result,
};
Expand Down Expand Up @@ -365,4 +366,60 @@ impl BlobContainerClient {
Err(e) => Err(e),
}
}

/// Sets the permissions for the specified container. The permissions indicate whether blobs in a
/// container may be accessed publicly.
///
/// # Arguments
///
/// * `container_acl` - The access control list for the container. You can create this from a
/// [`HashMap<String, AccessPolicy>`] using [`SignedIdentifiers::from()`] and then wrapping it into a RequestContent.
/// * `options` - Optional configuration for the request.
///
/// # Example
///
/// ```rust,no_run
/// use std::collections::HashMap;
/// use azure_core::{http::RequestContent, Result};
/// use azure_storage_blob::{BlobContainerClient, models::{AccessPolicy, SignedIdentifiers}};
///
/// async fn example() -> Result<()> {
/// let container_client = BlobContainerClient::new(
/// "https://storageaccount.blob.core.windows.net/",
/// "some_container_name",
/// None,
/// None,
/// )?;
///
/// let mut policies = HashMap::new();
/// policies.insert("some_policy_id".to_string(), AccessPolicy {
/// start: Some("2035-01-01T00:00:00Z".to_string()),
/// expiry: Some("2035-12-31T00:00:00Z".to_string()),
/// permission: Some("rwd".to_string()),
/// });
///
/// container_client.set_access_policy(RequestContent::try_from(SignedIdentifiers::from(policies))?, None).await?;
/// Ok(())
/// }
/// ```
pub async fn set_access_policy(
&self,
container_acl: RequestContent<SignedIdentifiers, XmlFormat>,
options: Option<BlobContainerClientSetAccessPolicyOptions<'_>>,
) -> Result<Response<(), NoFormat>> {
self.client.set_access_policy(container_acl, options).await
}

/// Gets the permissions for the specified container. The permissions indicate whether container data
/// may be accessed publicly.
///
/// # Arguments
///
/// * `options` - Optional configuration for the request.
pub async fn get_access_policy(
&self,
options: Option<BlobContainerClientGetAccessPolicyOptions<'_>>,
) -> Result<Response<SignedIdentifiers, XmlFormat>> {
self.client.get_access_policy(options).await
}
}

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

Loading