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

Add 'get_status' to datalake file client #722

Merged
merged 29 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
37980f4
Add request/response for set_blob_tier
Mar 25, 2022
08f264b
add set_blobtier function to BlobClient
Mar 28, 2022
9001f75
Check existing blob props to determine expected status code
Mar 28, 2022
a801da1
Add integration test
Mar 28, 2022
7074e21
Merge pull request #1 from rickrain/set_blob_tier
Mar 28, 2022
de83ffb
Merge branch 'Azure:main' into main
Mar 28, 2022
5a99501
Merge branch 'Azure:main' into main
Mar 29, 2022
da23cda
Merge branch 'Azure:main' into main
Mar 30, 2022
f47fa43
Merge branch 'Azure:main' into main
Apr 1, 2022
db58d34
Merge branch 'Azure:main' into main
Apr 5, 2022
291b74b
Add keyvault example create_key
Apr 6, 2022
48a84d4
Merge branch 'Azure:main' into main
Apr 6, 2022
023dbab
Fix spelling
Apr 6, 2022
9519df3
Merge branch 'main' of github.com:rickrain/azure-sdk-for-rust
Apr 6, 2022
1937fd4
cargo fmt
Apr 6, 2022
55ab73b
Apply suggestions from code review
bmc-msft Apr 6, 2022
62903be
Merge branch 'Azure:main' into main
Apr 6, 2022
1cf3d1b
Merge branch 'Azure:main' into main
Apr 8, 2022
296d6ac
Add file_system methods to get status, ACL, & check access
Apr 8, 2022
6dd3ee4
Move implmentation from file_system_client to file_client
Apr 9, 2022
7e6d906
Change file properties to Option
Apr 11, 2022
f421d57
Removing get access_control_list and check_access implementation - wi…
Apr 11, 2022
be80784
Merge branch 'Azure:main' into main
Apr 11, 2022
162e78f
Add test/transactions/datalake_file_properties
Apr 11, 2022
c2d32b7
format_json
Apr 11, 2022
9240810
Remove unused variables
Apr 26, 2022
3323b09
Better error handling for x-ms-properties
Apr 28, 2022
3d76e6c
use get_option_str_from_headers
ctaggart Apr 29, 2022
5c073a4
Merge pull request #3 from cataggar/pr722
Apr 29, 2022
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: 5 additions & 0 deletions sdk/storage_datalake/src/clients/file_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ impl FileClient {
HeadPathBuilder::new(self.clone(), self.file_system_client.context.clone())
}

pub fn get_status(&self) -> HeadPathBuilder<Self> {
HeadPathBuilder::new(self.clone(), self.file_system_client.context.clone())
.action(PathGetPropertiesAction::GetStatus)
}

pub fn set_properties(&self, properties: Properties) -> PatchPathBuilder<Self> {
PatchPathBuilder::new(self.clone(), self.file_system_client.context.clone())
.properties(properties)
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage_datalake/src/operations/path_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct HeadPathResponse {
pub common_storage_response_headers: CommonStorageResponseHeaders,
pub etag: String,
pub last_modified: DateTime<Utc>,
pub properties: Properties,
pub properties: Option<Properties>,
}

impl HeadPathResponse {
Expand All @@ -98,7 +98,7 @@ impl HeadPathResponse {
common_storage_response_headers: (&headers).try_into()?,
etag: etag_from_headers(&headers)?,
last_modified: last_modified_from_headers(&headers)?,
properties: (&headers).try_into()?,
properties: (&headers).try_into().ok(),
cataggar marked this conversation as resolved.
Show resolved Hide resolved
})
}
}
49 changes: 47 additions & 2 deletions sdk/storage_datalake/tests/files.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(feature = "mock_transport_framework")]
use azure_storage_datalake::Properties;
use std::error::Error;
use std::{assert_eq, assert_ne, error::Error};

mod setup;

