diff options
Diffstat (limited to 'rust/fatcat-openapi/examples')
-rw-r--r-- | rust/fatcat-openapi/examples/ca.pem | 17 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/client.rs | 685 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server-chain.pem | 66 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server-key.pem | 28 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server.rs | 64 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server_lib/mod.rs | 14 | ||||
-rw-r--r-- | rust/fatcat-openapi/examples/server_lib/server.rs | 1057 |
7 files changed, 1931 insertions, 0 deletions
diff --git a/rust/fatcat-openapi/examples/ca.pem b/rust/fatcat-openapi/examples/ca.pem new file mode 100644 index 00000000..d2317fb5 --- /dev/null +++ b/rust/fatcat-openapi/examples/ca.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICtjCCAZ4CCQDpKecRERZ0xDANBgkqhkiG9w0BAQsFADAdMQswCQYDVQQGEwJV +UzEOMAwGA1UEAxMFTXkgQ0EwHhcNMTcwNTIzMTYwMDIzWhcNMTcwNjIyMTYwMDIz +WjAdMQswCQYDVQQGEwJVUzEOMAwGA1UEAxMFTXkgQ0EwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCt66py3x7sCSASRF2D05L5wkNDxAUjQKYx23W8Gbwv +GMGykk89BIdU5LX1JB1cKiUOkoIxfwAYuWc2V/wzTvVV7+11besnk3uX1c9KiqUF +LIX7kn/z5hzS4aelhKvH+MJlSZCSlp1ytpZbwo5GB5Pi2SGH56jDBiBoDRNBVdWL +z4wH7TdrQjqWwNxIZumD5OGMtcfJyuX08iPiEOaslOeoMqzObhvjc9aUgjVjhqyA +FkJGTXsi0oaD7oml+NE+mTNfEeZvEJQpLSjBY0OvQHzuHkyGBShBnfu/9x7/NRwd +WaqsLiF7/re9KDGYdJwP7Cu6uxYfKAyWarp6h2mG/GIdAgMBAAEwDQYJKoZIhvcN +AQELBQADggEBAGIl/VVIafeq/AJOQ9r7TzzB2ABJYr7NZa6bTu5O1jSp1Fonac15 +SZ8gvRxODgH22ZYSqghPG4xzq4J3hkytlQqm57ZEt2I2M3OqIp17Ndcc1xDYzpLl +tA0FrVn6crQTM8vQkTDtGesaCWX+7Fir5dK7HnYWzfpSmsOpST07PfbNisEXKOxG +Dj4lBL1OnhTjsJeymVS1pFvkKkrcEJO+IxFiHL3CDsWjcXB0Z+E1zBtPoYyYsNsO +rBrjUxcZewF4xqWZhpW90Mt61fY2nRgU0uUwHcvDQUqvmzKcsqYa4mPKzfBI5mxo +01Ta96cDD6pS5Y1hOflZ0g84f2g/7xBLLDA= +-----END CERTIFICATE----- diff --git a/rust/fatcat-openapi/examples/client.rs b/rust/fatcat-openapi/examples/client.rs new file mode 100644 index 00000000..3cb0df50 --- /dev/null +++ b/rust/fatcat-openapi/examples/client.rs @@ -0,0 +1,685 @@ +#![allow(missing_docs, unused_variables, trivial_casts)] + +extern crate clap; +extern crate fatcat; +#[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::{ + AcceptEditgroupResponse, ApiError, ApiNoContext, AuthCheckResponse, AuthOidcResponse, ContextWrapperExt, 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(&[ + "DeleteContainer", + "DeleteContainerEdit", + "GetContainer", + "GetContainerEdit", + "GetContainerHistory", + "GetContainerRedirects", + "GetContainerRevision", + "LookupContainer", + "DeleteCreator", + "DeleteCreatorEdit", + "GetCreator", + "GetCreatorEdit", + "GetCreatorHistory", + "GetCreatorRedirects", + "GetCreatorReleases", + "GetCreatorRevision", + "LookupCreator", + "AuthCheck", + "GetEditgroupsReviewable", + "GetEditor", + "GetEditorEditgroups", + "AcceptEditgroup", + "GetChangelog", + "GetChangelogEntry", + "GetEditgroup", + "GetEditgroupAnnotations", + "GetEditorAnnotations", + "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::Client::try_new_https(&base_url, "examples/ca.pem").expect("Failed to create HTTPS client") + } else { + // Using HTTP + fatcat::Client::try_new_http(&base_url).expect("Failed to create HTTP client") + }; + + // Using a non-default `Context` is not required; this is just an example! + let client = client.with_context(fatcat::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string())); + + match matches.value_of("operation") { + // 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("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("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>"))); + } + + 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("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("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>"))); + // }, + + // 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>"))); + // }, + 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("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>"))); + } + + 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("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>"))); + } + + // 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>"))); + // }, + + // 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>"))); + // }, + 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("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/server-chain.pem b/rust/fatcat-openapi/examples/server-chain.pem new file mode 100644 index 00000000..47d7e201 --- /dev/null +++ b/rust/fatcat-openapi/examples/server-chain.pem @@ -0,0 +1,66 @@ +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 4096 (0x1000) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, CN=My CA + Validity + Not Before: May 23 16:00:23 2017 GMT + Not After : Apr 29 16:00:23 2117 GMT + Subject: CN=localhost, C=US + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:c9:d4:43:60:50:fc:d6:0f:38:4d:5d:5e:aa:7c: + c0:5e:a9:ec:d9:93:78:d3:93:72:28:41:f5:08:a5: + ea:ac:67:07:d7:1f:f7:7d:74:69:7e:46:89:20:4b: + 7a:2d:9b:02:08:e7:6f:0f:1d:0c:0f:c7:60:69:19: + 4b:df:7e:ca:75:94:0b:49:71:e3:6d:f2:e8:79:fd: + ed:0a:94:67:55:f3:ca:6b:61:ba:58:b7:2e:dd:7b: + ca:b9:02:9f:24:36:ac:26:8f:04:8f:81:c8:35:10: + f4:aa:33:b2:24:16:f8:f7:1e:ea:f7:16:fe:fa:34: + c3:dd:bb:2c:ba:7a:df:4d:e2:da:1e:e5:d2:28:44: + 6e:c8:96:e0:fd:09:0c:14:0c:31:dc:e0:ca:c1:a7: + 9b:bf:16:8c:f7:36:3f:1b:2e:dd:90:eb:45:78:51: + bf:59:22:1e:c6:8c:0a:69:88:e5:03:5e:73:b7:fc: + 93:7f:1b:46:1b:97:68:c5:c0:8b:35:1f:bb:1e:67: + 7f:55:b7:3b:55:3f:ea:f2:ca:db:cc:52:cd:16:89: + db:15:47:bd:f2:cd:6c:7a:d7:b4:1a:ac:c8:15:6c: + 6a:fb:77:c4:e9:f2:30:e0:14:24:66:65:6f:2a:e5: + 2d:cc:f6:81:ae:57:c8:d1:9b:38:90:dc:60:93:02: + 5e:cb + Exponent: 65537 (0x10001) + Signature Algorithm: sha256WithRSAEncryption + 1c:7c:39:e8:3d:49:b2:09:1e:68:5a:2f:74:18:f4:63:b5:8c: + f6:e6:a1:e3:4d:95:90:99:ef:32:5c:34:40:e8:55:13:0e:e0: + 1c:be:cd:ab:3f:64:38:99:5e:2b:c1:81:53:a0:18:a8:f6:ee: + 6a:33:73:6c:9a:73:9d:86:08:5d:c7:11:38:46:4c:cd:a0:47: + 37:8f:fe:a6:50:a9:02:21:99:42:86:5e:47:fe:65:56:60:1d: + 16:53:86:bd:e4:63:c5:69:cf:fa:30:51:ab:a1:c3:50:53:cc: + 66:1c:4c:ff:3f:2a:39:4d:a2:8f:9d:d1:a7:8b:22:e4:78:69: + 24:06:83:4d:cc:0a:c0:87:69:9b:bc:80:a9:d2:b7:a5:23:84: + 7e:a2:32:26:7c:78:0e:bd:db:cd:3b:69:18:33:b8:44:ef:96: + b4:99:86:ee:06:bd:51:1c:c7:a1:a4:0c:c4:4c:51:a0:df:ac: + 14:07:88:8e:d7:39:45:fe:52:e0:a3:4c:db:5d:7a:ab:4d:e4: + ca:06:e8:bd:74:6f:46:e7:93:4a:4f:1b:67:e7:a5:9f:ef:9c: + 02:49:d1:f2:d5:e9:53:ee:09:21:ac:08:c8:15:f7:af:35:b9: + 4f:11:0f:43:ae:46:8e:fd:5b:8d:a3:4e:a7:2c:b7:25:ed:e4: + e5:94:1d:e3 +-----BEGIN CERTIFICATE----- +MIICtTCCAZ0CAhAAMA0GCSqGSIb3DQEBCwUAMB0xCzAJBgNVBAYTAlVTMQ4wDAYD +VQQDEwVNeSBDQTAgFw0xNzA1MjMxNjAwMjNaGA8yMTE3MDQyOTE2MDAyM1owITES +MBAGA1UEAxMJbG9jYWxob3N0MQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAMnUQ2BQ/NYPOE1dXqp8wF6p7NmTeNOTcihB9Qil6qxn +B9cf9310aX5GiSBLei2bAgjnbw8dDA/HYGkZS99+ynWUC0lx423y6Hn97QqUZ1Xz +ymthuli3Lt17yrkCnyQ2rCaPBI+ByDUQ9KozsiQW+Pce6vcW/vo0w927LLp6303i +2h7l0ihEbsiW4P0JDBQMMdzgysGnm78WjPc2Pxsu3ZDrRXhRv1kiHsaMCmmI5QNe +c7f8k38bRhuXaMXAizUfux5nf1W3O1U/6vLK28xSzRaJ2xVHvfLNbHrXtBqsyBVs +avt3xOnyMOAUJGZlbyrlLcz2ga5XyNGbOJDcYJMCXssCAwEAATANBgkqhkiG9w0B +AQsFAAOCAQEAHHw56D1JsgkeaFovdBj0Y7WM9uah402VkJnvMlw0QOhVEw7gHL7N +qz9kOJleK8GBU6AYqPbuajNzbJpznYYIXccROEZMzaBHN4/+plCpAiGZQoZeR/5l +VmAdFlOGveRjxWnP+jBRq6HDUFPMZhxM/z8qOU2ij53Rp4si5HhpJAaDTcwKwIdp +m7yAqdK3pSOEfqIyJnx4Dr3bzTtpGDO4RO+WtJmG7ga9URzHoaQMxExRoN+sFAeI +jtc5Rf5S4KNM2116q03kygbovXRvRueTSk8bZ+eln++cAknR8tXpU+4JIawIyBX3 +rzW5TxEPQ65Gjv1bjaNOpyy3Je3k5ZQd4w== +-----END CERTIFICATE----- diff --git a/rust/fatcat-openapi/examples/server-key.pem b/rust/fatcat-openapi/examples/server-key.pem new file mode 100644 index 00000000..29c00682 --- /dev/null +++ b/rust/fatcat-openapi/examples/server-key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDJ1ENgUPzWDzhN +XV6qfMBeqezZk3jTk3IoQfUIpeqsZwfXH/d9dGl+RokgS3otmwII528PHQwPx2Bp +GUvffsp1lAtJceNt8uh5/e0KlGdV88prYbpYty7de8q5Ap8kNqwmjwSPgcg1EPSq +M7IkFvj3Hur3Fv76NMPduyy6et9N4toe5dIoRG7IluD9CQwUDDHc4MrBp5u/Foz3 +Nj8bLt2Q60V4Ub9ZIh7GjAppiOUDXnO3/JN/G0Ybl2jFwIs1H7seZ39VtztVP+ry +ytvMUs0WidsVR73yzWx617QarMgVbGr7d8Tp8jDgFCRmZW8q5S3M9oGuV8jRmziQ +3GCTAl7LAgMBAAECggEBAKEd1q9j14KWYc64s6KLthGbutyxsinMMbxbct11fdIk +6YhdF3fJ35ETg9IJDr6rWEN9ZRX+jStncNpVfFEs6ThVd3Eo/nI+EEGaaIkikR93 +X2a7fEPn7/yVHu70XdBN6L1bPDvHUeiy4W2hmRrgT90OjGm1rNRWHOm7yugOwIZu +HclzbR9Ca7EInFnotUiDQm9sw9VKHbJHqWx6OORdZrxR2ytYs0Qkq0XpGMvti2HW +7WAmKTg5QM8myXW7+/4iqb/u68wVBR2BBalShKmIf7lim9O3W2a1RjDdsvm/wNe9 +I+D+Iq825vpqkKXcrxYlpVg7hYiaQaW/MNsEb7lQRjECgYEA/RJYby0POW+/k0Jn +jO8UmJVEMiuGa8WIUu/JJWMOmzRCukjSRNQOkt7niQrZPJYE8W6clM6RJTolWf9L +IL6mIb+mRaoudUk8SHGDq7ho1iMg9GK8lhYxvKh1Q6uv8EyVSkgLknAEY0NANKC1 +zNdU5Dhven9aRX2gq9vP4XwMz2MCgYEAzCogQ7IFk+gkp3k491dOZnrGRoRCfuzo +4CJtyKFgOSd7BjmpcKkj0IPfVBjw6GjMIxfQRMTQmxAjjWevH45vG8l0Iiwz/gSp +81b5nsDEX5uv2Olcmcz5zxRFy36jOZ9ihMWinxcIlT2oDbyCdbruDKZq9ieJ9S8g +4qGx0OkwE3kCgYEA7CmAiU89U9YqqttfEq/RQoqY91CSwmO10d+ej9seuEtOsdRf +FIfnibulycdr7hP5TOxyBpO1802NqayJiWcgVYIpQf2MGTtcnCYCP+95NcvWZvj1 +EAJqK6nwtFO1fcOZ1ZXh5qfOEGujsPkAbsXLnKXlsiTCMvMHSxl3pu5Cbg0CgYBf +JjbZNctRrjv+7Qj2hPLd4dQsIxGWc7ToWENP4J2mpVa5hQAJqFovoHXhjKohtk2F +AWEn243Y5oGbMjo0e74edhmwn2cvuF64MM2vBem/ISCn98IXT6cQskMA3qkVfsl8 +VVs/x41ReGWs2TD3y0GMFbb9t1mdMfSiincDhNnKCQKBgGfeT4jKyYeCoCw4OLI1 +G75Gd0METt/IkppwODPpNwj3Rp9I5jctWZFA/3wCX/zk0HgBeou5AFNS4nQZ/X/L +L9axbSdR7UJTGkT1r4gu3rLkPV4Tk+8XM03/JT2cofMlzQBuhvl1Pn4SgKowz7hl +lS76ECw4Av3T0S34VW9Z5oye +-----END PRIVATE KEY----- diff --git a/rust/fatcat-openapi/examples/server.rs b/rust/fatcat-openapi/examples/server.rs new file mode 100644 index 00000000..8d2e9b64 --- /dev/null +++ b/rust/fatcat-openapi/examples/server.rs @@ -0,0 +1,64 @@ +//! Main binary entry point for fatcat implementation. + +#![allow(missing_docs)] + +// Imports required by this file. +// extern crate <name of this crate>; +extern crate clap; +extern crate fatcat; +extern crate hyper_openssl; +extern crate iron; +extern crate swagger; + +// Imports required by server library. +// extern crate fatcat; +// extern crate swagger; +extern crate chrono; +extern crate 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}; +use swagger::auth::AllowAllMiddleware; + +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::router(server); + + let mut chain = Chain::new(router); + chain.link_before(fatcat::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_lib/mod.rs b/rust/fatcat-openapi/examples/server_lib/mod.rs new file mode 100644 index 00000000..bf404d49 --- /dev/null +++ b/rust/fatcat-openapi/examples/server_lib/mod.rs @@ -0,0 +1,14 @@ +//! 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 new file mode 100644 index 00000000..c9f92d33 --- /dev/null +++ b/rust/fatcat-openapi/examples/server_lib/server.rs @@ -0,0 +1,1057 @@ +//! Server implementation of fatcat. + +#![allow(unused_imports)] + +use chrono; +use futures::{self, Future}; + +use std::collections::HashMap; + +use swagger; + +use fatcat::models; +use fatcat::{ + AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse, Context, 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 create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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 auth_check(&self, role: Option<String>, context: &Context) -> Box<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<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 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<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 get_editor(&self, editor_id: String, context: &Context) -> Box<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_editgroups( + &self, + editor_id: String, + limit: Option<i64>, + before: Option<chrono::DateTime<chrono::Utc>>, + since: Option<chrono::DateTime<chrono::Utc>>, + context: &Context, + ) -> Box<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_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>, context: &Context) -> Box<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 update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<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 accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<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<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<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_changelog(&self, limit: Option<i64>, context: &Context) -> Box<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<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 get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<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<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_editor_annotations( + &self, + editor_id: String, + limit: Option<i64>, + before: Option<chrono::DateTime<chrono::Utc>>, + since: Option<chrono::DateTime<chrono::Utc>>, + context: &Context, + ) -> Box<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 create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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 create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<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 delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box<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<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<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<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<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<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<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<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<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<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())) + } +} |