summaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/src/client.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-15 00:35:52 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-15 00:35:52 -0700
commit28978964a77e853031874230c2415b1b835e93fc (patch)
tree8080670ee5f60aee8ba058a5babf80eaca7b4ded /rust/fatcat-api/src/client.rs
parent33a4cce0b97832f5f0301b318a0a50073ce6b615 (diff)
downloadfatcat-28978964a77e853031874230c2415b1b835e93fc.tar.gz
fatcat-28978964a77e853031874230c2415b1b835e93fc.zip
fmt and cleanup
Diffstat (limited to 'rust/fatcat-api/src/client.rs')
-rw-r--r--rust/fatcat-api/src/client.rs1315
1 files changed, 815 insertions, 500 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs
index e8546f95..1219e01b 100644
--- a/rust/fatcat-api/src/client.rs
+++ b/rust/fatcat-api/src/client.rs
@@ -1,66 +1,51 @@
#![allow(unused_extern_crates)]
-extern crate hyper_openssl;
extern crate chrono;
+extern crate hyper_openssl;
extern crate url;
-
-
-use hyper;
-use hyper::client::IntoUrl;
-use hyper::mime;
-use hyper::header::{Headers, ContentType};
-use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
-use hyper::Url;
use self::hyper_openssl::openssl;
use self::url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use futures;
use futures::{Future, Stream};
use futures::{future, stream};
+use hyper;
+use hyper::Url;
+use hyper::client::IntoUrl;
+use hyper::header::{ContentType, Headers};
+use hyper::mime;
+use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use std::borrow::Cow;
-use std::io::{Read, Error};
use std::error;
use std::fmt;
+use std::io::{Error, Read};
use std::path::Path;
-use std::sync::Arc;
use std::str;
+use std::sync::Arc;
use mimetypes;
use serde_json;
-
#[allow(unused_imports)]
-use std::collections::{HashMap, BTreeMap};
+use std::collections::{BTreeMap, HashMap};
#[allow(unused_imports)]
use swagger;
-use swagger::{Context, ApiError, XSpanId};
-
-use {Api,
- ContainerIdGetResponse,
- ContainerLookupGetResponse,
- ContainerPostResponse,
- CreatorIdGetResponse,
- CreatorLookupGetResponse,
- CreatorPostResponse,
- EditgroupIdAcceptPostResponse,
- EditgroupIdGetResponse,
- EditgroupPostResponse,
- EditorUsernameChangelogGetResponse,
- EditorUsernameGetResponse,
- FileIdGetResponse,
- FileLookupGetResponse,
- FilePostResponse,
- ReleaseIdGetResponse,
- ReleaseLookupGetResponse,
- ReleasePostResponse,
- WorkIdGetResponse,
- WorkPostResponse
- };
+use swagger::{ApiError, Context, XSpanId};
+
use models;
+use {Api, ContainerIdGetResponse, ContainerLookupGetResponse, ContainerPostResponse,
+ CreatorIdGetResponse, CreatorLookupGetResponse, CreatorPostResponse,
+ EditgroupIdAcceptPostResponse, EditgroupIdGetResponse, EditgroupPostResponse,
+ EditorUsernameChangelogGetResponse, EditorUsernameGetResponse, FileIdGetResponse,
+ FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse,
+ ReleasePostResponse, WorkIdGetResponse, WorkPostResponse};
/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes.
-fn into_base_path<T: IntoUrl>(input: T, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> {
+fn into_base_path<T: IntoUrl>(
+ input: T,
+ correct_scheme: Option<&'static str>,
+) -> Result<String, ClientInitError> {
// First convert to Url, since a base path is a subset of Url.
let url = input.into_url()?;
@@ -93,7 +78,8 @@ impl fmt::Debug for Client {
impl Client {
pub fn try_new_http<T>(base_path: T) -> Result<Client, ClientInitError>
- where T: IntoUrl
+ where
+ T: IntoUrl,
{
Ok(Client {
base_path: into_base_path(base_path, Some("http"))?,
@@ -101,17 +87,17 @@ impl Client {
})
}
- pub fn try_new_https<T, CA>(base_path: T,
- ca_certificate: CA)
- -> Result<Client, ClientInitError>
- where T: IntoUrl,
- CA: AsRef<Path>
+ pub fn try_new_https<T, CA>(base_path: T, ca_certificate: CA) -> Result<Client, ClientInitError>
+ where
+ T: IntoUrl,
+ CA: AsRef<Path>,
{
let ca_certificate = ca_certificate.as_ref().to_owned();
let https_hyper_client = move || {
// SSL implementation
- let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
+ let mut ssl =
+ openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
// Server authentication
ssl.set_ca_file(ca_certificate.clone()).unwrap();
@@ -122,20 +108,22 @@ impl Client {
};
Ok(Client {
- base_path: into_base_path(base_path, Some("https"))?,
- hyper_client: Arc::new(https_hyper_client),
- })
+ base_path: into_base_path(base_path, Some("https"))?,
+ hyper_client: Arc::new(https_hyper_client),
+ })
}
- pub fn try_new_https_mutual<T, CA, K, C>(base_path: T,
- ca_certificate: CA,
- client_key: K,
- client_certificate: C)
- -> Result<Client, ClientInitError>
- where T: IntoUrl,
- CA: AsRef<Path>,
- K: AsRef<Path>,
- C: AsRef<Path>
+ pub fn try_new_https_mutual<T, CA, K, C>(
+ base_path: T,
+ ca_certificate: CA,
+ client_key: K,
+ client_certificate: C,
+ ) -> Result<Client, ClientInitError>
+ where
+ T: IntoUrl,
+ CA: AsRef<Path>,
+ K: AsRef<Path>,
+ C: AsRef<Path>,
{
let ca_certificate = ca_certificate.as_ref().to_owned();
let client_key = client_key.as_ref().to_owned();
@@ -143,14 +131,17 @@ impl Client {
let https_mutual_hyper_client = move || {
// SSL implementation
- let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
+ let mut ssl =
+ openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
// Server authentication
ssl.set_ca_file(ca_certificate.clone()).unwrap();
// Client authentication
- ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM).unwrap();
- ssl.set_certificate_chain_file(client_certificate.clone()).unwrap();
+ ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM)
+ .unwrap();
+ ssl.set_certificate_chain_file(client_certificate.clone())
+ .unwrap();
ssl.check_private_key().unwrap();
let ssl = hyper_openssl::OpensslClient::from(ssl.build());
@@ -159,9 +150,9 @@ impl Client {
};
Ok(Client {
- base_path: into_base_path(base_path, Some("https"))?,
- hyper_client: Arc::new(https_mutual_hyper_client)
- })
+ base_path: into_base_path(base_path, Some("https"))?,
+ hyper_client: Arc::new(https_mutual_hyper_client),
+ })
}
/// Constructor for creating a `Client` by passing in a pre-made `hyper` client.
@@ -173,169 +164,204 @@ impl Client {
/// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer.
/// This is not a recommended way to write new tests. If other reasons are found for using this function, they
/// should be mentioned here.
- pub fn try_new_with_hyper_client<T>(base_path: T,
- hyper_client: Arc<Fn() -> hyper::client::Client + Sync + Send>)
- -> Result<Client, ClientInitError>
- where T: IntoUrl
+ pub fn try_new_with_hyper_client<T>(
+ base_path: T,
+ hyper_client: Arc<Fn() -> hyper::client::Client + Sync + Send>,
+ ) -> Result<Client, ClientInitError>
+ where
+ T: IntoUrl,
{
Ok(Client {
base_path: into_base_path(base_path, None)?,
- hyper_client: hyper_client
+ hyper_client: hyper_client,
})
}
}
impl Api for Client {
-
- fn container_id_get(&self, param_id: String, context: &Context) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn container_id_get(
+ &self,
+ param_id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/container/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ContainerIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ContainerIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ContainerEntity>(&buf)?;
Ok(ContainerIdGetResponse::FetchASingleContainerById(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerIdGetResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn container_lookup_get(&self, param_issn: String, context: &Context) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send> {
-
+ fn container_lookup_get(
+ &self,
+ param_issn: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> {
// Query parameters
- let query_issn = format!("issn={issn}&", issn=param_issn.to_string());
-
+ let query_issn = format!("issn={issn}&", issn = param_issn.to_string());
let url = format!(
"{}/v0/container/lookup?{issn}",
self.base_path,
- issn=utf8_percent_encode(&query_issn, QUERY_ENCODE_SET)
+ issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ContainerLookupGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ContainerLookupGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ContainerEntity>(&buf)?;
Ok(ContainerLookupGetResponse::FindASingleContainerByExternalIdentifer(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerLookupGetResponse::BadRequest(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerLookupGetResponse::NoSuchContainer(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerLookupGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn container_post(&self, param_body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send> {
-
-
- let url = format!(
- "{}/v0/container",
- self.base_path
- );
-
- let body = param_body.map(|ref body| {
+ fn container_post(
+ &self,
+ param_body: Option<models::ContainerEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/container", self.base_path);
- serde_json::to_string(body).expect("impossible to fail to serialize")
- });
+ let body = param_body
+ .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
@@ -346,205 +372,255 @@ impl Api for Client {
};
custom_headers.set(ContentType(mimetypes::requests::CONTAINER_POST.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ContainerPostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ContainerPostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
Ok(ContainerPostResponse::Created(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerPostResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ContainerPostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn creator_id_get(&self, param_id: String, context: &Context) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn creator_id_get(
+ &self,
+ param_id: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/creator/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreatorIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<CreatorIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::CreatorEntity>(&buf)?;
Ok(CreatorIdGetResponse::FetchASingleCreatorById(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorIdGetResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn creator_lookup_get(&self, param_orcid: String, context: &Context) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send> {
-
+ fn creator_lookup_get(
+ &self,
+ param_orcid: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send> {
// Query parameters
- let query_orcid = format!("orcid={orcid}&", orcid=param_orcid.to_string());
-
+ let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string());
let url = format!(
"{}/v0/creator/lookup?{orcid}",
self.base_path,
- orcid=utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET)
+ orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreatorLookupGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<CreatorLookupGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::CreatorEntity>(&buf)?;
Ok(CreatorLookupGetResponse::FindASingleCreatorByExternalIdentifer(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorLookupGetResponse::BadRequest(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorLookupGetResponse::NoSuchCreator(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorLookupGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn creator_post(&self, param_body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send> {
+ fn creator_post(
+ &self,
+ param_body: Option<models::CreatorEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/creator", self.base_path);
-
- let url = format!(
- "{}/v0/creator",
- self.base_path
- );
-
- let body = param_body.map(|ref body| {
-
- serde_json::to_string(body).expect("impossible to fail to serialize")
- });
+ let body = param_body
+ .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
@@ -555,527 +631,670 @@ impl Api for Client {
};
custom_headers.set(ContentType(mimetypes::requests::CREATOR_POST.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreatorPostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<CreatorPostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
Ok(CreatorPostResponse::Created(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorPostResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(CreatorPostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn editgroup_id_accept_post(&self, param_id: i32, context: &Context) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send> {
-
-
+ fn editgroup_id_accept_post(
+ &self,
+ param_id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editgroup/{id}/accept",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<EditgroupIdAcceptPostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<EditgroupIdAcceptPostResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Success>(&buf)?;
- Ok(EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_(body))
- },
+ Ok(EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_(
+ body,
+ ))
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupIdAcceptPostResponse::EditgroupIsInAnUnmergableState(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupIdAcceptPostResponse::NoSuchEditgroup(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupIdAcceptPostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn editgroup_id_get(&self, param_id: i32, context: &Context) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn editgroup_id_get(
+ &self,
+ param_id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editgroup/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<EditgroupIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<EditgroupIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Editgroup>(&buf)?;
Ok(EditgroupIdGetResponse::FetchEditgroupByIdentifier(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupIdGetResponse::NoSuchEditgroup(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn editgroup_post(&self, context: &Context) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send> {
-
-
- let url = format!(
- "{}/v0/editgroup",
- self.base_path
- );
-
+ fn editgroup_post(
+ &self,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/editgroup", self.base_path);
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<EditgroupPostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<EditgroupPostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Editgroup>(&buf)?;
Ok(EditgroupPostResponse::SuccessfullyCreated(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupPostResponse::InvalidRequestParameters(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditgroupPostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn editor_username_changelog_get(&self, param_username: String, context: &Context) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send> {
-
-
+ fn editor_username_changelog_get(
+ &self,
+ param_username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editor/{username}/changelog",
- self.base_path, username=utf8_percent_encode(&param_username.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ username = utf8_percent_encode(&param_username.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<EditorUsernameChangelogGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<EditorUsernameChangelogGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Changelogentry>(&buf)?;
Ok(EditorUsernameChangelogGetResponse::FindChanges_(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditorUsernameChangelogGetResponse::UsernameNotFound(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
- Ok(EditorUsernameChangelogGetResponse::GenericErrorResponse(body))
- },
+ Ok(EditorUsernameChangelogGetResponse::GenericErrorResponse(
+ body,
+ ))
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn editor_username_get(&self, param_username: String, context: &Context) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send> {
-
-
+ fn editor_username_get(
+ &self,
+ param_username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editor/{username}",
- self.base_path, username=utf8_percent_encode(&param_username.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ username = utf8_percent_encode(&param_username.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<EditorUsernameGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<EditorUsernameGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Editor>(&buf)?;
Ok(EditorUsernameGetResponse::FetchGenericInformationAboutAnEditor(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditorUsernameGetResponse::UsernameNotFound(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(EditorUsernameGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn file_id_get(&self, param_id: String, context: &Context) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn file_id_get(
+ &self,
+ param_id: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/file/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<FileIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<FileIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::FileEntity>(&buf)?;
Ok(FileIdGetResponse::FetchASingleFileById(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FileIdGetResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FileIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn file_lookup_get(&self, param_sha1: String, context: &Context) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send> {
-
+ fn file_lookup_get(
+ &self,
+ param_sha1: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send> {
// Query parameters
- let query_sha1 = format!("sha1={sha1}&", sha1=param_sha1.to_string());
-
+ let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string());
let url = format!(
"{}/v0/file/lookup?{sha1}",
self.base_path,
- sha1=utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET)
+ sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<FileLookupGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<FileLookupGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::FileEntity>(&buf)?;
- Ok(FileLookupGetResponse::FindASingleFileByExternalIdentifer(body))
- },
+ Ok(FileLookupGetResponse::FindASingleFileByExternalIdentifer(
+ body,
+ ))
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FileLookupGetResponse::BadRequest(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FileLookupGetResponse::NoSuchFile(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FileLookupGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn file_post(&self, param_body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send> {
+ fn file_post(
+ &self,
+ param_body: Option<models::FileEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/file", self.base_path);
-
- let url = format!(
- "{}/v0/file",
- self.base_path
- );
-
- let body = param_body.map(|ref body| {
-
- serde_json::to_string(body).expect("impossible to fail to serialize")
- });
+ let body = param_body
+ .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
@@ -1086,205 +1305,255 @@ impl Api for Client {
};
custom_headers.set(ContentType(mimetypes::requests::FILE_POST.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<FilePostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<FilePostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
Ok(FilePostResponse::Created(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FilePostResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(FilePostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn release_id_get(&self, param_id: String, context: &Context) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn release_id_get(
+ &self,
+ param_id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/release/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ReleaseIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ReleaseIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ReleaseEntity>(&buf)?;
Ok(ReleaseIdGetResponse::FetchASingleReleaseById(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleaseIdGetResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleaseIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn release_lookup_get(&self, param_doi: String, context: &Context) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send> {
-
+ fn release_lookup_get(
+ &self,
+ param_doi: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send> {
// Query parameters
- let query_doi = format!("doi={doi}&", doi=param_doi.to_string());
-
+ let query_doi = format!("doi={doi}&", doi = param_doi.to_string());
let url = format!(
"{}/v0/release/lookup?{doi}",
self.base_path,
- doi=utf8_percent_encode(&query_doi, QUERY_ENCODE_SET)
+ doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ReleaseLookupGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ReleaseLookupGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ReleaseEntity>(&buf)?;
Ok(ReleaseLookupGetResponse::FindASingleReleaseByExternalIdentifer(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleaseLookupGetResponse::BadRequest(body))
- },
+ }
404 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleaseLookupGetResponse::NoSuchRelease(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleaseLookupGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn release_post(&self, param_body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send> {
-
-
- let url = format!(
- "{}/v0/release",
- self.base_path
- );
-
- let body = param_body.map(|ref body| {
+ fn release_post(
+ &self,
+ param_body: Option<models::ReleaseEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/release", self.base_path);
- serde_json::to_string(body).expect("impossible to fail to serialize")
- });
+ let body = param_body
+ .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
@@ -1295,131 +1564,162 @@ impl Api for Client {
};
custom_headers.set(ContentType(mimetypes::requests::RELEASE_POST.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<ReleasePostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<ReleasePostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
Ok(ReleasePostResponse::Created(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleasePostResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(ReleasePostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn work_id_get(&self, param_id: String, context: &Context) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send> {
-
-
+ fn work_id_get(
+ &self,
+ param_id: String,
+ context: &Context,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/work/{id}",
- self.base_path, id=utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ self.base_path,
+ id = utf8_percent_encode(&param_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
-
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<WorkIdGetResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<WorkIdGetResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::WorkEntity>(&buf)?;
Ok(WorkIdGetResponse::FetchASingleWorkById(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(WorkIdGetResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(WorkIdGetResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
- fn work_post(&self, param_body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send> {
-
-
- let url = format!(
- "{}/v0/work",
- self.base_path
- );
-
- let body = param_body.map(|ref body| {
+ fn work_post(
+ &self,
+ param_body: Option<models::WorkEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/work", self.base_path);
- serde_json::to_string(body).expect("impossible to fail to serialize")
- });
+ let body = param_body
+ .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
@@ -1430,56 +1730,71 @@ impl Api for Client {
};
custom_headers.set(ContentType(mimetypes::requests::WORK_POST.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<WorkPostResponse, ApiError> {
+ fn parse_response(
+ mut response: hyper::client::response::Response,
+ ) -> Result<WorkPostResponse, ApiError> {
match response.status.to_u16() {
201 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
Ok(WorkPostResponse::Created(body))
- },
+ }
400 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(WorkPostResponse::BadRequest(body))
- },
+ }
0 => {
let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ response
+ .read_to_string(&mut buf)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Error>(&buf)?;
Ok(WorkPostResponse::GenericErrorResponse(body))
- },
+ }
code => {
let mut buf = [0; 100];
let debug_body = match response.read(&mut buf) {
Ok(len) => match str::from_utf8(&buf[..len]) {
Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ Err(_) => Cow::from(format!(
+ "<Body was not UTF8: {:?}>",
+ &buf[..len].to_vec()
+ )),
},
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
};
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
- code,
- response.headers,
- debug_body)))
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code, response.headers, debug_body
+ )))
}
}
}
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ let result = request
+ .send()
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(parse_response);
Box::new(futures::done(result))
}
-
}
#[derive(Debug)]
@@ -1487,7 +1802,7 @@ pub enum ClientInitError {
InvalidScheme,
InvalidUrl(hyper::error::ParseError),
MissingHost,
- SslError(openssl::error::ErrorStack)
+ SslError(openssl::error::ErrorStack),
}
impl From<hyper::error::ParseError> for ClientInitError {