Skip to content
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] get_blob_properties for BlobClient #2014

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

vincenttran-msft
Copy link
Member

@vincenttran-msft vincenttran-msft commented Jan 22, 2025

This PR contains the following:

  • Fleshed out implementation of BlobClient to support get_blob_properties
  • get_blob_properties and simple test cases (get properties with existing blob, container not exists case)

@vincenttran-msft vincenttran-msft marked this pull request as ready for review January 24, 2025 20:39
@vincenttran-msft vincenttran-msft changed the title [Storage] get_blob_properties initial implementation [Storage] get_blob_properties for BlobClient Jan 24, 2025
heaths
heaths previously requested changes Jan 27, 2025
sdk/storage/azure_storage_blob/Cargo.toml Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/src/clients/blob_client.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/src/clients/blob_client.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/src/lib.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/src/lib.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/tests/test_blob_client.rs Outdated Show resolved Hide resolved
@vincenttran-msft vincenttran-msft dismissed heaths’s stale review January 31, 2025 23:25

Will fix in upcoming PR.

@vincenttran-msft
Copy link
Member Author

Hi @heaths Heath, I have documented the remaining 4 feedback items into my notes, and will address them in the following PR. I have commented out the testcases since they currently rely on static resources and have a hard dependency on some NYI functionality. With that in mind- please let me know if there is any other showstoppers in this specific PR. Thanks!

sdk/storage/azure_storage_blob/tests/test_blob_client.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/tests/test_blob_client.rs Outdated Show resolved Hide resolved
sdk/storage/azure_storage_blob/src/clients/blob_client.rs Outdated Show resolved Hide resolved
client: GeneratedBlobClient,
}

impl BlobClient {
Copy link
Member

Choose a reason for hiding this comment

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

In other languages, I thought you can only get a BlobClient from a ContainerClient or something i.e., these aren't creatable. If so, they must be exported from both the crate root (re-exported) and from the clients module in which all clients - creatable or gettable - are exported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +16 to +19
pub(crate) use blob_client::BlobClient as GeneratedBlobClient;

pub use blob_client::BlobClient;
pub use crate::generated::clients::blob_blob_client::BlobBlobClientGetPropertiesOptions;
pub use crate::generated::clients::blob_client::BlobClientOptions;
Copy link
Member

Choose a reason for hiding this comment

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

Why export them from the root for the crate? Just have the modules within the crate import crate::generated::clients::BlobClient. Re-exporting types only for the crate like this is going to lead to a lot of confusion, I think. It's not typical.

Copy link
Member Author

Choose a reason for hiding this comment

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

So for L16 pub(crate) use blob_client::BlobClient as GeneratedBlobClient;, I can change this to in-line importing:
generated::clients::blob_client::BlobClient as GeneratedBlobClient

wrt L18-19, I re-exported them because I thought we wanted all client options accessible from the root (guidelines section). Without re-exporting them, we would have to import them as:

use crate::generated::{BlobClientOptions, BlobBlobClientGetPropertiesOptions};

impl FromHeaders for BlobProperties {
type Error = url::ParseError;

fn header_names() -> &'static [&'static str] {
Copy link
Member Author

Choose a reason for hiding this comment

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

I was a little confused when trying to pattern match this-- is this supposed to be an exhaustive list of the possible optional headers? For now, I only had the plain-text version of the headers I had to create a new const for.

pub content_type: String,
pub creation_time: String,
pub etag: String,
pub last_modified: String,
Copy link
Member Author

Choose a reason for hiding this comment

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

wrt this comment, is there a currently accepted way to convert from RFC1123 strings (as returned by the service) ex:
creation_time: Some("Sat, 01 Feb 2025 00:17:37 GMT" to a OffsetDateTime object? I know you can provide a custom pattern query to parse, but I assume that if we have OffsetDateTime elsewhere we may have some common utility for this?

@vincenttran-msft vincenttran-msft requested a review from a team as a code owner February 12, 2025 00:30
@vincenttran-msft
Copy link
Member Author

I was under the impression this PR was no longer passing due to merging in main and messing up the Cargo.lock, but even after attempting to merge again and cargo generate lock-file, I am still hitting some errors here. Some assistance on getting CI green alongside the review would be greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants