From 09475b87821142c5cd36c6b90fb97deb2a058312 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 22 Jan 2019 21:41:35 -0800 Subject: allow passing description+extra to batch endpoints Pretty messy, but I needed some way to do this. In particular, requires json.dumps() in python code, for now. Blech. --- rust/fatcat-api-spec/examples/client.rs | 70 +++++++++++++++++++--- rust/fatcat-api-spec/examples/server_lib/server.rs | 42 ++++++++++--- 2 files changed, 98 insertions(+), 14 deletions(-) (limited to 'rust/fatcat-api-spec/examples') diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 196580e4..40a5a3ab 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -144,7 +144,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateContainerBatch") => { - let result = client.create_container_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_container_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -211,7 +219,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateCreatorBatch") => { - let result = client.create_creator_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_creator_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -359,7 +375,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateFileBatch") => { - let result = client.create_file_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_file_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -427,7 +451,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateFilesetBatch") => { - let result = client.create_fileset_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_fileset_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -482,7 +514,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateReleaseBatch") => { - let result = client.create_release_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_release_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -575,7 +615,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateWebcaptureBatch") => { - let result = client.create_webcapture_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_webcapture_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -624,7 +672,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateWorkBatch") => { - let result = client.create_work_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_work_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 20336528..98f31485 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -46,14 +46,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_container_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_container_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -171,14 +175,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_creator_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_creator_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -465,14 +473,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_file_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_file_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -592,14 +604,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_fileset_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_fileset_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -697,14 +713,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_release_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_release_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -878,14 +898,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_webcapture_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_webcapture_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -972,14 +996,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_work_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_work_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) -- cgit v1.2.3