Expand Down Expand Up @@ -162,7 +162,7 @@ async fn file_rename() -> Result<(), Box<dyn Error + Send + Sync>> {
let renamed_file_properties = file_client3.get_properties().into_future().await?;

// when renaming a file, the source file properties should be propagated
assert_eq!(renamed_file_properties.properties, file_properties);
assert_eq!(renamed_file_properties.properties, Some(file_properties));
assert_ne!(
renamed_file_properties.properties,
original_target_file_properties.properties
Expand All @@ -176,3 +176,48 @@ async fn file_rename() -> Result<(), Box<dyn Error + Send + Sync>> {

Ok(())
}

#[tokio::test]
async fn file_get_properties() -> Result<(), Box<dyn Error + Send + Sync>> {
let data_lake_client = setup::create_data_lake_client("datalake_file_properties")
.await
.unwrap();

let file_system_name = "azurerustsdk-datalake-file-get-properties";
let file_system_client = data_lake_client
.clone()
.into_file_system_client(file_system_name.to_string());

let create_fs_response = file_system_client.create().into_future().await?;
assert!(
create_fs_response.namespace_enabled,
"namespace should be enabled"
);

let file_path = "some/path/e2etest-file.txt";
let file_client = file_system_client.get_file_client(file_path);

file_client.create().into_future().await?;

let mut file_properties = Properties::new();
file_properties.insert("AddedVia", "Azure SDK for Rust");

file_client
.create()
.properties(file_properties.clone())
.into_future()
.await?;

// Get properties
let file_properties = file_client.get_properties().into_future().await?;
assert!(file_properties.properties.is_some());

// Get status (ie: only system-defined properties)
let file_properties = file_client.get_status().into_future().await?;
assert!(!file_properties.properties.is_some());

// Cleanup
file_system_client.delete().into_future().await?;

Ok(())
}
12 changes: 12 additions & 0 deletions test/transactions/datalake_file_properties/0_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties?resource=filesystem",
"method": "PUT",
"headers": {
"authorization": "<<STRIPPED>>",
"content-length": "0",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:46 GMT",
"x-ms-version": "2019-12-12"
},
"body": ""
}
14 changes: 14 additions & 0 deletions test/transactions/datalake_file_properties/0_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 201,
"headers": {
"content-length": "0",
"date": "Mon, 11 Apr 2022 16:19:47 GMT",
"etag": "\"0x8DA1BD718A4B558\"",
"last-modified": "Mon, 11 Apr 2022 16:19:47 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-namespace-enabled": "true",
"x-ms-request-id": "def5aa2e-901f-0073-67bf-4d3635000000",
"x-ms-version": "2019-12-12"
},
"body": ""
}
12 changes: 12 additions & 0 deletions test/transactions/datalake_file_properties/1_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties/some/path/e2etest-file.txt?resource=file",
"method": "PUT",
"headers": {
"authorization": "<<STRIPPED>>",
"content-length": "0",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:47 GMT",
"x-ms-version": "2019-12-12"
},
"body": ""
}
14 changes: 14 additions & 0 deletions test/transactions/datalake_file_properties/1_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 201,
"headers": {
"content-length": "0",
"date": "Mon, 11 Apr 2022 16:19:47 GMT",
"etag": "\"0x8DA1BD718F18E95\"",
"last-modified": "Mon, 11 Apr 2022 16:19:47 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-request-id": "def5aa30-901f-0073-69bf-4d3635000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2019-12-12"
},
"body": ""
}
13 changes: 13 additions & 0 deletions test/transactions/datalake_file_properties/2_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties/some/path/e2etest-file.txt?resource=file",
"method": "PUT",
"headers": {
"authorization": "<<STRIPPED>>",
"content-length": "0",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:47 GMT",
"x-ms-properties": "AddedVia=QXp1cmUgU0RLIGZvciBSdXN0",
"x-ms-version": "2019-12-12"
},
"body": ""
}
14 changes: 14 additions & 0 deletions test/transactions/datalake_file_properties/2_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 201,
"headers": {
"content-length": "0",
"date": "Mon, 11 Apr 2022 16:19:47 GMT",
"etag": "\"0x8DA1BD71918DC66\"",
"last-modified": "Mon, 11 Apr 2022 16:19:47 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-request-id": "def5aa32-901f-0073-6bbf-4d3635000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2019-12-12"
},
"body": ""
}
11 changes: 11 additions & 0 deletions test/transactions/datalake_file_properties/3_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties/some/path/e2etest-file.txt",
"method": "HEAD",
"headers": {
"authorization": "<<STRIPPED>>",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:47 GMT",
"x-ms-version": "2019-12-12"
},
"body": ""
}
24 changes: 24 additions & 0 deletions test/transactions/datalake_file_properties/3_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"status": 200,
"headers": {
"accept-ranges": "bytes",
"content-length": "0",
"content-type": "application/octet-stream",
"date": "Mon, 11 Apr 2022 16:19:48 GMT",
"etag": "\"0x8DA1BD71918DC66\"",
"last-modified": "Mon, 11 Apr 2022 16:19:47 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-content-crc64": "AAAAAAAAAAA=",
"x-ms-group": "$superuser",
"x-ms-lease-state": "available",
"x-ms-lease-status": "unlocked",
"x-ms-owner": "$superuser",
"x-ms-permissions": "rw-r-----",
"x-ms-properties": "AddedVia=QXp1cmUgU0RLIGZvciBSdXN0",
"x-ms-request-id": "def5aa4e-901f-0073-76bf-4d3635000000",
"x-ms-resource-type": "file",
"x-ms-server-encrypted": "true",
"x-ms-version": "2019-12-12"
},
"body": ""
}
11 changes: 11 additions & 0 deletions test/transactions/datalake_file_properties/4_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties/some/path/e2etest-file.txt?action=getStatus",
"method": "HEAD",
"headers": {
"authorization": "<<STRIPPED>>",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:48 GMT",
"x-ms-version": "2019-12-12"
},
"body": ""
}
18 changes: 18 additions & 0 deletions test/transactions/datalake_file_properties/4_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"status": 200,
"headers": {
"content-length": "0",
"date": "Mon, 11 Apr 2022 16:19:48 GMT",
"etag": "\"0x8DA1BD71918DC66\"",
"last-modified": "Mon, 11 Apr 2022 16:19:47 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-group": "$superuser",
"x-ms-owner": "$superuser",
"x-ms-permissions": "rw-r-----",
"x-ms-request-id": "def5aa4f-901f-0073-77bf-4d3635000000",
"x-ms-resource-type": "file",
"x-ms-server-encrypted": "true",
"x-ms-version": "2019-12-12"
},
"body": ""
}
12 changes: 12 additions & 0 deletions test/transactions/datalake_file_properties/5_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"uri": "/azurerustsdk-datalake-file-get-properties?resource=filesystem",
"method": "DELETE",
"headers": {
"authorization": "<<STRIPPED>>",
"content-length": "0",
"user-agent": "azsdk-rust-storage_datalake/0.1.1 (1.59.0; linux; x86_64)",
"x-ms-date": "Mon, 11 Apr 2022 16:19:48 GMT",
"x-ms-version": "2019-12-12"
},
"body": ""
}
11 changes: 11 additions & 0 deletions test/transactions/datalake_file_properties/5_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status": 202,
"headers": {
"content-length": "0",
"date": "Mon, 11 Apr 2022 16:19:48 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-request-id": "def5aa50-901f-0073-78bf-4d3635000000",
"x-ms-version": "2019-12-12"
},
"body": ""
}