-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ADLS Gen2 Filesystem API (#67)
* Initial go at ADLS Gen2 Filesystem API support (it compiles, at least) * Corrected support for List Filesystems using IncompleteVector Fix HTTP verbs for requests Fix expected status codes for responses * Format json * Add E2E tests and fix silly mistakes uncovered by them
- Loading branch information
Showing
35 changed files
with
1,890 additions
and
71 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -51,3 +51,4 @@ account = [] | |
blob = [] | ||
queue = [] | ||
table = [] | ||
adls_gen2 = [] |
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,90 @@ | ||
pub mod requests; | ||
pub mod responses; | ||
|
||
use azure_core::errors::AzureError; | ||
use azure_core::headers::{CONTINUATION, PROPERTIES}; | ||
use azure_core::incompletevector::IncompleteVector; | ||
use azure_core::util::HeaderMapExt; | ||
use http::{request::Builder, HeaderMap}; | ||
use serde::Deserialize; | ||
|
||
pub trait FilesystemRequired<'a> { | ||
fn filesystem(&self) -> &'a str; | ||
} | ||
|
||
pub trait FilesystemSupport<'a> { | ||
type O; | ||
fn with_filesystem(self, filesystem: &'a str) -> Self::O; | ||
} | ||
|
||
pub trait PropertiesOption<'a> { | ||
fn properties(&self) -> Option<&'a str>; | ||
|
||
#[must_use] | ||
fn add_header(&self, mut builder: Builder) -> Builder { | ||
if let Some(properties) = self.properties() { | ||
builder = builder.header(PROPERTIES, properties); | ||
} | ||
builder | ||
} | ||
} | ||
|
||
pub trait PropertiesSupport<'a> { | ||
type O; | ||
fn with_properties(self, properties: &'a str) -> Self::O; | ||
} | ||
|
||
pub(crate) fn properties_from_headers(headers: &HeaderMap) -> Result<String, AzureError> { | ||
let properties = headers | ||
.get_as_str(azure_core::headers::PROPERTIES) | ||
.ok_or_else(|| AzureError::HeaderNotFound(azure_core::headers::PROPERTIES.to_owned()))?; | ||
Ok(properties.to_owned()) | ||
} | ||
|
||
pub(crate) fn namespace_enabled_from_headers(headers: &HeaderMap) -> Result<bool, AzureError> { | ||
let namespace_enabled = headers | ||
.get(azure_core::headers::NAMESPACE_ENABLED) | ||
.ok_or_else(|| { | ||
AzureError::HeaderNotFound(azure_core::headers::NAMESPACE_ENABLED.to_owned()) | ||
})? | ||
.to_str()?; | ||
|
||
let namespace_enabled = namespace_enabled.parse::<bool>()?; | ||
Ok(namespace_enabled) | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct Filesystem { | ||
pub etag: String, | ||
#[serde(rename = "lastModified")] | ||
pub last_modified: String, | ||
pub name: String, | ||
} | ||
|
||
#[inline] | ||
pub(crate) fn incomplete_vector_from_response( | ||
headers: &HeaderMap, | ||
body: &str, | ||
) -> Result<IncompleteVector<Filesystem>, AzureError> { | ||
trace!("body = {}", body); | ||
|
||
let continuation = match headers.get_as_string(CONTINUATION) { | ||
Some(ref ct) if ct == "" => None, | ||
Some(ct) => Some(ct), | ||
None => None, | ||
}; | ||
|
||
debug!("continuation == {:?}", continuation); | ||
|
||
#[derive(Deserialize)] | ||
struct Filesystems { | ||
filesystems: Vec<Filesystem>, | ||
} | ||
|
||
let Filesystems { filesystems } = serde_json::from_str(&body)?; | ||
|
||
Ok(IncompleteVector::<Filesystem>::new( | ||
continuation, | ||
filesystems, | ||
)) | ||
} |
60 changes: 60 additions & 0 deletions
60
sdk/storage/src/adls_gen2/filesystem/requests/create_filesystem_builder.json
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,60 @@ | ||
{ | ||
"name": "CreateFilesystemBuilder", | ||
"derive": "Debug, Clone", | ||
"uses": [ | ||
"crate::core::prelude::*", | ||
"crate::filesystem::responses::CreateFilesystemResponse", | ||
"crate::filesystem::{FilesystemRequired, FilesystemSupport, PropertiesOption, PropertiesSupport}", | ||
"azure_core::errors::{check_status_extract_headers_and_body, AzureError}", | ||
"azure_core::{ClientRequestIdOption, ClientRequestIdSupport, TimeoutOption, TimeoutSupport}", | ||
"azure_core::{No, ToAssign, Yes}", | ||
"hyper::{Method, StatusCode}", | ||
"std::marker::PhantomData" | ||
], | ||
"inline": true, | ||
"extra_types": [ | ||
"'a", | ||
"C" | ||
], | ||
"extra_wheres": [ | ||
"C: Client" | ||
], | ||
"constructor_fields": [ | ||
{ | ||
"name": "client", | ||
"field_type": "&'a C", | ||
"trait_get": "ClientRequired<'a, C>" | ||
} | ||
], | ||
"fields": [ | ||
{ | ||
"name": "filesystem", | ||
"field_type": "&'a str", | ||
"builder_type": "FilesystemSet", | ||
"optional": false, | ||
"trait_get": "FilesystemRequired<'a>", | ||
"trait_set": "FilesystemSupport<'a>" | ||
}, | ||
{ | ||
"name": "timeout", | ||
"field_type": "u64", | ||
"optional": true, | ||
"trait_get": "TimeoutOption", | ||
"trait_set": "TimeoutSupport" | ||
}, | ||
{ | ||
"name": "properties", | ||
"field_type": "&'a str", | ||
"optional": true, | ||
"trait_get": "PropertiesOption", | ||
"trait_set": "PropertiesSupport" | ||
}, | ||
{ | ||
"name": "client_request_id", | ||
"field_type": "&'a str", | ||
"optional": true, | ||
"trait_get": "ClientRequestIdOption<'a>", | ||
"trait_set": "ClientRequestIdSupport<'a>" | ||
} | ||
] | ||
} |
Oops, something went wrong.