diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-09-19 00:38:00 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2020-05-10 13:08:45 -0700 |
commit | a9b23947c49275a11765c8a752c154b98c69b531 (patch) | |
tree | 0c8bef53cfb66b81996721fcab92d90ec1c4376c /rust/fatcat-openapi/examples | |
parent | 228a9245ea3680e11164f58367310406402d306b (diff) | |
download | fatcat-a9b23947c49275a11765c8a752c154b98c69b531.tar.gz fatcat-a9b23947c49275a11765c8a752c154b98c69b531.zip |
WIP: update rust codegen script
Only Cargo.toml project metadata updated.
Diffstat (limited to 'rust/fatcat-openapi/examples')
-rw-r--r-- | rust/fatcat-openapi/examples/client.rs | 691 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/client/main.rs | 1139 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server.rs | 59 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server/main.rs | 25 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server/server.rs | 1691 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server_lib/mod.rs | 14 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server_lib/server.rs | 1081 |
7 files changed, 2855 insertions, 1845 deletions
diff --git a/rust/fatcat-openapi/examples/client.rs b/rust/fatcat-openapi/examples/client.rs deleted file mode 100644 index 5ed6122a..00000000 --- a/rust/fatcat-openapi/examples/client.rs +++ /dev/null @@ -1,691 +0,0 @@ -#![allow(missing_docs, unused_variables, trivial_casts)] - -use fatcat_openapi; -#[allow(unused_extern_crates)] -extern crate futures; -#[allow(unused_extern_crates)] -extern crate swagger; -#[allow(unused_extern_crates)] -extern crate uuid; - -use clap::{App, Arg}; -#[allow(unused_imports)] -use fatcat_openapi::{ - AcceptEditgroupResponse, ApiError, ApiNoContext, AuthCheckResponse, AuthOidcResponse, ContextWrapperExt, CreateAuthTokenResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, - CreateCreatorAutoBatchResponse, CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, - CreateFilesetResponse, CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, - DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, - DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, - GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, - GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, - GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, - UpdateWebcaptureResponse, UpdateWorkResponse, -}; -#[allow(unused_imports)] -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(&[ - "AuthCheck", - "CreateAuthToken", - "GetChangelog", - "GetChangelogEntry", - "DeleteContainer", - "DeleteContainerEdit", - "GetContainer", - "GetContainerEdit", - "GetContainerHistory", - "GetContainerRedirects", - "GetContainerRevision", - "LookupContainer", - "DeleteCreator", - "DeleteCreatorEdit", - "GetCreator", - "GetCreatorEdit", - "GetCreatorHistory", - "GetCreatorRedirects", - "GetCreatorReleases", - "GetCreatorRevision", - "LookupCreator", - "AcceptEditgroup", - "GetEditgroup", - "GetEditgroupAnnotations", - "GetEditgroupsReviewable", - "GetEditor", - "GetEditorAnnotations", - "GetEditorEditgroups", - "DeleteFile", - "DeleteFileEdit", - "GetFile", - "GetFileEdit", - "GetFileHistory", - "GetFileRedirects", - "GetFileRevision", - "LookupFile", - "DeleteFileset", - "DeleteFilesetEdit", - "GetFileset", - "GetFilesetEdit", - "GetFilesetHistory", - "GetFilesetRedirects", - "GetFilesetRevision", - "DeleteRelease", - "DeleteReleaseEdit", - "GetRelease", - "GetReleaseEdit", - "GetReleaseFiles", - "GetReleaseFilesets", - "GetReleaseHistory", - "GetReleaseRedirects", - "GetReleaseRevision", - "GetReleaseWebcaptures", - "LookupRelease", - "DeleteWebcapture", - "DeleteWebcaptureEdit", - "GetWebcapture", - "GetWebcaptureEdit", - "GetWebcaptureHistory", - "GetWebcaptureRedirects", - "GetWebcaptureRevision", - "DeleteWork", - "DeleteWorkEdit", - "GetWork", - "GetWorkEdit", - "GetWorkHistory", - "GetWorkRedirects", - "GetWorkReleases", - "GetWorkRevision", - ]) - .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 client = if is_https { - // Using Simple HTTPS - fatcat_openapi::Client::try_new_https(&base_url, "examples/ca.pem").expect("Failed to create HTTPS client") - } else { - // Using HTTP - fatcat_openapi::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_openapi::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string())); - - match matches.value_of("operation") { - Some("AuthCheck") => { - let result = client.auth_check(Some("role_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("AuthOidc") => { - // let result = client.auth_oidc(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateAuthToken") => { - let result = client.create_auth_token("editor_id_example".to_string(), Some(56)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetChangelog") => { - let result = client.get_changelog(Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetChangelogEntry") => { - let result = client.get_changelog_entry(789).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateContainer") => { - // let result = client.create_container("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateContainerAutoBatch") => { - // let result = client.create_container_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteContainer") => { - let result = client.delete_container("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteContainerEdit") => { - let result = client.delete_container_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainer") => { - let result = client - .get_container("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainerEdit") => { - let result = client.get_container_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainerHistory") => { - let result = client.get_container_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainerRedirects") => { - let result = client.get_container_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainerRevision") => { - let result = client - .get_container_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupContainer") => { - let result = client - .lookup_container( - Some("issnl_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateContainer") => { - // let result = client.update_container("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateCreator") => { - // let result = client.create_creator("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateCreatorAutoBatch") => { - // let result = client.create_creator_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteCreator") => { - let result = client.delete_creator("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteCreatorEdit") => { - let result = client.delete_creator_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreator") => { - let result = client - .get_creator("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreatorEdit") => { - let result = client.get_creator_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreatorHistory") => { - let result = client.get_creator_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreatorRedirects") => { - let result = client.get_creator_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreatorReleases") => { - let result = client.get_creator_releases("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetCreatorRevision") => { - let result = client - .get_creator_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupCreator") => { - let result = client - .lookup_creator( - Some("orcid_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateCreator") => { - // let result = client.update_creator("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("AcceptEditgroup") => { - let result = client.accept_editgroup("editgroup_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateEditgroup") => { - // let result = client.create_editgroup(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateEditgroupAnnotation") => { - // let result = client.create_editgroup_annotation("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("GetEditgroup") => { - let result = client.get_editgroup("editgroup_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditgroupAnnotations") => { - let result = client.get_editgroup_annotations("editgroup_id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditgroupsReviewable") => { - let result = client.get_editgroups_reviewable(Some("expand_example".to_string()), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateEditgroup") => { - // let result = client.update_editgroup("editgroup_id_example".to_string(), ???, Some(true)).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("GetEditor") => { - let result = client.get_editor("editor_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditorAnnotations") => { - let result = client.get_editor_annotations("editor_id_example".to_string(), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditorEditgroups") => { - let result = client.get_editor_editgroups("editor_id_example".to_string(), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateEditor") => { - // let result = client.update_editor("editor_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateFile") => { - // let result = client.create_file("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateFileAutoBatch") => { - // let result = client.create_file_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteFile") => { - let result = client.delete_file("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteFileEdit") => { - let result = client.delete_file_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFile") => { - let result = client - .get_file("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFileEdit") => { - let result = client.get_file_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFileHistory") => { - let result = client.get_file_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFileRedirects") => { - let result = client.get_file_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFileRevision") => { - let result = client - .get_file_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupFile") => { - let result = client - .lookup_file( - Some("md5_example".to_string()), - Some("sha1_example".to_string()), - Some("sha256_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateFile") => { - // let result = client.update_file("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateFileset") => { - // let result = client.create_fileset("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateFilesetAutoBatch") => { - // let result = client.create_fileset_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteFileset") => { - let result = client.delete_fileset("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteFilesetEdit") => { - let result = client.delete_fileset_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFileset") => { - let result = client - .get_fileset("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFilesetEdit") => { - let result = client.get_fileset_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFilesetHistory") => { - let result = client.get_fileset_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFilesetRedirects") => { - let result = client.get_fileset_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFilesetRevision") => { - let result = client - .get_fileset_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateFileset") => { - // let result = client.update_fileset("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateRelease") => { - // let result = client.create_release("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateReleaseAutoBatch") => { - // let result = client.create_release_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteRelease") => { - let result = client.delete_release("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteReleaseEdit") => { - let result = client.delete_release_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetRelease") => { - let result = client - .get_release("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseEdit") => { - let result = client.get_release_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseFiles") => { - let result = client.get_release_files("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseFilesets") => { - let result = client.get_release_filesets("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseHistory") => { - let result = client.get_release_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseRedirects") => { - let result = client.get_release_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseRevision") => { - let result = client - .get_release_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseWebcaptures") => { - let result = client.get_release_webcaptures("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupRelease") => { - let result = client - .lookup_release( - Some("doi_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("isbn13_example".to_string()), - Some("pmid_example".to_string()), - Some("pmcid_example".to_string()), - Some("core_example".to_string()), - Some("arxiv_example".to_string()), - Some("jstor_example".to_string()), - Some("ark_example".to_string()), - Some("mag_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateRelease") => { - // let result = client.update_release("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateWebcapture") => { - // let result = client.create_webcapture("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateWebcaptureAutoBatch") => { - // let result = client.create_webcapture_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteWebcapture") => { - let result = client.delete_webcapture("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteWebcaptureEdit") => { - let result = client.delete_webcapture_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWebcapture") => { - let result = client - .get_webcapture("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWebcaptureEdit") => { - let result = client.get_webcapture_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWebcaptureHistory") => { - let result = client.get_webcapture_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWebcaptureRedirects") => { - let result = client.get_webcapture_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWebcaptureRevision") => { - let result = client - .get_webcapture_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateWebcapture") => { - // let result = client.update_webcapture("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateWork") => { - // let result = client.create_work("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateWorkAutoBatch") => { - // let result = client.create_work_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("DeleteWork") => { - let result = client.delete_work("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteWorkEdit") => { - let result = client.delete_work_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWork") => { - let result = client - .get_work("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWorkEdit") => { - let result = client.get_work_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWorkHistory") => { - let result = client.get_work_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWorkRedirects") => { - let result = client.get_work_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWorkReleases") => { - let result = client.get_work_releases("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWorkRevision") => { - let result = client - .get_work_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateWork") => { - // let result = client.update_work("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // 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-openapi/examples/client/main.rs b/rust/fatcat-openapi/examples/client/main.rs new file mode 100644 index 00000000..0bc66626 --- /dev/null +++ b/rust/fatcat-openapi/examples/client/main.rs @@ -0,0 +1,1139 @@ +#![allow(missing_docs, unused_variables, trivial_casts)] + +use clap::{App, Arg}; +#[allow(unused_imports)] +use fatcat_openapi::{ + models, AcceptEditgroupResponse, Api, ApiError, ApiNoContext, AuthCheckResponse, + AuthOidcResponse, Client, ContextWrapperExt, CreateAuthTokenResponse, + CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, + CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, + CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, + CreateFilesetResponse, CreateReleaseAutoBatchResponse, CreateReleaseResponse, + CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, + CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, + DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, + DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, + DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, + GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, + GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, + GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, + GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, + GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, + GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, + GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, + GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, + GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, + GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, + GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, + GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, + GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, + GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, + GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, + LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, + UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, + UpdateWebcaptureResponse, UpdateWorkResponse, +}; +#[allow(unused_imports)] +use futures::{future, stream, Future, Stream}; + +#[allow(unused_imports)] +use log::info; + +// swagger::Has may be unused if there are no examples +#[allow(unused_imports)] +use swagger::{AuthData, ContextBuilder, EmptyContext, Has, Push, XSpanIdString}; + +// rt may be unused if there are no examples +#[allow(unused_mut)] +fn main() { + env_logger::init(); + + let matches = App::new("client") + .arg( + Arg::with_name("operation") + .help("Sets the operation to run") + .possible_values(&[ + "AcceptEditgroup", + "AuthCheck", + "CreateAuthToken", + "DeleteContainer", + "DeleteContainerEdit", + "DeleteCreator", + "DeleteCreatorEdit", + "DeleteFile", + "DeleteFileEdit", + "DeleteFileset", + "DeleteFilesetEdit", + "DeleteRelease", + "DeleteReleaseEdit", + "DeleteWebcapture", + "DeleteWebcaptureEdit", + "DeleteWork", + "DeleteWorkEdit", + "GetChangelog", + "GetChangelogEntry", + "GetContainer", + "GetContainerEdit", + "GetContainerHistory", + "GetContainerRedirects", + "GetContainerRevision", + "GetCreator", + "GetCreatorEdit", + "GetCreatorHistory", + "GetCreatorRedirects", + "GetCreatorReleases", + "GetCreatorRevision", + "GetEditgroup", + "GetEditgroupAnnotations", + "GetEditgroupsReviewable", + "GetEditor", + "GetEditorAnnotations", + "GetEditorEditgroups", + "GetFile", + "GetFileEdit", + "GetFileHistory", + "GetFileRedirects", + "GetFileRevision", + "GetFileset", + "GetFilesetEdit", + "GetFilesetHistory", + "GetFilesetRedirects", + "GetFilesetRevision", + "GetRelease", + "GetReleaseEdit", + "GetReleaseFiles", + "GetReleaseFilesets", + "GetReleaseHistory", + "GetReleaseRedirects", + "GetReleaseRevision", + "GetReleaseWebcaptures", + "GetWebcapture", + "GetWebcaptureEdit", + "GetWebcaptureHistory", + "GetWebcaptureRedirects", + "GetWebcaptureRevision", + "GetWork", + "GetWorkEdit", + "GetWorkHistory", + "GetWorkRedirects", + "GetWorkReleases", + "GetWorkRevision", + "LookupContainer", + "LookupCreator", + "LookupFile", + "LookupRelease", + ]) + .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 client = if matches.is_present("https") { + // Using Simple HTTPS + Client::try_new_https(&base_url).expect("Failed to create HTTPS client") + } else { + // Using HTTP + Client::try_new_http(&base_url).expect("Failed to create HTTP client") + }; + + let context: swagger::make_context_ty!( + ContextBuilder, + EmptyContext, + Option<AuthData>, + XSpanIdString + ) = swagger::make_context!( + ContextBuilder, + EmptyContext, + None as Option<AuthData>, + XSpanIdString::default() + ); + + let client = client.with_context(context); + + let mut rt = tokio::runtime::Runtime::new().unwrap(); + + match matches.value_of("operation") { + Some("AcceptEditgroup") => { + let result = rt.block_on(client.accept_editgroup("editgroup_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("AuthCheck") => { + let result = rt.block_on(client.auth_check(Some("role_example".to_string()))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + /* Disabled because there's no example. + Some("AuthOidc") => { + let result = rt.block_on(client.auth_oidc( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + Some("CreateAuthToken") => { + let result = + rt.block_on(client.create_auth_token("editor_id_example".to_string(), Some(56))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + /* Disabled because there's no example. + Some("CreateContainer") => { + let result = rt.block_on(client.create_container( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateContainerAutoBatch") => { + let result = rt.block_on(client.create_container_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateCreator") => { + let result = rt.block_on(client.create_creator( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateCreatorAutoBatch") => { + let result = rt.block_on(client.create_creator_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateEditgroup") => { + let result = rt.block_on(client.create_editgroup( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateEditgroupAnnotation") => { + let result = rt.block_on(client.create_editgroup_annotation( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateFile") => { + let result = rt.block_on(client.create_file( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateFileAutoBatch") => { + let result = rt.block_on(client.create_file_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateFileset") => { + let result = rt.block_on(client.create_fileset( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateFilesetAutoBatch") => { + let result = rt.block_on(client.create_fileset_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateRelease") => { + let result = rt.block_on(client.create_release( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateReleaseAutoBatch") => { + let result = rt.block_on(client.create_release_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateWebcapture") => { + let result = rt.block_on(client.create_webcapture( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateWebcaptureAutoBatch") => { + let result = rt.block_on(client.create_webcapture_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateWork") => { + let result = rt.block_on(client.create_work( + "editgroup_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("CreateWorkAutoBatch") => { + let result = rt.block_on(client.create_work_auto_batch( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + Some("DeleteContainer") => { + let result = rt.block_on(client.delete_container( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteContainerEdit") => { + let result = rt.block_on(client.delete_container_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteCreator") => { + let result = rt.block_on(client.delete_creator( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteCreatorEdit") => { + let result = rt.block_on(client.delete_creator_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteFile") => { + let result = rt.block_on(client.delete_file( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteFileEdit") => { + let result = rt.block_on(client.delete_file_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteFileset") => { + let result = rt.block_on(client.delete_fileset( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteFilesetEdit") => { + let result = rt.block_on(client.delete_fileset_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteRelease") => { + let result = rt.block_on(client.delete_release( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteReleaseEdit") => { + let result = rt.block_on(client.delete_release_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteWebcapture") => { + let result = rt.block_on(client.delete_webcapture( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteWebcaptureEdit") => { + let result = rt.block_on(client.delete_webcapture_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteWork") => { + let result = rt.block_on(client.delete_work( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("DeleteWorkEdit") => { + let result = rt.block_on(client.delete_work_edit( + "editgroup_id_example".to_string(), + "edit_id_example".to_string(), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetChangelog") => { + let result = rt.block_on(client.get_changelog(Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetChangelogEntry") => { + let result = rt.block_on(client.get_changelog_entry(789)); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetContainer") => { + let result = rt.block_on(client.get_container( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetContainerEdit") => { + let result = rt.block_on(client.get_container_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetContainerHistory") => { + let result = + rt.block_on(client.get_container_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetContainerRedirects") => { + let result = rt.block_on(client.get_container_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetContainerRevision") => { + let result = rt.block_on(client.get_container_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreator") => { + let result = rt.block_on(client.get_creator( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreatorEdit") => { + let result = rt.block_on(client.get_creator_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreatorHistory") => { + let result = + rt.block_on(client.get_creator_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreatorRedirects") => { + let result = rt.block_on(client.get_creator_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreatorReleases") => { + let result = rt.block_on(client.get_creator_releases( + "ident_example".to_string(), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetCreatorRevision") => { + let result = rt.block_on(client.get_creator_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditgroup") => { + let result = rt.block_on(client.get_editgroup("editgroup_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditgroupAnnotations") => { + let result = rt.block_on(client.get_editgroup_annotations( + "editgroup_id_example".to_string(), + Some("expand_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditgroupsReviewable") => { + let result = rt.block_on(client.get_editgroups_reviewable( + Some("expand_example".to_string()), + Some(789), + None, + None, + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditor") => { + let result = rt.block_on(client.get_editor("editor_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditorAnnotations") => { + let result = rt.block_on(client.get_editor_annotations( + "editor_id_example".to_string(), + Some(789), + None, + None, + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetEditorEditgroups") => { + let result = rt.block_on(client.get_editor_editgroups( + "editor_id_example".to_string(), + Some(789), + None, + None, + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFile") => { + let result = rt.block_on(client.get_file( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFileEdit") => { + let result = rt.block_on(client.get_file_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFileHistory") => { + let result = + rt.block_on(client.get_file_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFileRedirects") => { + let result = rt.block_on(client.get_file_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFileRevision") => { + let result = rt.block_on(client.get_file_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFileset") => { + let result = rt.block_on(client.get_fileset( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFilesetEdit") => { + let result = rt.block_on(client.get_fileset_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFilesetHistory") => { + let result = + rt.block_on(client.get_fileset_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFilesetRedirects") => { + let result = rt.block_on(client.get_fileset_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetFilesetRevision") => { + let result = rt.block_on(client.get_fileset_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetRelease") => { + let result = rt.block_on(client.get_release( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseEdit") => { + let result = rt.block_on(client.get_release_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseFiles") => { + let result = rt.block_on(client.get_release_files( + "ident_example".to_string(), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseFilesets") => { + let result = rt.block_on(client.get_release_filesets( + "ident_example".to_string(), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseHistory") => { + let result = + rt.block_on(client.get_release_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseRedirects") => { + let result = rt.block_on(client.get_release_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseRevision") => { + let result = rt.block_on(client.get_release_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetReleaseWebcaptures") => { + let result = rt.block_on(client.get_release_webcaptures( + "ident_example".to_string(), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWebcapture") => { + let result = rt.block_on(client.get_webcapture( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWebcaptureEdit") => { + let result = rt.block_on(client.get_webcapture_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWebcaptureHistory") => { + let result = + rt.block_on(client.get_webcapture_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWebcaptureRedirects") => { + let result = rt.block_on(client.get_webcapture_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWebcaptureRevision") => { + let result = rt.block_on(client.get_webcapture_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWork") => { + let result = rt.block_on(client.get_work( + "ident_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWorkEdit") => { + let result = rt.block_on(client.get_work_edit("edit_id_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWorkHistory") => { + let result = + rt.block_on(client.get_work_history("ident_example".to_string(), Some(789))); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWorkRedirects") => { + let result = rt.block_on(client.get_work_redirects("ident_example".to_string())); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWorkReleases") => { + let result = rt.block_on(client.get_work_releases( + "ident_example".to_string(), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("GetWorkRevision") => { + let result = rt.block_on(client.get_work_revision( + "rev_id_example".to_string(), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("LookupContainer") => { + let result = rt.block_on(client.lookup_container( + Some("issnl_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("LookupCreator") => { + let result = rt.block_on(client.lookup_creator( + Some("orcid_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("LookupFile") => { + let result = rt.block_on(client.lookup_file( + Some("md5_example".to_string()), + Some("sha1_example".to_string()), + Some("sha256_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + Some("LookupRelease") => { + let result = rt.block_on(client.lookup_release( + Some("doi_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("isbn13_example".to_string()), + Some("pmid_example".to_string()), + Some("pmcid_example".to_string()), + Some("core_example".to_string()), + Some("arxiv_example".to_string()), + Some("jstor_example".to_string()), + Some("ark_example".to_string()), + Some("mag_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + )); + info!( + "{:?} (X-Span-ID: {:?})", + result, + (client.context() as &dyn Has<XSpanIdString>).get().clone() + ); + } + /* Disabled because there's no example. + Some("UpdateContainer") => { + let result = rt.block_on(client.update_container( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateCreator") => { + let result = rt.block_on(client.update_creator( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateEditgroup") => { + let result = rt.block_on(client.update_editgroup( + "editgroup_id_example".to_string(), + ???, + Some(true) + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateEditor") => { + let result = rt.block_on(client.update_editor( + "editor_id_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateFile") => { + let result = rt.block_on(client.update_file( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateFileset") => { + let result = rt.block_on(client.update_fileset( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateRelease") => { + let result = rt.block_on(client.update_release( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateWebcapture") => { + let result = rt.block_on(client.update_webcapture( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + /* Disabled because there's no example. + Some("UpdateWork") => { + let result = rt.block_on(client.update_work( + "editgroup_id_example".to_string(), + "ident_example".to_string(), + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone()); + }, + */ + _ => panic!("Invalid operation provided"), + } +} diff --git a/rust/fatcat-openapi/examples/server.rs b/rust/fatcat-openapi/examples/server.rs deleted file mode 100644 index a033413b..00000000 --- a/rust/fatcat-openapi/examples/server.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! Main binary entry point for fatcat implementation. - -#![allow(missing_docs)] - -// Imports required by this file. -// extern crate <name of this crate>; -use fatcat_openapi; - -// Imports required by server library. -// extern crate fatcat_openapi; -// extern crate swagger; -use chrono; -use futures; -#[macro_use] -extern crate error_chain; - -use clap::{App, Arg}; -use hyper_openssl::openssl::error::ErrorStack; -use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod}; -use hyper_openssl::openssl::x509::X509_FILETYPE_PEM; -use hyper_openssl::OpensslServer; -use iron::{Chain, Iron}; - -mod server_lib; - -/// 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")).get_matches(); - - let server = server_lib::server().unwrap(); - let router = fatcat_openapi::router(server); - - let mut chain = Chain::new(router); - chain.link_before(fatcat_openapi::server::ExtractAuthData); - // add authentication middlewares into the chain here - // for the purpose of this example, pretend we have authenticated a user - //chain.link_before(AllowAllMiddleware::new("cosmo")); - - 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"); - } else { - // Using HTTP - Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server"); - } -} diff --git a/rust/fatcat-openapi/examples/server/main.rs b/rust/fatcat-openapi/examples/server/main.rs new file mode 100644 index 00000000..af089c2f --- /dev/null +++ b/rust/fatcat-openapi/examples/server/main.rs @@ -0,0 +1,25 @@ +//! Main binary entry point for fatcat_openapi implementation. + +#![allow(missing_docs)] + +use clap::{App, Arg}; + +mod server; + +/// Create custom server, wire it to the autogenerated router, +/// and pass it to the web server. +fn main() { + env_logger::init(); + + let matches = App::new("server") + .arg( + Arg::with_name("https") + .long("https") + .help("Whether to use HTTPS or not"), + ) + .get_matches(); + + let addr = "127.0.0.1:8080"; + + hyper::rt::run(server::create(addr, matches.is_present("https"))); +} diff --git a/rust/fatcat-openapi/examples/server/server.rs b/rust/fatcat-openapi/examples/server/server.rs new file mode 100644 index 00000000..30f8bfed --- /dev/null +++ b/rust/fatcat-openapi/examples/server/server.rs @@ -0,0 +1,1691 @@ +//! Main library entry point for fatcat_openapi implementation. + +#![allow(unused_imports)] + +mod errors { + error_chain::error_chain! {} +} + +pub use self::errors::*; + +use chrono; +use futures::{future, Future, Stream}; +use hyper::server::conn::Http; +use hyper::service::MakeService as _; +use log::info; +use openssl::ssl::SslAcceptorBuilder; +use std::marker::PhantomData; +use std::net::SocketAddr; +use std::sync::{Arc, Mutex}; +use swagger; +use swagger::auth::MakeAllowAllAuthenticator; +use swagger::EmptyContext; +use swagger::{Has, XSpanIdString}; +use tokio::net::TcpListener; + +#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] +use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; +#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] +use tokio_openssl::SslAcceptorExt; + +use fatcat_openapi::models; + +#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] +/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names +pub fn create(addr: &str, https: bool) -> Box<dyn Future<Item = (), Error = ()> + Send> { + let addr = addr.parse().expect("Failed to parse bind address"); + + let server = Server::new(); + + let service_fn = MakeService::new(server); + + let service_fn = MakeAllowAllAuthenticator::new(service_fn, "cosmo"); + + let service_fn = + fatcat_openapi::server::context::MakeAddContext::<_, EmptyContext>::new(service_fn); + + if https { + #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))] + { + unimplemented!("SSL is not implemented for the examples on MacOS, Windows or iOS"); + } + + #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] + { + let mut ssl = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls()) + .expect("Failed to create SSL Acceptor"); + + // Server authentication + ssl.set_private_key_file("examples/server-key.pem", SslFiletype::PEM) + .expect("Failed to set private key"); + ssl.set_certificate_chain_file("examples/server-chain.pem") + .expect("Failed to set cerificate chain"); + ssl.check_private_key() + .expect("Failed to check private key"); + + let tls_acceptor = ssl.build(); + let service_fn = Arc::new(Mutex::new(service_fn)); + let tls_listener = TcpListener::bind(&addr) + .unwrap() + .incoming() + .for_each(move |tcp| { + let addr = tcp.peer_addr().expect("Unable to get remote address"); + + let service_fn = service_fn.clone(); + + hyper::rt::spawn(tls_acceptor.accept_async(tcp).map_err(|_| ()).and_then( + move |tls| { + let ms = { + let mut service_fn = service_fn.lock().unwrap(); + service_fn.make_service(&addr) + }; + + ms.and_then(move |service| Http::new().serve_connection(tls, service)) + .map_err(|_| ()) + }, + )); + + Ok(()) + }) + .map_err(|_| ()); + + Box::new(tls_listener) + } + } else { + // Using HTTP + Box::new( + hyper::server::Server::bind(&addr) + .serve(service_fn) + .map_err(|e| panic!("{:?}", e)), + ) + } +} + +#[derive(Copy, Clone)] +pub struct Server<C> { + marker: PhantomData<C>, +} + +impl<C> Server<C> { + pub fn new() -> Self { + Server { + marker: PhantomData, + } + } +} + +use fatcat_openapi::server::MakeService; +use fatcat_openapi::{ + AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse, + CreateAuthTokenResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, + CreateCreatorAutoBatchResponse, CreateCreatorResponse, CreateEditgroupAnnotationResponse, + CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, + CreateFilesetAutoBatchResponse, CreateFilesetResponse, CreateReleaseAutoBatchResponse, + CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, + CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, + DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, + DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, + DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, + DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, + GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, + GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, + GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, + GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, + GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, + GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, + GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, + GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, + GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, + GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, + GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, + GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, + GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, + GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, + GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, + LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, + UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, + UpdateWorkResponse, +}; + +impl<C> Api<C> for Server<C> +where + C: Has<XSpanIdString>, +{ + fn accept_editgroup( + &self, + editgroup_id: String, + context: &C, + ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "accept_editgroup(\"{}\") - X-Span-ID: {:?}", + editgroup_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn auth_check( + &self, + role: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "auth_check({:?}) - X-Span-ID: {:?}", + role, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn auth_oidc( + &self, + oidc_params: models::AuthOidc, + context: &C, + ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "auth_oidc({:?}) - X-Span-ID: {:?}", + oidc_params, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_auth_token( + &self, + editor_id: String, + duration_seconds: Option<i32>, + context: &C, + ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_auth_token(\"{}\", {:?}) - X-Span-ID: {:?}", + editor_id, + duration_seconds, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_container( + &self, + editgroup_id: String, + entity: models::ContainerEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_container(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_container_auto_batch( + &self, + auto_batch: models::ContainerAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_container_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_creator( + &self, + editgroup_id: String, + entity: models::CreatorEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_creator(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_creator_auto_batch( + &self, + auto_batch: models::CreatorAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_creator_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_editgroup( + &self, + editgroup: models::Editgroup, + context: &C, + ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_editgroup({:?}) - X-Span-ID: {:?}", + editgroup, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_editgroup_annotation( + &self, + editgroup_id: String, + annotation: models::EditgroupAnnotation, + context: &C, + ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + annotation, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_file( + &self, + editgroup_id: String, + entity: models::FileEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_file(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_file_auto_batch( + &self, + auto_batch: models::FileAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_file_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_fileset( + &self, + editgroup_id: String, + entity: models::FilesetEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_fileset(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_fileset_auto_batch( + &self, + auto_batch: models::FilesetAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_fileset_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_release( + &self, + editgroup_id: String, + entity: models::ReleaseEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_release(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_release_auto_batch( + &self, + auto_batch: models::ReleaseAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_release_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_webcapture( + &self, + editgroup_id: String, + entity: models::WebcaptureEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_webcapture_auto_batch( + &self, + auto_batch: models::WebcaptureAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_webcapture_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_work( + &self, + editgroup_id: String, + entity: models::WorkEntity, + context: &C, + ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_work(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn create_work_auto_batch( + &self, + auto_batch: models::WorkAutoBatch, + context: &C, + ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "create_work_auto_batch({:?}) - X-Span-ID: {:?}", + auto_batch, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_container( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_container_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_container_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_creator( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_creator_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_creator_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_file( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_file_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_file_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_fileset( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_fileset_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_fileset_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_release( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_release_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_release_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_webcapture( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_webcapture_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_webcapture_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_work( + &self, + editgroup_id: String, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn delete_work_edit( + &self, + editgroup_id: String, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "delete_work_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", + editgroup_id, + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_changelog( + &self, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_changelog({:?}) - X-Span-ID: {:?}", + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_changelog_entry( + &self, + index: i64, + context: &C, + ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_changelog_entry({}) - X-Span-ID: {:?}", + index, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_container( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_container_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_container_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_container_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_container_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_container_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_container_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator_releases( + &self, + ident: String, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_creator_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editgroup( + &self, + editgroup_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editgroup(\"{}\") - X-Span-ID: {:?}", + editgroup_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editgroup_annotations( + &self, + editgroup_id: String, + expand: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + expand, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editgroups_reviewable( + &self, + expand: Option<String>, + limit: Option<i64>, + before: Option<chrono::DateTime<chrono::Utc>>, + since: Option<chrono::DateTime<chrono::Utc>>, + context: &C, + ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + expand, + limit, + before, + since, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editor( + &self, + editor_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editor(\"{}\") - X-Span-ID: {:?}", + editor_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editor_annotations( + &self, + editor_id: String, + limit: Option<i64>, + before: Option<chrono::DateTime<chrono::Utc>>, + since: Option<chrono::DateTime<chrono::Utc>>, + context: &C, + ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + editor_id, + limit, + before, + since, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_editor_editgroups( + &self, + editor_id: String, + limit: Option<i64>, + before: Option<chrono::DateTime<chrono::Utc>>, + since: Option<chrono::DateTime<chrono::Utc>>, + context: &C, + ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + editor_id, + limit, + before, + since, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_file( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_file_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_file_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_file_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_file_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_file_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_file_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_fileset( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_fileset_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_fileset_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_fileset_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_fileset_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_fileset_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_fileset_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_fileset_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_fileset_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_files( + &self, + ident: String, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_filesets( + &self, + ident: String, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_filesets(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_release_webcaptures( + &self, + ident: String, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_release_webcaptures(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_webcapture( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_webcapture_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_webcapture_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_webcapture_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_webcapture_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_webcapture_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_webcapture_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_webcapture_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_webcapture_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work( + &self, + ident: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + ident, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work_edit( + &self, + edit_id: String, + context: &C, + ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work_edit(\"{}\") - X-Span-ID: {:?}", + edit_id, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work_history( + &self, + ident: String, + limit: Option<i64>, + context: &C, + ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + limit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work_redirects( + &self, + ident: String, + context: &C, + ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work_redirects(\"{}\") - X-Span-ID: {:?}", + ident, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work_releases( + &self, + ident: String, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}", + ident, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn get_work_revision( + &self, + rev_id: String, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + rev_id, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn lookup_container( + &self, + issnl: Option<String>, + wikidata_qid: Option<String>, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + issnl, + wikidata_qid, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn lookup_creator( + &self, + orcid: Option<String>, + wikidata_qid: Option<String>, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + orcid, + wikidata_qid, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn lookup_file( + &self, + md5: Option<String>, + sha1: Option<String>, + sha256: Option<String>, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + md5, + sha1, + sha256, + expand, + hide, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn lookup_release( + &self, + doi: Option<String>, + wikidata_qid: Option<String>, + isbn13: Option<String>, + pmid: Option<String>, + pmcid: Option<String>, + core: Option<String>, + arxiv: Option<String>, + jstor: Option<String>, + ark: Option<String>, + mag: Option<String>, + expand: Option<String>, + hide: Option<String>, + context: &C, + ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!("lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, expand, hide, context.get().0.clone()); + Box::new(future::err("Generic failure".into())) + } + + fn update_container( + &self, + editgroup_id: String, + ident: String, + entity: models::ContainerEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_container(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_creator( + &self, + editgroup_id: String, + ident: String, + entity: models::CreatorEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_creator(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_editgroup( + &self, + editgroup_id: String, + editgroup: models::Editgroup, + submit: Option<bool>, + context: &C, + ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + editgroup_id, + editgroup, + submit, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_editor( + &self, + editor_id: String, + editor: models::Editor, + context: &C, + ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}", + editor_id, + editor, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_file( + &self, + editgroup_id: String, + ident: String, + entity: models::FileEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_file(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_fileset( + &self, + editgroup_id: String, + ident: String, + entity: models::FilesetEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_fileset(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_release( + &self, + editgroup_id: String, + ident: String, + entity: models::ReleaseEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_release(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_webcapture( + &self, + editgroup_id: String, + ident: String, + entity: models::WebcaptureEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_webcapture(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } + + fn update_work( + &self, + editgroup_id: String, + ident: String, + entity: models::WorkEntity, + context: &C, + ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { + let context = context.clone(); + info!( + "update_work(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + ident, + entity, + context.get().0.clone() + ); + Box::new(future::err("Generic failure".into())) + } +} diff --git a/rust/fatcat-openapi/examples/server_lib/mod.rs b/rust/fatcat-openapi/examples/server_lib/mod.rs deleted file mode 100644 index bf404d49..00000000 --- a/rust/fatcat-openapi/examples/server_lib/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! Main library entry point for fatcat implementation. - -mod server; - -mod errors { - error_chain! {} -} - -pub use self::errors::*; - -/// Instantiate a new server. -pub fn server() -> Result<server::Server> { - Ok(server::Server {}) -} diff --git a/rust/fatcat-openapi/examples/server_lib/server.rs b/rust/fatcat-openapi/examples/server_lib/server.rs deleted file mode 100644 index 838bd63d..00000000 --- a/rust/fatcat-openapi/examples/server_lib/server.rs +++ /dev/null @@ -1,1081 +0,0 @@ -//! Server implementation of fatcat. - -#![allow(unused_imports)] - -use chrono; -use futures::{self, Future}; - -use std::collections::HashMap; - -use swagger; - -use fatcat_openapi::models; -use fatcat_openapi::{ - AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse, Context, CreateAuthTokenResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, - CreateCreatorAutoBatchResponse, CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, - CreateFilesetResponse, CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, - DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, - DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, - GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, - GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, - GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, - UpdateWebcaptureResponse, UpdateWorkResponse, -}; - -#[derive(Copy, Clone)] -pub struct Server; - -impl Api for Server { - fn auth_check(&self, role: Option<String>, context: &Context) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("auth_check({:?}) - X-Span-ID: {:?}", role, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("auth_oidc({:?}) - X-Span-ID: {:?}", oidc_params, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_auth_token(&self, editor_id: String, duration_seconds: Option<i32>, context: &Context) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_auth_token(\"{}\", {:?}) - X-Span-ID: {:?}", - editor_id, - duration_seconds, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog_entry(&self, index: i64, context: &Context) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_changelog_entry({}) - X-Span-ID: {:?}", index, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_container(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_container_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_container(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_container_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_container_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_container_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_container_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_container( - &self, - issnl: Option<String>, - wikidata_qid: Option<String>, - expand: Option<String>, - hide: Option<String>, - context: &Context, - ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - issnl, - wikidata_qid, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_container(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_creator(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_creator_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_creator(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_creator_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_creator_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_creator_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_creator_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_creator( - &self, - orcid: Option<String>, - wikidata_qid: Option<String>, - expand: Option<String>, - hide: Option<String>, - context: &Context, - ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - orcid, - wikidata_qid, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_creator(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_editgroup({:?}) - X-Span-ID: {:?}", editgroup, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup_annotation( - &self, - editgroup_id: String, - annotation: models::EditgroupAnnotation, - context: &Context, - ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - annotation, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>, context: &Context) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - expand, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroups_reviewable( - &self, - expand: Option<String>, - limit: Option<i64>, - before: Option<chrono::DateTime<chrono::Utc>>, - since: Option<chrono::DateTime<chrono::Utc>>, - context: &Context, - ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - expand, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_editgroup( - &self, - editgroup_id: String, - editgroup: models::Editgroup, - submit: Option<bool>, - context: &Context, - ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - editgroup_id, - editgroup, - submit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor(&self, editor_id: String, context: &Context) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor_annotations( - &self, - editor_id: String, - limit: Option<i64>, - before: Option<chrono::DateTime<chrono::Utc>>, - since: Option<chrono::DateTime<chrono::Utc>>, - context: &Context, - ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - editor_id, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor_editgroups( - &self, - editor_id: String, - limit: Option<i64>, - before: Option<chrono::DateTime<chrono::Utc>>, - since: Option<chrono::DateTime<chrono::Utc>>, - context: &Context, - ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - editor_id, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}", - editor_id, - editor, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_file(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_file_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_file(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_file_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_file_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_file_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_file_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_file( - &self, - md5: Option<String>, - sha1: Option<String>, - sha256: Option<String>, - expand: Option<String>, - hide: Option<String>, - context: &Context, - ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - md5, - sha1, - sha256, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_file(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_fileset(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_fileset_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_fileset(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_fileset_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_fileset_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_fileset_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_fileset_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_fileset_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_fileset(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_release(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_release_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_release_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_release_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_files(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_filesets(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_filesets(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_release_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_webcaptures(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_webcaptures(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_release( - &self, - doi: Option<String>, - wikidata_qid: Option<String>, - isbn13: Option<String>, - pmid: Option<String>, - pmcid: Option<String>, - core: Option<String>, - arxiv: Option<String>, - jstor: Option<String>, - ark: Option<String>, - mag: Option<String>, - expand: Option<String>, - hide: Option<String>, - context: &Context, - ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - doi, - wikidata_qid, - isbn13, - pmid, - pmcid, - core, - arxiv, - jstor, - ark, - mag, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_release(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_webcapture_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_webcapture(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_webcapture_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_webcapture_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_webcapture_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_webcapture_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_revision( - &self, - rev_id: String, - expand: Option<String>, - hide: Option<String>, - context: &Context, - ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_webcapture_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_webcapture(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_work(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_work_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_work_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_work_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_work_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_work_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_work(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } -} |