-
Notifications
You must be signed in to change notification settings - Fork 267
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
[Storage] stage_block
, commit_block_list
for BlobClient
, get_container_properties
for ContainerClient
, get_service_properties
for ServiceClient
#2273
Draft
vincenttran-msft
wants to merge
3
commits into
main
Choose a base branch
from
vincenttran/remaining_mvp_functionality
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
AAABBBCCC | ||
appendblock | ||
appendpos | ||
blockid | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_d76e2bb82c", | ||
"Tag": "rust/azure_storage_blob_d1ca6ac4ca", | ||
"TagPrefix": "rust/azure_storage_blob" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sdk/storage/azure_storage_blob/src/clients/blob_service_client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
use crate::{ | ||
clients::GeneratedBlobClient, | ||
models::{BlobServiceClientGetPropertiesOptions, StorageServiceProperties}, | ||
pipeline::StorageHeadersPolicy, | ||
BlobClientOptions, | ||
}; | ||
use azure_core::{ | ||
credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url, | ||
}; | ||
use std::sync::Arc; | ||
|
||
pub struct BlobServiceClient { | ||
endpoint: Url, | ||
client: GeneratedBlobClient, | ||
} | ||
|
||
impl BlobServiceClient { | ||
pub fn new( | ||
endpoint: &str, | ||
credential: Arc<dyn TokenCredential>, | ||
options: Option<BlobClientOptions>, | ||
) -> Result<Self> { | ||
let mut options = options.unwrap_or_default(); | ||
|
||
let storage_headers_policy = Arc::new(StorageHeadersPolicy); | ||
options | ||
.client_options | ||
.per_call_policies | ||
.push(storage_headers_policy); | ||
|
||
let oauth_token_policy = BearerTokenCredentialPolicy::new( | ||
credential.clone(), | ||
["https://storage.azure.com/.default"], | ||
); | ||
options | ||
.client_options | ||
.per_try_policies | ||
.push(Arc::new(oauth_token_policy) as Arc<dyn Policy>); | ||
|
||
let client = GeneratedBlobClient::new(endpoint, credential, Some(options))?; | ||
|
||
Ok(Self { | ||
endpoint: endpoint.parse()?, | ||
client, | ||
}) | ||
} | ||
|
||
pub fn endpoint(&self) -> &Url { | ||
&self.endpoint | ||
} | ||
|
||
pub async fn get_service_properties( | ||
&self, | ||
options: Option<BlobServiceClientGetPropertiesOptions<'_>>, | ||
) -> Result<Response<StorageServiceProperties>> { | ||
let response = self | ||
.client | ||
.get_blob_service_client() | ||
.get_properties(options) | ||
.await?; | ||
Ok(response) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
sdk/storage/azure_storage_blob/src/models/container_properties.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
use azure_core::{ | ||
headers::{ | ||
FromHeaders, HeaderName, Headers, ETAG, HAS_IMMUTABILITY_POLICY, HAS_LEGAL_HOLD, | ||
LEASE_STATE, LEASE_STATUS, VERSION, | ||
}, | ||
Error, Etag, LeaseStatus, | ||
}; | ||
use typespec_client_core::fmt::SafeDebug; | ||
|
||
use crate::models::LeaseState; | ||
|
||
pub const LAST_MODIFIED: HeaderName = HeaderName::from_static("last-modified"); | ||
pub const IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED: HeaderName = | ||
HeaderName::from_static("x-ms-immutable-storage-with-versioning-enabled"); | ||
|
||
/// Properties of an Azure Storage container. | ||
/// | ||
#[derive(Clone, Default, SafeDebug)] | ||
pub struct ContainerProperties { | ||
pub last_modified: Option<String>, | ||
pub lease_state: Option<LeaseState>, | ||
pub lease_status: Option<LeaseStatus>, | ||
pub has_immutability_policy: Option<bool>, | ||
pub has_legal_hold: Option<bool>, | ||
pub immutable_storage_with_versioning_enabled: Option<String>, | ||
pub etag: Option<Etag>, | ||
pub version: Option<String>, | ||
} | ||
|
||
impl FromHeaders for ContainerProperties { | ||
type Error = Error; | ||
fn header_names() -> &'static [&'static str] { | ||
&[ | ||
"etag", | ||
"last-modified", | ||
"x-ms-lease-state", | ||
"x-ms-lease-status", | ||
"x-ms-immutable-storage-with-versioning-enabled", | ||
"x-ms-has-immutability-policy", | ||
"x-ms-version", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version is not a container property, we should remove this and all its parsing logic. |
||
"x-ms-has-legal-hold", | ||
] | ||
} | ||
|
||
fn from_headers(headers: &Headers) -> Result<Option<Self>, Error> { | ||
let mut properties = ContainerProperties { | ||
..Default::default() | ||
}; | ||
|
||
let last_modified = headers.get_optional_str(&LAST_MODIFIED); | ||
properties.last_modified = last_modified.map(|s| s.to_string()); | ||
|
||
let lease_state: Option<LeaseState> = headers.get_optional_as(&LEASE_STATE)?; | ||
properties.lease_state = lease_state; | ||
|
||
let lease_status: Option<LeaseStatus> = headers.get_optional_as(&LEASE_STATUS)?; | ||
properties.lease_status = lease_status; | ||
|
||
let has_immutability_policy: Option<bool> = | ||
headers.get_optional_as(&HAS_IMMUTABILITY_POLICY)?; | ||
properties.has_immutability_policy = has_immutability_policy; | ||
|
||
let has_legal_hold: Option<bool> = headers.get_optional_as(&HAS_LEGAL_HOLD)?; | ||
properties.has_legal_hold = has_legal_hold; | ||
|
||
let immutable_storage_with_versioning_enabled = | ||
headers.get_optional_str(&IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED); | ||
properties.immutable_storage_with_versioning_enabled = | ||
immutable_storage_with_versioning_enabled.map(|s| s.to_string()); | ||
|
||
let version = headers.get_optional_str(&VERSION); | ||
properties.version = version.map(|s| s.to_string()); | ||
|
||
let etag: Option<Etag> = headers.get_optional_as(&ETAG)?; | ||
properties.etag = etag; | ||
|
||
let last_modified = headers.get_optional_str(&LAST_MODIFIED); | ||
properties.last_modified = last_modified.map(|s| s.to_string()); | ||
|
||
let lease_state: Option<LeaseState> = headers.get_optional_as(&LEASE_STATE)?; | ||
properties.lease_state = lease_state; | ||
|
||
let lease_status: Option<LeaseStatus> = headers.get_optional_as(&LEASE_STATUS)?; | ||
properties.lease_status = lease_status; | ||
|
||
Ok(Some(properties)) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fully working E2E against a forked copy of the generated code that contained the necessary fixes. This will be fixed when we can regenerate and get the necessary generated code changes (emitter currently is broken by newest
.tsp
definition).Same comment applies to
get_service_properties
forBlobServiceClient
.