From eb6993c6cc40e532cb1462e44408ed30db5244c0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 13 Sep 2019 11:27:09 -0700 Subject: rust codegen This re-ordered a lot of code, because several endpoints had their tags changed, but should be no actual change in behavior/spec. --- rust/fatcat-openapi/examples/client.rs | 112 ++++++------- rust/fatcat-openapi/examples/server_lib/server.rs | 182 +++++++++++----------- 2 files changed, 147 insertions(+), 147 deletions(-) (limited to 'rust/fatcat-openapi/examples') diff --git a/rust/fatcat-openapi/examples/client.rs b/rust/fatcat-openapi/examples/client.rs index 3cb0df50..502d8ee6 100644 --- a/rust/fatcat-openapi/examples/client.rs +++ b/rust/fatcat-openapi/examples/client.rs @@ -35,6 +35,9 @@ fn main() { Arg::with_name("operation") .help("Sets the operation to run") .possible_values(&[ + "AuthCheck", + "GetChangelog", + "GetChangelogEntry", "DeleteContainer", "DeleteContainerEdit", "GetContainer", @@ -52,16 +55,13 @@ fn main() { "GetCreatorReleases", "GetCreatorRevision", "LookupCreator", - "AuthCheck", - "GetEditgroupsReviewable", - "GetEditor", - "GetEditorEditgroups", "AcceptEditgroup", - "GetChangelog", - "GetChangelogEntry", "GetEditgroup", "GetEditgroupAnnotations", + "GetEditgroupsReviewable", + "GetEditor", "GetEditorAnnotations", + "GetEditorEditgroups", "DeleteFile", "DeleteFileEdit", "GetFile", @@ -131,6 +131,26 @@ fn main() { let client = client.with_context(fatcat::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(""))); + } + + // 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(""))); + // }, + 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(""))); + } + + 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(""))); + } + // Disabled because there's no example. // Some("CreateContainer") => { // let result = client.create_container("editgroup_id_example".to_string(), ???).wait(); @@ -271,42 +291,6 @@ fn main() { // 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(""))); // }, - 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(""))); - } - - // 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(""))); - // }, - 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(""))); - } - - 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(""))); - } - - 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(""))); - } - - // 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(""))); - // }, - - // 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(""))); - // }, 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(""))); @@ -323,23 +307,28 @@ fn main() { // 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(""))); // }, - Some("GetChangelog") => { - let result = client.get_changelog(Some(789)).wait(); + 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(""))); } - Some("GetChangelogEntry") => { - let result = client.get_changelog_entry(789).wait(); + 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(""))); } - Some("GetEditgroup") => { - let result = client.get_editgroup("editgroup_id_example".to_string()).wait(); + 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(""))); } - Some("GetEditgroupAnnotations") => { - let result = client.get_editgroup_annotations("editgroup_id_example".to_string(), Some("expand_example".to_string())).wait(); + // 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(""))); + // }, + 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(""))); } @@ -348,6 +337,17 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + 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(""))); + } + + // 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(""))); + // }, + // Disabled because there's no example. // Some("CreateFile") => { // let result = client.create_file("editgroup_id_example".to_string(), ???).wait(); @@ -484,12 +484,6 @@ fn main() { // let result = client.create_release_auto_batch(???).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, - - // 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(""))); - // }, 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(""))); @@ -626,6 +620,12 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, + // 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(""))); + // }, + // Disabled because there's no example. // Some("CreateWorkAutoBatch") => { // let result = client.create_work_auto_batch(???).wait(); diff --git a/rust/fatcat-openapi/examples/server_lib/server.rs b/rust/fatcat-openapi/examples/server_lib/server.rs index c9f92d33..e0f9045f 100644 --- a/rust/fatcat-openapi/examples/server_lib/server.rs +++ b/rust/fatcat-openapi/examples/server_lib/server.rs @@ -30,6 +30,30 @@ use fatcat::{ pub struct Server; impl Api for Server { + fn auth_check(&self, role: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("auth_check({:?}) - X-Span-ID: {:?}", role, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("auth_oidc({:?}) - X-Span-ID: {:?}", oidc_params, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_changelog_entry(&self, index: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_changelog_entry({}) - X-Span-ID: {:?}", index, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -285,56 +309,63 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn auth_check(&self, role: Option, context: &Context) -> Box + Send> { + fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); - println!("auth_check({:?}) - X-Span-ID: {:?}", role, context.x_span_id.unwrap_or(String::from("")).clone()); + println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box + Send> { + fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box + Send> { let context = context.clone(); - println!("auth_oidc({:?}) - X-Span-ID: {:?}", oidc_params, context.x_span_id.unwrap_or(String::from("")).clone()); + println!("create_editgroup({:?}) - X-Span-ID: {:?}", editgroup, context.x_span_id.unwrap_or(String::from("")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn get_editgroups_reviewable( + fn create_editgroup_annotation( &self, - expand: Option, - limit: Option, - before: Option>, - since: Option>, + editgroup_id: String, + annotation: models::EditgroupAnnotation, context: &Context, - ) -> Box + Send> { + ) -> Box + Send> { let context = context.clone(); println!( - "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - expand, - limit, - before, - since, + "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + annotation, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) } - fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send> { + fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); - println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("")).clone()); + println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn get_editor_editgroups( + fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + expand, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_editgroups_reviewable( &self, - editor_id: String, + expand: Option, limit: Option, before: Option>, since: Option>, context: &Context, - ) -> Box + Send> { + ) -> Box + Send> { let context = context.clone(); println!( - "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - editor_id, + "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + expand, limit, before, since, @@ -355,85 +386,43 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}", - editor_id, - editor, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box + Send> { + fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send> { let context = context.clone(); - println!("create_editgroup({:?}) - X-Span-ID: {:?}", editgroup, context.x_span_id.unwrap_or(String::from("")).clone()); + println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn create_editgroup_annotation( + fn get_editor_annotations( &self, - editgroup_id: String, - annotation: models::EditgroupAnnotation, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - annotation, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog_entry(&self, index: i64, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_changelog_entry({}) - X-Span-ID: {:?}", index, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send> { + ) -> Box + Send> { let context = context.clone(); println!( - "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - expand, + "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + editor_id, + limit, + before, + since, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) } - fn get_editor_annotations( + fn get_editor_editgroups( &self, editor_id: String, limit: Option, before: Option>, since: Option>, context: &Context, - ) -> Box + Send> { + ) -> Box + Send> { let context = context.clone(); println!( - "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", editor_id, limit, before, @@ -443,6 +432,17 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}", + editor_id, + editor, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -690,17 +690,6 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_work(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -953,6 +942,17 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "create_work(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + entity, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box + Send> { let context = context.clone(); println!( -- cgit v1.2.3