Skip to content

Commit

Permalink
Optional middleware (#95)
Browse files Browse the repository at this point in the history
* Move middleware behind flag

* Make middleware default

* Bump version

* Update version to 0.9
  • Loading branch information
augustuswm authored Dec 16, 2024
1 parent 011d903 commit 2345aa6
Show file tree
Hide file tree
Showing 202 changed files with 25,771 additions and 27,091 deletions.
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := bash

VERSION = 0.8.0-rc.2
VERSION = 0.9.0

DOCUSIGN_SPEC_DIR = $(CURDIR)/specs/docusign
DOCUSIGN_SPEC = $(DOCUSIGN_SPEC_DIR)/docusign.yaml
Expand Down
18 changes: 12 additions & 6 deletions docusign/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
[package]
name = "docusign"
description = "A fully generated & opinionated API client for the DocuSign API."
version = "0.8.0-rc.2"
version = "0.9.0"
documentation = "https://docs.rs/docusign/"
repository = "https://github.com/oxidecomputer/third-party-api-clients/tree/main/docusign"
readme = "README.md"
edition = "2021"
license = "MIT"

[features]
default = ["rustls-tls"]
default = ["middleware", "rustls-tls"]
# enable etag-based http_cache functionality
httpcache = ["dirs"]
native-tls = ["reqwest/default-tls", "openssl"]
rustls-tls = ["reqwest/rustls-tls", "ring", "pem"]
middleware = [
"reqwest-conditional-middleware",
"reqwest-middleware",
"reqwest-retry",
"reqwest-tracing",
]

[dependencies]
async-recursion = "^1.0"
Expand All @@ -28,10 +34,10 @@ parse_link_header = "0.3.3"
pem = { version = "1.1.0", default-features = false, optional = true }
percent-encoding = "2.2"
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart"] }
reqwest-conditional-middleware = "0.4"
reqwest-middleware = { version = "0.4", features = ["multipart"] }
reqwest-retry = "0.7"
reqwest-tracing = "0.5.4"
reqwest-conditional-middleware = { version = "0.4", optional = true }
reqwest-middleware = { version = "0.4", features = ["multipart"], optional = true }
reqwest-retry = { version = "0.7", optional = true }
reqwest-tracing = { version = "0.5.4", optional = true }
ring = { version = "0.16", default-features = false, optional = true }
schemars = { version = "0.8", features = ["bytes", "chrono", "url", "uuid1"] }
serde = { version = "1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion docusign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To install the library, add the following to your `Cargo.toml` file.

```toml
[dependencies]
docusign = "0.8.0-rc.2"
docusign = "0.9.0"
```

## Basic example
Expand Down
4 changes: 1 addition & 3 deletions docusign/src/account_password_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ impl AccountPasswordRules {
pub async fn password_rules_get(
&self,
) -> ClientResult<crate::Response<crate::types::UserPasswordRules>> {
let url = self
.client
.url("/v2.1/current_user/password_rules", None);
let url = self.client.url("/v2.1/current_user/password_rules", None);
self.client
.get(
&url,
Expand Down
4 changes: 1 addition & 3 deletions docusign/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ impl Accounts {
pub async fn get_provisioning(
&self,
) -> ClientResult<crate::Response<crate::types::ProvisioningInformation>> {
let url = self
.client
.url("/v2.1/accounts/provisioning", None);
let url = self.client.url("/v2.1/accounts/provisioning", None);
self.client
.get(
&url,
Expand Down
8 changes: 2 additions & 6 deletions docusign/src/appliance_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,7 @@ impl ApplianceInfo {
*
*/
pub async fn envelope_post_error(&self) -> ClientResult<crate::Response<()>> {
let url = self
.client
.url("/v2.1/display_appliance_info/error", None);
let url = self.client.url("/v2.1/display_appliance_info/error", None);
self.client
.post(
&url,
Expand All @@ -891,9 +889,7 @@ impl ApplianceInfo {
pub async fn envelope_post_redeem(
&self,
) -> ClientResult<crate::Response<crate::types::ApplianceInfo>> {
let url = self
.client
.url("/v2.1/display_appliance_info/redeem", None);
let url = self.client.url("/v2.1/display_appliance_info/redeem", None);
self.client
.post(
&url,
Expand Down
29 changes: 19 additions & 10 deletions docusign/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//!
//! ```toml
//! [dependencies]
//! docusign = "0.8.0-rc.2"
//! docusign = "0.9.0"
//! ```
//!
//! ## Basic example
Expand Down Expand Up @@ -2227,6 +2227,7 @@ pub enum ClientError {
/// Errors returned by reqwest::header
#[error(transparent)]
InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
#[cfg(feature = "middleware")]
/// Errors returned by reqwest middleware
#[error(transparent)]
ReqwestMiddleWareError(#[from] reqwest_middleware::Error),
Expand Down Expand Up @@ -2297,7 +2298,10 @@ pub struct Client {
redirect_uri: String,

auto_refresh: bool,
#[cfg(feature = "middleware")]
client: reqwest_middleware::ClientWithMiddleware,
#[cfg(not(feature = "middleware"))]
client: reqwest::Client,
}

use schemars::JsonSchema;
Expand Down Expand Up @@ -2378,15 +2382,20 @@ impl Client {
.build();
match client {
Ok(c) => {
let client = reqwest_middleware::ClientBuilder::new(c)
// Trace HTTP requests. See the tracing crate to make use of these traces.
.with(reqwest_tracing::TracingMiddleware::default())
// Retry failed requests.
.with(reqwest_conditional_middleware::ConditionalMiddleware::new(
reqwest_retry::RetryTransientMiddleware::new_with_policy(retry_policy),
|req: &reqwest::Request| req.try_clone().is_some(),
))
.build();
#[cfg(feature = "middleware")]
let client = {
reqwest_middleware::ClientBuilder::new(c)
// Trace HTTP requests. See the tracing crate to make use of these traces.
.with(reqwest_tracing::TracingMiddleware::default())
// Retry failed requests.
.with(reqwest_conditional_middleware::ConditionalMiddleware::new(
reqwest_retry::RetryTransientMiddleware::new_with_policy(retry_policy),
|req: &reqwest::Request| req.try_clone().is_some(),
))
.build()
};
#[cfg(not(feature = "middleware"))]
let client = c;

let host = RootDefaultServer::default().default_url().to_string();

Expand Down
8 changes: 2 additions & 6 deletions docusign/src/notary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ impl Notary {
&self,
body: &crate::types::NotaryData,
) -> ClientResult<crate::Response<crate::types::NotaryData>> {
let url = self
.client
.url("/v2.1/current_user/notary", None);
let url = self.client.url("/v2.1/current_user/notary", None);
self.client
.put(
&url,
Expand All @@ -83,9 +81,7 @@ impl Notary {
&self,
body: &crate::types::NotaryData,
) -> ClientResult<crate::Response<crate::types::NotaryData>> {
let url = self
.client
.url("/v2.1/current_user/notary", None);
let url = self.client.url("/v2.1/current_user/notary", None);
self.client
.post(
&url,
Expand Down
Loading

0 comments on commit 2345aa6

Please sign in to comment.