aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/TODO2
-rw-r--r--rust/fatcat-api/examples/client.rs386
-rw-r--r--rust/fatcat-api/examples/server.rs32
-rw-r--r--rust/fatcat-api/examples/server_lib/server.rs276
-rw-r--r--rust/fatcat-api/src/client.rs1315
-rw-r--r--rust/fatcat-api/src/lib.rs573
-rw-r--r--rust/fatcat-api/src/mimetypes.rs156
-rw-r--r--rust/fatcat-api/src/models.rs137
-rw-r--r--rust/fatcat-api/src/server.rs2597
-rw-r--r--rust/src/api_server.rs277
-rw-r--r--rust/src/bin/fatcat-iron.rs50
11 files changed, 3799 insertions, 2002 deletions
diff --git a/rust/TODO b/rust/TODO
index af67367d..f66b2b3a 100644
--- a/rust/TODO
+++ b/rust/TODO
@@ -1,4 +1,4 @@
-- re-generate OpenAPI
+x re-generate OpenAPI
=> using whatever sagger-codegen 2.3.1 (stable?)
=> take iron example from older generator 2.3.1 (iron)
=> cargo swagger (docker) seems to only use latest
diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs
index 6693a3b1..bd43e7cc 100644
--- a/rust/fatcat-api/examples/client.rs
+++ b/rust/fatcat-api/examples/client.rs
@@ -1,5 +1,6 @@
#![allow(missing_docs, unused_variables, trivial_casts)]
+extern crate clap;
extern crate fatcat;
#[allow(unused_extern_crates)]
extern crate futures;
@@ -7,195 +8,346 @@ extern crate futures;
extern crate swagger;
#[allow(unused_extern_crates)]
extern crate uuid;
-extern crate clap;
+use clap::{App, Arg};
#[allow(unused_imports)]
-use futures::{Future, future, Stream, stream};
+use fatcat::{ApiError, ApiNoContext, ContainerIdGetResponse, ContainerLookupGetResponse,
+ ContainerPostResponse, ContextWrapperExt, CreatorIdGetResponse,
+ CreatorLookupGetResponse, CreatorPostResponse, EditgroupIdAcceptPostResponse,
+ EditgroupIdGetResponse, EditgroupPostResponse, EditorUsernameChangelogGetResponse,
+ EditorUsernameGetResponse, FileIdGetResponse, FileLookupGetResponse,
+ FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse,
+ ReleasePostResponse, WorkIdGetResponse, WorkPostResponse};
#[allow(unused_imports)]
-use fatcat::{ApiNoContext, ContextWrapperExt,
- ApiError,
- ContainerIdGetResponse,
- ContainerLookupGetResponse,
- ContainerPostResponse,
- CreatorIdGetResponse,
- CreatorLookupGetResponse,
- CreatorPostResponse,
- EditgroupIdAcceptPostResponse,
- EditgroupIdGetResponse,
- EditgroupPostResponse,
- EditorUsernameChangelogGetResponse,
- EditorUsernameGetResponse,
- FileIdGetResponse,
- FileLookupGetResponse,
- FilePostResponse,
- ReleaseIdGetResponse,
- ReleaseLookupGetResponse,
- ReleasePostResponse,
- WorkIdGetResponse,
- WorkPostResponse
- };
-use clap::{App, Arg};
+use futures::{future, stream, Future, Stream};
fn main() {
let matches = App::new("client")
- .arg(Arg::with_name("operation")
- .help("Sets the operation to run")
- .possible_values(&[
- "ContainerIdGet",
- "ContainerLookupGet",
- "ContainerPost",
- "CreatorIdGet",
- "CreatorLookupGet",
- "CreatorPost",
- "EditgroupIdAcceptPost",
- "EditgroupIdGet",
- "EditgroupPost",
- "EditorUsernameChangelogGet",
- "EditorUsernameGet",
- "FileIdGet",
- "FileLookupGet",
- "FilePost",
- "ReleaseIdGet",
- "ReleaseLookupGet",
- "ReleasePost",
- "WorkIdGet",
- "WorkPost",
-])
- .required(true)
- .index(1))
- .arg(Arg::with_name("https")
- .long("https")
- .help("Whether to use HTTPS or not"))
- .arg(Arg::with_name("host")
- .long("host")
- .takes_value(true)
- .default_value("api.fatcat.wiki")
- .help("Hostname to contact"))
- .arg(Arg::with_name("port")
- .long("port")
- .takes_value(true)
- .default_value("8080")
- .help("Port to contact"))
+ .arg(
+ Arg::with_name("operation")
+ .help("Sets the operation to run")
+ .possible_values(&[
+ "ContainerIdGet",
+ "ContainerLookupGet",
+ "ContainerPost",
+ "CreatorIdGet",
+ "CreatorLookupGet",
+ "CreatorPost",
+ "EditgroupIdAcceptPost",
+ "EditgroupIdGet",
+ "EditgroupPost",
+ "EditorUsernameChangelogGet",
+ "EditorUsernameGet",
+ "FileIdGet",
+ "FileLookupGet",
+ "FilePost",
+ "ReleaseIdGet",
+ "ReleaseLookupGet",
+ "ReleasePost",
+ "WorkIdGet",
+ "WorkPost",
+ ])
+ .required(true)
+ .index(1),
+ )
+ .arg(
+ Arg::with_name("https")
+ .long("https")
+ .help("Whether to use HTTPS or not"),
+ )
+ .arg(
+ Arg::with_name("host")
+ .long("host")
+ .takes_value(true)
+ .default_value("api.fatcat.wiki")
+ .help("Hostname to contact"),
+ )
+ .arg(
+ Arg::with_name("port")
+ .long("port")
+ .takes_value(true)
+ .default_value("8080")
+ .help("Port to contact"),
+ )
.get_matches();
let is_https = matches.is_present("https");
- let base_url = format!("{}://{}:{}",
- if is_https { "https" } else { "http" },
- matches.value_of("host").unwrap(),
- matches.value_of("port").unwrap());
+ let base_url = format!(
+ "{}://{}:{}",
+ if is_https { "https" } else { "http" },
+ matches.value_of("host").unwrap(),
+ matches.value_of("port").unwrap()
+ );
let client = if is_https {
// Using Simple HTTPS
fatcat::Client::try_new_https(&base_url, "examples/ca.pem")
.expect("Failed to create HTTPS client")
} else {
// Using HTTP
- fatcat::Client::try_new_http(&base_url)
- .expect("Failed to create HTTP client")
+ fatcat::Client::try_new_http(&base_url).expect("Failed to create HTTP client")
};
// Using a non-default `Context` is not required; this is just an example!
- let client = client.with_context(fatcat::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string()));
+ let client = client.with_context(fatcat::Context::new_with_span_id(
+ self::uuid::Uuid::new_v4().to_string(),
+ ));
match matches.value_of("operation") {
-
Some("ContainerIdGet") => {
let result = client.container_id_get("id_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("ContainerLookupGet") => {
- let result = client.container_lookup_get("issn_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ let result = client
+ .container_lookup_get("issn_example".to_string())
+ .wait();
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("ContainerPost") => {
let result = client.container_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("CreatorIdGet") => {
let result = client.creator_id_get("id_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("CreatorLookupGet") => {
- let result = client.creator_lookup_get("orcid_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ let result = client
+ .creator_lookup_get("orcid_example".to_string())
+ .wait();
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("CreatorPost") => {
let result = client.creator_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("EditgroupIdAcceptPost") => {
let result = client.editgroup_id_accept_post(56).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("EditgroupIdGet") => {
let result = client.editgroup_id_get(56).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("EditgroupPost") => {
let result = client.editgroup_post().wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("EditorUsernameChangelogGet") => {
- let result = client.editor_username_changelog_get("username_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ let result = client
+ .editor_username_changelog_get("username_example".to_string())
+ .wait();
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("EditorUsernameGet") => {
- let result = client.editor_username_get("username_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ let result = client
+ .editor_username_get("username_example".to_string())
+ .wait();
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("FileIdGet") => {
let result = client.file_id_get("id_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("FileLookupGet") => {
let result = client.file_lookup_get("sha1_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("FilePost") => {
let result = client.file_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("ReleaseIdGet") => {
let result = client.release_id_get("id_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("ReleaseLookupGet") => {
let result = client.release_lookup_get("doi_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("ReleasePost") => {
let result = client.release_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("WorkIdGet") => {
let result = client.work_id_get("id_example".to_string()).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
+ }
Some("WorkPost") => {
let result = client.work_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- },
-
- _ => {
- panic!("Invalid operation provided")
+ println!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ client
+ .context()
+ .x_span_id
+ .clone()
+ .unwrap_or(String::from("<none>"))
+ );
}
+
+ _ => panic!("Invalid operation provided"),
}
}
-
diff --git a/rust/fatcat-api/examples/server.rs b/rust/fatcat-api/examples/server.rs
index 79d7367e..e97d69ca 100644
--- a/rust/fatcat-api/examples/server.rs
+++ b/rust/fatcat-api/examples/server.rs
@@ -4,26 +4,26 @@
// Imports required by this file.
// extern crate <name of this crate>;
+extern crate clap;
extern crate fatcat;
-extern crate swagger;
-extern crate iron;
extern crate hyper_openssl;
-extern crate clap;
+extern crate iron;
+extern crate swagger;
// Imports required by server library.
// extern crate fatcat;
// extern crate swagger;
-extern crate futures;
extern crate chrono;
+extern crate futures;
#[macro_use]
extern crate error_chain;
+use clap::{App, Arg};
use hyper_openssl::OpensslServer;
-use hyper_openssl::openssl::x509::X509_FILETYPE_PEM;
-use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod};
use hyper_openssl::openssl::error::ErrorStack;
-use clap::{App, Arg};
-use iron::{Iron, Chain};
+use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod};
+use hyper_openssl::openssl::x509::X509_FILETYPE_PEM;
+use iron::{Chain, Iron};
use swagger::auth::AllowAllMiddleware;
mod server_lib;
@@ -44,9 +44,11 @@ fn ssl() -> Result<OpensslServer, ErrorStack> {
/// and pass it to the web server.
fn main() {
let matches = App::new("server")
- .arg(Arg::with_name("https")
- .long("https")
- .help("Whether to use HTTPS or not"))
+ .arg(
+ Arg::with_name("https")
+ .long("https")
+ .help("Whether to use HTTPS or not"),
+ )
.get_matches();
let server = server_lib::server().unwrap();
@@ -60,9 +62,13 @@ fn main() {
if matches.is_present("https") {
// Using Simple HTTPS
- Iron::new(chain).https("localhost:8080", ssl().expect("Failed to load SSL keys")).expect("Failed to start HTTPS server");
+ Iron::new(chain)
+ .https("localhost:8080", ssl().expect("Failed to load SSL keys"))
+ .expect("Failed to start HTTPS server");
} else {
// Using HTTP
- Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server");
+ Iron::new(chain)
+ .http("localhost:8080")
+ .expect("Failed to start HTTP server");
}
}
diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs
index 58414e31..ec915786 100644
--- a/rust/fatcat-api/examples/server_lib/server.rs
+++ b/rust/fatcat-api/examples/server_lib/server.rs
@@ -2,172 +2,286 @@
#![allow(unused_imports)]
-use futures::{self, Future};
use chrono;
+use futures::{self, Future};
use std::collections::HashMap;
use swagger;
-use fatcat::{Api, ApiError, Context,
- ContainerIdGetResponse,
- ContainerLookupGetResponse,
- ContainerPostResponse,
- CreatorIdGetResponse,
- CreatorLookupGetResponse,
- CreatorPostResponse,
- EditgroupIdAcceptPostResponse,
- EditgroupIdGetResponse,
- EditgroupPostResponse,
- EditorUsernameChangelogGetResponse,
- EditorUsernameGetResponse,
- FileIdGetResponse,
- FileLookupGetResponse,
- FilePostResponse,
- ReleaseIdGetResponse,
- ReleaseLookupGetResponse,
- ReleasePostResponse,
- WorkIdGetResponse,
- WorkPostResponse
-};
use fatcat::models;
+use fatcat::{Api, ApiError, ContainerIdGetResponse, ContainerLookupGetResponse,
+ ContainerPostResponse, Context, CreatorIdGetResponse, CreatorLookupGetResponse,
+ CreatorPostResponse, EditgroupIdAcceptPostResponse, EditgroupIdGetResponse,
+ EditgroupPostResponse, EditorUsernameChangelogGetResponse, EditorUsernameGetResponse,
+ FileIdGetResponse, FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse,
+ ReleaseLookupGetResponse, ReleasePostResponse, WorkIdGetResponse, WorkPostResponse};
#[derive(Copy, Clone)]
pub struct Server;
impl Api for Server {
-
-
- fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send> {
+ fn container_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send> {
+ fn container_lookup_get(
+ &self,
+ issn: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_lookup_get(\"{}\") - X-Span-ID: {:?}", issn, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ issn,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send> {
+ fn container_post(
+ &self,
+ body: Option<models::ContainerEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send> {
+ fn creator_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send> {
+ fn creator_lookup_get(
+ &self,
+ orcid: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_lookup_get(\"{}\") - X-Span-ID: {:?}", orcid, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ orcid,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_post(&self, body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send> {
+ fn creator_post(
+ &self,
+ body: Option<models::CreatorEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send> {
+ fn editgroup_id_accept_post(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_id_accept_post({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_id_accept_post({}) - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_id_get(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send> {
+ fn editgroup_id_get(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_id_get({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_id_get({}) - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_post(&self, context: &Context) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send> {
+ fn editgroup_post(
+ &self,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_post() - X-Span-ID: {:?}", context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_post() - X-Span-ID: {:?}",
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send> {
+ fn editor_username_changelog_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}",
+ username,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editor_username_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send> {
+ fn editor_username_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editor_username_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editor_username_get(\"{}\") - X-Span-ID: {:?}",
+ username,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_id_get(&self, id: String, context: &Context) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send> {
+ fn file_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send> {
+ fn file_lookup_get(
+ &self,
+ sha1: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_lookup_get(\"{}\") - X-Span-ID: {:?}", sha1, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ sha1,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_post(&self, body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send> {
+ fn file_post(
+ &self,
+ body: Option<models::FileEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send> {
+ fn release_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send> {
+ fn release_lookup_get(
+ &self,
+ doi: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_lookup_get(\"{}\") - X-Span-ID: {:?}", doi, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ doi,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_post(&self, body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send> {
+ fn release_post(
+ &self,
+ body: Option<models::ReleaseEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send> {
+ fn work_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("work_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "work_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn work_post(&self, body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send> {
+ fn work_post(
+ &self,
+ body: Option<models::WorkEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("work_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "work_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
}
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 {
diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs
index e695daa7..2b7c84a0 100644
--- a/rust/fatcat-api/src/lib.rs
+++ b/rust/fatcat-api/src/lib.rs
@@ -1,11 +1,12 @@
-#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
+#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports,
+ unused_extern_crates, non_camel_case_types)]
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
-extern crate futures;
extern crate chrono;
+extern crate futures;
#[macro_use]
extern crate lazy_static;
@@ -32,441 +33,563 @@ mod mimetypes;
pub use swagger::{ApiError, Context, ContextWrapper};
-
#[derive(Debug, PartialEq)]
pub enum ContainerIdGetResponse {
/// fetch a single container by id
- FetchASingleContainerById ( models::ContainerEntity ) ,
+ FetchASingleContainerById(models::ContainerEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum ContainerLookupGetResponse {
/// find a single container by external identifer
- FindASingleContainerByExternalIdentifer ( models::ContainerEntity ) ,
+ FindASingleContainerByExternalIdentifer(models::ContainerEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// no such container
- NoSuchContainer ( models::Error ) ,
+ NoSuchContainer(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum ContainerPostResponse {
/// created
- Created ( models::EntityEdit ) ,
+ Created(models::EntityEdit),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum CreatorIdGetResponse {
/// fetch a single creator by id
- FetchASingleCreatorById ( models::CreatorEntity ) ,
+ FetchASingleCreatorById(models::CreatorEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum CreatorLookupGetResponse {
/// find a single creator by external identifer
- FindASingleCreatorByExternalIdentifer ( models::CreatorEntity ) ,
+ FindASingleCreatorByExternalIdentifer(models::CreatorEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// no such creator
- NoSuchCreator ( models::Error ) ,
+ NoSuchCreator(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum CreatorPostResponse {
/// created
- Created ( models::EntityEdit ) ,
+ Created(models::EntityEdit),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum EditgroupIdAcceptPostResponse {
/// merged editgroup successfully (\&quot;live\&quot;)
- MergedEditgroupSuccessfully_ ( models::Success ) ,
+ MergedEditgroupSuccessfully_(models::Success),
/// editgroup is in an unmergable state
- EditgroupIsInAnUnmergableState ( models::Error ) ,
+ EditgroupIsInAnUnmergableState(models::Error),
/// no such editgroup
- NoSuchEditgroup ( models::Error ) ,
+ NoSuchEditgroup(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum EditgroupIdGetResponse {
/// fetch editgroup by identifier
- FetchEditgroupByIdentifier ( models::Editgroup ) ,
+ FetchEditgroupByIdentifier(models::Editgroup),
/// no such editgroup
- NoSuchEditgroup ( models::Error ) ,
+ NoSuchEditgroup(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum EditgroupPostResponse {
/// successfully created
- SuccessfullyCreated ( models::Editgroup ) ,
+ SuccessfullyCreated(models::Editgroup),
/// invalid request parameters
- InvalidRequestParameters ( models::Error ) ,
+ InvalidRequestParameters(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum EditorUsernameChangelogGetResponse {
/// find changes (editgroups) by this editor which have been merged
- FindChanges_ ( models::Changelogentry ) ,
+ FindChanges_(models::Changelogentry),
/// username not found
- UsernameNotFound ( models::Error ) ,
+ UsernameNotFound(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum EditorUsernameGetResponse {
/// fetch generic information about an editor
- FetchGenericInformationAboutAnEditor ( models::Editor ) ,
+ FetchGenericInformationAboutAnEditor(models::Editor),
/// username not found
- UsernameNotFound ( models::Error ) ,
+ UsernameNotFound(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum FileIdGetResponse {
/// fetch a single file by id
- FetchASingleFileById ( models::FileEntity ) ,
+ FetchASingleFileById(models::FileEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum FileLookupGetResponse {
/// find a single file by external identifer
- FindASingleFileByExternalIdentifer ( models::FileEntity ) ,
+ FindASingleFileByExternalIdentifer(models::FileEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// no such file
- NoSuchFile ( models::Error ) ,
+ NoSuchFile(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum FilePostResponse {
/// created
- Created ( models::EntityEdit ) ,
+ Created(models::EntityEdit),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum ReleaseIdGetResponse {
/// fetch a single release by id
- FetchASingleReleaseById ( models::ReleaseEntity ) ,
+ FetchASingleReleaseById(models::ReleaseEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum ReleaseLookupGetResponse {
/// find a single release by external identifer
- FindASingleReleaseByExternalIdentifer ( models::ReleaseEntity ) ,
+ FindASingleReleaseByExternalIdentifer(models::ReleaseEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// no such release
- NoSuchRelease ( models::Error ) ,
+ NoSuchRelease(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum ReleasePostResponse {
/// created
- Created ( models::EntityEdit ) ,
+ Created(models::EntityEdit),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum WorkIdGetResponse {
/// fetch a single work by id
- FetchASingleWorkById ( models::WorkEntity ) ,
+ FetchASingleWorkById(models::WorkEntity),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
#[derive(Debug, PartialEq)]
pub enum WorkPostResponse {
/// created
- Created ( models::EntityEdit ) ,
+ Created(models::EntityEdit),
/// bad request
- BadRequest ( models::Error ) ,
+ BadRequest(models::Error),
/// generic error response
- GenericErrorResponse ( models::Error ) ,
+ GenericErrorResponse(models::Error),
}
-
/// API
pub trait Api {
-
-
- fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send>;
-
-
- fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send>;
-
-
- fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send>;
-
-
- fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn creator_post(&self, body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_id_get(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_post(&self, context: &Context) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send>;
-
-
- fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send>;
-
-
- fn editor_username_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send>;
-
-
- fn file_id_get(&self, id: String, context: &Context) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send>;
-
-
- fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn file_post(&self, body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send>;
-
-
- fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send>;
-
-
- fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn release_post(&self, body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send>;
-
-
- fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send>;
-
-
- fn work_post(&self, body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send>;
-
+ fn container_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>;
+
+ fn container_lookup_get(
+ &self,
+ issn: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
+
+ fn container_post(
+ &self,
+ body: Option<models::ContainerEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+
+ fn creator_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>;
+
+ fn creator_lookup_get(
+ &self,
+ orcid: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>;
+
+ fn creator_post(
+ &self,
+ body: Option<models::CreatorEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
+
+ fn editgroup_id_accept_post(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>;
+
+ fn editgroup_id_get(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send>;
+
+ fn editgroup_post(
+ &self,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>;
+
+ fn editor_username_changelog_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send>;
+
+ fn editor_username_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send>;
+
+ fn file_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send>;
+
+ fn file_lookup_get(
+ &self,
+ sha1: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>;
+
+ fn file_post(
+ &self,
+ body: Option<models::FileEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+
+ fn release_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>;
+
+ fn release_lookup_get(
+ &self,
+ doi: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>;
+
+ fn release_post(
+ &self,
+ body: Option<models::ReleaseEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+
+ fn work_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>;
+
+ fn work_post(
+ &self,
+ body: Option<models::WorkEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
}
/// API without a `Context`
pub trait ApiNoContext {
-
-
- fn container_id_get(&self, id: String) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send>;
-
-
- fn container_lookup_get(&self, issn: String) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn container_post(&self, body: Option<models::ContainerEntity>) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send>;
-
-
- fn creator_id_get(&self, id: String) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send>;
-
-
- fn creator_lookup_get(&self, orcid: String) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn creator_post(&self, body: Option<models::CreatorEntity>) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_id_accept_post(&self, id: i32) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_id_get(&self, id: i32) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send>;
-
-
- fn editgroup_post(&self) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send>;
-
-
- fn editor_username_changelog_get(&self, username: String) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send>;
-
-
- fn editor_username_get(&self, username: String) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send>;
-
-
- fn file_id_get(&self, id: String) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send>;
-
-
- fn file_lookup_get(&self, sha1: String) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn file_post(&self, body: Option<models::FileEntity>) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send>;
-
-
- fn release_id_get(&self, id: String) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send>;
-
-
- fn release_lookup_get(&self, doi: String) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send>;
-
-
- fn release_post(&self, body: Option<models::ReleaseEntity>) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send>;
-
-
- fn work_id_get(&self, id: String) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send>;
-
-
- fn work_post(&self, body: Option<models::WorkEntity>) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send>;
-
+ fn container_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>;
+
+ fn container_lookup_get(
+ &self,
+ issn: String,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
+
+ fn container_post(
+ &self,
+ body: Option<models::ContainerEntity>,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+
+ fn creator_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>;
+
+ fn creator_lookup_get(
+ &self,
+ orcid: String,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>;
+
+ fn creator_post(
+ &self,
+ body: Option<models::CreatorEntity>,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
+
+ fn editgroup_id_accept_post(
+ &self,
+ id: i32,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>;
+
+ fn editgroup_id_get(
+ &self,
+ id: i32,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send>;
+
+ fn editgroup_post(&self) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>;
+
+ fn editor_username_changelog_get(
+ &self,
+ username: String,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send>;
+
+ fn editor_username_get(
+ &self,
+ username: String,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send>;
+
+ fn file_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send>;
+
+ fn file_lookup_get(
+ &self,
+ sha1: String,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>;
+
+ fn file_post(
+ &self,
+ body: Option<models::FileEntity>,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+
+ fn release_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>;
+
+ fn release_lookup_get(
+ &self,
+ doi: String,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>;
+
+ fn release_post(
+ &self,
+ body: Option<models::ReleaseEntity>,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+
+ fn work_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>;
+
+ fn work_post(
+ &self,
+ body: Option<models::WorkEntity>,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
}
/// Trait to extend an API to make it easy to bind it to a context.
-pub trait ContextWrapperExt<'a> where Self: Sized {
+pub trait ContextWrapperExt<'a>
+where
+ Self: Sized,
+{
/// Binds this API to a context.
fn with_context(self: &'a Self, context: Context) -> ContextWrapper<'a, Self>;
}
impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T {
fn with_context(self: &'a T, context: Context) -> ContextWrapper<'a, T> {
- ContextWrapper::<T>::new(self, context)
+ ContextWrapper::<T>::new(self, context)
}
}
impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
-
-
- fn container_id_get(&self, id: String) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send> {
+ fn container_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send> {
self.api().container_id_get(id, &self.context())
}
-
- fn container_lookup_get(&self, issn: String) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send> {
+ fn container_lookup_get(
+ &self,
+ issn: String,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> {
self.api().container_lookup_get(issn, &self.context())
}
-
- fn container_post(&self, body: Option<models::ContainerEntity>) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send> {
+ fn container_post(
+ &self,
+ body: Option<models::ContainerEntity>,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
self.api().container_post(body, &self.context())
}
-
- fn creator_id_get(&self, id: String) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send> {
+ fn creator_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send> {
self.api().creator_id_get(id, &self.context())
}
-
- fn creator_lookup_get(&self, orcid: String) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send> {
+ fn creator_lookup_get(
+ &self,
+ orcid: String,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send> {
self.api().creator_lookup_get(orcid, &self.context())
}
-
- fn creator_post(&self, body: Option<models::CreatorEntity>) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send> {
+ fn creator_post(
+ &self,
+ body: Option<models::CreatorEntity>,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
self.api().creator_post(body, &self.context())
}
-
- fn editgroup_id_accept_post(&self, id: i32) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send> {
+ fn editgroup_id_accept_post(
+ &self,
+ id: i32,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send> {
self.api().editgroup_id_accept_post(id, &self.context())
}
-
- fn editgroup_id_get(&self, id: i32) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send> {
+ fn editgroup_id_get(
+ &self,
+ id: i32,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send> {
self.api().editgroup_id_get(id, &self.context())
}
-
- fn editgroup_post(&self) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send> {
+ fn editgroup_post(&self) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> {
self.api().editgroup_post(&self.context())
}
-
- fn editor_username_changelog_get(&self, username: String) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send> {
- self.api().editor_username_changelog_get(username, &self.context())
+ fn editor_username_changelog_get(
+ &self,
+ username: String,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send> {
+ self.api()
+ .editor_username_changelog_get(username, &self.context())
}
-
- fn editor_username_get(&self, username: String) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send> {
+ fn editor_username_get(
+ &self,
+ username: String,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send> {
self.api().editor_username_get(username, &self.context())
}
-
- fn file_id_get(&self, id: String) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send> {
+ fn file_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send> {
self.api().file_id_get(id, &self.context())
}
-
- fn file_lookup_get(&self, sha1: String) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send> {
+ fn file_lookup_get(
+ &self,
+ sha1: String,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send> {
self.api().file_lookup_get(sha1, &self.context())
}
-
- fn file_post(&self, body: Option<models::FileEntity>) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send> {
+ fn file_post(
+ &self,
+ body: Option<models::FileEntity>,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
self.api().file_post(body, &self.context())
}
-
- fn release_id_get(&self, id: String) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send> {
+ fn release_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send> {
self.api().release_id_get(id, &self.context())
}
-
- fn release_lookup_get(&self, doi: String) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send> {
+ fn release_lookup_get(
+ &self,
+ doi: String,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send> {
self.api().release_lookup_get(doi, &self.context())
}
-
- fn release_post(&self, body: Option<models::ReleaseEntity>) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send> {
+ fn release_post(
+ &self,
+ body: Option<models::ReleaseEntity>,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
self.api().release_post(body, &self.context())
}
-
- fn work_id_get(&self, id: String) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send> {
+ fn work_id_get(
+ &self,
+ id: String,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> {
self.api().work_id_get(id, &self.context())
}
-
- fn work_post(&self, body: Option<models::WorkEntity>) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send> {
+ fn work_post(
+ &self,
+ body: Option<models::WorkEntity>,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
self.api().work_post(body, &self.context())
}
-
}
#[cfg(feature = "client")]
diff --git a/rust/fatcat-api/src/mimetypes.rs b/rust/fatcat-api/src/mimetypes.rs
index c0b83a05..6076d488 100644
--- a/rust/fatcat-api/src/mimetypes.rs
+++ b/rust/fatcat-api/src/mimetypes.rs
@@ -6,276 +6,288 @@ pub mod responses {
// The macro is called per-operation to beat the recursion limit
/// Create Mime objects for the response content types for ContainerIdGet
lazy_static! {
- pub static ref CONTAINER_ID_GET_FETCH_A_SINGLE_CONTAINER_BY_ID: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_ID_GET_FETCH_A_SINGLE_CONTAINER_BY_ID: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerIdGet
lazy_static! {
- pub static ref CONTAINER_ID_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerIdGet
lazy_static! {
- pub static ref CONTAINER_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerLookupGet
lazy_static! {
- pub static ref CONTAINER_LOOKUP_GET_FIND_A_SINGLE_CONTAINER_BY_EXTERNAL_IDENTIFER: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_LOOKUP_GET_FIND_A_SINGLE_CONTAINER_BY_EXTERNAL_IDENTIFER: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerLookupGet
lazy_static! {
- pub static ref CONTAINER_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerLookupGet
lazy_static! {
- pub static ref CONTAINER_LOOKUP_GET_NO_SUCH_CONTAINER: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_LOOKUP_GET_NO_SUCH_CONTAINER: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerLookupGet
lazy_static! {
- pub static ref CONTAINER_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerPost
lazy_static! {
- pub static ref CONTAINER_POST_CREATED: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_POST_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerPost
lazy_static! {
- pub static ref CONTAINER_POST_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_POST_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ContainerPost
lazy_static! {
- pub static ref CONTAINER_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorIdGet
lazy_static! {
- pub static ref CREATOR_ID_GET_FETCH_A_SINGLE_CREATOR_BY_ID: Mime = mime!(Application/Json);
+ pub static ref CREATOR_ID_GET_FETCH_A_SINGLE_CREATOR_BY_ID: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorIdGet
lazy_static! {
- pub static ref CREATOR_ID_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CREATOR_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorIdGet
lazy_static! {
- pub static ref CREATOR_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CREATOR_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorLookupGet
lazy_static! {
- pub static ref CREATOR_LOOKUP_GET_FIND_A_SINGLE_CREATOR_BY_EXTERNAL_IDENTIFER: Mime = mime!(Application/Json);
+ pub static ref CREATOR_LOOKUP_GET_FIND_A_SINGLE_CREATOR_BY_EXTERNAL_IDENTIFER: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorLookupGet
lazy_static! {
- pub static ref CREATOR_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CREATOR_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorLookupGet
lazy_static! {
- pub static ref CREATOR_LOOKUP_GET_NO_SUCH_CREATOR: Mime = mime!(Application/Json);
+ pub static ref CREATOR_LOOKUP_GET_NO_SUCH_CREATOR: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorLookupGet
lazy_static! {
- pub static ref CREATOR_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CREATOR_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorPost
lazy_static! {
- pub static ref CREATOR_POST_CREATED: Mime = mime!(Application/Json);
+ pub static ref CREATOR_POST_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorPost
lazy_static! {
- pub static ref CREATOR_POST_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref CREATOR_POST_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for CreatorPost
lazy_static! {
- pub static ref CREATOR_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref CREATOR_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdAcceptPost
lazy_static! {
- pub static ref EDITGROUP_ID_ACCEPT_POST_MERGED_EDITGROUP_SUCCESSFULLY_: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_ACCEPT_POST_MERGED_EDITGROUP_SUCCESSFULLY_: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdAcceptPost
lazy_static! {
- pub static ref EDITGROUP_ID_ACCEPT_POST_EDITGROUP_IS_IN_AN_UNMERGABLE_STATE: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_ACCEPT_POST_EDITGROUP_IS_IN_AN_UNMERGABLE_STATE: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdAcceptPost
lazy_static! {
- pub static ref EDITGROUP_ID_ACCEPT_POST_NO_SUCH_EDITGROUP: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_ACCEPT_POST_NO_SUCH_EDITGROUP: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdAcceptPost
lazy_static! {
- pub static ref EDITGROUP_ID_ACCEPT_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_ACCEPT_POST_GENERIC_ERROR_RESPONSE: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdGet
lazy_static! {
- pub static ref EDITGROUP_ID_GET_FETCH_EDITGROUP_BY_IDENTIFIER: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_GET_FETCH_EDITGROUP_BY_IDENTIFIER: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdGet
lazy_static! {
- pub static ref EDITGROUP_ID_GET_NO_SUCH_EDITGROUP: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_GET_NO_SUCH_EDITGROUP: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdGet
lazy_static! {
- pub static ref EDITGROUP_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupPost
lazy_static! {
- pub static ref EDITGROUP_POST_SUCCESSFULLY_CREATED: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_POST_SUCCESSFULLY_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupPost
lazy_static! {
- pub static ref EDITGROUP_POST_INVALID_REQUEST_PARAMETERS: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_POST_INVALID_REQUEST_PARAMETERS: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupPost
lazy_static! {
- pub static ref EDITGROUP_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref EDITGROUP_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameChangelogGet
lazy_static! {
- pub static ref EDITOR_USERNAME_CHANGELOG_GET_FIND_CHANGES_: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_CHANGELOG_GET_FIND_CHANGES_: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameChangelogGet
lazy_static! {
- pub static ref EDITOR_USERNAME_CHANGELOG_GET_USERNAME_NOT_FOUND: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_CHANGELOG_GET_USERNAME_NOT_FOUND: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameChangelogGet
lazy_static! {
- pub static ref EDITOR_USERNAME_CHANGELOG_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_CHANGELOG_GET_GENERIC_ERROR_RESPONSE: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameGet
lazy_static! {
- pub static ref EDITOR_USERNAME_GET_FETCH_GENERIC_INFORMATION_ABOUT_AN_EDITOR: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_GET_FETCH_GENERIC_INFORMATION_ABOUT_AN_EDITOR: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameGet
lazy_static! {
- pub static ref EDITOR_USERNAME_GET_USERNAME_NOT_FOUND: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_GET_USERNAME_NOT_FOUND: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditorUsernameGet
lazy_static! {
- pub static ref EDITOR_USERNAME_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref EDITOR_USERNAME_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileIdGet
lazy_static! {
- pub static ref FILE_ID_GET_FETCH_A_SINGLE_FILE_BY_ID: Mime = mime!(Application/Json);
+ pub static ref FILE_ID_GET_FETCH_A_SINGLE_FILE_BY_ID: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileIdGet
lazy_static! {
- pub static ref FILE_ID_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref FILE_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileIdGet
lazy_static! {
- pub static ref FILE_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref FILE_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileLookupGet
lazy_static! {
- pub static ref FILE_LOOKUP_GET_FIND_A_SINGLE_FILE_BY_EXTERNAL_IDENTIFER: Mime = mime!(Application/Json);
+ pub static ref FILE_LOOKUP_GET_FIND_A_SINGLE_FILE_BY_EXTERNAL_IDENTIFER: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileLookupGet
lazy_static! {
- pub static ref FILE_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref FILE_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileLookupGet
lazy_static! {
- pub static ref FILE_LOOKUP_GET_NO_SUCH_FILE: Mime = mime!(Application/Json);
+ pub static ref FILE_LOOKUP_GET_NO_SUCH_FILE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FileLookupGet
lazy_static! {
- pub static ref FILE_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref FILE_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FilePost
lazy_static! {
- pub static ref FILE_POST_CREATED: Mime = mime!(Application/Json);
+ pub static ref FILE_POST_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FilePost
lazy_static! {
- pub static ref FILE_POST_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref FILE_POST_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for FilePost
lazy_static! {
- pub static ref FILE_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref FILE_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseIdGet
lazy_static! {
- pub static ref RELEASE_ID_GET_FETCH_A_SINGLE_RELEASE_BY_ID: Mime = mime!(Application/Json);
+ pub static ref RELEASE_ID_GET_FETCH_A_SINGLE_RELEASE_BY_ID: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseIdGet
lazy_static! {
- pub static ref RELEASE_ID_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref RELEASE_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseIdGet
lazy_static! {
- pub static ref RELEASE_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref RELEASE_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseLookupGet
lazy_static! {
- pub static ref RELEASE_LOOKUP_GET_FIND_A_SINGLE_RELEASE_BY_EXTERNAL_IDENTIFER: Mime = mime!(Application/Json);
+ pub static ref RELEASE_LOOKUP_GET_FIND_A_SINGLE_RELEASE_BY_EXTERNAL_IDENTIFER: Mime =
+ mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseLookupGet
lazy_static! {
- pub static ref RELEASE_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref RELEASE_LOOKUP_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseLookupGet
lazy_static! {
- pub static ref RELEASE_LOOKUP_GET_NO_SUCH_RELEASE: Mime = mime!(Application/Json);
+ pub static ref RELEASE_LOOKUP_GET_NO_SUCH_RELEASE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleaseLookupGet
lazy_static! {
- pub static ref RELEASE_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref RELEASE_LOOKUP_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleasePost
lazy_static! {
- pub static ref RELEASE_POST_CREATED: Mime = mime!(Application/Json);
+ pub static ref RELEASE_POST_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleasePost
lazy_static! {
- pub static ref RELEASE_POST_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref RELEASE_POST_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for ReleasePost
lazy_static! {
- pub static ref RELEASE_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref RELEASE_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkIdGet
lazy_static! {
- pub static ref WORK_ID_GET_FETCH_A_SINGLE_WORK_BY_ID: Mime = mime!(Application/Json);
+ pub static ref WORK_ID_GET_FETCH_A_SINGLE_WORK_BY_ID: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkIdGet
lazy_static! {
- pub static ref WORK_ID_GET_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref WORK_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkIdGet
lazy_static! {
- pub static ref WORK_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref WORK_ID_GET_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkPost
lazy_static! {
- pub static ref WORK_POST_CREATED: Mime = mime!(Application/Json);
+ pub static ref WORK_POST_CREATED: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkPost
lazy_static! {
- pub static ref WORK_POST_BAD_REQUEST: Mime = mime!(Application/Json);
+ pub static ref WORK_POST_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for WorkPost
lazy_static! {
- pub static ref WORK_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application/Json);
+ pub static ref WORK_POST_GENERIC_ERROR_RESPONSE: Mime = mime!(Application / Json);
}
}
pub mod requests {
use hyper::mime::*;
- /// Create Mime objects for the request content types for ContainerPost
+ /// Create Mime objects for the request content types for ContainerPost
lazy_static! {
- pub static ref CONTAINER_POST: Mime = mime!(Application/Json);
+ pub static ref CONTAINER_POST: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for CreatorPost
+ /// Create Mime objects for the request content types for CreatorPost
lazy_static! {
- pub static ref CREATOR_POST: Mime = mime!(Application/Json);
+ pub static ref CREATOR_POST: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for FilePost
+ /// Create Mime objects for the request content types for FilePost
lazy_static! {
- pub static ref FILE_POST: Mime = mime!(Application/Json);
+ pub static ref FILE_POST: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for ReleasePost
+ /// Create Mime objects for the request content types for ReleasePost
lazy_static! {
- pub static ref RELEASE_POST: Mime = mime!(Application/Json);
+ pub static ref RELEASE_POST: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for WorkPost
+ /// Create Mime objects for the request content types for WorkPost
lazy_static! {
- pub static ref WORK_POST: Mime = mime!(Application/Json);
+ pub static ref WORK_POST: Mime = mime!(Application / Json);
}
}
diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs
index 1d7ed56a..3d104b78 100644
--- a/rust/fatcat-api/src/models.rs
+++ b/rust/fatcat-api/src/models.rs
@@ -2,31 +2,28 @@
extern crate chrono;
extern crate uuid;
-
use serde::ser::Serializer;
-use std::collections::HashMap;
use models;
+use std::collections::HashMap;
use swagger;
-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Changelogentry {
#[serde(rename = "index")]
pub index: isize,
#[serde(rename = "editgroup_id")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup_id: Option<isize>,
#[serde(rename = "timestamp")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
-
}
impl Changelogentry {
- pub fn new(index: isize, ) -> Changelogentry {
+ pub fn new(index: isize) -> Changelogentry {
Changelogentry {
index: index,
editgroup_id: None,
@@ -38,42 +35,41 @@ impl Changelogentry {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ContainerEntity {
#[serde(rename = "issn")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub issn: Option<String>,
#[serde(rename = "publisher")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
#[serde(rename = "parent")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub parent: Option<String>,
#[serde(rename = "name")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "redirect")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
#[serde(rename = "editgroup")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
-
}
impl ContainerEntity {
@@ -95,34 +91,33 @@ impl ContainerEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreatorEntity {
#[serde(rename = "orcid")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub orcid: Option<String>,
#[serde(rename = "name")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "editgroup")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
#[serde(rename = "redirect")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
-
}
impl CreatorEntity {
@@ -146,11 +141,10 @@ pub struct Editgroup {
#[serde(rename = "editor_id")]
pub editor_id: isize,
-
}
impl Editgroup {
- pub fn new(id: isize, editor_id: isize, ) -> Editgroup {
+ pub fn new(id: isize, editor_id: isize) -> Editgroup {
Editgroup {
id: id,
editor_id: editor_id,
@@ -162,35 +156,31 @@ impl Editgroup {
pub struct Editor {
#[serde(rename = "username")]
pub username: String,
-
}
impl Editor {
- pub fn new(username: String, ) -> Editor {
- Editor {
- username: username,
- }
+ pub fn new(username: String) -> Editor {
+ Editor { username: username }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EntityEdit {
#[serde(rename = "editgroup_id")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup_id: Option<isize>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
#[serde(rename = "id")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<isize>,
-
}
impl EntityEdit {
@@ -208,52 +198,48 @@ impl EntityEdit {
pub struct Error {
#[serde(rename = "message")]
pub message: String,
-
}
impl Error {
- pub fn new(message: String, ) -> Error {
- Error {
- message: message,
- }
+ pub fn new(message: String) -> Error {
+ Error { message: message }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FileEntity {
#[serde(rename = "url")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "sha1")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub sha1: Option<String>,
#[serde(rename = "size")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<isize>,
#[serde(rename = "editgroup")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
#[serde(rename = "redirect")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
-
}
impl FileEntity {
@@ -274,58 +260,57 @@ impl FileEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseEntity {
#[serde(rename = "issue")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub issue: Option<String>,
#[serde(rename = "pages")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub pages: Option<String>,
#[serde(rename = "volume")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub volume: Option<String>,
#[serde(rename = "doi")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub doi: Option<String>,
#[serde(rename = "release_type")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub release_type: Option<String>,
#[serde(rename = "license")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub license: Option<String>,
#[serde(rename = "container")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub container: Option<String>,
#[serde(rename = "work")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub work: Option<String>,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "redirect")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
#[serde(rename = "editgroup")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
-
}
impl ReleaseEntity {
@@ -352,48 +337,44 @@ impl ReleaseEntity {
pub struct Success {
#[serde(rename = "message")]
pub message: String,
-
}
impl Success {
- pub fn new(message: String, ) -> Success {
- Success {
- message: message,
- }
+ pub fn new(message: String) -> Success {
+ Success { message: message }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WorkEntity {
#[serde(rename = "work_type")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub work_type: Option<String>,
#[serde(rename = "title")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "editgroup")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
#[serde(rename = "redirect")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
#[serde(rename = "revision")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<isize>,
#[serde(rename = "ident")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
- #[serde(skip_serializing_if="Option::is_none")]
+ #[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
-
}
impl WorkEntity {
diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs
index cb307ad4..66539c55 100644
--- a/rust/fatcat-api/src/server.rs
+++ b/rust/fatcat-api/src/server.rs
@@ -1,34 +1,31 @@
#![allow(unused_extern_crates)]
-extern crate serde_ignored;
+extern crate bodyparser;
+extern crate chrono;
extern crate iron;
extern crate router;
-extern crate bodyparser;
+extern crate serde_ignored;
extern crate urlencoded;
extern crate uuid;
-extern crate chrono;
-
-use futures::Future;
-use futures::future;
-use futures::{stream, Stream};
-use hyper;
-use hyper::header::{Headers, ContentType};
use self::iron::prelude::*;
-use self::iron::{status, modifiers, BeforeMiddleware};
use self::iron::url::percent_encoding::percent_decode;
+use self::iron::{modifiers, status, BeforeMiddleware};
use self::router::Router;
use self::urlencoded::UrlEncodedQuery;
+use futures::Future;
+use futures::future;
+use futures::{stream, Stream};
+use hyper;
+use hyper::header::{ContentType, Headers};
use mimetypes;
-
use serde_json;
-
#[allow(unused_imports)]
-use std::collections::{HashMap, BTreeMap};
+use std::collections::{BTreeMap, HashMap};
+use std::io::Error;
#[allow(unused_imports)]
use swagger;
-use std::io::Error;
#[allow(unused_imports)]
use std::collections::BTreeSet;
@@ -37,34 +34,22 @@ pub use swagger::auth::Authorization;
use swagger::auth::{AuthData, Scopes};
use swagger::{ApiError, Context, XSpanId};
-use {Api,
- ContainerIdGetResponse,
- ContainerLookupGetResponse,
- ContainerPostResponse,
- CreatorIdGetResponse,
- CreatorLookupGetResponse,
- CreatorPostResponse,
- EditgroupIdAcceptPostResponse,
- EditgroupIdGetResponse,
- EditgroupPostResponse,
- EditorUsernameChangelogGetResponse,
- EditorUsernameGetResponse,
- FileIdGetResponse,
- FileLookupGetResponse,
- FilePostResponse,
- ReleaseIdGetResponse,
- ReleaseLookupGetResponse,
- ReleasePostResponse,
- WorkIdGetResponse,
- WorkPostResponse
- };
#[allow(unused_imports)]
use models;
+use {Api, ContainerIdGetResponse, ContainerLookupGetResponse, ContainerPostResponse,
+ CreatorIdGetResponse, CreatorLookupGetResponse, CreatorPostResponse,
+ EditgroupIdAcceptPostResponse, EditgroupIdGetResponse, EditgroupPostResponse,
+ EditorUsernameChangelogGetResponse, EditorUsernameGetResponse, FileIdGetResponse,
+ FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse,
+ ReleasePostResponse, WorkIdGetResponse, WorkPostResponse};
header! { (Warning, "Warning") => [String] }
/// Create a new router for `Api`
-pub fn router<T>(api: T) -> Router where T: Api + Send + Sync + Clone + 'static {
+pub fn router<T>(api: T) -> Router
+where
+ T: Api + Send + Sync + Clone + 'static,
+{
let mut router = Router::new();
add_routes(&mut router, api);
router
@@ -90,14 +75,19 @@ pub fn router<T>(api: T) -> Router where T: Api + Send + Sync + Clone + 'static
///
/// This function exists to allow legacy code, which doesn't separate its APIs properly, to make
/// use of this crate.
-#[deprecated(note="APIs should not overlap - only for use in legacy code.")]
-pub fn route<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone + 'static {
+#[deprecated(note = "APIs should not overlap - only for use in legacy code.")]
+pub fn route<T>(router: &mut Router, api: T)
+where
+ T: Api + Send + Sync + Clone + 'static,
+{
add_routes(router, api)
}
/// Add routes for `Api` to a provided router
-fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone + 'static {
-
+fn add_routes<T>(router: &mut Router, api: T)
+where
+ T: Api + Send + Sync + Clone + 'static,
+{
let api_clone = api.clone();
router.get(
"/v0/container/:id",
@@ -105,75 +95,134 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.container_id_get(param_id, context).wait() {
Ok(rsp) => match rsp {
ContainerIdGetResponse::FetchASingleContainerById(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::CONTAINER_ID_GET_FETCH_A_SINGLE_CONTAINER_BY_ID.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
ContainerIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_ID_GET_BAD_REQUEST.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_ID_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
ContainerIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_ID_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ContainerIdGet");
+ "ContainerIdGet",
+ );
let api_clone = api.clone();
router.get(
@@ -182,84 +231,144 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_issn = query_params.get("issn")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issn".to_string())))?
- .first().ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issn was empty".to_string())))?
- .parse::<String>().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issn - doesn't match schema: {}", e))))?;
-
+ let param_issn = query_params
+ .get("issn")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing required query parameter issn".to_string(),
+ ))
+ })?
+ .first()
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Required query parameter issn was empty".to_string(),
+ ))
+ })?
+ .parse::<String>()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't parse query parameter issn - doesn't match schema: {}",
+ e
+ ),
+ ))
+ })?;
match api.container_lookup_get(param_issn, context).wait() {
- Ok(rsp) => match rsp {
- ContainerLookupGetResponse::FindASingleContainerByExternalIdentifer(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_FIND_A_SINGLE_CONTAINER_BY_EXTERNAL_IDENTIFER.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- ContainerLookupGetResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- ContainerLookupGetResponse::NoSuchContainer(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_NO_SUCH_CONTAINER.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- ContainerLookupGetResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ Ok(rsp) => {
+ match rsp {
+ ContainerLookupGetResponse::FindASingleContainerByExternalIdentifer(
+ body,
+ ) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_FIND_A_SINGLE_CONTAINER_BY_EXTERNAL_IDENTIFER.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ ContainerLookupGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_LOOKUP_GET_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ ContainerLookupGetResponse::NoSuchContainer(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_LOOKUP_GET_NO_SUCH_CONTAINER
+ .clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ ContainerLookupGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CONTAINER_LOOKUP_GET_GENERIC_ERROR_RESPONSE.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- },
- },
+ Ok(response)
+ }
+ }
+ }
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ContainerLookupGet");
+ "ContainerLookupGet",
+ );
let api_clone = api.clone();
router.post(
@@ -268,15 +377,23 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -285,10 +402,11 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut unused_elements = Vec::new();
- let param_body = if let Some(param_body_raw) = param_body {
+ let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::ContainerEntity> = serde_ignored::deserialize(deserializer, |path| {
+ let param_body: Option<models::ContainerEntity> =
+ serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}).unwrap_or(None);
@@ -296,65 +414,98 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
param_body
} else {
None
- };;
-
+ };
match api.container_post(param_body, context).wait() {
Ok(rsp) => match rsp {
ContainerPostResponse::Created(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_POST_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_POST_CREATED.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
ContainerPostResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_POST_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_POST_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
ContainerPostResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CONTAINER_POST_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CONTAINER_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ContainerPost");
+ "ContainerPost",
+ );
let api_clone = api.clone();
router.get(
@@ -363,75 +514,136 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.creator_id_get(param_id, context).wait() {
- Ok(rsp) => match rsp {
- CreatorIdGetResponse::FetchASingleCreatorById(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_ID_GET_FETCH_A_SINGLE_CREATOR_BY_ID.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- CreatorIdGetResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_ID_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- CreatorIdGetResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- },
+ Ok(rsp) => {
+ match rsp {
+ CreatorIdGetResponse::FetchASingleCreatorById(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATOR_ID_GET_FETCH_A_SINGLE_CREATOR_BY_ID.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ CreatorIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_ID_GET_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ CreatorIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_ID_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ }
+ }
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "CreatorIdGet");
+ "CreatorIdGet",
+ );
let api_clone = api.clone();
router.get(
@@ -440,84 +652,142 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_orcid = query_params.get("orcid")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter orcid".to_string())))?
- .first().ok_or_else(|| Response::with((status::BadRequest, "Required query parameter orcid was empty".to_string())))?
- .parse::<String>().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter orcid - doesn't match schema: {}", e))))?;
-
+ let param_orcid = query_params
+ .get("orcid")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing required query parameter orcid".to_string(),
+ ))
+ })?
+ .first()
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Required query parameter orcid was empty".to_string(),
+ ))
+ })?
+ .parse::<String>()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't parse query parameter orcid - doesn't match schema: {}",
+ e
+ ),
+ ))
+ })?;
match api.creator_lookup_get(param_orcid, context).wait() {
Ok(rsp) => match rsp {
CreatorLookupGetResponse::FindASingleCreatorByExternalIdentifer(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::CREATOR_LOOKUP_GET_FIND_A_SINGLE_CREATOR_BY_EXTERNAL_IDENTIFER.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
CreatorLookupGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_LOOKUP_GET_BAD_REQUEST.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_LOOKUP_GET_BAD_REQUEST.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
CreatorLookupGetResponse::NoSuchCreator(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_LOOKUP_GET_NO_SUCH_CREATOR.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_LOOKUP_GET_NO_SUCH_CREATOR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
CreatorLookupGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_LOOKUP_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_LOOKUP_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "CreatorLookupGet");
+ "CreatorLookupGet",
+ );
let api_clone = api.clone();
router.post(
@@ -526,15 +796,23 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -543,10 +821,11 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut unused_elements = Vec::new();
- let param_body = if let Some(param_body_raw) = param_body {
+ let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::CreatorEntity> = serde_ignored::deserialize(deserializer, |path| {
+ let param_body: Option<models::CreatorEntity> =
+ serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}).unwrap_or(None);
@@ -554,65 +833,98 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
param_body
} else {
None
- };;
-
+ };
match api.creator_post(param_body, context).wait() {
Ok(rsp) => match rsp {
CreatorPostResponse::Created(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_POST_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_POST_CREATED.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
CreatorPostResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_POST_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_POST_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
CreatorPostResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATOR_POST_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::CREATOR_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "CreatorPost");
+ "CreatorPost",
+ );
let api_clone = api.clone();
router.post(
@@ -621,86 +933,146 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.editgroup_id_accept_post(param_id, context).wait() {
- Ok(rsp) => match rsp {
- EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_MERGED_EDITGROUP_SUCCESSFULLY_.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- EditgroupIdAcceptPostResponse::EditgroupIsInAnUnmergableState(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_EDITGROUP_IS_IN_AN_UNMERGABLE_STATE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(rsp) => {
+ match rsp {
+ EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_MERGED_EDITGROUP_SUCCESSFULLY_.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ EditgroupIdAcceptPostResponse::EditgroupIsInAnUnmergableState(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- Ok(response)
- },
- EditgroupIdAcceptPostResponse::NoSuchEditgroup(body) => {
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_EDITGROUP_IS_IN_AN_UNMERGABLE_STATE.clone()));
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_NO_SUCH_EDITGROUP.clone()));
+ Ok(response)
+ }
+ EditgroupIdAcceptPostResponse::NoSuchEditgroup(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_NO_SUCH_EDITGROUP.clone()));
- Ok(response)
- },
- EditgroupIdAcceptPostResponse::GenericErrorResponse(body) => {
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ Ok(response)
+ }
+ EditgroupIdAcceptPostResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_ACCEPT_POST_GENERIC_ERROR_RESPONSE.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- },
- },
+ Ok(response)
+ }
+ }
+ }
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "EditgroupIdAcceptPost");
+ "EditgroupIdAcceptPost",
+ );
let api_clone = api.clone();
router.get(
@@ -709,75 +1081,134 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.editgroup_id_get(param_id, context).wait() {
Ok(rsp) => match rsp {
EditgroupIdGetResponse::FetchEditgroupByIdentifier(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_FETCH_EDITGROUP_BY_IDENTIFIER.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditgroupIdGetResponse::NoSuchEditgroup(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITGROUP_ID_GET_NO_SUCH_EDITGROUP.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_NO_SUCH_EDITGROUP.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditgroupIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITGROUP_ID_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "EditgroupIdGet");
+ "EditgroupIdGet",
+ );
let api_clone = api.clone();
router.post(
@@ -786,66 +1217,99 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
-
match api.editgroup_post(context).wait() {
Ok(rsp) => match rsp {
EditgroupPostResponse::SuccessfullyCreated(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITGROUP_POST_SUCCESSFULLY_CREATED.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_POST_SUCCESSFULLY_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditgroupPostResponse::InvalidRequestParameters(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_POST_INVALID_REQUEST_PARAMETERS.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITGROUP_POST_INVALID_REQUEST_PARAMETERS
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditgroupPostResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_POST_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITGROUP_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "EditgroupPost");
+ "EditgroupPost",
+ );
let api_clone = api.clone();
router.get(
@@ -854,75 +1318,133 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_username = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("username").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter username".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter username: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("username")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter username".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter username: {}", e),
+ ))
+ })?
};
+ match api.editor_username_changelog_get(param_username, context)
+ .wait()
+ {
+ Ok(rsp) => {
+ match rsp {
+ EditorUsernameChangelogGetResponse::FindChanges_(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_FIND_CHANGES_.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ EditorUsernameChangelogGetResponse::UsernameNotFound(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_USERNAME_NOT_FOUND.clone()));
- match api.editor_username_changelog_get(param_username, context).wait() {
- Ok(rsp) => match rsp {
- EditorUsernameChangelogGetResponse::FindChanges_(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_FIND_CHANGES_.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- EditorUsernameChangelogGetResponse::UsernameNotFound(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_USERNAME_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- EditorUsernameChangelogGetResponse::GenericErrorResponse(body) => {
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ Ok(response)
+ }
+ EditorUsernameChangelogGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_CHANGELOG_GET_GENERIC_ERROR_RESPONSE.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- },
- },
+ Ok(response)
+ }
+ }
+ }
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "EditorUsernameChangelogGet");
+ "EditorUsernameChangelogGet",
+ );
let api_clone = api.clone();
router.get(
@@ -931,75 +1453,135 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_username = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("username").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter username".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter username: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("username")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter username".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter username: {}", e),
+ ))
+ })?
};
-
-
match api.editor_username_get(param_username, context).wait() {
Ok(rsp) => match rsp {
EditorUsernameGetResponse::FetchGenericInformationAboutAnEditor(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_GET_FETCH_GENERIC_INFORMATION_ABOUT_AN_EDITOR.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditorUsernameGetResponse::UsernameNotFound(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_GET_USERNAME_NOT_FOUND.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITOR_USERNAME_GET_USERNAME_NOT_FOUND
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
EditorUsernameGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::EDITOR_USERNAME_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITOR_USERNAME_GET_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "EditorUsernameGet");
+ "EditorUsernameGet",
+ );
let api_clone = api.clone();
router.get(
@@ -1008,75 +1590,135 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.file_id_get(param_id, context).wait() {
Ok(rsp) => match rsp {
FileIdGetResponse::FetchASingleFileById(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_ID_GET_FETCH_A_SINGLE_FILE_BY_ID.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_ID_GET_FETCH_A_SINGLE_FILE_BY_ID.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
FileIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_ID_GET_BAD_REQUEST.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_ID_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
FileIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_ID_GET_GENERIC_ERROR_RESPONSE.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "FileIdGet");
+ "FileIdGet",
+ );
let api_clone = api.clone();
router.get(
@@ -1085,84 +1727,142 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_sha1 = query_params.get("sha1")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter sha1".to_string())))?
- .first().ok_or_else(|| Response::with((status::BadRequest, "Required query parameter sha1 was empty".to_string())))?
- .parse::<String>().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter sha1 - doesn't match schema: {}", e))))?;
-
+ let param_sha1 = query_params
+ .get("sha1")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing required query parameter sha1".to_string(),
+ ))
+ })?
+ .first()
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Required query parameter sha1 was empty".to_string(),
+ ))
+ })?
+ .parse::<String>()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't parse query parameter sha1 - doesn't match schema: {}",
+ e
+ ),
+ ))
+ })?;
match api.file_lookup_get(param_sha1, context).wait() {
Ok(rsp) => match rsp {
FileLookupGetResponse::FindASingleFileByExternalIdentifer(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::FILE_LOOKUP_GET_FIND_A_SINGLE_FILE_BY_EXTERNAL_IDENTIFER.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
FileLookupGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_LOOKUP_GET_BAD_REQUEST.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_LOOKUP_GET_BAD_REQUEST.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
FileLookupGetResponse::NoSuchFile(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_LOOKUP_GET_NO_SUCH_FILE.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_LOOKUP_GET_NO_SUCH_FILE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
FileLookupGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_LOOKUP_GET_GENERIC_ERROR_RESPONSE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_LOOKUP_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "FileLookupGet");
+ "FileLookupGet",
+ );
let api_clone = api.clone();
router.post(
@@ -1171,15 +1871,23 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -1188,10 +1896,11 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut unused_elements = Vec::new();
- let param_body = if let Some(param_body_raw) = param_body {
+ let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::FileEntity> = serde_ignored::deserialize(deserializer, |path| {
+ let param_body: Option<models::FileEntity> =
+ serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}).unwrap_or(None);
@@ -1199,65 +1908,98 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
param_body
} else {
None
- };;
-
+ };
match api.file_post(param_body, context).wait() {
Ok(rsp) => match rsp {
FilePostResponse::Created(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_POST_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response
+ .headers
+ .set(ContentType(mimetypes::responses::FILE_POST_CREATED.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
FilePostResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_POST_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_POST_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
FilePostResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::FILE_POST_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::FILE_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "FilePost");
+ "FilePost",
+ );
let api_clone = api.clone();
router.get(
@@ -1266,75 +2008,136 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.release_id_get(param_id, context).wait() {
- Ok(rsp) => match rsp {
- ReleaseIdGetResponse::FetchASingleReleaseById(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_ID_GET_FETCH_A_SINGLE_RELEASE_BY_ID.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- ReleaseIdGetResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_ID_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- ReleaseIdGetResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- },
- },
+ Ok(rsp) => {
+ match rsp {
+ ReleaseIdGetResponse::FetchASingleReleaseById(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::RELEASE_ID_GET_FETCH_A_SINGLE_RELEASE_BY_ID.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ ReleaseIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_ID_GET_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ ReleaseIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_ID_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ }
+ }
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ReleaseIdGet");
+ "ReleaseIdGet",
+ );
let api_clone = api.clone();
router.get(
@@ -1343,84 +2146,142 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_doi = query_params.get("doi")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter doi".to_string())))?
- .first().ok_or_else(|| Response::with((status::BadRequest, "Required query parameter doi was empty".to_string())))?
- .parse::<String>().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter doi - doesn't match schema: {}", e))))?;
-
+ let param_doi = query_params
+ .get("doi")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing required query parameter doi".to_string(),
+ ))
+ })?
+ .first()
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Required query parameter doi was empty".to_string(),
+ ))
+ })?
+ .parse::<String>()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't parse query parameter doi - doesn't match schema: {}",
+ e
+ ),
+ ))
+ })?;
match api.release_lookup_get(param_doi, context).wait() {
Ok(rsp) => match rsp {
ReleaseLookupGetResponse::FindASingleReleaseByExternalIdentifer(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
response.headers.set(ContentType(mimetypes::responses::RELEASE_LOOKUP_GET_FIND_A_SINGLE_RELEASE_BY_EXTERNAL_IDENTIFER.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
ReleaseLookupGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_LOOKUP_GET_BAD_REQUEST.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_LOOKUP_GET_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
ReleaseLookupGetResponse::NoSuchRelease(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_LOOKUP_GET_NO_SUCH_RELEASE.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_LOOKUP_GET_NO_SUCH_RELEASE.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
ReleaseLookupGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_LOOKUP_GET_GENERIC_ERROR_RESPONSE
+ .clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_LOOKUP_GET_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ReleaseLookupGet");
+ "ReleaseLookupGet",
+ );
let api_clone = api.clone();
router.post(
@@ -1429,15 +2290,23 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -1446,10 +2315,11 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut unused_elements = Vec::new();
- let param_body = if let Some(param_body_raw) = param_body {
+ let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::ReleaseEntity> = serde_ignored::deserialize(deserializer, |path| {
+ let param_body: Option<models::ReleaseEntity> =
+ serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}).unwrap_or(None);
@@ -1457,65 +2327,98 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
param_body
} else {
None
- };;
-
+ };
match api.release_post(param_body, context).wait() {
Ok(rsp) => match rsp {
ReleasePostResponse::Created(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_POST_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_POST_CREATED.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
ReleasePostResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_POST_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_POST_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
ReleasePostResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::RELEASE_POST_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::RELEASE_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "ReleasePost");
+ "ReleasePost",
+ );
let api_clone = api.clone();
router.get(
@@ -1524,75 +2427,135 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
// Path parameters
let param_id = {
- let param = req.extensions.get::<Router>().ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("id").ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?;
- percent_decode(param.as_bytes()).decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse().map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))?
+ let param = req.extensions
+ .get::<Router>()
+ .ok_or_else(|| {
+ Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ ))
+ })?
+ .find("id")
+ .ok_or_else(|| {
+ Response::with((
+ status::BadRequest,
+ "Missing path parameter id".to_string(),
+ ))
+ })?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| {
+ Response::with((
+ status::BadRequest,
+ format!(
+ "Couldn't percent-decode path parameter as UTF-8: {}",
+ param
+ ),
+ ))
+ })?
+ .parse()
+ .map_err(|e| {
+ Response::with((
+ status::BadRequest,
+ format!("Couldn't parse path parameter id: {}", e),
+ ))
+ })?
};
-
-
match api.work_id_get(param_id, context).wait() {
Ok(rsp) => match rsp {
WorkIdGetResponse::FetchASingleWorkById(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::WORK_ID_GET_FETCH_A_SINGLE_WORK_BY_ID.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_ID_GET_FETCH_A_SINGLE_WORK_BY_ID.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
WorkIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_ID_GET_BAD_REQUEST.clone()));
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::WORK_ID_GET_BAD_REQUEST.clone(),
+ ));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
WorkIdGetResponse::GenericErrorResponse(body) => {
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::WORK_ID_GET_GENERIC_ERROR_RESPONSE.clone(),
+ ));
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_ID_GET_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "WorkIdGet");
+ "WorkIdGet",
+ );
let api_clone = api.clone();
router.post(
@@ -1601,15 +2564,23 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut context = Context::default();
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> where T: Api {
-
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ fn handle_request<T>(
+ req: &mut Request,
+ api: &T,
+ context: &mut Context,
+ ) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(
+ req.headers
+ .get::<XSpanId>()
+ .map(XSpanId::to_string)
+ .unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()),
+ );
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
-
-
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -1618,10 +2589,11 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
let mut unused_elements = Vec::new();
- let param_body = if let Some(param_body_raw) = param_body {
+ let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
+ let param_body: Option<models::WorkEntity> =
+ serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}).unwrap_or(None);
@@ -1629,66 +2601,98 @@ fn add_routes<T>(router: &mut Router, api: T) where T: Api + Send + Sync + Clone
param_body
} else {
None
- };;
-
+ };
match api.work_post(param_body, context).wait() {
Ok(rsp) => match rsp {
WorkPostResponse::Created(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_POST_CREATED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(201), body_string));
+ response
+ .headers
+ .set(ContentType(mimetypes::responses::WORK_POST_CREATED.clone()));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
WorkPostResponse::BadRequest(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_POST_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::WORK_POST_BAD_REQUEST.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
WorkPostResponse::GenericErrorResponse(body) => {
-
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(0), body_string));
- response.headers.set(ContentType(mimetypes::responses::WORK_POST_GENERIC_ERROR_RESPONSE.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ let body_string = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+
+ let mut response =
+ Response::with((status::Status::from_u16(0), body_string));
+ response.headers.set(ContentType(
+ mimetypes::responses::WORK_POST_GENERIC_ERROR_RESPONSE.clone(),
+ ));
+
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ response.headers.set(Warning(format!(
+ "Ignoring unknown fields in body: {:?}",
+ unused_elements
+ )));
}
Ok(response)
- },
+ }
},
Err(_) => {
// Application code returned an error. This should not happen, as the implementation should
// return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ Err(Response::with((
+ status::InternalServerError,
+ "An internal error occurred".to_string(),
+ )))
}
}
}
handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ context
+ .x_span_id
+ .as_ref()
+ .map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
})
},
- "WorkPost");
-
+ "WorkPost",
+ );
}
/// Middleware to extract authentication data from request
@@ -1696,7 +2700,6 @@ pub struct ExtractAuthData;
impl BeforeMiddleware for ExtractAuthData {
fn before(&self, req: &mut Request) -> IronResult<()> {
-
Ok(())
}
}
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index fa3b3958..59836e31 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -2,172 +2,287 @@
#![allow(unused_imports)]
-use futures::{self, Future};
use chrono;
+use futures::{self, Future};
use std::collections::HashMap;
use swagger;
-use fatcat_api::{Api, ApiError, Context,
- ContainerIdGetResponse,
- ContainerLookupGetResponse,
- ContainerPostResponse,
- CreatorIdGetResponse,
- CreatorLookupGetResponse,
- CreatorPostResponse,
- EditgroupIdAcceptPostResponse,
- EditgroupIdGetResponse,
- EditgroupPostResponse,
- EditorUsernameChangelogGetResponse,
- EditorUsernameGetResponse,
- FileIdGetResponse,
- FileLookupGetResponse,
- FilePostResponse,
- ReleaseIdGetResponse,
- ReleaseLookupGetResponse,
- ReleasePostResponse,
- WorkIdGetResponse,
- WorkPostResponse
-};
use fatcat_api::models;
+use fatcat_api::{Api, ApiError, ContainerIdGetResponse, ContainerLookupGetResponse,
+ ContainerPostResponse, Context, CreatorIdGetResponse, CreatorLookupGetResponse,
+ CreatorPostResponse, EditgroupIdAcceptPostResponse, EditgroupIdGetResponse,
+ EditgroupPostResponse, EditorUsernameChangelogGetResponse,
+ EditorUsernameGetResponse, FileIdGetResponse, FileLookupGetResponse,
+ FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse,
+ ReleasePostResponse, WorkIdGetResponse, WorkPostResponse};
#[derive(Copy, Clone)]
pub struct Server;
impl Api for Server {
-
-
- fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send> {
+ fn container_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send> {
+ fn container_lookup_get(
+ &self,
+ issn: String,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_lookup_get(\"{}\") - X-Span-ID: {:?}", issn, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ issn,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send> {
+ fn container_post(
+ &self,
+ body: Option<models::ContainerEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("container_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "container_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send> {
+ fn creator_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send> {
+ fn creator_lookup_get(
+ &self,
+ orcid: String,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_lookup_get(\"{}\") - X-Span-ID: {:?}", orcid, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ orcid,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn creator_post(&self, body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send> {
+ fn creator_post(
+ &self,
+ body: Option<models::CreatorEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("creator_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "creator_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send> {
+ fn editgroup_id_accept_post(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_id_accept_post({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_id_accept_post({}) - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_id_get(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send> {
+ fn editgroup_id_get(
+ &self,
+ id: i32,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_id_get({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_id_get({}) - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editgroup_post(&self, context: &Context) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send> {
+ fn editgroup_post(
+ &self,
+ context: &Context,
+ ) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editgroup_post() - X-Span-ID: {:?}", context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editgroup_post() - X-Span-ID: {:?}",
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send> {
+ fn editor_username_changelog_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}",
+ username,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn editor_username_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send> {
+ fn editor_username_get(
+ &self,
+ username: String,
+ context: &Context,
+ ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("editor_username_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "editor_username_get(\"{}\") - X-Span-ID: {:?}",
+ username,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_id_get(&self, id: String, context: &Context) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send> {
+ fn file_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send> {
+ fn file_lookup_get(
+ &self,
+ sha1: String,
+ context: &Context,
+ ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_lookup_get(\"{}\") - X-Span-ID: {:?}", sha1, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ sha1,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn file_post(&self, body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send> {
+ fn file_post(
+ &self,
+ body: Option<models::FileEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("file_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "file_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send> {
+ fn release_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send> {
+ fn release_lookup_get(
+ &self,
+ doi: String,
+ context: &Context,
+ ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_lookup_get(\"{}\") - X-Span-ID: {:?}", doi, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_lookup_get(\"{}\") - X-Span-ID: {:?}",
+ doi,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn release_post(&self, body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send> {
+ fn release_post(
+ &self,
+ body: Option<models::ReleaseEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("release_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "release_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send> {
+ fn work_id_get(
+ &self,
+ id: String,
+ context: &Context,
+ ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("work_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "work_id_get(\"{}\") - X-Span-ID: {:?}",
+ id,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
- fn work_post(&self, body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send> {
+ fn work_post(
+ &self,
+ body: Option<models::WorkEntity>,
+ context: &Context,
+ ) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("work_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "work_post({:?}) - X-Span-ID: {:?}",
+ body,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
-
}
diff --git a/rust/src/bin/fatcat-iron.rs b/rust/src/bin/fatcat-iron.rs
index 8c87f55f..4c168981 100644
--- a/rust/src/bin/fatcat-iron.rs
+++ b/rust/src/bin/fatcat-iron.rs
@@ -1,52 +1,28 @@
-//! Main binary entry point for fatcat implementation.
-
#![allow(missing_docs)]
-// Imports required by this file.
+extern crate chrono;
+extern crate clap;
extern crate fatcat;
extern crate fatcat_api;
-extern crate swagger;
-extern crate iron;
-//extern crate hyper_openssl;
-extern crate clap;
-
-// Imports required by server library.
-// extern crate fatcat;
-// extern crate swagger;
extern crate futures;
-extern crate chrono;
+extern crate iron;
+extern crate swagger;
#[macro_use]
extern crate error_chain;
-//use hyper_openssl::OpensslServer;
-//use hyper_openssl::openssl::x509::X509_FILETYPE_PEM;
-//use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod};
-//use hyper_openssl::openssl::error::ErrorStack;
use clap::{App, Arg};
-use iron::{Iron, Chain};
+use iron::{Chain, Iron};
use swagger::auth::AllowAllMiddleware;
-/*
-/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
-fn ssl() -> Result<OpensslServer, ErrorStack> {
- let mut ssl = SslAcceptorBuilder::mozilla_intermediate_raw(SslMethod::tls())?;
-
- // Server authentication
- ssl.set_private_key_file("examples/server-key.pem", X509_FILETYPE_PEM)?;
- ssl.set_certificate_chain_file("examples/server-chain.pem")?;
- ssl.check_private_key()?;
-
- Ok(OpensslServer::from(ssl.build()))
-}
-*/
-
/// Create custom server, wire it to the autogenerated router,
/// and pass it to the web server.
fn main() {
let matches = App::new("server")
- .arg(Arg::with_name("https")
- .long("https")
- .help("Whether to use HTTPS or not"))
+ .arg(
+ Arg::with_name("https")
+ .long("https")
+ .help("Whether to use HTTPS or not"),
+ )
.get_matches();
let server = fatcat::server().unwrap();
@@ -60,10 +36,10 @@ fn main() {
if matches.is_present("https") {
unimplemented!()
- // Using Simple HTTPS
- //Iron::new(chain).https("localhost:8080", ssl().expect("Failed to load SSL keys")).expect("Failed to start HTTPS server");
} else {
// Using HTTP
- Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server");
+ Iron::new(chain)
+ .http("localhost:8080")
+ .expect("Failed to start HTTP server");
}
}