diff --git a/sdk/core/Cargo.toml b/sdk/core/Cargo.toml index 12991c401e..b86f36ac95 100644 --- a/sdk/core/Cargo.toml +++ b/sdk/core/Cargo.toml @@ -19,7 +19,8 @@ bytes = "1.0" chrono = "0.4" dyn-clone = "1.0" futures = "0.3" -http = "0.2" +http-types = "2.12" + log = "0.4" rand = "0.8" reqwest = { version = "0.11", features = [ diff --git a/sdk/core/src/error/http_error.rs b/sdk/core/src/error/http_error.rs index bd647ff5a9..8fa52fb235 100644 --- a/sdk/core/src/error/http_error.rs +++ b/sdk/core/src/error/http_error.rs @@ -1,4 +1,4 @@ -use crate::{headers, Response}; +use crate::{headers, response, Response, INVALID_BODY}; use bytes::Bytes; use std::collections::HashMap; @@ -16,19 +16,21 @@ impl HttpError { /// /// This does not check whether the response was a success and should only be used with unsuccessful responses. pub async fn new(response: Response) -> Self { - let status = response.status(); let mut error_code = get_error_code_from_header(&response); - let mut headers = HashMap::new(); + let (status, headers, body) = response.deconstruct(); + let mut error_headers = HashMap::new(); - for (name, value) in response.headers().iter() { - headers.insert(name.as_str().to_string(), value.as_str().to_string()); + for (name, value) in headers.iter() { + error_headers.insert(name.as_str().to_string(), value.as_str().to_string()); } - let body = response.into_body().await; + let body = response::collect_pinned_stream(body) + .await + .unwrap_or_else(|_| Bytes::from_static(INVALID_BODY)); error_code = error_code.or_else(|| get_error_code_from_body(&body)); HttpError { status: status.as_u16(), - headers, + headers: error_headers, error_code, body, } diff --git a/sdk/core/src/error/hyperium_http.rs b/sdk/core/src/error/hyperium_http.rs deleted file mode 100644 index b47e5bfbe5..0000000000 --- a/sdk/core/src/error/hyperium_http.rs +++ /dev/null @@ -1,34 +0,0 @@ -use super::{Error, ErrorKind}; -use http::method::InvalidMethod; -use http::status::InvalidStatusCode; -use http::uri::{InvalidUri, InvalidUriParts}; - -impl From for super::Error { - fn from(err: http::Error) -> super::Error { - Error::new(ErrorKind::DataConversion, err) - } -} - -impl From for super::Error { - fn from(err: InvalidMethod) -> super::Error { - Error::new(ErrorKind::DataConversion, err) - } -} - -impl From for super::Error { - fn from(err: InvalidStatusCode) -> super::Error { - Error::new(ErrorKind::DataConversion, err) - } -} - -impl From for super::Error { - fn from(err: InvalidUri) -> super::Error { - Error::new(ErrorKind::DataConversion, err) - } -} - -impl From for super::Error { - fn from(err: InvalidUriParts) -> super::Error { - Error::new(ErrorKind::DataConversion, err) - } -} diff --git a/sdk/core/src/error/mod.rs b/sdk/core/src/error/mod.rs index 0b2f19d492..c20bb1a688 100644 --- a/sdk/core/src/error/mod.rs +++ b/sdk/core/src/error/mod.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use std::fmt::{Debug, Display}; mod http_error; -mod hyperium_http; mod macros; pub use http_error::HttpError; diff --git a/sdk/core/src/headers/mod.rs b/sdk/core/src/headers/mod.rs index 3fc9a5d322..8cec598b7b 100644 --- a/sdk/core/src/headers/mod.rs +++ b/sdk/core/src/headers/mod.rs @@ -2,7 +2,7 @@ mod utilities; use crate::error::{Error, ErrorKind, ResultExt}; -use std::{collections::HashMap, fmt::Debug, str::FromStr}; +use std::{fmt::Debug, str::FromStr}; pub use utilities::*; /// A trait for converting a type into request headers @@ -162,22 +162,6 @@ impl From> for Headers { } } -impl From<&http::HeaderMap> for Headers { - fn from(map: &http::HeaderMap) -> Self { - let map = map - .into_iter() - .map(|(k, v)| { - let key = k.as_str().to_owned(); - let value = std::str::from_utf8(v.as_bytes()) - .expect("non-UTF8 header value") - .to_owned(); - (key.into(), value.into()) - }) - .collect::>(); - Self(map) - } -} - /// A header name #[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] pub struct HeaderName(std::borrow::Cow<'static, str>); diff --git a/sdk/core/src/http_client.rs b/sdk/core/src/http_client/mod.rs similarity index 52% rename from sdk/core/src/http_client.rs rename to sdk/core/src/http_client/mod.rs index fdf37d6ac5..0d2f4b9a78 100644 --- a/sdk/core/src/http_client.rs +++ b/sdk/core/src/http_client/mod.rs @@ -1,3 +1,10 @@ +#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))] +#[cfg(not(target_arch = "wasm32"))] +mod reqwest; + +#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))] +#[cfg(not(target_arch = "wasm32"))] +pub use self::reqwest::*; #[allow(unused_imports)] use crate::error::{Error, ErrorKind, ResultExt}; #[allow(unused_imports)] @@ -10,13 +17,6 @@ use bytes::Bytes; use futures::TryStreamExt; use serde::Serialize; -/// Construct a new `HttpClient` with the `reqwest` backend. -#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))] -#[cfg(not(target_arch = "wasm32"))] -pub fn new_http_client() -> std::sync::Arc { - std::sync::Arc::new(reqwest::Client::new()) -} - /// An HTTP client which can send requests. #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] @@ -45,53 +45,6 @@ pub trait HttpClient: Send + Sync + std::fmt::Debug { } } -#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))] -#[cfg(not(target_arch = "wasm32"))] -#[async_trait] -impl HttpClient for reqwest::Client { - async fn execute_request(&self, request: &crate::Request) -> crate::Result { - let url = request.url().clone(); - let mut reqwest_request = self.request(request.method().clone(), url); - for (name, value) in request.headers().iter() { - reqwest_request = reqwest_request.header(name.as_str(), value.as_str()); - } - - let body = request.body().clone(); - - let reqwest_request = match body { - Body::Bytes(bytes) => reqwest_request - .body(bytes) - .build() - .context(ErrorKind::Other, "failed to build request")?, - Body::SeekableStream(mut seekable_stream) => { - seekable_stream.reset().await.unwrap(); // TODO: remove unwrap when `HttpError` has been removed - - reqwest_request - .body(reqwest::Body::wrap_stream(seekable_stream)) - .build() - .context(ErrorKind::Other, "failed to build request")? - } - }; - - let reqwest_response = self - .execute(reqwest_request) - .await - .context(ErrorKind::Io, "failed to execute request")?; - - let status = reqwest_response.status(); - let headers = Headers::from(reqwest_response.headers()); - let body: PinnedStream = Box::pin(reqwest_response.bytes_stream().map_err(|error| { - Error::full( - ErrorKind::Io, - error, - "error converting `reqwest` request into a byte stream", - ) - })); - - Ok(crate::Response::new(status, headers, body)) - } -} - /// Serialize a type to json. pub fn to_json(value: &T) -> crate::Result where diff --git a/sdk/core/src/http_client/reqwest.rs b/sdk/core/src/http_client/reqwest.rs new file mode 100644 index 0000000000..50a7833283 --- /dev/null +++ b/sdk/core/src/http_client/reqwest.rs @@ -0,0 +1,84 @@ +use super::*; +use std::{collections::HashMap, str::FromStr}; + +/// Construct a new `HttpClient` with the `reqwest` backend. +pub fn new_http_client() -> std::sync::Arc { + std::sync::Arc::new(::reqwest::Client::new()) +} + +#[async_trait] +impl HttpClient for ::reqwest::Client { + async fn execute_request(&self, request: &crate::Request) -> crate::Result { + let url = request.url().clone(); + let mut req = self.request(try_from_method(request.method())?, url); + for (name, value) in request.headers().iter() { + req = req.header(name.as_str(), value.as_str()); + } + + let body = request.body().clone(); + + let reqwest_request = match body { + Body::Bytes(bytes) => req + .body(bytes) + .build() + .context(ErrorKind::Other, "failed to build request")?, + Body::SeekableStream(mut seekable_stream) => { + seekable_stream.reset().await.unwrap(); // TODO: remove unwrap when `HttpError` has been removed + req.body(::reqwest::Body::wrap_stream(seekable_stream)) + .build() + .context(ErrorKind::Other, "failed to build request")? + } + }; + + let rsp = self + .execute(reqwest_request) + .await + .context(ErrorKind::Io, "failed to execute request")?; + + let status = rsp.status(); + let headers = to_headers(rsp.headers())?; + let body: PinnedStream = Box::pin(rsp.bytes_stream().map_err(|error| { + Error::full( + ErrorKind::Io, + error, + "error converting `reqwest` request into a byte stream", + ) + })); + + Ok(crate::Response::new( + try_from_status(status)?, + headers, + body, + )) + } +} + +fn to_headers(map: &::reqwest::header::HeaderMap) -> crate::Result { + let map = map + .iter() + .map(|(k, v)| { + let key = k.as_str(); + let value = std::str::from_utf8(v.as_bytes()).expect("non-UTF8 header value"); + ( + crate::headers::HeaderName::from(key.to_owned()), + crate::headers::HeaderValue::from(value.to_owned()), + ) + }) + .collect::>(); + Ok(crate::headers::Headers::from(map)) +} + +fn try_from_method(method: &crate::Method) -> crate::Result<::reqwest::Method> { + ::reqwest::Method::from_str(method.as_ref()).map_kind(ErrorKind::DataConversion) +} + +fn try_from_status(status: ::reqwest::StatusCode) -> crate::Result { + let status = status.as_u16(); + http_types::StatusCode::try_from(status) + .map_err(|_| { + Error::with_message(ErrorKind::DataConversion, || { + format!("invalid status code {status}") + }) + }) + .map(crate::StatusCode) +} diff --git a/sdk/core/src/lib.rs b/sdk/core/src/lib.rs index 53ad4e3eda..a5d9945ba9 100644 --- a/sdk/core/src/lib.rs +++ b/sdk/core/src/lib.rs @@ -16,6 +16,7 @@ mod constants; mod context; pub mod error; mod http_client; +mod method; mod models; mod options; mod pageable; @@ -25,6 +26,7 @@ mod request; mod request_options; mod response; mod seekable_stream; +mod status_code; pub mod auth; pub mod headers; @@ -47,6 +49,7 @@ pub use headers::Header; #[cfg(not(target_arch = "wasm32"))] pub use http_client::new_http_client; pub use http_client::{to_json, HttpClient}; +pub use method::Method; pub use models::*; pub use options::*; pub use pageable::*; @@ -56,7 +59,12 @@ pub use request::*; pub use response::*; pub use seekable_stream::*; pub use sleep::sleep; +pub use status_code::StatusCode; +// re-export packages +pub use url; + +// re-export important types at crate level pub use url::Url; /// A unique identifier for a request. diff --git a/sdk/core/src/method.rs b/sdk/core/src/method.rs new file mode 100644 index 0000000000..58a1589b12 --- /dev/null +++ b/sdk/core/src/method.rs @@ -0,0 +1,46 @@ +use crate::error::{Error, ErrorKind}; +use std::{ops::Deref, str::FromStr}; + +#[derive(PartialEq, Eq, Clone, Debug)] +pub struct Method(pub(crate) http_types::Method); + +impl Method { + pub fn as_str(&self) -> &str { + self.as_ref() + } +} + +impl Deref for Method { + type Target = http_types::Method; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Method { + pub const CONNECT: Method = Method(http_types::Method::Connect); + pub const DELETE: Method = Method(http_types::Method::Delete); + pub const GET: Method = Method(http_types::Method::Get); + pub const HEAD: Method = Method(http_types::Method::Head); + pub const MERGE: Method = Method(http_types::Method::Merge); + pub const OPTIONS: Method = Method(http_types::Method::Options); + pub const PATCH: Method = Method(http_types::Method::Patch); + pub const POST: Method = Method(http_types::Method::Post); + pub const PUT: Method = Method(http_types::Method::Put); + pub const TRACE: Method = Method(http_types::Method::Trace); +} + +impl Default for Method { + fn default() -> Method { + Method::GET + } +} + +impl FromStr for Method { + type Err = Error; + fn from_str(s: &str) -> crate::Result { + Ok(Method(http_types::Method::from_str(s).map_err( + |error| Error::full(ErrorKind::DataConversion, error, "Method::from_str failed"), + )?)) + } +} diff --git a/sdk/core/src/mock/mock_request.rs b/sdk/core/src/mock/mock_request.rs index 45af91f6a8..883f9c42a0 100644 --- a/sdk/core/src/mock/mock_request.rs +++ b/sdk/core/src/mock/mock_request.rs @@ -1,5 +1,5 @@ +use crate::Method; use crate::{Body, Request}; -use http::Method; use serde::de::Visitor; use serde::ser::{Serialize, SerializeStruct, Serializer}; use serde::{Deserialize, Deserializer}; diff --git a/sdk/core/src/mock/mock_response.rs b/sdk/core/src/mock/mock_response.rs index 5b03c19c76..6f8ab51224 100644 --- a/sdk/core/src/mock/mock_response.rs +++ b/sdk/core/src/mock/mock_response.rs @@ -1,13 +1,11 @@ -use bytes::Bytes; -use http::StatusCode; -use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; - use crate::{ collect_pinned_stream, error, headers::{HeaderName, HeaderValue, Headers}, - BytesStream, Response, + BytesStream, Response, StatusCode, }; +use bytes::Bytes; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; #[derive(Debug, Clone, PartialEq)] pub(crate) struct MockResponse { @@ -48,7 +46,7 @@ impl MockResponse { )?; let response = Response::new( - status_code, + status_code.clone(), header_map.clone(), Box::pin(BytesStream::new(response_bytes.clone())), ); diff --git a/sdk/core/src/mock/player_policy.rs b/sdk/core/src/mock/player_policy.rs index f118a9fbb4..3849baeb51 100644 --- a/sdk/core/src/mock/player_policy.rs +++ b/sdk/core/src/mock/player_policy.rs @@ -115,7 +115,7 @@ impl Policy for MockTransportPlayerPolicy { if expected_request.method() != request.method() { return Err(Error::with_message(ErrorKind::MockFramework, || { format!( - "mismatched HTTP request method. Actual: {0}, Expected: {1}", + "mismatched HTTP request method. Actual: {0:?}, Expected: {1:?}", expected_request.method(), request.method(), ) diff --git a/sdk/core/src/policies/retry_policies/retry_policy.rs b/sdk/core/src/policies/retry_policies/retry_policy.rs index 143a8b8214..0c32d73060 100644 --- a/sdk/core/src/policies/retry_policies/retry_policy.rs +++ b/sdk/core/src/policies/retry_policies/retry_policy.rs @@ -1,10 +1,8 @@ use crate::error::{Error, ErrorKind, HttpError}; use crate::policies::{Policy, PolicyResult, Request}; use crate::sleep::sleep; -use crate::Context; - +use crate::{Context, StatusCode}; use chrono::{DateTime, Local}; -use http::StatusCode; use std::sync::Arc; use std::time::Duration; @@ -78,14 +76,14 @@ where if !RETRY_STATUSES.contains(&status) { log::error!( - "server returned error status which will not be retried: {}", + "server returned error status which will not be retried: {:?}", status ); // Server didn't return a status we retry on so return early return Err(error); } log::debug!( - "server returned error status which requires retry: {}", + "server returned error status which requires retry: {:?}", status ); error diff --git a/sdk/core/src/request.rs b/sdk/core/src/request.rs index 8afe53a585..9c5ee1886f 100644 --- a/sdk/core/src/request.rs +++ b/sdk/core/src/request.rs @@ -1,7 +1,6 @@ use crate::headers::{AsHeaders, Headers}; -use crate::SeekableStream; +use crate::{Method, SeekableStream}; use bytes::Bytes; -use http::Method; use std::fmt::Debug; use url::Url; diff --git a/sdk/core/src/response.rs b/sdk/core/src/response.rs index ecd62f6828..58ea8db309 100644 --- a/sdk/core/src/response.rs +++ b/sdk/core/src/response.rs @@ -1,12 +1,14 @@ use crate::headers::Headers; +use crate::StatusCode; use bytes::Bytes; use futures::Stream; use futures::StreamExt; -use http::StatusCode; use std::pin::Pin; pub type PinnedStream = Pin> + Send + Sync>>; +pub(crate) const INVALID_BODY: &[u8] = b""; + /// An HTTP Response. pub struct Response { status: StatusCode, @@ -26,8 +28,8 @@ impl Response { } /// Get the status code from the response. - pub fn status(&self) -> StatusCode { - self.status + pub fn status(&self) -> &StatusCode { + &self.status } /// Get the headers from the response. @@ -44,7 +46,7 @@ impl Response { pub async fn into_body(self) -> Bytes { collect_pinned_stream(self.body) .await - .unwrap_or_else(|_| Bytes::from_static(b"")) + .unwrap_or_else(|_| Bytes::from_static(INVALID_BODY)) } /// Consume the HTTP response and read the HTTP body into a string. diff --git a/sdk/core/src/status_code.rs b/sdk/core/src/status_code.rs new file mode 100644 index 0000000000..68a5a98ffc --- /dev/null +++ b/sdk/core/src/status_code.rs @@ -0,0 +1,59 @@ +use crate::error::{Error, ErrorKind}; +use std::ops::Deref; + +#[derive(PartialEq, Clone, Debug)] +pub struct StatusCode(pub(crate) http_types::StatusCode); + +impl Deref for StatusCode { + type Target = http_types::StatusCode; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl StatusCode { + pub fn as_u16(&self) -> u16 { + self.0 as u16 + } + pub fn from_u16(value: u16) -> crate::Result { + Ok(StatusCode( + http_types::StatusCode::try_from(value).map_err(|_error| { + Error::with_message(ErrorKind::DataConversion, || { + format!("unable to convert {value} to StatusCode") + }) + })?, + )) + } + + pub const BAD_GATEWAY: StatusCode = StatusCode(http_types::StatusCode::BadGateway); + pub const GATEWAY_TIMEOUT: StatusCode = StatusCode(http_types::StatusCode::GatewayTimeout); + pub const INTERNAL_SERVER_ERROR: StatusCode = + StatusCode(http_types::StatusCode::InternalServerError); + pub const NOT_MODIFIED: StatusCode = StatusCode(http_types::StatusCode::NotModified); + pub const OK: StatusCode = StatusCode(http_types::StatusCode::Ok); + pub const REQUEST_TIMEOUT: StatusCode = StatusCode(http_types::StatusCode::RequestTimeout); + pub const SERVICE_UNAVAILABLE: StatusCode = + StatusCode(http_types::StatusCode::ServiceUnavailable); + pub const TOO_MANY_REQUESTS: StatusCode = StatusCode(http_types::StatusCode::TooManyRequests); +} + +impl Default for StatusCode { + fn default() -> StatusCode { + StatusCode::OK + } +} + +impl TryFrom for StatusCode { + type Error = Error; + fn try_from(value: u16) -> crate::Result { + Ok(StatusCode( + http_types::StatusCode::try_from(value).map_err(|error| { + Error::full( + ErrorKind::DataConversion, + error, + "StatusCode::try_from failed", + ) + })?, + )) + } +} diff --git a/sdk/data_cosmos/Cargo.toml b/sdk/data_cosmos/Cargo.toml index dd8efb6e23..6ef490978e 100644 --- a/sdk/data_cosmos/Cargo.toml +++ b/sdk/data_cosmos/Cargo.toml @@ -19,7 +19,6 @@ async-trait = "0.1" azure_core = { path = "../core", version = "0.3" } base64 = "0.13" chrono = "0.4" -http = "0.2" futures = "0.3" log = "0.4" serde = { version = "1.0", features = ["derive"] } diff --git a/sdk/data_cosmos/src/authorization_policy.rs b/sdk/data_cosmos/src/authorization_policy.rs index 5bf0582641..c88f4cef85 100644 --- a/sdk/data_cosmos/src/authorization_policy.rs +++ b/sdk/data_cosmos/src/authorization_policy.rs @@ -141,7 +141,7 @@ fn generate_resource_link(request: &Request) -> String { /// In the second case, the signature is just the resource key. fn generate_authorization( auth_token: &AuthorizationToken, - http_method: &http::Method, + http_method: &azure_core::Method, resource_type: &ResourceType, resource_link: &str, time_nonce: TimeNonce, @@ -174,7 +174,7 @@ fn generate_authorization( /// In case of authorization problems we can compare the string_to_sign generated by Azure against /// our own. fn string_to_sign( - http_method: &http::Method, + http_method: &azure_core::Method, rt: &ResourceType, resource_link: &str, time_nonce: TimeNonce, @@ -191,15 +191,15 @@ fn string_to_sign( format!( "{}\n{}\n{}\n{}\n\n", match *http_method { - http::Method::GET => "get", - http::Method::PUT => "put", - http::Method::POST => "post", - http::Method::DELETE => "delete", - http::Method::HEAD => "head", - http::Method::TRACE => "trace", - http::Method::OPTIONS => "options", - http::Method::CONNECT => "connect", - http::Method::PATCH => "patch", + azure_core::Method::GET => "get", + azure_core::Method::PUT => "put", + azure_core::Method::POST => "post", + azure_core::Method::DELETE => "delete", + azure_core::Method::HEAD => "head", + azure_core::Method::TRACE => "trace", + azure_core::Method::OPTIONS => "options", + azure_core::Method::CONNECT => "connect", + azure_core::Method::PATCH => "patch", _ => "extension", }, match rt { @@ -242,7 +242,7 @@ mod tests { let time = time.with_timezone(&chrono::Utc).into(); let ret = string_to_sign( - &http::Method::GET, + &azure_core::Method::GET, &ResourceType::Databases, "dbs/MyDatabase/colls/MyCollection", time, @@ -271,7 +271,7 @@ mon, 01 jan 1900 01:00:00 gmt let ret = generate_authorization( &auth_token, - &http::Method::GET, + &azure_core::Method::GET, &ResourceType::Databases, "dbs/MyDatabase/colls/MyCollection", time, @@ -295,7 +295,7 @@ mon, 01 jan 1900 01:00:00 gmt let ret = generate_authorization( &auth_token, - &http::Method::GET, + &azure_core::Method::GET, &ResourceType::Databases, "dbs/ToDoList", time, @@ -316,7 +316,7 @@ mon, 01 jan 1900 01:00:00 gmt fn generate_resource_link_00() { let request = Request::new( reqwest::Url::parse("https://.documents.azure.com/dbs/second").unwrap(), - http::Method::GET, + azure_core::Method::GET, ); assert_eq!(&generate_resource_link(&request), "dbs/second"); } @@ -325,7 +325,7 @@ mon, 01 jan 1900 01:00:00 gmt fn generate_resource_link_01() { let request = Request::new( reqwest::Url::parse("https://.documents.azure.com/dbs").unwrap(), - http::Method::GET, + azure_core::Method::GET, ); assert_eq!(&generate_resource_link(&request), ""); } @@ -334,7 +334,7 @@ mon, 01 jan 1900 01:00:00 gmt fn generate_resource_link_02() { let request = Request::new( reqwest::Url::parse("https://.documents.azure.com/colls/second/third").unwrap(), - http::Method::GET, + azure_core::Method::GET, ); assert_eq!(&generate_resource_link(&request), "colls/second/third"); } @@ -343,7 +343,7 @@ mon, 01 jan 1900 01:00:00 gmt fn generate_resource_link_03() { let request = Request::new( reqwest::Url::parse("https://.documents.azure.com/dbs/test_db/colls").unwrap(), - http::Method::GET, + azure_core::Method::GET, ); assert_eq!(&generate_resource_link(&request), "dbs/test_db"); } diff --git a/sdk/data_cosmos/src/clients/attachment.rs b/sdk/data_cosmos/src/clients/attachment.rs index 5c4ee8e67d..ebb0d8d55c 100644 --- a/sdk/data_cosmos/src/clients/attachment.rs +++ b/sdk/data_cosmos/src/clients/attachment.rs @@ -99,7 +99,7 @@ impl AttachmentClient { &self.attachment_name } - pub(crate) fn attachments_request(&self, method: http::Method) -> Request { + pub(crate) fn attachments_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/docs/{}/attachments", @@ -111,7 +111,7 @@ impl AttachmentClient { ) } - pub(crate) fn attachment_request(&self, method: http::Method) -> Request { + pub(crate) fn attachment_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/docs/{}/attachments/{}", diff --git a/sdk/data_cosmos/src/clients/collection.rs b/sdk/data_cosmos/src/clients/collection.rs index c5af60699a..17341c851e 100644 --- a/sdk/data_cosmos/src/clients/collection.rs +++ b/sdk/data_cosmos/src/clients/collection.rs @@ -127,7 +127,7 @@ impl CollectionClient { &self.collection_name } - pub(crate) fn collection_request(&self, http_method: http::Method) -> Request { + pub(crate) fn collection_request(&self, http_method: azure_core::Method) -> Request { let path = &format!( "dbs/{}/colls/{}", self.database_client().database_name(), @@ -136,7 +136,7 @@ impl CollectionClient { self.cosmos_client().request(path, http_method) } - pub(crate) fn docs_request(&self, http_method: http::Method) -> Request { + pub(crate) fn docs_request(&self, http_method: azure_core::Method) -> Request { let path = &format!( "dbs/{}/colls/{}/docs", self.database_client().database_name(), diff --git a/sdk/data_cosmos/src/clients/cosmos.rs b/sdk/data_cosmos/src/clients/cosmos.rs index 9177e89d7f..e7c2fe585a 100644 --- a/sdk/data_cosmos/src/clients/cosmos.rs +++ b/sdk/data_cosmos/src/clients/cosmos.rs @@ -121,7 +121,7 @@ impl CosmosClient { /// This function will add the cloud location to the URI suffix and generate /// a Request with the specified HTTP Method. It will also set the body /// to an empty `Bytes` instance. - pub(crate) fn request(&self, uri_path: &str, http_method: http::Method) -> Request { + pub(crate) fn request(&self, uri_path: &str, http_method: azure_core::Method) -> Request { let uri = format!("{}/{}", self.cloud_location.url(), uri_path); Request::new(uri.parse().unwrap(), http_method) } diff --git a/sdk/data_cosmos/src/clients/database.rs b/sdk/data_cosmos/src/clients/database.rs index ff967d6ad7..015bb234d2 100644 --- a/sdk/data_cosmos/src/clients/database.rs +++ b/sdk/data_cosmos/src/clients/database.rs @@ -2,8 +2,8 @@ use crate::clients::*; use crate::operations::*; use crate::resources::collection::PartitionKey; use crate::ReadonlyString; +use azure_core::Method; use azure_core::Request; -use http::Method; /// A client for Cosmos database resources. #[derive(Debug, Clone)] diff --git a/sdk/data_cosmos/src/clients/document.rs b/sdk/data_cosmos/src/clients/document.rs index 4acf1dee32..83bc9855b1 100644 --- a/sdk/data_cosmos/src/clients/document.rs +++ b/sdk/data_cosmos/src/clients/document.rs @@ -85,7 +85,7 @@ impl DocumentClient { &self.partition_key_serialized } - pub(crate) fn document_request(&self, method: http::Method) -> Request { + pub(crate) fn document_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/docs/{}", diff --git a/sdk/data_cosmos/src/clients/permission.rs b/sdk/data_cosmos/src/clients/permission.rs index 9597ff8727..3a63702b3e 100644 --- a/sdk/data_cosmos/src/clients/permission.rs +++ b/sdk/data_cosmos/src/clients/permission.rs @@ -59,7 +59,7 @@ impl PermissionClient { &self.permission_name } - pub(crate) fn permission_request(&self, method: http::Method) -> Request { + pub(crate) fn permission_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/users/{}/permissions/{}", diff --git a/sdk/data_cosmos/src/clients/stored_procedure.rs b/sdk/data_cosmos/src/clients/stored_procedure.rs index 5a97afee66..fe30615203 100644 --- a/sdk/data_cosmos/src/clients/stored_procedure.rs +++ b/sdk/data_cosmos/src/clients/stored_procedure.rs @@ -70,7 +70,7 @@ impl StoredProcedureClient { &self.stored_procedure_name } - pub(crate) fn stored_procedure_request(&self, method: http::Method) -> Request { + pub(crate) fn stored_procedure_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/sprocs/{}", @@ -82,7 +82,7 @@ impl StoredProcedureClient { ) } - pub(crate) fn stored_procedures_request(&self, method: http::Method) -> Request { + pub(crate) fn stored_procedures_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/sprocs", diff --git a/sdk/data_cosmos/src/clients/trigger.rs b/sdk/data_cosmos/src/clients/trigger.rs index c2be6ae636..2ecd03f2f9 100644 --- a/sdk/data_cosmos/src/clients/trigger.rs +++ b/sdk/data_cosmos/src/clients/trigger.rs @@ -91,7 +91,7 @@ impl TriggerClient { } /// Create a request for a specific collection trigger - pub(crate) fn trigger_request(&self, method: http::Method) -> Request { + pub(crate) fn trigger_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/triggers/{}", @@ -104,7 +104,7 @@ impl TriggerClient { } /// Create a request for collection triggers - pub(crate) fn triggers_request(&self, method: http::Method) -> Request { + pub(crate) fn triggers_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/triggers", diff --git a/sdk/data_cosmos/src/clients/user.rs b/sdk/data_cosmos/src/clients/user.rs index 1463cda7d2..21e4fc0611 100644 --- a/sdk/data_cosmos/src/clients/user.rs +++ b/sdk/data_cosmos/src/clients/user.rs @@ -66,7 +66,7 @@ impl UserClient { &self.user_name } - pub(crate) fn user_request(&self, method: http::Method) -> Request { + pub(crate) fn user_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/users/{}", diff --git a/sdk/data_cosmos/src/clients/user_defined_function.rs b/sdk/data_cosmos/src/clients/user_defined_function.rs index 8dd6a242d6..0bc2651543 100644 --- a/sdk/data_cosmos/src/clients/user_defined_function.rs +++ b/sdk/data_cosmos/src/clients/user_defined_function.rs @@ -68,7 +68,7 @@ impl UserDefinedFunctionClient { &self.user_defined_function_name } - pub(crate) fn udfs_request(&self, method: http::Method) -> Request { + pub(crate) fn udfs_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/udfs", @@ -79,7 +79,7 @@ impl UserDefinedFunctionClient { ) } - pub(crate) fn udf_request(&self, method: http::Method) -> Request { + pub(crate) fn udf_request(&self, method: azure_core::Method) -> Request { self.cosmos_client().request( &format!( "dbs/{}/colls/{}/udfs/{}", diff --git a/sdk/data_cosmos/src/operations/create_collection.rs b/sdk/data_cosmos/src/operations/create_collection.rs index dc7e71fe59..8a7117e8be 100644 --- a/sdk/data_cosmos/src/operations/create_collection.rs +++ b/sdk/data_cosmos/src/operations/create_collection.rs @@ -42,7 +42,7 @@ impl CreateCollectionBuilder { pub fn into_future(self) -> CreateCollection { Box::pin(async move { - let mut request = self.client.collections_request(http::Method::POST); + let mut request = self.client.collections_request(azure_core::Method::POST); request.insert_headers(&self.offer); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/create_database.rs b/sdk/data_cosmos/src/operations/create_database.rs index 89f474d16d..5607e4b6f3 100644 --- a/sdk/data_cosmos/src/operations/create_database.rs +++ b/sdk/data_cosmos/src/operations/create_database.rs @@ -36,7 +36,7 @@ impl CreateDatabaseBuilder { pub fn into_future(self) -> CreateDatabase { Box::pin(async move { - let mut request = self.client.request("dbs", http::Method::POST); + let mut request = self.client.request("dbs", azure_core::Method::POST); let body = CreateDatabaseBody { id: self.database_name.as_str(), diff --git a/sdk/data_cosmos/src/operations/create_document.rs b/sdk/data_cosmos/src/operations/create_document.rs index f24967ad6e..153d0afa98 100644 --- a/sdk/data_cosmos/src/operations/create_document.rs +++ b/sdk/data_cosmos/src/operations/create_document.rs @@ -4,9 +4,8 @@ use crate::prelude::*; use crate::resources::document::DocumentAttributes; use crate::ResourceQuota; use azure_core::headers::{etag_from_headers, session_token_from_headers}; -use azure_core::prelude::*; +use azure_core::{prelude::*, StatusCode}; use chrono::{DateTime, Utc}; -use http::StatusCode; use serde::Serialize; use std::convert::TryFrom; @@ -65,7 +64,7 @@ impl CreateDocumentBuilder { Some(s) => s, None => serialize_partition_key(&document.partition_key())?, }; - let mut request = self.client.docs_request(http::Method::POST); + let mut request = self.client.docs_request(azure_core::Method::POST); add_as_partition_key_header_serialized(&partition_key, &mut request); request.insert_headers(&self.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/create_or_replace_attachment.rs b/sdk/data_cosmos/src/operations/create_or_replace_attachment.rs index f6bf07916a..bc2cf316f6 100644 --- a/sdk/data_cosmos/src/operations/create_or_replace_attachment.rs +++ b/sdk/data_cosmos/src/operations/create_or_replace_attachment.rs @@ -43,9 +43,9 @@ impl CreateOrReplaceAttachmentBuilder { pub fn into_future(self) -> CreateOrReplaceAttachment { Box::pin(async move { let mut req = if self.is_create { - self.client.attachments_request(http::Method::POST) + self.client.attachments_request(azure_core::Method::POST) } else { - self.client.attachment_request(http::Method::PUT) + self.client.attachment_request(azure_core::Method::PUT) }; if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/create_or_replace_slug_attachment.rs b/sdk/data_cosmos/src/operations/create_or_replace_slug_attachment.rs index 2a8c8e6420..9bd45c273b 100644 --- a/sdk/data_cosmos/src/operations/create_or_replace_slug_attachment.rs +++ b/sdk/data_cosmos/src/operations/create_or_replace_slug_attachment.rs @@ -5,13 +5,13 @@ use crate::ResourceQuota; use azure_core::headers::{ date_from_headers, etag_from_headers, session_token_from_headers, HeaderValue, }; +use azure_core::Method; use azure_core::Response as HttpResponse; use azure_core::SessionToken; use azure_core::{collect_pinned_stream, headers}; use azure_core::{content_type, prelude::*}; use bytes::Bytes; use chrono::{DateTime, Utc}; -use http::Method; #[derive(Debug, Clone)] pub struct CreateOrReplaceSlugAttachmentBuilder { diff --git a/sdk/data_cosmos/src/operations/create_or_replace_trigger.rs b/sdk/data_cosmos/src/operations/create_or_replace_trigger.rs index 6ddd39dfe3..35c0aa078f 100644 --- a/sdk/data_cosmos/src/operations/create_or_replace_trigger.rs +++ b/sdk/data_cosmos/src/operations/create_or_replace_trigger.rs @@ -47,9 +47,9 @@ impl CreateOrReplaceTriggerBuilder { pub fn into_future(self) -> CreateOrReplaceTrigger { Box::pin(async move { let mut request = if self.is_create { - self.client.triggers_request(http::Method::POST) + self.client.triggers_request(azure_core::Method::POST) } else { - self.client.trigger_request(http::Method::PUT) + self.client.trigger_request(azure_core::Method::PUT) }; if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs b/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs index 6ac806df31..cb88955fa1 100644 --- a/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs +++ b/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs @@ -36,8 +36,8 @@ impl CreateOrReplaceUserDefinedFunctionBuilder { pub fn into_future(self) -> CreateOrReplaceUserDefinedFunction { Box::pin(async move { let mut request = match self.is_create { - true => self.client.udfs_request(http::Method::POST), - false => self.client.udf_request(http::Method::PUT), + true => self.client.udfs_request(azure_core::Method::POST), + false => self.client.udf_request(azure_core::Method::PUT), }; if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/create_permission.rs b/sdk/data_cosmos/src/operations/create_permission.rs index 3e786b3071..f541b007aa 100644 --- a/sdk/data_cosmos/src/operations/create_permission.rs +++ b/sdk/data_cosmos/src/operations/create_permission.rs @@ -37,7 +37,7 @@ impl CreatePermissionBuilder { self.client.database_client().database_name(), self.client.user_client().user_name() ), - http::Method::POST, + azure_core::Method::POST, ); if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/create_stored_procedure.rs b/sdk/data_cosmos/src/operations/create_stored_procedure.rs index 37faa7c652..83bc7be27d 100644 --- a/sdk/data_cosmos/src/operations/create_stored_procedure.rs +++ b/sdk/data_cosmos/src/operations/create_stored_procedure.rs @@ -31,7 +31,9 @@ impl CreateStoredProcedureBuilder { pub fn into_future(self) -> CreateStoredProcedure { Box::pin(async move { - let mut req = self.client.stored_procedures_request(http::Method::POST); + let mut req = self + .client + .stored_procedures_request(azure_core::Method::POST); if let Some(cl) = &self.consistency_level { req.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/create_user.rs b/sdk/data_cosmos/src/operations/create_user.rs index b534740156..615531b858 100644 --- a/sdk/data_cosmos/src/operations/create_user.rs +++ b/sdk/data_cosmos/src/operations/create_user.rs @@ -29,7 +29,7 @@ impl CreateUserBuilder { "dbs/{}/users", self.client.database_client().database_name() ), - http::Method::POST, + azure_core::Method::POST, ); if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/delete_attachment.rs b/sdk/data_cosmos/src/operations/delete_attachment.rs index 2fe561d12b..585cabf738 100644 --- a/sdk/data_cosmos/src/operations/delete_attachment.rs +++ b/sdk/data_cosmos/src/operations/delete_attachment.rs @@ -34,7 +34,7 @@ impl DeleteAttachmentBuilder { pub fn into_future(self) -> DeleteAttachment { Box::pin(async move { - let mut request = self.client.attachment_request(http::Method::DELETE); + let mut request = self.client.attachment_request(azure_core::Method::DELETE); request.insert_headers(&self.if_match_condition); if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/delete_collection.rs b/sdk/data_cosmos/src/operations/delete_collection.rs index b818ff894a..af58446fea 100644 --- a/sdk/data_cosmos/src/operations/delete_collection.rs +++ b/sdk/data_cosmos/src/operations/delete_collection.rs @@ -27,7 +27,7 @@ impl DeleteCollectionBuilder { pub fn into_future(self) -> DeleteCollection { Box::pin(async move { - let mut request = self.client.collection_request(http::Method::DELETE); + let mut request = self.client.collection_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/delete_database.rs b/sdk/data_cosmos/src/operations/delete_database.rs index da81661118..0909788a75 100644 --- a/sdk/data_cosmos/src/operations/delete_database.rs +++ b/sdk/data_cosmos/src/operations/delete_database.rs @@ -28,7 +28,7 @@ impl DeleteDatabaseBuilder { pub fn into_future(self) -> DeleteDatabase { Box::pin(async move { - let mut request = self.client.database_request(http::Method::DELETE); + let mut request = self.client.database_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); } diff --git a/sdk/data_cosmos/src/operations/delete_document.rs b/sdk/data_cosmos/src/operations/delete_document.rs index ad9d90c8ce..d391f14a87 100644 --- a/sdk/data_cosmos/src/operations/delete_document.rs +++ b/sdk/data_cosmos/src/operations/delete_document.rs @@ -38,7 +38,7 @@ impl DeleteDocumentBuilder { pub fn into_future(self) -> DeleteDocument { Box::pin(async move { - let mut request = self.client.document_request(http::Method::DELETE); + let mut request = self.client.document_request(azure_core::Method::DELETE); request.insert_headers(&self.if_match_condition); request.insert_headers(&self.if_modified_since); diff --git a/sdk/data_cosmos/src/operations/delete_permission.rs b/sdk/data_cosmos/src/operations/delete_permission.rs index 0aa6569840..5d31a2b692 100644 --- a/sdk/data_cosmos/src/operations/delete_permission.rs +++ b/sdk/data_cosmos/src/operations/delete_permission.rs @@ -28,7 +28,7 @@ impl DeletePermissionBuilder { pub fn into_future(self) -> DeletePermission { Box::pin(async move { - let mut request = self.client.permission_request(http::Method::DELETE); + let mut request = self.client.permission_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/delete_stored_procedure.rs b/sdk/data_cosmos/src/operations/delete_stored_procedure.rs index 26a7e2b531..5a35228615 100644 --- a/sdk/data_cosmos/src/operations/delete_stored_procedure.rs +++ b/sdk/data_cosmos/src/operations/delete_stored_procedure.rs @@ -28,7 +28,9 @@ impl DeleteStoredProcedureBuilder { pub fn into_future(self) -> DeleteStoredProcedure { Box::pin(async move { - let mut request = self.client.stored_procedure_request(http::Method::DELETE); + let mut request = self + .client + .stored_procedure_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/delete_trigger.rs b/sdk/data_cosmos/src/operations/delete_trigger.rs index d0cad2d1ee..908f430cfb 100644 --- a/sdk/data_cosmos/src/operations/delete_trigger.rs +++ b/sdk/data_cosmos/src/operations/delete_trigger.rs @@ -30,7 +30,7 @@ impl DeleteTriggerBuilder { pub fn into_future(self) -> DeleteTrigger { Box::pin(async move { - let mut request = self.client.trigger_request(http::Method::DELETE); + let mut request = self.client.trigger_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/delete_user.rs b/sdk/data_cosmos/src/operations/delete_user.rs index c269bc1c31..ae5f6af663 100644 --- a/sdk/data_cosmos/src/operations/delete_user.rs +++ b/sdk/data_cosmos/src/operations/delete_user.rs @@ -25,7 +25,7 @@ impl DeleteUserBuilder { pub fn into_future(self) -> DeleteUser { Box::pin(async move { - let mut request = self.client.user_request(http::Method::DELETE); + let mut request = self.client.user_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); } diff --git a/sdk/data_cosmos/src/operations/delete_user_defined_function.rs b/sdk/data_cosmos/src/operations/delete_user_defined_function.rs index 58c665708b..d36f38c63e 100644 --- a/sdk/data_cosmos/src/operations/delete_user_defined_function.rs +++ b/sdk/data_cosmos/src/operations/delete_user_defined_function.rs @@ -30,7 +30,7 @@ impl DeleteUserDefinedFunctionBuilder { pub fn into_future(self) -> DeleteUserDefinedFunction { Box::pin(async move { - let mut request = self.client.udf_request(http::Method::DELETE); + let mut request = self.client.udf_request(azure_core::Method::DELETE); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/execute_stored_procedure.rs b/sdk/data_cosmos/src/operations/execute_stored_procedure.rs index debe92d4df..b05d1f5ed3 100644 --- a/sdk/data_cosmos/src/operations/execute_stored_procedure.rs +++ b/sdk/data_cosmos/src/operations/execute_stored_procedure.rs @@ -53,7 +53,9 @@ impl ExecuteStoredProcedureBuilder { pub fn into_future(self) -> ExecuteStoredProcedure { Box::pin(async move { - let mut request = self.client.stored_procedure_request(http::Method::POST); + let mut request = self + .client + .stored_procedure_request(azure_core::Method::POST); if let Some(pk) = self.partition_key.as_ref() { crate::cosmos_entity::add_as_partition_key_header_serialized(pk, &mut request) diff --git a/sdk/data_cosmos/src/operations/get_attachment.rs b/sdk/data_cosmos/src/operations/get_attachment.rs index fce96e4649..1dd60aec4d 100644 --- a/sdk/data_cosmos/src/operations/get_attachment.rs +++ b/sdk/data_cosmos/src/operations/get_attachment.rs @@ -36,7 +36,7 @@ impl GetAttachmentBuilder { pub fn into_future(self) -> GetAttachment { Box::pin(async move { - let mut request = self.client.attachment_request(http::Method::GET); + let mut request = self.client.attachment_request(azure_core::Method::GET); request.insert_headers(&self.if_match_condition); if let Some(cl) = &self.consistency_level { diff --git a/sdk/data_cosmos/src/operations/get_collection.rs b/sdk/data_cosmos/src/operations/get_collection.rs index 0d5a76b5de..44d8129bc6 100644 --- a/sdk/data_cosmos/src/operations/get_collection.rs +++ b/sdk/data_cosmos/src/operations/get_collection.rs @@ -30,7 +30,7 @@ impl GetCollectionBuilder { pub fn into_future(self) -> GetCollection { Box::pin(async move { - let mut request = self.client.collection_request(http::Method::GET); + let mut request = self.client.collection_request(azure_core::Method::GET); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/get_database.rs b/sdk/data_cosmos/src/operations/get_database.rs index ad2658874e..c61c23ca95 100644 --- a/sdk/data_cosmos/src/operations/get_database.rs +++ b/sdk/data_cosmos/src/operations/get_database.rs @@ -30,7 +30,7 @@ impl GetDatabaseBuilder { pub fn into_future(self) -> GetDatabase { Box::pin(async move { - let mut request = self.client.database_request(http::Method::GET); + let mut request = self.client.database_request(azure_core::Method::GET); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); } diff --git a/sdk/data_cosmos/src/operations/get_document.rs b/sdk/data_cosmos/src/operations/get_document.rs index 521ce0c5dd..a8e8af98bc 100644 --- a/sdk/data_cosmos/src/operations/get_document.rs +++ b/sdk/data_cosmos/src/operations/get_document.rs @@ -5,10 +5,9 @@ use crate::prelude::*; use crate::resources::Document; use crate::ResourceQuota; use azure_core::headers::{etag_from_headers, session_token_from_headers, Headers}; -use azure_core::prelude::*; use azure_core::{collect_pinned_stream, Response as HttpResponse, SessionToken}; +use azure_core::{prelude::*, StatusCode}; use chrono::{DateTime, Utc}; -use http::StatusCode; use serde::de::DeserializeOwned; #[derive(Debug, Clone)] @@ -47,7 +46,7 @@ impl GetDocumentBuilder { /// generic associated types (GATs) stabilize, this will become possible. pub fn into_future(self) -> GetDocument { Box::pin(async move { - let mut request = self.client.document_request(http::Method::GET); + let mut request = self.client.document_request(azure_core::Method::GET); request.insert_headers(&self.if_match_condition); request.insert_headers(&self.if_modified_since); diff --git a/sdk/data_cosmos/src/operations/get_partition_key_ranges.rs b/sdk/data_cosmos/src/operations/get_partition_key_ranges.rs index f6953fec9b..435aca726d 100644 --- a/sdk/data_cosmos/src/operations/get_partition_key_ranges.rs +++ b/sdk/data_cosmos/src/operations/get_partition_key_ranges.rs @@ -40,7 +40,7 @@ impl GetPartitionKeyRangesBuilder { self.client.database_client().database_name(), self.client.collection_name() ), - http::Method::GET, + azure_core::Method::GET, ); request.insert_headers(&self.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/get_permission.rs b/sdk/data_cosmos/src/operations/get_permission.rs index 4c0dbdb5c7..0e6aefd3fe 100644 --- a/sdk/data_cosmos/src/operations/get_permission.rs +++ b/sdk/data_cosmos/src/operations/get_permission.rs @@ -25,7 +25,7 @@ impl GetPermissionBuilder { pub fn into_future(self) -> GetPermission { Box::pin(async move { - let mut request = self.client.permission_request(http::Method::GET); + let mut request = self.client.permission_request(azure_core::Method::GET); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/get_user.rs b/sdk/data_cosmos/src/operations/get_user.rs index 6546c571bc..c589aa8570 100644 --- a/sdk/data_cosmos/src/operations/get_user.rs +++ b/sdk/data_cosmos/src/operations/get_user.rs @@ -24,7 +24,7 @@ impl GetUserBuilder { pub fn into_future(self) -> GetUser { Box::pin(async move { - let mut request = self.client.user_request(http::Method::GET); + let mut request = self.client.user_request(azure_core::Method::GET); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/list_attachments.rs b/sdk/data_cosmos/src/operations/list_attachments.rs index e92d93abc1..85e4664350 100644 --- a/sdk/data_cosmos/src/operations/list_attachments.rs +++ b/sdk/data_cosmos/src/operations/list_attachments.rs @@ -53,7 +53,7 @@ impl ListAttachmentsBuilder { this.client.collection_client().collection_name(), this.client.document_name() ), - http::Method::GET, + azure_core::Method::GET, ); request.insert_headers(&this.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/list_collections.rs b/sdk/data_cosmos/src/operations/list_collections.rs index 4161b1bb71..492325686c 100644 --- a/sdk/data_cosmos/src/operations/list_collections.rs +++ b/sdk/data_cosmos/src/operations/list_collections.rs @@ -37,7 +37,7 @@ impl ListCollectionsBuilder { let this = self.clone(); let ctx = self.context.clone(); async move { - let mut request = this.client.collections_request(http::Method::GET); + let mut request = this.client.collections_request(azure_core::Method::GET); if let Some(cl) = &this.consistency_level { request.insert_headers(cl); } diff --git a/sdk/data_cosmos/src/operations/list_databases.rs b/sdk/data_cosmos/src/operations/list_databases.rs index 780524c986..98a8416ba6 100644 --- a/sdk/data_cosmos/src/operations/list_databases.rs +++ b/sdk/data_cosmos/src/operations/list_databases.rs @@ -36,7 +36,7 @@ impl ListDatabasesBuilder { let this = self.clone(); let ctx = self.context.clone(); async move { - let mut request = this.client.request("dbs", http::Method::GET); + let mut request = this.client.request("dbs", azure_core::Method::GET); if let Some(cl) = &this.consistency_level { request.insert_headers(cl); } diff --git a/sdk/data_cosmos/src/operations/list_documents.rs b/sdk/data_cosmos/src/operations/list_documents.rs index e361c5fec5..23308d86d2 100644 --- a/sdk/data_cosmos/src/operations/list_documents.rs +++ b/sdk/data_cosmos/src/operations/list_documents.rs @@ -57,7 +57,7 @@ impl ListDocumentsBuilder { this.client.database_client().database_name(), this.client.collection_name() ), - http::Method::GET, + azure_core::Method::GET, ); req.insert_headers(&this.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/list_permissions.rs b/sdk/data_cosmos/src/operations/list_permissions.rs index 16d6174819..fe46192f94 100644 --- a/sdk/data_cosmos/src/operations/list_permissions.rs +++ b/sdk/data_cosmos/src/operations/list_permissions.rs @@ -42,7 +42,7 @@ impl ListPermissionsBuilder { this.client.database_client().database_name(), this.client.user_name() ), - http::Method::GET, + azure_core::Method::GET, ); if let Some(cl) = &this.consistency_level { diff --git a/sdk/data_cosmos/src/operations/list_stored_procedures.rs b/sdk/data_cosmos/src/operations/list_stored_procedures.rs index 01759373aa..01f752a970 100644 --- a/sdk/data_cosmos/src/operations/list_stored_procedures.rs +++ b/sdk/data_cosmos/src/operations/list_stored_procedures.rs @@ -44,7 +44,7 @@ impl ListStoredProceduresBuilder { this.client.database_client().database_name(), this.client.collection_name(), ), - http::Method::GET, + azure_core::Method::GET, ); if let Some(cl) = &this.consistency_level { diff --git a/sdk/data_cosmos/src/operations/list_triggers.rs b/sdk/data_cosmos/src/operations/list_triggers.rs index 15a90aa5e4..a24c74770e 100644 --- a/sdk/data_cosmos/src/operations/list_triggers.rs +++ b/sdk/data_cosmos/src/operations/list_triggers.rs @@ -47,7 +47,7 @@ impl ListTriggersBuilder { this.client.database_client().database_name(), this.client.collection_name() ), - http::Method::GET, + azure_core::Method::GET, ); request.insert_headers(&this.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/list_user_defined_functions.rs b/sdk/data_cosmos/src/operations/list_user_defined_functions.rs index 49f06e52a9..76a7db2708 100644 --- a/sdk/data_cosmos/src/operations/list_user_defined_functions.rs +++ b/sdk/data_cosmos/src/operations/list_user_defined_functions.rs @@ -48,7 +48,7 @@ impl ListUserDefinedFunctionsBuilder { this.client.database_client().database_name(), this.client.collection_name() ), - http::Method::GET, + azure_core::Method::GET, ); request.insert_headers(&this.if_match_condition); diff --git a/sdk/data_cosmos/src/operations/list_users.rs b/sdk/data_cosmos/src/operations/list_users.rs index 4bf3339744..b9347d381a 100644 --- a/sdk/data_cosmos/src/operations/list_users.rs +++ b/sdk/data_cosmos/src/operations/list_users.rs @@ -41,7 +41,7 @@ impl ListUsersBuilder { async move { let mut request = this.client.cosmos_client().request( &format!("dbs/{}/users", this.client.database_name()), - http::Method::GET, + azure_core::Method::GET, ); if let Some(cl) = &this.consistency_level { diff --git a/sdk/data_cosmos/src/operations/query_documents.rs b/sdk/data_cosmos/src/operations/query_documents.rs index bcdbeb71ca..db3ce6bf56 100644 --- a/sdk/data_cosmos/src/operations/query_documents.rs +++ b/sdk/data_cosmos/src/operations/query_documents.rs @@ -12,11 +12,11 @@ use azure_core::headers::{ }; use azure_core::prelude::*; use azure_core::CollectedResponse; +use azure_core::Method; use azure_core::Pageable; use azure_core::Response as HttpResponse; use azure_core::SessionToken; use chrono::{DateTime, Utc}; -use http::Method; use serde::de::DeserializeOwned; use serde_json::Value; use std::convert::TryInto; diff --git a/sdk/data_cosmos/src/operations/replace_collection.rs b/sdk/data_cosmos/src/operations/replace_collection.rs index 1df0c18e84..14c79ac4fd 100644 --- a/sdk/data_cosmos/src/operations/replace_collection.rs +++ b/sdk/data_cosmos/src/operations/replace_collection.rs @@ -35,7 +35,7 @@ impl ReplaceCollectionBuilder { pub fn into_future(self) -> ReplaceCollection { Box::pin(async move { - let mut request = self.client.collection_request(http::Method::PUT); + let mut request = self.client.collection_request(azure_core::Method::PUT); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/replace_document.rs b/sdk/data_cosmos/src/operations/replace_document.rs index 499e3aa4a3..71e4355e0b 100644 --- a/sdk/data_cosmos/src/operations/replace_document.rs +++ b/sdk/data_cosmos/src/operations/replace_document.rs @@ -55,7 +55,7 @@ impl ReplaceDocumentBuilder { pub fn into_future(self) -> ReplaceDocument { Box::pin(async move { - let mut request = self.client.document_request(http::Method::PUT); + let mut request = self.client.document_request(azure_core::Method::PUT); let partition_key = self .partition_key diff --git a/sdk/data_cosmos/src/operations/replace_permission.rs b/sdk/data_cosmos/src/operations/replace_permission.rs index 2189a8d434..5ac9675ed7 100644 --- a/sdk/data_cosmos/src/operations/replace_permission.rs +++ b/sdk/data_cosmos/src/operations/replace_permission.rs @@ -31,7 +31,7 @@ impl ReplacePermissionBuilder { pub fn into_future(self) -> ReplacePermission { Box::pin(async move { - let mut request = self.client.permission_request(http::Method::PUT); + let mut request = self.client.permission_request(azure_core::Method::PUT); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/replace_stored_procedure.rs b/sdk/data_cosmos/src/operations/replace_stored_procedure.rs index 878798773b..b4c8a126cb 100644 --- a/sdk/data_cosmos/src/operations/replace_stored_procedure.rs +++ b/sdk/data_cosmos/src/operations/replace_stored_procedure.rs @@ -28,7 +28,9 @@ impl ReplaceStoredProcedureBuilder { pub fn into_future(self) -> ReplaceStoredProcedure { Box::pin(async move { - let mut req = self.client.stored_procedure_request(http::Method::PUT); + let mut req = self + .client + .stored_procedure_request(azure_core::Method::PUT); if let Some(cl) = &self.consistency_level { req.insert_headers(cl); diff --git a/sdk/data_cosmos/src/operations/replace_user.rs b/sdk/data_cosmos/src/operations/replace_user.rs index 62c3455d06..ac76a984a4 100644 --- a/sdk/data_cosmos/src/operations/replace_user.rs +++ b/sdk/data_cosmos/src/operations/replace_user.rs @@ -26,7 +26,7 @@ impl ReplaceUserBuilder { pub fn into_future(self) -> ReplaceUser { Box::pin(async move { - let mut request = self.client.user_request(http::Method::PUT); + let mut request = self.client.user_request(azure_core::Method::PUT); if let Some(cl) = &self.consistency_level { request.insert_headers(cl); diff --git a/sdk/data_tables/Cargo.toml b/sdk/data_tables/Cargo.toml index d7eb155199..706b0aef86 100644 --- a/sdk/data_tables/Cargo.toml +++ b/sdk/data_tables/Cargo.toml @@ -18,9 +18,8 @@ azure_storage = { path = "../storage", version = "0.4", default-features=false, bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } futures = "0.3" -http = "0.2" log = "0.4" -once_cell = "1.0" +# once_cell = "1.0" serde = { version = "1.0" } serde_derive = "1.0" serde_json = "1.0" diff --git a/sdk/data_tables/src/clients/entity_client.rs b/sdk/data_tables/src/clients/entity_client.rs index dcad86879f..b37a62dad8 100644 --- a/sdk/data_tables/src/clients/entity_client.rs +++ b/sdk/data_tables/src/clients/entity_client.rs @@ -1,10 +1,10 @@ use crate::{prelude::*, requests::*}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind}, Request, }; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; use url::Url; diff --git a/sdk/data_tables/src/clients/partition_key_client.rs b/sdk/data_tables/src/clients/partition_key_client.rs index b40eabb06b..3284345fac 100644 --- a/sdk/data_tables/src/clients/partition_key_client.rs +++ b/sdk/data_tables/src/clients/partition_key_client.rs @@ -1,9 +1,9 @@ use crate::{prelude::*, requests::*}; +use azure_core::Method; use azure_core::Request; use azure_storage::core::clients::StorageAccountClient; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsPartitionKeyClient> { diff --git a/sdk/data_tables/src/clients/table_client.rs b/sdk/data_tables/src/clients/table_client.rs index c0d02d58fc..e525212337 100644 --- a/sdk/data_tables/src/clients/table_client.rs +++ b/sdk/data_tables/src/clients/table_client.rs @@ -1,8 +1,8 @@ use crate::{clients::TableServiceClient, requests::*}; +use azure_core::Method; use azure_core::Request; use azure_storage::core::clients::StorageAccountClient; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsTableClient> { diff --git a/sdk/data_tables/src/clients/table_service_client.rs b/sdk/data_tables/src/clients/table_service_client.rs index d998b84529..dae9af862b 100644 --- a/sdk/data_tables/src/clients/table_service_client.rs +++ b/sdk/data_tables/src/clients/table_service_client.rs @@ -1,9 +1,9 @@ use crate::requests::ListTablesBuilder; use azure_core::error::{ErrorKind, ResultExt}; +use azure_core::Method; use azure_core::Request; use azure_storage::core::clients::{StorageAccountClient, StorageClient}; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; use url::Url; diff --git a/sdk/data_tables/src/lib.rs b/sdk/data_tables/src/lib.rs index 6d69872a45..c9c5e2f0ff 100644 --- a/sdk/data_tables/src/lib.rs +++ b/sdk/data_tables/src/lib.rs @@ -28,12 +28,8 @@ pub use entity_with_metadata::EntityWithMetadata; pub use filter::Filter; pub use if_match_condition::IfMatchCondition; pub use model::Table; -use once_cell::sync::Lazy; pub use return_entity::ReturnEntity; pub use select::Select; pub use top::Top; pub use transaction::Transaction; pub use transaction_operation::TransactionOperation; - -// we need this since the http::Method does not have the MERGE verb. The unwrap is safe here. -static MERGE: Lazy = Lazy::new(|| http::Method::from_bytes(b"MERGE").unwrap()); diff --git a/sdk/data_tables/src/requests/create_table_builder.rs b/sdk/data_tables/src/requests/create_table_builder.rs index bbcf5e1308..37da45f47b 100644 --- a/sdk/data_tables/src/requests/create_table_builder.rs +++ b/sdk/data_tables/src/requests/create_table_builder.rs @@ -1,6 +1,6 @@ use crate::{prelude::*, responses::*}; use azure_core::prelude::*; -use http::method::Method; +use azure_core::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/data_tables/src/requests/delete_entity_builder.rs b/sdk/data_tables/src/requests/delete_entity_builder.rs index ab3ca9ebdc..055b8c66a9 100644 --- a/sdk/data_tables/src/requests/delete_entity_builder.rs +++ b/sdk/data_tables/src/requests/delete_entity_builder.rs @@ -3,8 +3,8 @@ use crate::{ responses::*, TransactionOperation, }; +use azure_core::Method; use azure_core::{prelude::*, Request}; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/data_tables/src/requests/delete_table_builder.rs b/sdk/data_tables/src/requests/delete_table_builder.rs index 8fcb132091..9fa0b12a74 100644 --- a/sdk/data_tables/src/requests/delete_table_builder.rs +++ b/sdk/data_tables/src/requests/delete_table_builder.rs @@ -1,9 +1,9 @@ use crate::{prelude::*, responses::*}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind}, prelude::*, }; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/data_tables/src/requests/get_entity_builder.rs b/sdk/data_tables/src/requests/get_entity_builder.rs index 1af6402ece..e1214e814f 100644 --- a/sdk/data_tables/src/requests/get_entity_builder.rs +++ b/sdk/data_tables/src/requests/get_entity_builder.rs @@ -1,6 +1,6 @@ use crate::{prelude::*, responses::*}; +use azure_core::Method; use azure_core::{error::Result, prelude::*, AppendToUrlQuery}; -use http::method::Method; use serde::de::DeserializeOwned; use std::convert::TryInto; diff --git a/sdk/data_tables/src/requests/insert_entity_builder.rs b/sdk/data_tables/src/requests/insert_entity_builder.rs index 1c35c466b4..818f4a2303 100644 --- a/sdk/data_tables/src/requests/insert_entity_builder.rs +++ b/sdk/data_tables/src/requests/insert_entity_builder.rs @@ -1,10 +1,10 @@ use crate::{prelude::*, responses::*, TransactionOperation}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind}, prelude::*, Request, }; -use http::method::Method; use serde::{de::DeserializeOwned, Serialize}; use std::convert::TryInto; diff --git a/sdk/data_tables/src/requests/insert_or_replace_or_merge_entity_builder.rs b/sdk/data_tables/src/requests/insert_or_replace_or_merge_entity_builder.rs index b638ac9739..99f4e200dd 100644 --- a/sdk/data_tables/src/requests/insert_or_replace_or_merge_entity_builder.rs +++ b/sdk/data_tables/src/requests/insert_or_replace_or_merge_entity_builder.rs @@ -1,6 +1,6 @@ use crate::{prelude::*, responses::*, TransactionOperation}; +use azure_core::Method; use azure_core::{prelude::*, Request}; -use http::method::Method; use serde::Serialize; use std::convert::TryInto; @@ -46,7 +46,7 @@ impl<'a> InsertOrReplaceOrMergeEntityBuilder<'a> { let mut request = self.entity_client.prepare_request( url.as_str(), match self.operation { - Operation::InsertOrMerge => crate::MERGE.to_owned(), + Operation::InsertOrMerge => Method::MERGE, Operation::InsertOrReplace => Method::PUT, }, Some(bytes::Bytes::from(request_body_serialized)), @@ -75,7 +75,7 @@ impl<'a> InsertOrReplaceOrMergeEntityBuilder<'a> { let mut request = Request::new( url.clone(), match self.operation { - Operation::InsertOrMerge => crate::MERGE.to_owned(), + Operation::InsertOrMerge => Method::MERGE, Operation::InsertOrReplace => Method::PUT, }, ); diff --git a/sdk/data_tables/src/requests/list_tables_builder.rs b/sdk/data_tables/src/requests/list_tables_builder.rs index 707ebf836b..94ecedcb22 100644 --- a/sdk/data_tables/src/requests/list_tables_builder.rs +++ b/sdk/data_tables/src/requests/list_tables_builder.rs @@ -1,7 +1,7 @@ use crate::{prelude::*, responses::*, ContinuationNextTableName}; +use azure_core::Method; use azure_core::{prelude::*, AppendToUrlQuery}; use futures::stream::{unfold, Stream}; -use http::method::Method; use std::convert::TryInto; #[cfg(test)] diff --git a/sdk/data_tables/src/requests/query_entity_builder.rs b/sdk/data_tables/src/requests/query_entity_builder.rs index ef74dcaa0c..ea4d458422 100644 --- a/sdk/data_tables/src/requests/query_entity_builder.rs +++ b/sdk/data_tables/src/requests/query_entity_builder.rs @@ -1,11 +1,11 @@ use crate::{prelude::*, responses::*, ContinuationNextPartitionAndRowKey}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind}, prelude::*, AppendToUrlQuery, }; use futures::stream::{unfold, Stream}; -use http::method::Method; use serde::de::DeserializeOwned; use std::convert::TryInto; diff --git a/sdk/data_tables/src/requests/submit_transaction_builder.rs b/sdk/data_tables/src/requests/submit_transaction_builder.rs index 4dd458a5e6..d3e4b1071f 100644 --- a/sdk/data_tables/src/requests/submit_transaction_builder.rs +++ b/sdk/data_tables/src/requests/submit_transaction_builder.rs @@ -1,9 +1,9 @@ use crate::{prelude::*, responses::*}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind, ResultExt}, prelude::*, }; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/data_tables/src/requests/update_or_merge_entity_builder.rs b/sdk/data_tables/src/requests/update_or_merge_entity_builder.rs index a16d2928cb..6869345798 100644 --- a/sdk/data_tables/src/requests/update_or_merge_entity_builder.rs +++ b/sdk/data_tables/src/requests/update_or_merge_entity_builder.rs @@ -1,6 +1,6 @@ use crate::{prelude::*, responses::*, IfMatchCondition, TransactionOperation}; +use azure_core::Method; use azure_core::{prelude::*, Request}; -use http::method::Method; use serde::Serialize; use std::convert::TryInto; @@ -49,7 +49,7 @@ impl<'a> UpdateOrMergeEntityBuilder<'a> { let mut request = self.entity_client.prepare_request( url.as_str(), match self.operation { - Operation::Merge => crate::MERGE.to_owned(), + Operation::Merge => Method::MERGE, Operation::Update => Method::PUT, }, Some(bytes::Bytes::from(request_body_serialized)), @@ -80,7 +80,7 @@ impl<'a> UpdateOrMergeEntityBuilder<'a> { let mut request = Request::new( url.clone(), match self.operation { - Operation::Merge => crate::MERGE.to_owned(), + Operation::Merge => Method::MERGE, Operation::Update => Method::PUT, }, ); diff --git a/sdk/data_tables/src/responses/submit_transaction_response.rs b/sdk/data_tables/src/responses/submit_transaction_response.rs index c2dbf2b4e2..f1beeb02b2 100644 --- a/sdk/data_tables/src/responses/submit_transaction_response.rs +++ b/sdk/data_tables/src/responses/submit_transaction_response.rs @@ -1,9 +1,8 @@ use azure_core::{ error::{Error, ErrorKind}, - CollectedResponse, Etag, + CollectedResponse, Etag, StatusCode, }; use azure_storage::core::headers::CommonStorageResponseHeaders; -use http::StatusCode; use std::convert::{TryFrom, TryInto}; use url::Url; @@ -40,13 +39,17 @@ impl TryFrom for SubmitTransactionResponse { for line in change_set_response.lines() { if line.starts_with("HTTP/1.1") { - operation_response.status_code = line + let status_code = line .split_whitespace() .nth(1) .ok_or_else(|| { Error::message(ErrorKind::Other, "missing HTTP status code") })? - .parse()?; + .parse::() + .map_err(|_| { + Error::message(ErrorKind::DataConversion, "invalid HTTP status code") + })?; + operation_response.status_code = StatusCode::try_from(status_code)? } else if line.starts_with("Location:") { operation_response.location = Some( line.split_whitespace() diff --git a/sdk/data_tables/src/transaction.rs b/sdk/data_tables/src/transaction.rs index bea830f2d1..775e8911cd 100644 --- a/sdk/data_tables/src/transaction.rs +++ b/sdk/data_tables/src/transaction.rs @@ -40,7 +40,7 @@ impl Transaction { for transaction_operation in self.transaction_operations.iter() { s.push_str(&format!("--changeset_{}\nContent-Type: application/http\nContent-Transfer-Encoding: binary\n\n", self.change_set_uuid.hyphenated())); s.push_str(&format!( - "{} {} HTTP/1.1\n", + "{:?} {} HTTP/1.1\n", transaction_operation.request.method(), transaction_operation.request.url() )); diff --git a/sdk/identity/Cargo.toml b/sdk/identity/Cargo.toml index f05410a253..74f977a95e 100644 --- a/sdk/identity/Cargo.toml +++ b/sdk/identity/Cargo.toml @@ -27,7 +27,6 @@ async-trait = "0.1" openssl = { version = "0.10", optional=true } base64 = "0.13.0" uuid = { version = "1.0", features = ["v4"] } -http = "0.2" # work around https://github.com/rust-lang/rust/issues/63033 fix-hidden-lifetime-bug = "0.2" diff --git a/sdk/identity/src/client_credentials_flow/mod.rs b/sdk/identity/src/client_credentials_flow/mod.rs index 77ad99363a..319c6d5bea 100644 --- a/sdk/identity/src/client_credentials_flow/mod.rs +++ b/sdk/identity/src/client_credentials_flow/mod.rs @@ -39,12 +39,12 @@ mod login_response; +use azure_core::Method; use azure_core::{ content_type, error::{ErrorKind, ResultExt}, headers, HttpClient, Request, }; -use http::Method; use login_response::LoginResponse; use std::sync::Arc; use url::{form_urlencoded, Url}; @@ -81,7 +81,7 @@ pub async fn perform( ); req.set_body(encoded); let rsp = http_client.execute_request(&req).await?; - let rsp_status = rsp.status(); + let rsp_status = rsp.status().clone(); let rsp_body = rsp.into_body().await; if !rsp_status.is_success() { return Err( diff --git a/sdk/identity/src/device_code_flow/mod.rs b/sdk/identity/src/device_code_flow/mod.rs index fcd086adb5..f31b3c867e 100644 --- a/sdk/identity/src/device_code_flow/mod.rs +++ b/sdk/identity/src/device_code_flow/mod.rs @@ -6,6 +6,7 @@ mod device_code_responses; use async_timer::timer::new_timer; +use azure_core::Method; use azure_core::{ content_type, error::{Error, ErrorKind}, @@ -13,7 +14,6 @@ use azure_core::{ }; pub use device_code_responses::*; use futures::stream::unfold; -use http::Method; use oauth2::ClientId; use serde::Deserialize; use std::{borrow::Cow, sync::Arc, time::Duration}; @@ -42,7 +42,7 @@ where let encoded = encoded.finish(); let rsp = post_form(http_client.clone(), url, encoded).await?; - let rsp_status = rsp.status(); + let rsp_status = rsp.status().clone(); let rsp_body = rsp.into_body().await; if !rsp_status.is_success() { return Err( @@ -128,7 +128,7 @@ impl<'a> DeviceCodePhaseOneResponse<'a> { match post_form(http_client.clone(), url, encoded).await { Ok(rsp) => { - let rsp_status = rsp.status(); + let rsp_status = rsp.status().clone(); let rsp_body = rsp.into_body().await; if rsp_status.is_success() { match serde_json::from_slice::(&rsp_body) { diff --git a/sdk/identity/src/refresh_token.rs b/sdk/identity/src/refresh_token.rs index 52f16075ad..8b83fce419 100644 --- a/sdk/identity/src/refresh_token.rs +++ b/sdk/identity/src/refresh_token.rs @@ -1,12 +1,12 @@ //! Refresh token utilities +use azure_core::Method; use azure_core::{ auth::AccessToken, content_type, error::{Error, ErrorKind, ResultExt}, headers, HttpClient, Request, }; -use http::Method; use oauth2::{ClientId, ClientSecret}; use serde::Deserialize; use std::fmt; @@ -49,7 +49,7 @@ pub async fn exchange( let rsp = http_client.execute_request(&req).await?; - let rsp_status = rsp.status(); + let rsp_status = rsp.status().clone(); let rsp_body = rsp.into_body().await; if !rsp_status.is_success() { diff --git a/sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs b/sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs index e35c0fead6..e0ec9cd197 100644 --- a/sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs +++ b/sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs @@ -1,8 +1,8 @@ use azure_core::auth::{AccessToken, TokenCredential, TokenResponse}; use azure_core::error::{Error, ErrorKind, ResultExt}; +use azure_core::Method; use azure_core::{HttpClient, Request}; use chrono::{DateTime, TimeZone, Utc}; -use http::Method; use serde::{ de::{self, Deserializer}, Deserialize, @@ -121,7 +121,7 @@ impl TokenCredential for ImdsManagedIdentityCredential { }; let rsp = self.http_client.execute_request(&req).await?; - let rsp_status = rsp.status(); + let rsp_status = rsp.status().clone(); let rsp_body = rsp.into_body().await; if !rsp_status.is_success() { diff --git a/sdk/iot_hub/Cargo.toml b/sdk/iot_hub/Cargo.toml index 4168a2a1e0..3568078b84 100644 --- a/sdk/iot_hub/Cargo.toml +++ b/sdk/iot_hub/Cargo.toml @@ -12,7 +12,6 @@ base64 = "0.13" bytes = "1.0" chrono = "0.4" hmac = "0.12" -http = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_derive = "1.0" diff --git a/sdk/iot_hub/src/service/mod.rs b/sdk/iot_hub/src/service/mod.rs index 458ccb1ac1..cf5d25adeb 100644 --- a/sdk/iot_hub/src/service/mod.rs +++ b/sdk/iot_hub/src/service/mod.rs @@ -1,8 +1,8 @@ use azure_core::error::{Error, ErrorKind, ResultExt}; +use azure_core::Method; use azure_core::{content_type, headers, CollectedResponse, HttpClient, Request, Url}; use base64::{decode, encode_config}; use hmac::{Hmac, Mac}; -use http::Method; use sha2::Sha256; use std::sync::Arc; @@ -871,7 +871,7 @@ mod tests { let builder = service_client.update_module_twin("deviceid", "moduleid"); assert_eq!(builder.device_id, "deviceid".to_string()); assert_eq!(builder.module_id, Some("moduleid".to_string())); - assert_eq!(builder.method, http::Method::PATCH); + assert_eq!(builder.method, azure_core::Method::PATCH); Ok(()) } @@ -888,7 +888,7 @@ mod tests { let builder = service_client.replace_module_twin("deviceid", "moduleid"); assert_eq!(builder.device_id, "deviceid".to_string()); assert_eq!(builder.module_id, Some("moduleid".to_string())); - assert_eq!(builder.method, http::Method::PUT); + assert_eq!(builder.method, azure_core::Method::PUT); Ok(()) } @@ -905,7 +905,7 @@ mod tests { let builder = service_client.update_device_twin("deviceid"); assert_eq!(builder.device_id, "deviceid".to_string()); assert_eq!(builder.module_id, None); - assert_eq!(builder.method, http::Method::PATCH); + assert_eq!(builder.method, azure_core::Method::PATCH); Ok(()) } @@ -922,7 +922,7 @@ mod tests { let builder = service_client.replace_device_twin("deviceid"); assert_eq!(builder.device_id, "deviceid".to_string()); assert_eq!(builder.module_id, None); - assert_eq!(builder.method, http::Method::PUT); + assert_eq!(builder.method, azure_core::Method::PUT); Ok(()) } diff --git a/sdk/iot_hub/src/service/requests/apply_on_edge_device_builder.rs b/sdk/iot_hub/src/service/requests/apply_on_edge_device_builder.rs index 39084ebe05..a74194359c 100644 --- a/sdk/iot_hub/src/service/requests/apply_on_edge_device_builder.rs +++ b/sdk/iot_hub/src/service/requests/apply_on_edge_device_builder.rs @@ -1,6 +1,6 @@ use crate::service::{ServiceClient, API_VERSION}; -use http::Method; +use azure_core::Method; use serde::Serialize; /// The ApplyOnEdgeDeviceBuilder is used to construct a new device identity /// or the update an existing one. diff --git a/sdk/iot_hub/src/service/requests/create_or_update_configuration_builder.rs b/sdk/iot_hub/src/service/requests/create_or_update_configuration_builder.rs index 82a6dfcb02..905a311df1 100644 --- a/sdk/iot_hub/src/service/requests/create_or_update_configuration_builder.rs +++ b/sdk/iot_hub/src/service/requests/create_or_update_configuration_builder.rs @@ -1,5 +1,5 @@ use azure_core::headers; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::collections::HashMap; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/create_or_update_device_identity_builder.rs b/sdk/iot_hub/src/service/requests/create_or_update_device_identity_builder.rs index 93d35124dd..395320d23c 100644 --- a/sdk/iot_hub/src/service/requests/create_or_update_device_identity_builder.rs +++ b/sdk/iot_hub/src/service/requests/create_or_update_device_identity_builder.rs @@ -6,7 +6,7 @@ use crate::service::responses::DeviceIdentityResponse; use crate::service::{ServiceClient, API_VERSION}; use azure_core::error::{Error, ErrorKind}; use azure_core::headers; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/create_or_update_module_identity_builder.rs b/sdk/iot_hub/src/service/requests/create_or_update_module_identity_builder.rs index 5815ba6445..5848b98793 100644 --- a/sdk/iot_hub/src/service/requests/create_or_update_module_identity_builder.rs +++ b/sdk/iot_hub/src/service/requests/create_or_update_module_identity_builder.rs @@ -3,7 +3,7 @@ use crate::service::responses::ModuleIdentityResponse; use crate::service::{ServiceClient, API_VERSION}; use azure_core::error::{Error, ErrorKind}; use azure_core::headers; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/delete_configuration_builder.rs b/sdk/iot_hub/src/service/requests/delete_configuration_builder.rs index d94eafeda1..8d3368404f 100644 --- a/sdk/iot_hub/src/service/requests/delete_configuration_builder.rs +++ b/sdk/iot_hub/src/service/requests/delete_configuration_builder.rs @@ -1,7 +1,7 @@ use crate::service::{ServiceClient, API_VERSION}; use azure_core::headers; -use http::Method; +use azure_core::Method; /// The DeleteConfigurationBuilder is used to construct a request to delete a configuration. pub struct DeleteConfigurationBuilder<'a> { diff --git a/sdk/iot_hub/src/service/requests/delete_identity_builder.rs b/sdk/iot_hub/src/service/requests/delete_identity_builder.rs index 2de4837aa2..31c6639710 100644 --- a/sdk/iot_hub/src/service/requests/delete_identity_builder.rs +++ b/sdk/iot_hub/src/service/requests/delete_identity_builder.rs @@ -1,6 +1,6 @@ use crate::service::{ServiceClient, API_VERSION}; use azure_core::headers; -use http::Method; +use azure_core::Method; /// The DeleteIdentityBuilder is used to construct a request to delete a module or device identity. pub struct DeleteIdentityBuilder<'a> { diff --git a/sdk/iot_hub/src/service/requests/get_configuration.rs b/sdk/iot_hub/src/service/requests/get_configuration.rs index 5b109cd1ec..8f60584070 100644 --- a/sdk/iot_hub/src/service/requests/get_configuration.rs +++ b/sdk/iot_hub/src/service/requests/get_configuration.rs @@ -1,6 +1,6 @@ use crate::service::{ServiceClient, API_VERSION}; use azure_core::error::Error; -use http::Method; +use azure_core::Method; use std::convert::{TryFrom, TryInto}; /// Execute the request to get the configuration of a given identifier. diff --git a/sdk/iot_hub/src/service/requests/get_identity.rs b/sdk/iot_hub/src/service/requests/get_identity.rs index 09f0463353..e2c684741f 100644 --- a/sdk/iot_hub/src/service/requests/get_identity.rs +++ b/sdk/iot_hub/src/service/requests/get_identity.rs @@ -1,6 +1,6 @@ use crate::service::{ServiceClient, API_VERSION}; use azure_core::error::Error; -use http::Method; +use azure_core::Method; use std::convert::{TryFrom, TryInto}; /// Execute the request to get the identity of a device or module. diff --git a/sdk/iot_hub/src/service/requests/get_twin.rs b/sdk/iot_hub/src/service/requests/get_twin.rs index 220e63a58f..b4e5a7adda 100644 --- a/sdk/iot_hub/src/service/requests/get_twin.rs +++ b/sdk/iot_hub/src/service/requests/get_twin.rs @@ -1,6 +1,6 @@ use crate::service::{ServiceClient, API_VERSION}; use azure_core::error::Error; -use http::Method; +use azure_core::Method; use std::convert::TryFrom; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/invoke_method_builder.rs b/sdk/iot_hub/src/service/requests/invoke_method_builder.rs index e8ea2d88e2..e592dc21c0 100644 --- a/sdk/iot_hub/src/service/requests/invoke_method_builder.rs +++ b/sdk/iot_hub/src/service/requests/invoke_method_builder.rs @@ -1,6 +1,6 @@ use crate::service::responses::InvokeMethodResponse; use crate::service::{ServiceClient, API_VERSION}; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/query_builder.rs b/sdk/iot_hub/src/service/requests/query_builder.rs index c8b492f8f6..ddfefa1ead 100644 --- a/sdk/iot_hub/src/service/requests/query_builder.rs +++ b/sdk/iot_hub/src/service/requests/query_builder.rs @@ -3,7 +3,7 @@ use crate::service::{responses::QueryResponse, ServiceClient, API_VERSION}; use azure_core::prelude::*; use azure_core::setters; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::convert::TryInto; diff --git a/sdk/iot_hub/src/service/requests/update_or_replace_twin_builder.rs b/sdk/iot_hub/src/service/requests/update_or_replace_twin_builder.rs index 06ffdf9b66..e6c1be8292 100644 --- a/sdk/iot_hub/src/service/requests/update_or_replace_twin_builder.rs +++ b/sdk/iot_hub/src/service/requests/update_or_replace_twin_builder.rs @@ -1,6 +1,6 @@ use azure_core::error::Error; use azure_core::headers; -use http::Method; +use azure_core::Method; use serde::Serialize; use std::collections::HashMap; use std::convert::TryFrom; diff --git a/sdk/messaging_eventgrid/Cargo.toml b/sdk/messaging_eventgrid/Cargo.toml index 09c830c0b5..3818623c78 100644 --- a/sdk/messaging_eventgrid/Cargo.toml +++ b/sdk/messaging_eventgrid/Cargo.toml @@ -15,7 +15,6 @@ edition = "2021" [dependencies] azure_core = { path = "../core", version = "0.3" } chrono = { version = "0.4", features = ["serde"] } -http = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" uuid = { version = "1.0", features = ["v4"] } diff --git a/sdk/messaging_servicebus/Cargo.toml b/sdk/messaging_servicebus/Cargo.toml index cae387aac1..73b4c66c07 100644 --- a/sdk/messaging_servicebus/Cargo.toml +++ b/sdk/messaging_servicebus/Cargo.toml @@ -23,7 +23,6 @@ url = "2.2" hmac = "0.12" sha2 = "0.10" ring = "0.16" -http = "0.2" bytes = "1.0" [dev-dependencies] diff --git a/sdk/messaging_servicebus/src/service_bus/mod.rs b/sdk/messaging_servicebus/src/service_bus/mod.rs index b95460919f..9b79b902a6 100644 --- a/sdk/messaging_servicebus/src/service_bus/mod.rs +++ b/sdk/messaging_servicebus/src/service_bus/mod.rs @@ -1,6 +1,6 @@ use azure_core::{error::Error, headers, CollectedResponse, HttpClient, Request, Url}; +use azure_core::{Method, StatusCode}; use chrono::Duration; -use http::Method; use ring::hmac; use std::{ops::Add, sync::Arc}; use url::form_urlencoded::{self, Serializer}; @@ -17,7 +17,7 @@ const DEFAULT_SAS_DURATION: i64 = 1; /// Prepares an HTTP request fn prepare_request( url: &str, - method: http::Method, + method: azure_core::Method, body: Option, policy_name: &str, signing_key: &hmac::Key, @@ -170,7 +170,7 @@ async fn peek_lock_message2( let res = http_client.execute_request(&req).await?; - let status = res.status(); + let status = res.status().clone(); let lock_location: String = match res.headers().get(&headers::LOCATION) { Some(header_value) => header_value.as_str().to_owned(), _ => "".to_owned(), @@ -191,7 +191,7 @@ async fn peek_lock_message2( pub struct PeekLockResponse { body: String, lock_location: String, - status: http::StatusCode, + status: StatusCode, http_client: Arc, policy_name: String, signing_key: hmac::Key, @@ -204,8 +204,8 @@ impl PeekLockResponse { } /// Get the status of the peek - pub fn status(&self) -> http::StatusCode { - self.status + pub fn status(&self) -> &StatusCode { + &self.status } /// Delete message in the lock diff --git a/sdk/storage/Cargo.toml b/sdk/storage/Cargo.toml index 5c828a074f..8907cf4dcb 100644 --- a/sdk/storage/Cargo.toml +++ b/sdk/storage/Cargo.toml @@ -17,7 +17,6 @@ async-trait = "0.1" azure_core = { path = "../core", version = "0.3", default-features=false } base64 = "0.13" chrono = "0.4" -http = "0.2" futures = "0.3" log = "0.4" serde = "1.0" diff --git a/sdk/storage/src/account/operations/find_blobs_by_tags.rs b/sdk/storage/src/account/operations/find_blobs_by_tags.rs index f97127b178..0411cf6a9e 100644 --- a/sdk/storage/src/account/operations/find_blobs_by_tags.rs +++ b/sdk/storage/src/account/operations/find_blobs_by_tags.rs @@ -41,7 +41,7 @@ impl FindBlobsByTagsBuilder { let mut request = self .client .storage_account_client() - .blob_storage_request(http::Method::GET); + .blob_storage_request(azure_core::Method::GET); self.timeout.append_to_url_query(request.url_mut()); request diff --git a/sdk/storage/src/account/operations/get_account_information.rs b/sdk/storage/src/account/operations/get_account_information.rs index c7173101b0..be1c57b38d 100644 --- a/sdk/storage/src/account/operations/get_account_information.rs +++ b/sdk/storage/src/account/operations/get_account_information.rs @@ -29,7 +29,7 @@ impl GetAccountInformationBuilder { let mut request = self .client .storage_account_client() - .blob_storage_request(http::Method::GET); + .blob_storage_request(azure_core::Method::GET); for (k, v) in [("restype", "account"), ("comp", "properties")].iter() { request.url_mut().query_pairs_mut().append_pair(k, v); diff --git a/sdk/storage/src/authorization_policy.rs b/sdk/storage/src/authorization_policy.rs index f6c2e953c1..13c3fbb263 100644 --- a/sdk/storage/src/authorization_policy.rs +++ b/sdk/storage/src/authorization_policy.rs @@ -1,7 +1,7 @@ use crate::clients::{ServiceType, StorageCredentials}; use azure_core::error::{ErrorKind, ResultExt}; +use azure_core::Method; use azure_core::{headers::*, Context, Policy, PolicyResult, Request}; -use http::Method; use std::borrow::Cow; use std::sync::Arc; use url::Url; diff --git a/sdk/storage/src/core/clients/storage_account_client.rs b/sdk/storage/src/core/clients/storage_account_client.rs index 2e53fade1a..2fdd31480f 100644 --- a/sdk/storage/src/core/clients/storage_account_client.rs +++ b/sdk/storage/src/core/clients/storage_account_client.rs @@ -7,6 +7,7 @@ use crate::{ AccountSharedAccessSignatureBuilder, ClientAccountSharedAccessSignature, }, }; +use azure_core::Method; use azure_core::{ auth::TokenCredential, error::{Error, ErrorKind, ResultExt}, @@ -14,7 +15,6 @@ use azure_core::{ ClientOptions, Context, HttpClient, Pipeline, Request, Response, }; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; use url::Url; @@ -509,7 +509,7 @@ impl StorageAccountClient { } /// Prepares' an `azure_core::Request`. - pub(crate) fn blob_storage_request(&self, http_method: http::Method) -> Request { + pub(crate) fn blob_storage_request(&self, http_method: azure_core::Method) -> Request { Request::new(self.blob_storage_url().clone(), http_method) } } diff --git a/sdk/storage/src/core/clients/storage_client.rs b/sdk/storage/src/core/clients/storage_client.rs index 0364857eec..7b3896bfef 100644 --- a/sdk/storage/src/core/clients/storage_client.rs +++ b/sdk/storage/src/core/clients/storage_client.rs @@ -1,11 +1,11 @@ use crate::core::clients::{ServiceType, StorageAccountClient}; use crate::operations::*; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind}, Context, Request, Response, }; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsStorageClient { diff --git a/sdk/storage_blobs/Cargo.toml b/sdk/storage_blobs/Cargo.toml index 3705aebacc..5669895af0 100644 --- a/sdk/storage_blobs/Cargo.toml +++ b/sdk/storage_blobs/Cargo.toml @@ -21,7 +21,6 @@ base64 = "0.13" bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } futures = "0.3" -http = "0.2" log = "0.4" md5 = "0.7" RustyXML = "0.3" diff --git a/sdk/storage_blobs/src/blob/operations/acquire_lease.rs b/sdk/storage_blobs/src/blob/operations/acquire_lease.rs index 099b894f52..935a5497a4 100644 --- a/sdk/storage_blobs/src/blob/operations/acquire_lease.rs +++ b/sdk/storage_blobs/src/blob/operations/acquire_lease.rs @@ -46,7 +46,7 @@ impl AcquireLeaseBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(LEASE_ACTION, "acquire"); request.add_mandatory_header(&self.lease_duration); request.add_optional_header(&self.proposed_lease_id); diff --git a/sdk/storage_blobs/src/blob/operations/append_block.rs b/sdk/storage_blobs/src/blob/operations/append_block.rs index b801e8330a..3ce593a7d7 100644 --- a/sdk/storage_blobs/src/blob/operations/append_block.rs +++ b/sdk/storage_blobs/src/blob/operations/append_block.rs @@ -45,7 +45,7 @@ impl AppendBlockBuilder { let mut request = self.blob_client.prepare_request( url.as_str(), - http::Method::PUT, + azure_core::Method::PUT, Some(self.body.clone()), )?; request.add_optional_header(&self.hash); diff --git a/sdk/storage_blobs/src/blob/operations/break_lease.rs b/sdk/storage_blobs/src/blob/operations/break_lease.rs index 5a33684bc8..6626e70e0b 100644 --- a/sdk/storage_blobs/src/blob/operations/break_lease.rs +++ b/sdk/storage_blobs/src/blob/operations/break_lease.rs @@ -37,7 +37,7 @@ impl BreakLeaseBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(LEASE_ACTION, "break"); request.add_optional_header(&self.lease_break_period); request.add_optional_header(&self.lease_id); diff --git a/sdk/storage_blobs/src/blob/operations/change_lease.rs b/sdk/storage_blobs/src/blob/operations/change_lease.rs index d903e6d23e..3394645dec 100644 --- a/sdk/storage_blobs/src/blob/operations/change_lease.rs +++ b/sdk/storage_blobs/src/blob/operations/change_lease.rs @@ -34,9 +34,11 @@ impl ChangeLeaseBuilder { url.query_pairs_mut().append_pair("comp", "lease"); self.timeout.append_to_url_query(&mut url); - let mut request = - self.blob_lease_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + let mut request = self.blob_lease_client.prepare_request( + url.as_str(), + azure_core::Method::PUT, + None, + )?; request.insert_header(LEASE_ACTION, "change"); request.add_mandatory_header(self.blob_lease_client.lease_id()); request.add_mandatory_header(&self.proposed_lease_id); diff --git a/sdk/storage_blobs/src/blob/operations/clear_page.rs b/sdk/storage_blobs/src/blob/operations/clear_page.rs index 9d15713883..20bbd06490 100644 --- a/sdk/storage_blobs/src/blob/operations/clear_page.rs +++ b/sdk/storage_blobs/src/blob/operations/clear_page.rs @@ -49,7 +49,7 @@ impl ClearPageBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(PAGE_WRITE, "clear"); request.insert_header(BLOB_TYPE, "PageBlob"); diff --git a/sdk/storage_blobs/src/blob/operations/copy_blob.rs b/sdk/storage_blobs/src/blob/operations/copy_blob.rs index ea4ca05437..5eccc327fd 100644 --- a/sdk/storage_blobs/src/blob/operations/copy_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/copy_blob.rs @@ -73,7 +73,7 @@ impl CopyBlobBuilder { self.timeout.append_to_url_query(&mut url); let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(COPY_SOURCE, self.source_url.as_str().to_owned()); if let Some(metadata) = &self.metadata { for m in metadata.iter() { diff --git a/sdk/storage_blobs/src/blob/operations/copy_blob_from_url.rs b/sdk/storage_blobs/src/blob/operations/copy_blob_from_url.rs index 1e2bb15857..144d12b7ed 100644 --- a/sdk/storage_blobs/src/blob/operations/copy_blob_from_url.rs +++ b/sdk/storage_blobs/src/blob/operations/copy_blob_from_url.rs @@ -73,7 +73,7 @@ impl CopyBlobFromUrlBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(COPY_SOURCE, self.source_url.to_string()); request.insert_header(REQUIRES_SYNC, format!("{}", self.is_synchronous)); if let Some(metadata) = &self.metadata { diff --git a/sdk/storage_blobs/src/blob/operations/delete_blob.rs b/sdk/storage_blobs/src/blob/operations/delete_blob.rs index 6d808377d1..f879a1e373 100644 --- a/sdk/storage_blobs/src/blob/operations/delete_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/delete_blob.rs @@ -36,7 +36,7 @@ impl DeleteBlobBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::DELETE, None)?; + .prepare_request(url.as_str(), azure_core::Method::DELETE, None)?; request.add_optional_header(&self.lease_id); request.add_mandatory_header(&self.delete_snapshots_method); diff --git a/sdk/storage_blobs/src/blob/operations/delete_blob_snapshot.rs b/sdk/storage_blobs/src/blob/operations/delete_blob_snapshot.rs index ab6b65598a..abec3fd295 100644 --- a/sdk/storage_blobs/src/blob/operations/delete_blob_snapshot.rs +++ b/sdk/storage_blobs/src/blob/operations/delete_blob_snapshot.rs @@ -41,7 +41,7 @@ impl DeleteBlobSnapshotBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::DELETE, None)?; + .prepare_request(url.as_str(), azure_core::Method::DELETE, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/delete_blob_version.rs b/sdk/storage_blobs/src/blob/operations/delete_blob_version.rs index b9c9e26244..8706137cb3 100644 --- a/sdk/storage_blobs/src/blob/operations/delete_blob_version.rs +++ b/sdk/storage_blobs/src/blob/operations/delete_blob_version.rs @@ -41,7 +41,7 @@ impl DeleteBlobVersionBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::DELETE, None)?; + .prepare_request(url.as_str(), azure_core::Method::DELETE, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/get_blob.rs b/sdk/storage_blobs/src/blob/operations/get_blob.rs index b351b693d6..b323a199f6 100644 --- a/sdk/storage_blobs/src/blob/operations/get_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/get_blob.rs @@ -51,7 +51,7 @@ impl<'a> GetBlobBuilder<'a> { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::GET, None)?; + .prepare_request(url.as_str(), azure_core::Method::GET, None)?; if let Some(item) = &self.range { for (name, value) in item.as_headers() { request.insert_header(name, value); diff --git a/sdk/storage_blobs/src/blob/operations/get_block_list.rs b/sdk/storage_blobs/src/blob/operations/get_block_list.rs index 4e6be5ee6f..24f682e752 100644 --- a/sdk/storage_blobs/src/blob/operations/get_block_list.rs +++ b/sdk/storage_blobs/src/blob/operations/get_block_list.rs @@ -45,7 +45,7 @@ impl GetBlockListBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::GET, None)?; + .prepare_request(url.as_str(), azure_core::Method::GET, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/get_metadata.rs b/sdk/storage_blobs/src/blob/operations/get_metadata.rs index d6f6301b59..9efd347d2b 100644 --- a/sdk/storage_blobs/src/blob/operations/get_metadata.rs +++ b/sdk/storage_blobs/src/blob/operations/get_metadata.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use azure_core::{headers::*, prelude::*, RequestId}; +use azure_core::{headers::*, prelude::*, Method, RequestId}; use chrono::{DateTime, Utc}; use std::convert::{TryFrom, TryInto}; @@ -37,9 +37,9 @@ impl GetMetadataBuilder { self.blob_versioning.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = - self.blob_client - .prepare_request(url.as_str(), http::Method::GET, None)?; + let mut request = self + .blob_client + .prepare_request(url.as_str(), Method::GET, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/get_page_ranges.rs b/sdk/storage_blobs/src/blob/operations/get_page_ranges.rs index ee730df7a3..62de9d53d3 100644 --- a/sdk/storage_blobs/src/blob/operations/get_page_ranges.rs +++ b/sdk/storage_blobs/src/blob/operations/get_page_ranges.rs @@ -38,7 +38,7 @@ impl<'a> GetPageRangesBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::GET, None)?; + .prepare_request(url.as_str(), azure_core::Method::GET, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/get_properties.rs b/sdk/storage_blobs/src/blob/operations/get_properties.rs index da56703400..1020bbd4c5 100644 --- a/sdk/storage_blobs/src/blob/operations/get_properties.rs +++ b/sdk/storage_blobs/src/blob/operations/get_properties.rs @@ -37,7 +37,7 @@ impl GetPropertiesBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::HEAD, None)?; + .prepare_request(url.as_str(), azure_core::Method::HEAD, None)?; request.add_optional_header(&self.lease_id); let response = self diff --git a/sdk/storage_blobs/src/blob/operations/put_append_blob.rs b/sdk/storage_blobs/src/blob/operations/put_append_blob.rs index 756eb78cb6..7dbabcef34 100644 --- a/sdk/storage_blobs/src/blob/operations/put_append_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/put_append_blob.rs @@ -50,7 +50,7 @@ impl PutAppendBlobBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(BLOB_TYPE, "AppendBlob"); request.add_optional_header(&self.content_type); request.add_optional_header(&self.content_encoding); diff --git a/sdk/storage_blobs/src/blob/operations/put_block.rs b/sdk/storage_blobs/src/blob/operations/put_block.rs index 91ef4f3228..482cca4d02 100644 --- a/sdk/storage_blobs/src/blob/operations/put_block.rs +++ b/sdk/storage_blobs/src/blob/operations/put_block.rs @@ -49,7 +49,7 @@ impl<'a> PutBlockBuilder { let mut request = self.blob_client.prepare_request( url.as_str(), - http::Method::PUT, + azure_core::Method::PUT, Some(self.body.clone()), )?; request.add_optional_header(&self.lease_id); diff --git a/sdk/storage_blobs/src/blob/operations/put_block_blob.rs b/sdk/storage_blobs/src/blob/operations/put_block_blob.rs index 5b42842c91..adfa19c0a7 100644 --- a/sdk/storage_blobs/src/blob/operations/put_block_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/put_block_blob.rs @@ -64,7 +64,7 @@ impl PutBlockBlobBuilder { let mut request = self.blob_client.prepare_request( url.as_str(), - http::Method::PUT, + azure_core::Method::PUT, Some(self.body.clone()), )?; request.insert_header(BLOB_TYPE, "BlockBlob"); diff --git a/sdk/storage_blobs/src/blob/operations/put_block_list.rs b/sdk/storage_blobs/src/blob/operations/put_block_list.rs index 122a725b2f..0ee933f314 100644 --- a/sdk/storage_blobs/src/blob/operations/put_block_list.rs +++ b/sdk/storage_blobs/src/blob/operations/put_block_list.rs @@ -75,7 +75,7 @@ impl PutBlockListBuilder { let mut request = self.blob_client.prepare_request( url.as_str(), - http::Method::PUT, + azure_core::Method::PUT, Some(body_bytes), )?; request.insert_header("Content-MD5", &md5); diff --git a/sdk/storage_blobs/src/blob/operations/put_page_blob.rs b/sdk/storage_blobs/src/blob/operations/put_page_blob.rs index f267813808..585a2f2883 100644 --- a/sdk/storage_blobs/src/blob/operations/put_page_blob.rs +++ b/sdk/storage_blobs/src/blob/operations/put_page_blob.rs @@ -57,7 +57,7 @@ impl PutPageBlobBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.insert_header(BLOB_TYPE, "PageBlob"); request.insert_header(BLOB_CONTENT_LENGTH, &format!("{}", self.length)); request.add_optional_header(&self.content_type); diff --git a/sdk/storage_blobs/src/blob/operations/release_lease.rs b/sdk/storage_blobs/src/blob/operations/release_lease.rs index 8658e50398..02bee87540 100644 --- a/sdk/storage_blobs/src/blob/operations/release_lease.rs +++ b/sdk/storage_blobs/src/blob/operations/release_lease.rs @@ -34,9 +34,11 @@ impl ReleaseLeaseBuilder { url.query_pairs_mut().append_pair("comp", "lease"); self.timeout.append_to_url_query(&mut url); - let mut request = - self.blob_lease_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + let mut request = self.blob_lease_client.prepare_request( + url.as_str(), + azure_core::Method::PUT, + None, + )?; request.insert_header(LEASE_ACTION, "release"); request.add_mandatory_header(self.blob_lease_client.lease_id()); diff --git a/sdk/storage_blobs/src/blob/operations/renew_lease.rs b/sdk/storage_blobs/src/blob/operations/renew_lease.rs index 509547c013..87533d0d8d 100644 --- a/sdk/storage_blobs/src/blob/operations/renew_lease.rs +++ b/sdk/storage_blobs/src/blob/operations/renew_lease.rs @@ -34,9 +34,11 @@ impl RenewLeaseBuilder { url.query_pairs_mut().append_pair("comp", "lease"); self.timeout.append_to_url_query(&mut url); - let mut request = - self.blob_lease_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + let mut request = self.blob_lease_client.prepare_request( + url.as_str(), + azure_core::Method::PUT, + None, + )?; request.insert_header(LEASE_ACTION, "renew"); request.add_mandatory_header(self.blob_lease_client.lease_id()); diff --git a/sdk/storage_blobs/src/blob/operations/set_blob_tier.rs b/sdk/storage_blobs/src/blob/operations/set_blob_tier.rs index 4415d3a876..24d268070e 100644 --- a/sdk/storage_blobs/src/blob/operations/set_blob_tier.rs +++ b/sdk/storage_blobs/src/blob/operations/set_blob_tier.rs @@ -42,7 +42,7 @@ impl SetBlobTierBuilder { let mut request = self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + .prepare_request(url.as_str(), azure_core::Method::PUT, None)?; request.add_mandatory_header(&self.access_tier); request.add_optional_header(&self.rehydrate_priority); diff --git a/sdk/storage_blobs/src/blob/operations/set_metadata.rs b/sdk/storage_blobs/src/blob/operations/set_metadata.rs index 9513ca4e94..9b43cd1485 100644 --- a/sdk/storage_blobs/src/blob/operations/set_metadata.rs +++ b/sdk/storage_blobs/src/blob/operations/set_metadata.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use azure_core::{headers::*, prelude::*, RequestId}; +use azure_core::{headers::*, prelude::*, Method, RequestId}; use chrono::{DateTime, Utc}; use std::convert::{TryFrom, TryInto}; @@ -37,9 +37,9 @@ impl SetMetadataBuilder { url.query_pairs_mut().append_pair("comp", "metadata"); self.timeout.append_to_url_query(&mut url); - let mut request = - self.blob_client - .prepare_request(url.as_str(), http::Method::PUT, None)?; + let mut request = self + .blob_client + .prepare_request(url.as_str(), Method::PUT, None)?; request.add_optional_header(&self.lease_id); if let Some(metadata) = &self.metadata { for m in metadata.iter() { diff --git a/sdk/storage_blobs/src/blob/operations/update_page.rs b/sdk/storage_blobs/src/blob/operations/update_page.rs index f8f4b7bd15..916099849d 100644 --- a/sdk/storage_blobs/src/blob/operations/update_page.rs +++ b/sdk/storage_blobs/src/blob/operations/update_page.rs @@ -57,7 +57,7 @@ impl UpdatePageBuilder { let mut request = self.blob_client.prepare_request( url.as_str(), - http::Method::PUT, + azure_core::Method::PUT, Some(self.content.clone()), )?; request.insert_header(PAGE_WRITE, "update"); diff --git a/sdk/storage_blobs/src/clients/blob_client.rs b/sdk/storage_blobs/src/clients/blob_client.rs index 9de526b39f..93f2438c2a 100644 --- a/sdk/storage_blobs/src/clients/blob_client.rs +++ b/sdk/storage_blobs/src/clients/blob_client.rs @@ -1,4 +1,5 @@ use crate::{blob::operations::*, prelude::*, BA512Range}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind, ResultExt}, prelude::*, @@ -14,7 +15,6 @@ use azure_storage::core::{ }; use bytes::Bytes; use futures::StreamExt; -use http::method::Method; use std::sync::Arc; use url::Url; diff --git a/sdk/storage_blobs/src/clients/blob_lease_client.rs b/sdk/storage_blobs/src/clients/blob_lease_client.rs index 4c41d9cb99..948aa5a65a 100644 --- a/sdk/storage_blobs/src/clients/blob_lease_client.rs +++ b/sdk/storage_blobs/src/clients/blob_lease_client.rs @@ -1,8 +1,7 @@ use crate::{blob::operations::*, prelude::*}; -use azure_core::{prelude::*, Context, Request, Response}; +use azure_core::{prelude::*, Context, Method, Request, Response}; use azure_storage::core::prelude::*; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsBlobLeaseClient { diff --git a/sdk/storage_blobs/src/clients/container_client.rs b/sdk/storage_blobs/src/clients/container_client.rs index 838aa64dec..2afd9df90e 100644 --- a/sdk/storage_blobs/src/clients/container_client.rs +++ b/sdk/storage_blobs/src/clients/container_client.rs @@ -1,4 +1,5 @@ use crate::{container::operations::*, prelude::PublicAccess}; +use azure_core::Method; use azure_core::{ error::{Error, ErrorKind, ResultExt}, prelude::*, @@ -14,7 +15,6 @@ use azure_storage::{ }, }; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsContainerClient> { diff --git a/sdk/storage_blobs/src/clients/container_lease_client.rs b/sdk/storage_blobs/src/clients/container_lease_client.rs index 65eec00ebc..891808211f 100644 --- a/sdk/storage_blobs/src/clients/container_lease_client.rs +++ b/sdk/storage_blobs/src/clients/container_lease_client.rs @@ -1,8 +1,7 @@ use crate::{container::operations::*, prelude::*}; -use azure_core::{prelude::*, Context, Request, Response}; +use azure_core::{prelude::*, Context, Method, Request, Response}; use azure_storage::core::prelude::*; use bytes::Bytes; -use http::method::Method; use std::sync::Arc; pub trait AsContainerLeaseClient { diff --git a/sdk/storage_blobs/src/container/operations/acquire_lease.rs b/sdk/storage_blobs/src/container/operations/acquire_lease.rs index fd42deb7a8..a6433537ee 100644 --- a/sdk/storage_blobs/src/container/operations/acquire_lease.rs +++ b/sdk/storage_blobs/src/container/operations/acquire_lease.rs @@ -1,7 +1,7 @@ use crate::prelude::*; +use azure_core::Method; use azure_core::{headers::*, prelude::*, RequestId}; use chrono::{DateTime, Utc}; -use http::method::Method; #[derive(Debug, Clone)] pub struct AcquireLeaseBuilder { diff --git a/sdk/storage_blobs/src/container/operations/break_lease.rs b/sdk/storage_blobs/src/container/operations/break_lease.rs index 24b175a783..45e1b34854 100644 --- a/sdk/storage_blobs/src/container/operations/break_lease.rs +++ b/sdk/storage_blobs/src/container/operations/break_lease.rs @@ -1,11 +1,11 @@ use crate::prelude::*; +use azure_core::Method; use azure_core::{ headers::{LEASE_ACTION, *}, prelude::*, RequestId, }; use chrono::{DateTime, Utc}; -use http::method::Method; #[derive(Debug, Clone)] pub struct BreakLeaseBuilder { diff --git a/sdk/storage_blobs/src/container/operations/create.rs b/sdk/storage_blobs/src/container/operations/create.rs index 233df33929..1af8502414 100644 --- a/sdk/storage_blobs/src/container/operations/create.rs +++ b/sdk/storage_blobs/src/container/operations/create.rs @@ -1,6 +1,6 @@ use crate::{container::PublicAccess, prelude::*}; +use azure_core::Method; use azure_core::{headers::AsHeaders, prelude::*}; -use http::method::Method; #[derive(Debug, Clone)] pub struct CreateBuilder { diff --git a/sdk/storage_blobs/src/container/operations/delete.rs b/sdk/storage_blobs/src/container/operations/delete.rs index f26564517b..5d1d085ff1 100644 --- a/sdk/storage_blobs/src/container/operations/delete.rs +++ b/sdk/storage_blobs/src/container/operations/delete.rs @@ -1,6 +1,6 @@ use crate::prelude::*; use azure_core::prelude::*; -use http::method::Method; +use azure_core::Method; #[derive(Debug, Clone)] pub struct DeleteBuilder { diff --git a/sdk/storage_blobs/src/container/operations/get_acl.rs b/sdk/storage_blobs/src/container/operations/get_acl.rs index d9f48bc95b..6c0e03707b 100644 --- a/sdk/storage_blobs/src/container/operations/get_acl.rs +++ b/sdk/storage_blobs/src/container/operations/get_acl.rs @@ -2,6 +2,7 @@ use crate::{ container::{public_access_from_header, PublicAccess}, prelude::*, }; +use azure_core::Method; use azure_core::{ collect_pinned_stream, error::{Error, ErrorKind, ResultExt}, @@ -12,7 +13,6 @@ use azure_core::{ use azure_storage::core::StoredAccessPolicyList; use bytes::Bytes; use chrono::{DateTime, FixedOffset}; -use http::Method; use std::convert::TryFrom; use uuid::Uuid; diff --git a/sdk/storage_blobs/src/container/operations/get_properties.rs b/sdk/storage_blobs/src/container/operations/get_properties.rs index f6541ee22a..bfcf18e47e 100644 --- a/sdk/storage_blobs/src/container/operations/get_properties.rs +++ b/sdk/storage_blobs/src/container/operations/get_properties.rs @@ -1,4 +1,5 @@ use crate::{container::Container, prelude::*}; +use azure_core::Method; use azure_core::{ error::{ErrorKind, ResultExt}, headers::{self, Headers}, @@ -6,7 +7,6 @@ use azure_core::{ RequestId, }; use chrono::{DateTime, FixedOffset}; -use http::method::Method; use std::convert::{TryFrom, TryInto}; use uuid::Uuid; diff --git a/sdk/storage_blobs/src/container/operations/list_blobs.rs b/sdk/storage_blobs/src/container/operations/list_blobs.rs index ebeddad5ff..2779616aef 100644 --- a/sdk/storage_blobs/src/container/operations/list_blobs.rs +++ b/sdk/storage_blobs/src/container/operations/list_blobs.rs @@ -1,4 +1,5 @@ use crate::{blob::Blob, prelude::*}; +use azure_core::Method; use azure_core::{ collect_pinned_stream, error::{Error, ErrorKind, ResultExt}, @@ -8,7 +9,6 @@ use azure_core::{ }; use azure_storage::xml::read_xml; use chrono::{DateTime, Utc}; -use http::method::Method; #[derive(Debug, Clone)] pub struct ListBlobsBuilder { diff --git a/sdk/storage_blobs/src/container/operations/list_containers.rs b/sdk/storage_blobs/src/container/operations/list_containers.rs index e2ffa92cee..6578c4b55c 100644 --- a/sdk/storage_blobs/src/container/operations/list_containers.rs +++ b/sdk/storage_blobs/src/container/operations/list_containers.rs @@ -3,10 +3,9 @@ use crate::container::Container; use azure_core::{ error::{Error, ErrorKind, ResultExt}, prelude::*, - Pageable, Response, + Method, Pageable, Response, }; use azure_storage::parsing_xml::{cast_optional, traverse}; -use http::method::Method; use xml::Element; #[derive(Debug, Clone)] diff --git a/sdk/storage_blobs/src/container/operations/release_lease.rs b/sdk/storage_blobs/src/container/operations/release_lease.rs index 2c5a798c3c..b705c77d90 100644 --- a/sdk/storage_blobs/src/container/operations/release_lease.rs +++ b/sdk/storage_blobs/src/container/operations/release_lease.rs @@ -1,11 +1,11 @@ use crate::prelude::*; +use azure_core::Method; use azure_core::{ headers::{LEASE_ACTION, *}, prelude::*, RequestId, }; use chrono::{DateTime, Utc}; -use http::method::Method; #[derive(Debug, Clone)] pub struct ReleaseLeaseBuilder { diff --git a/sdk/storage_blobs/src/container/operations/renew_lease.rs b/sdk/storage_blobs/src/container/operations/renew_lease.rs index 626060d986..43284d6db5 100644 --- a/sdk/storage_blobs/src/container/operations/renew_lease.rs +++ b/sdk/storage_blobs/src/container/operations/renew_lease.rs @@ -1,6 +1,6 @@ use crate::{container::operations::AcquireLeaseResponse, prelude::*}; +use azure_core::Method; use azure_core::{headers::LEASE_ACTION, prelude::*}; -use http::method::Method; pub type RenewLeaseResponse = AcquireLeaseResponse; diff --git a/sdk/storage_blobs/src/container/operations/set_acl.rs b/sdk/storage_blobs/src/container/operations/set_acl.rs index ad51b6e0f8..2a98a7afc1 100644 --- a/sdk/storage_blobs/src/container/operations/set_acl.rs +++ b/sdk/storage_blobs/src/container/operations/set_acl.rs @@ -1,8 +1,8 @@ use crate::{container::public_access_from_header, prelude::*}; +use azure_core::Method; use azure_core::{headers::AsHeaders, prelude::*}; use azure_storage::core::StoredAccessPolicyList; use bytes::Bytes; -use http::method::Method; #[derive(Debug, Clone)] pub struct SetACLBuilder { diff --git a/sdk/storage_datalake/Cargo.toml b/sdk/storage_datalake/Cargo.toml index c689676d40..3e37629ffb 100644 --- a/sdk/storage_datalake/Cargo.toml +++ b/sdk/storage_datalake/Cargo.toml @@ -20,7 +20,6 @@ base64 = "0.13" bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } futures = "0.3" -http = "0.2" log = "0.4" serde = { version = "1.0" } serde_derive = "1.0" diff --git a/sdk/storage_datalake/src/authorization_policies/shared_key.rs b/sdk/storage_datalake/src/authorization_policies/shared_key.rs index 4093572eda..4e11a8e347 100644 --- a/sdk/storage_datalake/src/authorization_policies/shared_key.rs +++ b/sdk/storage_datalake/src/authorization_policies/shared_key.rs @@ -1,7 +1,7 @@ use azure_core::headers::{self, HeaderName, HeaderValue, Headers}; +use azure_core::Method; use azure_core::{Context, Policy, PolicyResult, Request}; use azure_storage::{core::storage_shared_key_credential::StorageSharedKeyCredential, hmac::sign}; -use http::Method; use std::sync::Arc; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/sdk/storage_datalake/src/clients/data_lake_client.rs b/sdk/storage_datalake/src/clients/data_lake_client.rs index 020cb48d50..a44afcab36 100644 --- a/sdk/storage_datalake/src/clients/data_lake_client.rs +++ b/sdk/storage_datalake/src/clients/data_lake_client.rs @@ -113,7 +113,7 @@ impl DataLakeClient { // pub(crate) fn prepare_request( // &self, // url: Url, - // http_method: http::Method, + // http_method: azure_core::Method, // ) -> azure_core::Request { // Request::new() // Builder::new() diff --git a/sdk/storage_datalake/src/clients/file_system_client.rs b/sdk/storage_datalake/src/clients/file_system_client.rs index 0cb707010f..c095755be3 100644 --- a/sdk/storage_datalake/src/clients/file_system_client.rs +++ b/sdk/storage_datalake/src/clients/file_system_client.rs @@ -91,7 +91,7 @@ impl FileSystemClient { // pub(crate) fn prepare_request( // &self, // uri: &str, - // http_method: http::Method, + // http_method: azure_core::Method, // ) -> azure_core::Request { // self.data_lake_client.prepare_request(uri, http_method) // } diff --git a/sdk/storage_datalake/src/operations/file_system_create.rs b/sdk/storage_datalake/src/operations/file_system_create.rs index 0f2bc78ba3..0bf51ae9cf 100644 --- a/sdk/storage_datalake/src/operations/file_system_create.rs +++ b/sdk/storage_datalake/src/operations/file_system_create.rs @@ -48,7 +48,7 @@ impl CreateFileSystemBuilder { url.query_pairs_mut().append_pair("resource", "filesystem"); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::PUT); + let mut request = Request::new(url, azure_core::Method::PUT); request.insert_headers(&this.client_request_id); request.insert_headers(&this.properties); diff --git a/sdk/storage_datalake/src/operations/file_system_delete.rs b/sdk/storage_datalake/src/operations/file_system_delete.rs index 35792421cc..b3b98c170c 100644 --- a/sdk/storage_datalake/src/operations/file_system_delete.rs +++ b/sdk/storage_datalake/src/operations/file_system_delete.rs @@ -41,7 +41,7 @@ impl DeleteFileSystemBuilder { self.timeout.append_to_url_query(&mut url); url.query_pairs_mut().append_pair("resource", "filesystem"); - let mut request = Request::new(url, http::Method::DELETE); + let mut request = Request::new(url, azure_core::Method::DELETE); request.insert_headers(&this.client_request_id); request.insert_headers(&this.if_modified_since_condition); diff --git a/sdk/storage_datalake/src/operations/file_system_get_properties.rs b/sdk/storage_datalake/src/operations/file_system_get_properties.rs index a32cb81946..ac47639b88 100644 --- a/sdk/storage_datalake/src/operations/file_system_get_properties.rs +++ b/sdk/storage_datalake/src/operations/file_system_get_properties.rs @@ -45,7 +45,7 @@ impl GetFileSystemPropertiesBuilder { self.timeout.append_to_url_query(&mut url); url.query_pairs_mut().append_pair("resource", "filesystem"); - let mut request = Request::new(url, http::Method::HEAD); + let mut request = Request::new(url, azure_core::Method::HEAD); request.insert_headers(&this.client_request_id); request.insert_headers(&ContentLength::new(0)); diff --git a/sdk/storage_datalake/src/operations/file_system_set_properties.rs b/sdk/storage_datalake/src/operations/file_system_set_properties.rs index 5d14c87a0c..c313df0a59 100644 --- a/sdk/storage_datalake/src/operations/file_system_set_properties.rs +++ b/sdk/storage_datalake/src/operations/file_system_set_properties.rs @@ -49,7 +49,7 @@ impl SetFileSystemPropertiesBuilder { self.timeout.append_to_url_query(&mut url); url.query_pairs_mut().append_pair("resource", "filesystem"); - let mut request = Request::new(url, http::Method::PATCH); + let mut request = Request::new(url, azure_core::Method::PATCH); request.insert_headers(&this.client_request_id); request.insert_headers(&this.if_modified_since_condition); diff --git a/sdk/storage_datalake/src/operations/file_systems_list.rs b/sdk/storage_datalake/src/operations/file_systems_list.rs index e28784ca5d..90d35d29f8 100644 --- a/sdk/storage_datalake/src/operations/file_systems_list.rs +++ b/sdk/storage_datalake/src/operations/file_systems_list.rs @@ -65,7 +65,7 @@ impl ListFileSystemsBuilder { this.next_marker.append_to_url_query(&mut url); }; - let mut request = Request::new(url, http::Method::GET); + let mut request = Request::new(url, azure_core::Method::GET); request.insert_headers(&this.client_request_id); diff --git a/sdk/storage_datalake/src/operations/path_delete.rs b/sdk/storage_datalake/src/operations/path_delete.rs index e4b7217257..77a346918f 100644 --- a/sdk/storage_datalake/src/operations/path_delete.rs +++ b/sdk/storage_datalake/src/operations/path_delete.rs @@ -60,7 +60,7 @@ impl DeletePathBuilder { self.recursive.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::DELETE); + let mut request = Request::new(url, azure_core::Method::DELETE); request.insert_headers(&this.client_request_id); request.insert_headers(&this.if_match_condition); diff --git a/sdk/storage_datalake/src/operations/path_get.rs b/sdk/storage_datalake/src/operations/path_get.rs index 9891e15c32..483f33d6cf 100644 --- a/sdk/storage_datalake/src/operations/path_get.rs +++ b/sdk/storage_datalake/src/operations/path_get.rs @@ -59,7 +59,7 @@ impl GetFileBuilder { self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::GET); + let mut request = Request::new(url, azure_core::Method::GET); let requested_range = self.range.unwrap_or_else(|| Range::new(0, u64::MAX)); request.insert_headers(&requested_range); diff --git a/sdk/storage_datalake/src/operations/path_head.rs b/sdk/storage_datalake/src/operations/path_head.rs index 739ad9c273..4509f50acb 100644 --- a/sdk/storage_datalake/src/operations/path_head.rs +++ b/sdk/storage_datalake/src/operations/path_head.rs @@ -66,7 +66,7 @@ impl HeadPathBuilder { self.upn.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::HEAD); + let mut request = Request::new(url, azure_core::Method::HEAD); request.insert_headers(&this.client_request_id); request.insert_headers(&this.if_match_condition); diff --git a/sdk/storage_datalake/src/operations/path_list.rs b/sdk/storage_datalake/src/operations/path_list.rs index 3376f8b8a5..1d8de22d56 100644 --- a/sdk/storage_datalake/src/operations/path_list.rs +++ b/sdk/storage_datalake/src/operations/path_list.rs @@ -72,7 +72,7 @@ impl ListPathsBuilder { this.continuation.append_to_url_query(&mut url); }; - let mut request = Request::new(url, http::Method::GET); + let mut request = Request::new(url, azure_core::Method::GET); request.insert_headers(&this.client_request_id); diff --git a/sdk/storage_datalake/src/operations/path_patch.rs b/sdk/storage_datalake/src/operations/path_patch.rs index 0408ba3649..fb86bb6781 100644 --- a/sdk/storage_datalake/src/operations/path_patch.rs +++ b/sdk/storage_datalake/src/operations/path_patch.rs @@ -84,7 +84,7 @@ impl PatchPathBuilder { self.retain_uncommitted_data.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::PATCH); + let mut request = Request::new(url, azure_core::Method::PATCH); request.insert_headers(&this.client_request_id); request.insert_headers(&this.properties); diff --git a/sdk/storage_datalake/src/operations/path_put.rs b/sdk/storage_datalake/src/operations/path_put.rs index 22bfd205e3..22bfd89464 100644 --- a/sdk/storage_datalake/src/operations/path_put.rs +++ b/sdk/storage_datalake/src/operations/path_put.rs @@ -72,7 +72,7 @@ impl PutPathBuilder { self.mode.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::PUT); + let mut request = Request::new(url, azure_core::Method::PUT); request.insert_headers(&this.client_request_id); request.insert_headers(&this.properties); @@ -149,7 +149,7 @@ impl RenamePathBuilder { self.mode.append_to_url_query(&mut url); self.timeout.append_to_url_query(&mut url); - let mut request = Request::new(url, http::Method::PUT); + let mut request = Request::new(url, azure_core::Method::PUT); request.insert_headers(&this.client_request_id); request.insert_headers(&this.properties); diff --git a/sdk/storage_queues/Cargo.toml b/sdk/storage_queues/Cargo.toml index fe25dc7a26..eba69f581f 100644 --- a/sdk/storage_queues/Cargo.toml +++ b/sdk/storage_queues/Cargo.toml @@ -18,7 +18,6 @@ azure_storage = { path = "../storage", version = "0.4", default-features=false, bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } futures = "0.3" -http = "0.2" log = "0.4" serde = { version = "1.0" } serde_derive = "1.0" diff --git a/sdk/storage_queues/src/requests/clear_messages_builder.rs b/sdk/storage_queues/src/requests/clear_messages_builder.rs index 3ab52207ff..c7d1b2f43a 100644 --- a/sdk/storage_queues/src/requests/clear_messages_builder.rs +++ b/sdk/storage_queues/src/requests/clear_messages_builder.rs @@ -32,7 +32,7 @@ impl<'a> ClearMessagesBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::DELETE, + azure_core::Method::DELETE, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/create_queue_builder.rs b/sdk/storage_queues/src/requests/create_queue_builder.rs index 5c6c2db99f..e3f7715e12 100644 --- a/sdk/storage_queues/src/requests/create_queue_builder.rs +++ b/sdk/storage_queues/src/requests/create_queue_builder.rs @@ -34,7 +34,7 @@ impl<'a> CreateQueueBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::PUT, + azure_core::Method::PUT, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/delete_message_builder.rs b/sdk/storage_queues/src/requests/delete_message_builder.rs index f8033ee9f2..ae3aa518c0 100644 --- a/sdk/storage_queues/src/requests/delete_message_builder.rs +++ b/sdk/storage_queues/src/requests/delete_message_builder.rs @@ -32,7 +32,7 @@ impl<'a> DeleteMessageBuilder<'a> { let mut request = self.pop_receipt_client.storage_client().prepare_request( url.as_str(), - http::method::Method::DELETE, + azure_core::Method::DELETE, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/delete_queue_builder.rs b/sdk/storage_queues/src/requests/delete_queue_builder.rs index 8fef4845e8..69b6f1b2b7 100644 --- a/sdk/storage_queues/src/requests/delete_queue_builder.rs +++ b/sdk/storage_queues/src/requests/delete_queue_builder.rs @@ -32,7 +32,7 @@ impl<'a> DeleteQueueBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::DELETE, + azure_core::Method::DELETE, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/get_messages_builder.rs b/sdk/storage_queues/src/requests/get_messages_builder.rs index 80a395e29e..2f10181d94 100644 --- a/sdk/storage_queues/src/requests/get_messages_builder.rs +++ b/sdk/storage_queues/src/requests/get_messages_builder.rs @@ -41,7 +41,7 @@ impl<'a> GetMessagesBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::GET, + azure_core::Method::GET, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/get_queue_acl_builder.rs b/sdk/storage_queues/src/requests/get_queue_acl_builder.rs index bbfa8b43a0..034dac6022 100644 --- a/sdk/storage_queues/src/requests/get_queue_acl_builder.rs +++ b/sdk/storage_queues/src/requests/get_queue_acl_builder.rs @@ -1,7 +1,7 @@ use crate::clients::QueueClient; use crate::responses::*; use azure_core::prelude::*; -use http::method::Method; +use azure_core::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/storage_queues/src/requests/get_queue_metadata_builder.rs b/sdk/storage_queues/src/requests/get_queue_metadata_builder.rs index d401adadd1..f6c9f5064e 100644 --- a/sdk/storage_queues/src/requests/get_queue_metadata_builder.rs +++ b/sdk/storage_queues/src/requests/get_queue_metadata_builder.rs @@ -1,7 +1,7 @@ use crate::clients::QueueClient; use crate::responses::*; use azure_core::prelude::*; -use http::method::Method; +use azure_core::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/storage_queues/src/requests/get_queue_service_properties_builder.rs b/sdk/storage_queues/src/requests/get_queue_service_properties_builder.rs index 068578858f..5c2708e0df 100644 --- a/sdk/storage_queues/src/requests/get_queue_service_properties_builder.rs +++ b/sdk/storage_queues/src/requests/get_queue_service_properties_builder.rs @@ -1,7 +1,7 @@ use crate::responses::*; use azure_core::prelude::*; +use azure_core::Method; use azure_storage::core::prelude::*; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/storage_queues/src/requests/get_queue_service_stats_builder.rs b/sdk/storage_queues/src/requests/get_queue_service_stats_builder.rs index 468ce4b02d..6833d3696f 100644 --- a/sdk/storage_queues/src/requests/get_queue_service_stats_builder.rs +++ b/sdk/storage_queues/src/requests/get_queue_service_stats_builder.rs @@ -1,7 +1,7 @@ use crate::responses::*; use azure_core::prelude::*; +use azure_core::Method; use azure_storage::core::prelude::*; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/storage_queues/src/requests/list_queues_builder.rs b/sdk/storage_queues/src/requests/list_queues_builder.rs index cb39c33750..1cfe94a781 100644 --- a/sdk/storage_queues/src/requests/list_queues_builder.rs +++ b/sdk/storage_queues/src/requests/list_queues_builder.rs @@ -1,8 +1,8 @@ use crate::responses::*; use azure_core::prelude::*; +use azure_core::Method; use azure_storage::core::prelude::*; use futures::stream::{unfold, Stream}; -use http::method::Method; use std::convert::TryInto; #[derive(Debug, Clone)] diff --git a/sdk/storage_queues/src/requests/peek_messages_builder.rs b/sdk/storage_queues/src/requests/peek_messages_builder.rs index 52bdbdd929..617cd6a82d 100644 --- a/sdk/storage_queues/src/requests/peek_messages_builder.rs +++ b/sdk/storage_queues/src/requests/peek_messages_builder.rs @@ -38,7 +38,7 @@ impl<'a> PeekMessagesBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::GET, + azure_core::Method::GET, None, )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/put_message_builder.rs b/sdk/storage_queues/src/requests/put_message_builder.rs index 8486b55cf8..f9221133e9 100644 --- a/sdk/storage_queues/src/requests/put_message_builder.rs +++ b/sdk/storage_queues/src/requests/put_message_builder.rs @@ -48,7 +48,7 @@ impl<'a> PutMessageBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::POST, + azure_core::Method::POST, Some(message.into()), )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/set_queue_acl_builder.rs b/sdk/storage_queues/src/requests/set_queue_acl_builder.rs index 3abdde3272..7a1fd90de3 100644 --- a/sdk/storage_queues/src/requests/set_queue_acl_builder.rs +++ b/sdk/storage_queues/src/requests/set_queue_acl_builder.rs @@ -56,7 +56,7 @@ impl<'a> SetQueueACLBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::PUT, + azure_core::Method::PUT, Some(xml_body.into()), )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/set_queue_metadata_builder.rs b/sdk/storage_queues/src/requests/set_queue_metadata_builder.rs index 8757cf5404..1cba996f8b 100644 --- a/sdk/storage_queues/src/requests/set_queue_metadata_builder.rs +++ b/sdk/storage_queues/src/requests/set_queue_metadata_builder.rs @@ -43,7 +43,7 @@ impl<'a> SetQueueMetadataBuilder<'a> { let mut request = self.queue_client.storage_client().prepare_request( url.as_str(), - http::method::Method::PUT, + azure_core::Method::PUT, None, )?; for m in metadata.iter() { diff --git a/sdk/storage_queues/src/requests/set_queue_service_properties_builder.rs b/sdk/storage_queues/src/requests/set_queue_service_properties_builder.rs index 4c7f079efc..c928226179 100644 --- a/sdk/storage_queues/src/requests/set_queue_service_properties_builder.rs +++ b/sdk/storage_queues/src/requests/set_queue_service_properties_builder.rs @@ -48,7 +48,7 @@ impl<'a> SetQueueServicePropertiesBuilder<'a> { let mut request = self.storage_client.prepare_request( url.as_str(), - http::method::Method::PUT, + azure_core::Method::PUT, Some(xml_body.into()), )?; request.add_optional_header(&self.client_request_id); diff --git a/sdk/storage_queues/src/requests/update_message_builder.rs b/sdk/storage_queues/src/requests/update_message_builder.rs index 4fc300a585..8202ffbcd2 100644 --- a/sdk/storage_queues/src/requests/update_message_builder.rs +++ b/sdk/storage_queues/src/requests/update_message_builder.rs @@ -49,7 +49,7 @@ impl<'a> UpdateMessageBuilder<'a> { let mut request = self.pop_receipt_client.storage_client().prepare_request( url.as_str(), - http::method::Method::PUT, + azure_core::Method::PUT, Some(message.into()), )?; request.add_optional_header(&self.client_request_id);