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 reqest properties for azure_kusto_data crate #685

Merged
merged 29 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7b2ad71
add kusto client
roeap Mar 12, 2022
447c600
remove dead code
roeap Mar 12, 2022
285f796
clippy
roeap Mar 12, 2022
c767cf0
move request options to core crate
roeap Mar 22, 2022
b4cadce
update to new header insertion
roeap Mar 22, 2022
1eb092c
IntoFuture trait for ExecuteQuery
roeap Mar 22, 2022
ba00d69
add some more request options
roeap Mar 22, 2022
7d16308
set content length
roeap Mar 22, 2022
fa0d684
remove mosleading comment
roeap Mar 22, 2022
4716139
consolidate boolean parsing
roeap Mar 23, 2022
2db6b17
more robust boolean parsing
roeap Mar 23, 2022
d4b8b6e
remove needless lifetime
roeap Mar 23, 2022
896ad6e
support key alias in connection string
roeap Mar 23, 2022
23123ad
add alias test
roeap Mar 23, 2022
9d30ef0
Re-did aliases
AsafMah Mar 24, 2022
a530f6d
clean up request options
roeap Mar 26, 2022
c447225
use direct imports for serde macros
roeap Mar 26, 2022
1b7b286
cleanup connection string
roeap Mar 26, 2022
734c35b
add example
roeap Mar 26, 2022
411cdf3
api cleanup
roeap Mar 26, 2022
736beaa
use async-convert
roeap Mar 26, 2022
3f8c9b4
Merge branch 'kusto' into redo-aliases
AsafMah Mar 27, 2022
b60a0e1
Merge pull request #5 from AsafMah/redo-aliases
roeap Mar 27, 2022
53b1c7d
remove panics, improve result set
roeap Mar 26, 2022
7dcd591
formatting
roeap Mar 27, 2022
903a9b5
draft arrow integration
roeap Mar 27, 2022
c9cb878
clippy
roeap Mar 27, 2022
a908b36
move kusto sdk to sepatate repo
roeap Apr 23, 2022
f4d7cf5
Merge branch 'main' into kusto
roeap Apr 23, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ __queuestorage__
*.iml
*.bat
*.ps1
.env
7 changes: 5 additions & 2 deletions sdk/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ http = "0.2"
hyper = { version = "0.14", optional = true }
hyper-rustls = { version = "0.23", optional = true }
log = "0.4"
oauth2 = { version = "4.0", default-features=false }
oauth2 = { version = "4.0", default-features = false }
rand = "0.8"
reqwest = { version = "0.11", features = ["stream"], default-features=false, optional = true }
reqwest = { version = "0.11", features = [
"stream",
], default-features = false, optional = true }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand All @@ -48,6 +50,7 @@ tokio = { version = "1", features = ["default"] }
[features]
default = ["enable_reqwest"]
enable_reqwest = ["reqwest/default-tls", "oauth2/native-tls"]
enable_reqwest_gzip = ["reqwest/gzip"]
enable_reqwest_rustls = ["reqwest/rustls-tls", "oauth2/rustls-tls"]
enable_hyper = ["hyper", "hyper-rustls"]
test_e2e = []
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/src/headers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub fn add_mandatory_header<T: Header>(item: &T, builder: Builder) -> Builder {

pub const ACCOUNT_KIND: &str = "x-ms-account-kind";
pub const ACTIVITY_ID: &str = "x-ms-activity-id";
pub const APP: &str = "x-ms-app";
pub const APPEND_POSITION: &str = "x-ms-blob-condition-appendpos";
pub const BLOB_ACCESS_TIER: &str = "x-ms-access-tier";
pub const BLOB_CONTENT_LENGTH: &str = "x-ms-blob-content-length";
Expand All @@ -219,6 +220,7 @@ pub const BLOB_SEQUENCE_NUMBER: &str = "x-ms-blob-sequence-number";
pub const BLOB_TYPE: &str = "x-ms-blob-type";
pub const CACHE_CONTROL: &str = "x-ms-blob-cache-control";
pub const CLIENT_REQUEST_ID: &str = "x-ms-client-request-id";
pub const CLIENT_VERSION: &str = "x-ms-client-version";
pub const CONTENT_DISPOSITION: &str = "x-ms-blob-content-disposition";
pub const CONTINUATION: &str = "x-ms-continuation";
pub const COPY_COMPLETION_TIME: &str = "x-ms-copy-completion-time";
Expand Down Expand Up @@ -262,4 +264,5 @@ pub const SOURCE_IF_MODIFIED_SINCE: &str = "x-ms-source-if-modified-since";
pub const SOURCE_IF_NONE_MATCH: &str = "x-ms-source-if-none-match";
pub const SOURCE_IF_UNMODIFIED_SINCE: &str = "x-ms-source-if-unmodified-since";
pub const SOURCE_LEASE_ID: &str = "x-ms-source-lease-id";
pub const USER: &str = "x-ms-user";
pub const VERSION: &str = "x-ms-version";
39 changes: 39 additions & 0 deletions sdk/core/src/request_options/accept.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::headers::{self, Header};

/// Advertises which content types the client is able to understand.
///
/// The Accept request HTTP header advertises which content types, expressed
/// as MIME types, the client is able to understand. Using content
/// negotiation, the server then selects one of the proposals, uses it and
/// informs the client of its choice with the Content-Type response header.
/// Browsers set adequate values for this header depending of the context
/// where the request is done: when fetching a CSS stylesheet a different
/// value is set for the request than when fetching an image, video or a
/// script.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Accept(String);

impl Accept {
pub fn new(s: String) -> Self {
Self(s)
}
}

impl<S> From<S> for Accept
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for Accept {
fn name(&self) -> headers::HeaderName {
http::header::ACCEPT.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
40 changes: 40 additions & 0 deletions sdk/core/src/request_options/accept_encoding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use crate::headers::{self, Header};

/// Advertises which content encoding the client is able to understand.
///
/// The Accept-Encoding request HTTP header advertises which content
/// encoding, usually a compression algorithm, the client is able to
/// understand. Using content negotiation, the server selects one of the
/// proposals, uses it and informs the client of its choice with the
/// Content-Encoding response header.
///
/// Even if both the client and the server supports the same compression
/// algorithms, the server may choose not to compress the body of a
/// response, if the identity value is also acceptable.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AcceptEncoding(String);

impl AcceptEncoding {
pub fn new(s: String) -> Self {
Self(s)
}
}

impl<S> From<S> for AcceptEncoding
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for AcceptEncoding {
fn name(&self) -> headers::HeaderName {
http::header::ACCEPT_ENCODING.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
19 changes: 14 additions & 5 deletions sdk/core/src/request_options/activity_id.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
use crate::headers::{self, Header};

#[derive(Debug, Clone, Copy)]
pub struct ActivityId<'a>(&'a str);
#[derive(Debug, Clone)]
pub struct ActivityId(String);

impl<'a> ActivityId<'a> {
pub fn new(id: &'a str) -> Self {
impl ActivityId {
pub fn new(id: String) -> Self {
Self(id)
}
}

impl<'a> Header for ActivityId<'a> {
impl<S> From<S> for ActivityId
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for ActivityId {
fn name(&self) -> headers::HeaderName {
headers::ACTIVITY_ID.into()
}
Expand Down
30 changes: 30 additions & 0 deletions sdk/core/src/request_options/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::headers::{self, Header};

/// The (friendly) name of the application making the request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct App(String);

impl App {
pub fn new(s: String) -> Self {
Self(s)
}
}

impl<S> From<S> for App
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for App {
fn name(&self) -> headers::HeaderName {
headers::APP.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
16 changes: 7 additions & 9 deletions sdk/core/src/request_options/client_request_id.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::headers;
use crate::Header;

/// A unique identifier for the request
#[derive(Debug, Clone)]
pub struct ClientRequestId(String);

Expand All @@ -10,15 +11,12 @@ impl ClientRequestId {
}
}

impl From<String> for ClientRequestId {
fn from(client_request_id: String) -> Self {
Self::new(client_request_id)
}
}

impl From<&str> for ClientRequestId {
fn from(client_request_id: &str) -> Self {
Self::new(client_request_id.into())
impl<S> From<S> for ClientRequestId
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

Expand Down
31 changes: 31 additions & 0 deletions sdk/core/src/request_options/client_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::headers;
use crate::Header;

/// The (friendly) version identifier for the client making the request
#[derive(Debug, Clone)]
pub struct ClientVersion(String);

impl ClientVersion {
pub fn new(client_request_id: String) -> Self {
Self(client_request_id)
}
}

impl<S> From<S> for ClientVersion
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for ClientVersion {
fn name(&self) -> headers::HeaderName {
headers::CLIENT_VERSION.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
12 changes: 12 additions & 0 deletions sdk/core/src/request_options/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
mod accept;
mod accept_encoding;
mod activity_id;
mod app;
mod client_request_id;
mod client_version;
mod content_disposition;
mod content_encoding;
mod content_language;
Expand Down Expand Up @@ -27,10 +31,16 @@ mod sequence_number;
mod sequence_number_condition;
mod source_lease_id;
mod timeout;
mod user;
mod user_agent;
mod version;

pub use accept::Accept;
pub use accept_encoding::AcceptEncoding;
pub use activity_id::ActivityId;
pub use app::App;
pub use client_request_id::ClientRequestId;
pub use client_version::ClientVersion;
pub use content_disposition::ContentDisposition;
pub use content_encoding::ContentEncoding;
pub use content_language::ContentLanguage;
Expand Down Expand Up @@ -58,4 +68,6 @@ pub use sequence_number::SequenceNumber;
pub use sequence_number_condition::SequenceNumberCondition;
pub use source_lease_id::SourceLeaseId;
pub use timeout::Timeout;
pub use user::User;
pub use user_agent::UserAgent;
pub use version::Version;
30 changes: 30 additions & 0 deletions sdk/core/src/request_options/user.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::headers::{self, Header};

/// The (friendly) name of the user making the request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct User(String);

impl User {
pub fn new(s: String) -> Self {
Self(s)
}
}

impl<S> From<S> for User
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for User {
fn name(&self) -> headers::HeaderName {
headers::USER.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
29 changes: 29 additions & 0 deletions sdk/core/src/request_options/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::headers::{self, Header};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Version(String);

impl Version {
pub fn new(s: String) -> Self {
Self(s)
}
}

impl<S> From<S> for Version
where
S: Into<String>,
{
fn from(s: S) -> Self {
Self(s.into())
}
}

impl Header for Version {
fn name(&self) -> headers::HeaderName {
headers::VERSION.into()
}

fn value(&self) -> headers::HeaderValue {
self.0.to_owned().into()
}
}
40 changes: 40 additions & 0 deletions sdk/data_kusto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "azure_data_kusto"
version = "0.1.0"
description = "Rust wrappers around Microsoft Azure REST APIs - Azure Data Explorer"
readme = "README.md"
license = "MIT"
edition = "2021"
repository = "https://github.com/azure/azure-sdk-for-rust"
homepage = "https://github.com/azure/azure-sdk-for-rust"
documentation = "https://docs.rs/azure_data_kusto"
keywords = ["sdk", "azure", "kusto", "azure-data-explorer"]
categories = ["api-bindings"]

[dependencies]
arrow = { version = "9", optional = true }
azure_core = { path = "../core", version = "0.1", features = [
"enable_reqwest",
"enable_reqwest_gzip",
] }
azure_identity = { path = "../identity", version = "0.1" }
async-trait = "0.1"
async-convert = "1"
bytes = "1"
futures = "0.3"
http = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
thiserror = "1"
lazy_static = "1.4.0"
hashbrown = "0.12.0"

[dev-dependencies]
env_logger = "0.9"
tokio = { version = "1", features = ["macros"] }

[features]
default = ["arrow"]
mock_transport_framework = ["azure_core/mock_transport_framework"]
into_future = []
test_e2e = []
8 changes: 8 additions & 0 deletions sdk/data_kusto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Azure SDK for Rust - Azure Kusto crate

## The Kusto crate.

`azure-data-kusto` offers functionality needed to interact with Azure Data Explorer (Kusto) from Rust.
As an abstraction over the [Azure Data Explorer REST API](https://docs.microsoft.com/en-us/azure/data-explorer/kusto/api/rest/)

For usage have a look at the [examples](https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/data_kusto/examples).
Loading