From 17fe81ea8d58f93f129492dc44a38df9ab8d528e Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 9 Jan 2019 13:18:38 -0800 Subject: rust impl required editgroup_id --- rust/fatcat-api-spec/README.md | 2 +- rust/fatcat-api-spec/api.yaml | 42 +++--- rust/fatcat-api-spec/api/swagger.yaml | 126 ++++++++-------- rust/fatcat-api-spec/examples/client.rs | 42 +++--- rust/fatcat-api-spec/examples/server_lib/server.rs | 96 ++++++------ rust/fatcat-api-spec/src/client.rs | 101 ++++++------- rust/fatcat-api-spec/src/lib.rs | 133 ++++++++-------- rust/fatcat-api-spec/src/server.rs | 168 ++++++++++++++++++--- rust/src/endpoints.rs | 36 ++--- rust/tests/test_api_server_http.rs | 60 ++++++-- rust/tests/test_old_python_tests.rs | 22 +-- 11 files changed, 471 insertions(+), 357 deletions(-) (limited to 'rust') diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index f8a6e817..3dcee270 100644 --- a/rust/fatcat-api-spec/README.md +++ b/rust/fatcat-api-spec/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2019-01-08T01:49:55.777Z +- Build date: 2019-01-09T21:14:27.679Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml index 625a0143..38f06948 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -619,7 +619,7 @@ paths: $ref: "#/definitions/container_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -703,7 +703,7 @@ paths: $ref: "#/definitions/container_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -721,7 +721,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -877,7 +877,7 @@ paths: $ref: "#/definitions/creator_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -961,7 +961,7 @@ paths: $ref: "#/definitions/creator_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -979,7 +979,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1158,7 +1158,7 @@ paths: $ref: "#/definitions/file_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1242,7 +1242,7 @@ paths: $ref: "#/definitions/file_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1260,7 +1260,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1421,7 +1421,7 @@ paths: $ref: "#/definitions/fileset_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1505,7 +1505,7 @@ paths: $ref: "#/definitions/fileset_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1523,7 +1523,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1650,7 +1650,7 @@ paths: $ref: "#/definitions/webcapture_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1734,7 +1734,7 @@ paths: $ref: "#/definitions/webcapture_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1752,7 +1752,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1879,7 +1879,7 @@ paths: $ref: "#/definitions/release_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1963,7 +1963,7 @@ paths: $ref: "#/definitions/release_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -1981,7 +1981,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -2223,7 +2223,7 @@ paths: $ref: "#/definitions/work_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -2307,7 +2307,7 @@ paths: $ref: "#/definitions/work_entity" - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] @@ -2325,7 +2325,7 @@ paths: parameters: - name: editgroup_id in: query - required: false + required: true type: string security: - Bearer: [] diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 9d4767c0..7ee33725 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -41,10 +41,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -307,10 +307,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -390,10 +390,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -887,10 +887,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -1153,10 +1153,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -1236,10 +1236,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -1797,10 +1797,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -2063,10 +2063,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -2146,10 +2146,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -2656,10 +2656,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -2922,10 +2922,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -3005,10 +3005,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -3425,10 +3425,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -3691,10 +3691,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -3774,10 +3774,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -4194,10 +4194,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -4460,10 +4460,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -4543,10 +4543,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" @@ -5254,10 +5254,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 201: description: "Created Entity" @@ -5520,10 +5520,10 @@ paths: consumesJson: true - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Updated Entity" @@ -5603,10 +5603,10 @@ paths: example: "\"ident_example\".to_string()" - name: "editgroup_id" in: "query" - required: false + required: true type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_id_example\".to_string())" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" responses: 200: description: "Deleted Entity" diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 5a43a33c..f5f336b0 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -137,7 +137,7 @@ fn main() { match matches.value_of("operation") { // Disabled because there's no example. // Some("CreateContainer") => { - // let result = client.create_container(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateContainerBatch") => { @@ -146,7 +146,7 @@ fn main() { } Some("DeleteContainer") => { - let result = client.delete_container("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_container("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -198,13 +198,13 @@ fn main() { // Disabled because there's no example. // Some("UpdateContainer") => { - // let result = client.update_container("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_container("ident_example".to_string(), ???, "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("CreateCreator") => { - // let result = client.create_creator(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateCreatorBatch") => { @@ -213,7 +213,7 @@ fn main() { } Some("DeleteCreator") => { - let result = client.delete_creator("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_creator("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -270,7 +270,7 @@ fn main() { // Disabled because there's no example. // Some("UpdateCreator") => { - // let result = client.update_creator("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_creator("ident_example".to_string(), ???, "editgroup_id_example".to_string()).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("AuthCheck") => { @@ -325,7 +325,7 @@ fn main() { // Disabled because there's no example. // Some("CreateFile") => { - // let result = client.create_file(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateFileBatch") => { @@ -334,7 +334,7 @@ fn main() { } Some("DeleteFile") => { - let result = client.delete_file("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_file("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -387,13 +387,13 @@ fn main() { // Disabled because there's no example. // Some("UpdateFile") => { - // let result = client.update_file("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_file("ident_example".to_string(), ???, "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("CreateFileset") => { - // let result = client.create_fileset(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateFilesetBatch") => { @@ -402,7 +402,7 @@ fn main() { } Some("DeleteFileset") => { - let result = client.delete_fileset("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_fileset("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -442,13 +442,13 @@ fn main() { // Disabled because there's no example. // Some("UpdateFileset") => { - // let result = client.update_fileset("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_fileset("ident_example".to_string(), ???, "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("CreateRelease") => { - // let result = client.create_release(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateReleaseBatch") => { @@ -458,11 +458,11 @@ fn main() { // Disabled because there's no example. // Some("CreateWork") => { - // let result = client.create_work(???, Some("editgroup_id_example".to_string())).wait(); + // 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("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_release("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -533,13 +533,13 @@ fn main() { // Disabled because there's no example. // Some("UpdateRelease") => { - // let result = client.update_release("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_release("ident_example".to_string(), ???, "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("CreateWebcapture") => { - // let result = client.create_webcapture(???, Some("editgroup_id_example".to_string())).wait(); + // 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(""))); // }, Some("CreateWebcaptureBatch") => { @@ -548,7 +548,7 @@ fn main() { } Some("DeleteWebcapture") => { - let result = client.delete_webcapture("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_webcapture("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -588,7 +588,7 @@ fn main() { // Disabled because there's no example. // Some("UpdateWebcapture") => { - // let result = client.update_webcapture("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_webcapture("ident_example".to_string(), ???, "editgroup_id_example".to_string()).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateWorkBatch") => { @@ -597,7 +597,7 @@ fn main() { } Some("DeleteWork") => { - let result = client.delete_work("ident_example".to_string(), Some("editgroup_id_example".to_string())).wait(); + let result = client.delete_work("ident_example".to_string(), "editgroup_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -642,7 +642,7 @@ fn main() { // Disabled because there's no example. // Some("UpdateWork") => { - // let result = client.update_work("ident_example".to_string(), ???, Some("editgroup_id_example".to_string())).wait(); + // let result = client.update_work("ident_example".to_string(), ???, "editgroup_id_example".to_string()).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, _ => panic!("Invalid operation provided"), diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 73917351..febd61de 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -30,10 +30,10 @@ use fatcat::{ pub struct Server; impl Api for Server { - fn create_container(&self, entity: models::ContainerEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_container(&self, entity: models::ContainerEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_container({:?}, {:?}) - X-Span-ID: {:?}", + "create_container({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -59,10 +59,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_container(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_container(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_container(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -143,16 +143,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_container( - &self, - ident: String, - entity: models::ContainerEntity, - editgroup_id: Option, - context: &Context, - ) -> Box + Send> { + fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_container(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -161,10 +155,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_creator({:?}, {:?}) - X-Span-ID: {:?}", + "create_creator({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -190,10 +184,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_creator(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_creator(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_creator(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -285,10 +279,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_creator(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -362,10 +356,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_file(&self, entity: models::FileEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_file(&self, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_file({:?}, {:?}) - X-Span-ID: {:?}", + "create_file({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -391,10 +385,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_file(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_file(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_file(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -477,10 +471,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_file(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -489,10 +483,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_fileset({:?}, {:?}) - X-Span-ID: {:?}", + "create_fileset({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -518,10 +512,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_fileset(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_fileset(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_fileset(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -582,10 +576,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_fileset(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -594,10 +588,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_release({:?}, {:?}) - X-Span-ID: {:?}", + "create_release({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -623,10 +617,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_work(&self, entity: models::WorkEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_work(&self, entity: models::WorkEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_work({:?}, {:?}) - X-Span-ID: {:?}", + "create_work({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -634,10 +628,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_release(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_release(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_release(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -759,10 +753,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_release(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -771,10 +765,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "create_webcapture({:?}, {:?}) - X-Span-ID: {:?}", + "create_webcapture({:?}, \"{}\") - X-Span-ID: {:?}", entity, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -800,10 +794,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_webcapture(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_webcapture(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -864,16 +858,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_webcapture( - &self, - ident: String, - entity: models::WebcaptureEntity, - editgroup_id: Option, - context: &Context, - ) -> Box + Send> { + fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_webcapture(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, @@ -900,10 +888,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn delete_work(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_work(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "delete_work(\"{}\", {:?}) - X-Span-ID: {:?}", + "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}", ident, editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone() @@ -975,10 +963,10 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: Option, context: &Context) -> Box + Send> { + fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "update_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + "update_work(\"{}\", {:?}, \"{}\") - X-Span-ID: {:?}", ident, entity, editgroup_id, diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index 7f364eb4..5937b7f2 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -173,9 +173,9 @@ impl Client { } impl Api for Client { - fn create_container(&self, param_entity: models::ContainerEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_container(&self, param_entity: models::ContainerEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/container?{editgroup_id}", @@ -369,9 +369,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_container(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_container(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/container/{ident}?{editgroup_id}", @@ -971,11 +971,11 @@ impl Api for Client { &self, param_ident: String, param_entity: models::ContainerEntity, - param_editgroup_id: Option, + param_editgroup_id: String, context: &Context, ) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/container/{ident}?{editgroup_id}", @@ -1068,9 +1068,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_creator(&self, param_entity: models::CreatorEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_creator(&self, param_entity: models::CreatorEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/creator?{editgroup_id}", @@ -1264,9 +1264,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_creator(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_creator(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/creator/{ident}?{editgroup_id}", @@ -1934,11 +1934,11 @@ impl Api for Client { &self, param_ident: String, param_entity: models::CreatorEntity, - param_editgroup_id: Option, + param_editgroup_id: String, context: &Context, ) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/creator/{ident}?{editgroup_id}", @@ -2765,9 +2765,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_file(&self, param_entity: models::FileEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_file(&self, param_entity: models::FileEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!("{}/v0/file?{editgroup_id}", self.base_path, editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET)); @@ -2957,9 +2957,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_file(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_file(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/file/{ident}?{editgroup_id}", @@ -3558,15 +3558,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_file( - &self, - param_ident: String, - param_entity: models::FileEntity, - param_editgroup_id: Option, - context: &Context, - ) -> Box + Send> { + fn update_file(&self, param_ident: String, param_entity: models::FileEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/file/{ident}?{editgroup_id}", @@ -3659,9 +3653,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_fileset(&self, param_entity: models::FilesetEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_fileset(&self, param_entity: models::FilesetEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/fileset?{editgroup_id}", @@ -3855,9 +3849,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_fileset(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_fileset(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/fileset/{ident}?{editgroup_id}", @@ -4377,11 +4371,11 @@ impl Api for Client { &self, param_ident: String, param_entity: models::FilesetEntity, - param_editgroup_id: Option, + param_editgroup_id: String, context: &Context, ) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/fileset/{ident}?{editgroup_id}", @@ -4474,9 +4468,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_release(&self, param_entity: models::ReleaseEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_release(&self, param_entity: models::ReleaseEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/release?{editgroup_id}", @@ -4670,9 +4664,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_work(&self, param_entity: models::WorkEntity, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn create_work(&self, param_entity: models::WorkEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!("{}/v0/work?{editgroup_id}", self.base_path, editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET)); @@ -4760,9 +4754,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_release(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_release(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/release/{ident}?{editgroup_id}", @@ -5578,11 +5572,11 @@ impl Api for Client { &self, param_ident: String, param_entity: models::ReleaseEntity, - param_editgroup_id: Option, + param_editgroup_id: String, context: &Context, ) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/release/{ident}?{editgroup_id}", @@ -5675,14 +5669,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_webcapture( - &self, - param_entity: models::WebcaptureEntity, - param_editgroup_id: Option, - context: &Context, - ) -> Box + Send> { + fn create_webcapture(&self, param_entity: models::WebcaptureEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/webcapture?{editgroup_id}", @@ -5876,9 +5865,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_webcapture(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_webcapture(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/webcapture/{ident}?{editgroup_id}", @@ -6398,11 +6387,11 @@ impl Api for Client { &self, param_ident: String, param_entity: models::WebcaptureEntity, - param_editgroup_id: Option, + param_editgroup_id: String, context: &Context, ) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/webcapture/{ident}?{editgroup_id}", @@ -6597,9 +6586,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn delete_work(&self, param_ident: String, param_editgroup_id: Option, context: &Context) -> Box + Send> { + fn delete_work(&self, param_ident: String, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/work/{ident}?{editgroup_id}", @@ -7183,15 +7172,9 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_work( - &self, - param_ident: String, - param_entity: models::WorkEntity, - param_editgroup_id: Option, - context: &Context, - ) -> Box + Send> { + fn update_work(&self, param_ident: String, param_entity: models::WorkEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters - let query_editgroup_id = param_editgroup_id.map_or_else(String::new, |query| format!("editgroup_id={editgroup_id}&", editgroup_id = query.to_string())); + let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); let url = format!( "{}/v0/work/{ident}?{editgroup_id}", diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index 17c74384..cd281a3d 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -1256,7 +1256,7 @@ pub enum UpdateWorkResponse { /// API pub trait Api { - fn create_container(&self, entity: models::ContainerEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_container(&self, entity: models::ContainerEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_container_batch( &self, @@ -1266,7 +1266,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_container(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_container(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_container_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1289,10 +1289,9 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: Option, context: &Context) - -> Box + Send>; + fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: String, context: &Context) -> Box + Send>; - fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_creator_batch( &self, @@ -1302,7 +1301,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_creator(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_creator(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_creator_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1327,7 +1326,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn auth_check(&self, role: Option, context: &Context) -> Box + Send>; @@ -1349,7 +1348,7 @@ pub trait Api { fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send>; - fn create_file(&self, entity: models::FileEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_file_batch( &self, @@ -1359,7 +1358,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_file(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_file(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_file_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1383,9 +1382,9 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send>; - fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_fileset_batch( &self, @@ -1395,7 +1394,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_fileset(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_fileset(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_fileset_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1409,9 +1408,9 @@ pub trait Api { fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: String, context: &Context) -> Box + Send>; - fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_release_batch( &self, @@ -1421,9 +1420,9 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn create_work(&self, entity: models::WorkEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_work(&self, entity: models::WorkEntity, editgroup_id: String, context: &Context) -> Box + Send>; - fn delete_release(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_release(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_release_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1456,9 +1455,9 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String, context: &Context) -> Box + Send>; - fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_webcapture_batch( &self, @@ -1468,7 +1467,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_webcapture(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_webcapture(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_webcapture_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1482,13 +1481,7 @@ pub trait Api { fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - fn update_webcapture( - &self, - ident: String, - entity: models::WebcaptureEntity, - editgroup_id: Option, - context: &Context, - ) -> Box + Send>; + fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_work_batch( &self, @@ -1498,7 +1491,7 @@ pub trait Api { context: &Context, ) -> Box + Send>; - fn delete_work(&self, ident: String, editgroup_id: Option, context: &Context) -> Box + Send>; + fn delete_work(&self, ident: String, editgroup_id: String, context: &Context) -> Box + Send>; fn delete_work_edit(&self, edit_id: String, context: &Context) -> Box + Send>; @@ -1514,12 +1507,12 @@ pub trait Api { fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: Option, context: &Context) -> Box + Send>; + fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: String, context: &Context) -> Box + Send>; } /// API without a `Context` pub trait ApiNoContext { - fn create_container(&self, entity: models::ContainerEntity, editgroup_id: Option) -> Box + Send>; + fn create_container(&self, entity: models::ContainerEntity, editgroup_id: String) -> Box + Send>; fn create_container_batch( &self, @@ -1528,7 +1521,7 @@ pub trait ApiNoContext { editgroup_id: Option, ) -> Box + Send>; - fn delete_container(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_container(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_container_edit(&self, edit_id: String) -> Box + Send>; @@ -1550,9 +1543,9 @@ pub trait ApiNoContext { hide: Option, ) -> Box + Send>; - fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: Option) -> Box + Send>; + fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: String) -> Box + Send>; - fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: Option) -> Box + Send>; + fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: String) -> Box + Send>; fn create_creator_batch( &self, @@ -1561,7 +1554,7 @@ pub trait ApiNoContext { editgroup_id: Option, ) -> Box + Send>; - fn delete_creator(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_creator(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_creator_edit(&self, edit_id: String) -> Box + Send>; @@ -1579,7 +1572,7 @@ pub trait ApiNoContext { fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, expand: Option, hide: Option) -> Box + Send>; - fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: Option) -> Box + Send>; + fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: String) -> Box + Send>; fn auth_check(&self, role: Option) -> Box + Send>; @@ -1601,11 +1594,11 @@ pub trait ApiNoContext { fn get_editgroup(&self, editgroup_id: String) -> Box + Send>; - fn create_file(&self, entity: models::FileEntity, editgroup_id: Option) -> Box + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup_id: String) -> Box + Send>; fn create_file_batch(&self, entity_list: &Vec, autoaccept: Option, editgroup_id: Option) -> Box + Send>; - fn delete_file(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_file(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_file_edit(&self, edit_id: String) -> Box + Send>; @@ -1628,9 +1621,9 @@ pub trait ApiNoContext { hide: Option, ) -> Box + Send>; - fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: Option) -> Box + Send>; + fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: String) -> Box + Send>; - fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: Option) -> Box + Send>; + fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: String) -> Box + Send>; fn create_fileset_batch( &self, @@ -1639,7 +1632,7 @@ pub trait ApiNoContext { editgroup_id: Option, ) -> Box + Send>; - fn delete_fileset(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_fileset(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_fileset_edit(&self, edit_id: String) -> Box + Send>; @@ -1653,9 +1646,9 @@ pub trait ApiNoContext { fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: Option) -> Box + Send>; + fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: String) -> Box + Send>; - fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: Option) -> Box + Send>; + fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: String) -> Box + Send>; fn create_release_batch( &self, @@ -1664,9 +1657,9 @@ pub trait ApiNoContext { editgroup_id: Option, ) -> Box + Send>; - fn create_work(&self, entity: models::WorkEntity, editgroup_id: Option) -> Box + Send>; + fn create_work(&self, entity: models::WorkEntity, editgroup_id: String) -> Box + Send>; - fn delete_release(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_release(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_release_edit(&self, edit_id: String) -> Box + Send>; @@ -1698,9 +1691,9 @@ pub trait ApiNoContext { hide: Option, ) -> Box + Send>; - fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: Option) -> Box + Send>; + fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String) -> Box + Send>; - fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: Option) -> Box + Send>; + fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: String) -> Box + Send>; fn create_webcapture_batch( &self, @@ -1709,7 +1702,7 @@ pub trait ApiNoContext { editgroup_id: Option, ) -> Box + Send>; - fn delete_webcapture(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_webcapture(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_webcapture_edit(&self, edit_id: String) -> Box + Send>; @@ -1723,11 +1716,11 @@ pub trait ApiNoContext { fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: Option) -> Box + Send>; + fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: String) -> Box + Send>; fn create_work_batch(&self, entity_list: &Vec, autoaccept: Option, editgroup_id: Option) -> Box + Send>; - fn delete_work(&self, ident: String, editgroup_id: Option) -> Box + Send>; + fn delete_work(&self, ident: String, editgroup_id: String) -> Box + Send>; fn delete_work_edit(&self, edit_id: String) -> Box + Send>; @@ -1743,7 +1736,7 @@ pub trait ApiNoContext { fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: Option) -> Box + Send>; + fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: String) -> Box + Send>; } /// Trait to extend an API to make it easy to bind it to a context. @@ -1762,7 +1755,7 @@ impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T { } impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { - fn create_container(&self, entity: models::ContainerEntity, editgroup_id: Option) -> Box + Send> { + fn create_container(&self, entity: models::ContainerEntity, editgroup_id: String) -> Box + Send> { self.api().create_container(entity, editgroup_id, &self.context()) } @@ -1775,7 +1768,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_container_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_container(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_container(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_container(ident, editgroup_id, &self.context()) } @@ -1813,11 +1806,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().lookup_container(issnl, wikidata_qid, expand, hide, &self.context()) } - fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: Option) -> Box + Send> { + fn update_container(&self, ident: String, entity: models::ContainerEntity, editgroup_id: String) -> Box + Send> { self.api().update_container(ident, entity, editgroup_id, &self.context()) } - fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: Option) -> Box + Send> { + fn create_creator(&self, entity: models::CreatorEntity, editgroup_id: String) -> Box + Send> { self.api().create_creator(entity, editgroup_id, &self.context()) } @@ -1830,7 +1823,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_creator_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_creator(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_creator(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_creator(ident, editgroup_id, &self.context()) } @@ -1866,7 +1859,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().lookup_creator(orcid, wikidata_qid, expand, hide, &self.context()) } - fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: Option) -> Box + Send> { + fn update_creator(&self, ident: String, entity: models::CreatorEntity, editgroup_id: String) -> Box + Send> { self.api().update_creator(ident, entity, editgroup_id, &self.context()) } @@ -1910,7 +1903,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_editgroup(editgroup_id, &self.context()) } - fn create_file(&self, entity: models::FileEntity, editgroup_id: Option) -> Box + Send> { + fn create_file(&self, entity: models::FileEntity, editgroup_id: String) -> Box + Send> { self.api().create_file(entity, editgroup_id, &self.context()) } @@ -1918,7 +1911,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_file_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_file(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_file(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_file(ident, editgroup_id, &self.context()) } @@ -1957,11 +1950,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().lookup_file(md5, sha1, sha256, expand, hide, &self.context()) } - fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: Option) -> Box + Send> { + fn update_file(&self, ident: String, entity: models::FileEntity, editgroup_id: String) -> Box + Send> { self.api().update_file(ident, entity, editgroup_id, &self.context()) } - fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: Option) -> Box + Send> { + fn create_fileset(&self, entity: models::FilesetEntity, editgroup_id: String) -> Box + Send> { self.api().create_fileset(entity, editgroup_id, &self.context()) } @@ -1974,7 +1967,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_fileset_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_fileset(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_fileset(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_fileset(ident, editgroup_id, &self.context()) } @@ -2002,11 +1995,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_fileset_revision(rev_id, expand, hide, &self.context()) } - fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: Option) -> Box + Send> { + fn update_fileset(&self, ident: String, entity: models::FilesetEntity, editgroup_id: String) -> Box + Send> { self.api().update_fileset(ident, entity, editgroup_id, &self.context()) } - fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: Option) -> Box + Send> { + fn create_release(&self, entity: models::ReleaseEntity, editgroup_id: String) -> Box + Send> { self.api().create_release(entity, editgroup_id, &self.context()) } @@ -2019,11 +2012,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_release_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn create_work(&self, entity: models::WorkEntity, editgroup_id: Option) -> Box + Send> { + fn create_work(&self, entity: models::WorkEntity, editgroup_id: String) -> Box + Send> { self.api().create_work(entity, editgroup_id, &self.context()) } - fn delete_release(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_release(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_release(ident, editgroup_id, &self.context()) } @@ -2077,11 +2070,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, expand, hide, &self.context()) } - fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: Option) -> Box + Send> { + fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String) -> Box + Send> { self.api().update_release(ident, entity, editgroup_id, &self.context()) } - fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: Option) -> Box + Send> { + fn create_webcapture(&self, entity: models::WebcaptureEntity, editgroup_id: String) -> Box + Send> { self.api().create_webcapture(entity, editgroup_id, &self.context()) } @@ -2094,7 +2087,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_webcapture_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_webcapture(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_webcapture(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_webcapture(ident, editgroup_id, &self.context()) } @@ -2122,7 +2115,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_webcapture_revision(rev_id, expand, hide, &self.context()) } - fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: Option) -> Box + Send> { + fn update_webcapture(&self, ident: String, entity: models::WebcaptureEntity, editgroup_id: String) -> Box + Send> { self.api().update_webcapture(ident, entity, editgroup_id, &self.context()) } @@ -2130,7 +2123,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_work_batch(entity_list, autoaccept, editgroup_id, &self.context()) } - fn delete_work(&self, ident: String, editgroup_id: Option) -> Box + Send> { + fn delete_work(&self, ident: String, editgroup_id: String) -> Box + Send> { self.api().delete_work(ident, editgroup_id, &self.context()) } @@ -2162,7 +2155,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_work_revision(rev_id, expand, hide, &self.context()) } - fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: Option) -> Box + Send> { + fn update_work(&self, ident: String, entity: models::WorkEntity, editgroup_id: String) -> Box + Send> { self.api().update_work(ident, entity, editgroup_id, &self.context()) } } diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index d8fc7dc2..2f1c5d27 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -116,7 +116,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -412,7 +418,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_container(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -1184,7 +1196,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -1324,7 +1342,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -1620,7 +1644,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_creator(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -2485,7 +2515,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -3669,7 +3705,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -3965,7 +4007,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_file(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -4738,7 +4786,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -4878,7 +4932,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -5174,7 +5234,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_fileset(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -5865,7 +5931,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -6005,7 +6077,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -6286,7 +6364,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -6441,7 +6525,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_release(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -7499,7 +7589,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -7639,7 +7735,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -7935,7 +8037,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_webcapture(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -8626,7 +8734,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for @@ -8922,7 +9036,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; match api.delete_work(param_ident, param_editgroup_id, context).wait() { Ok(rsp) => match rsp { @@ -9706,7 +9826,13 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup_id = query_params + .get("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter editgroup_id".to_string())))? + .first() + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter editgroup_id was empty".to_string())))? + .parse::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter editgroup_id - doesn't match schema: {}", e))))?; // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs index 6e67eadc..ada13654 100644 --- a/rust/src/endpoints.rs +++ b/rust/src/endpoints.rs @@ -88,19 +88,16 @@ macro_rules! wrap_entity_handlers { fn $post_fn( &self, entity: models::$model, - editgroup_id: Option, + editgroup_id: String, context: &Context, ) -> Box + Send> { let conn = self.db_pool.get().expect("db_pool error"); let ret = match conn.transaction(|| { + let editgroup_id = FatCatId::from_str(&editgroup_id)?; let auth_context = self.auth_confectionary.require_auth(&conn, &context.auth_data, Some(stringify!($post_fn)))?; auth_context.require_role(FatcatRole::Editor)?; - let editgroup_id = if let Some(s) = editgroup_id { - let eg_id = FatCatId::from_str(&s)?; - auth_context.require_editgroup(&conn, eg_id)?; - Some(eg_id) - } else { None }; - let edit_context = make_edit_context(&conn, auth_context.editor_id, editgroup_id, false)?; + auth_context.require_editgroup(&conn, editgroup_id)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; edit_context.check(&conn)?; entity.db_create(&conn, &edit_context)?.into_model() }) { @@ -190,20 +187,17 @@ macro_rules! wrap_entity_handlers { &self, ident: String, entity: models::$model, - editgroup_id: Option, + editgroup_id: String, context: &Context, ) -> Box + Send> { let conn = self.db_pool.get().expect("db_pool error"); let ret = match conn.transaction(|| { + let editgroup_id = FatCatId::from_str(&editgroup_id)?; let auth_context = self.auth_confectionary.require_auth(&conn, &context.auth_data, Some(stringify!($update_fn)))?; auth_context.require_role(FatcatRole::Editor)?; let entity_id = FatCatId::from_str(&ident)?; - let editgroup_id = if let Some(s) = editgroup_id { - let eg_id = FatCatId::from_str(&s)?; - auth_context.require_editgroup(&conn, eg_id)?; - Some(eg_id) - } else { None }; - let edit_context = make_edit_context(&conn, auth_context.editor_id, editgroup_id, false)?; + auth_context.require_editgroup(&conn, editgroup_id)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; edit_context.check(&conn)?; entity.db_update(&conn, &edit_context, entity_id)?.into_model() }) { @@ -246,23 +240,17 @@ macro_rules! wrap_entity_handlers { fn $delete_fn( &self, ident: String, - editgroup_id: Option, + editgroup_id: String, context: &Context, ) -> Box + Send> { let conn = self.db_pool.get().expect("db_pool error"); let ret = match conn.transaction(|| { + let editgroup_id = FatCatId::from_str(&editgroup_id)?; let auth_context = self.auth_confectionary.require_auth(&conn, &context.auth_data, Some(stringify!($delete_fn)))?; auth_context.require_role(FatcatRole::Editor)?; let entity_id = FatCatId::from_str(&ident)?; - let editgroup_id: Option = match editgroup_id { - Some(s) => { - let editgroup_id = FatCatId::from_str(&s)?; - auth_context.require_editgroup(&conn, editgroup_id)?; - Some(editgroup_id) - }, - None => None, - }; - let edit_context = make_edit_context(&conn, auth_context.editor_id, editgroup_id, false)?; + auth_context.require_editgroup(&conn, editgroup_id)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; edit_context.check(&conn)?; $model::db_delete(&conn, &edit_context, entity_id)?.into_model() }) { diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs index e82037f0..7d4469af 100644 --- a/rust/tests/test_api_server_http.rs +++ b/rust/tests/test_api_server_http.rs @@ -538,7 +538,10 @@ fn test_post_file() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/file?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/file?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{ }"#, &router, @@ -605,7 +608,10 @@ fn test_post_fileset() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/fileset?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/fileset?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{ }"#, &router, @@ -662,7 +668,10 @@ fn test_post_webcapture() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/webcapture?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/webcapture?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{ "original_url": "https://fatcat.wiki", "timestamp": "2018-12-28T11:11:11Z" }"#, @@ -674,7 +683,10 @@ fn test_post_webcapture() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/webcapture?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/webcapture?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{"original_url": "https://bnewbold.net/", "timestamp": "2018-12-28T05:06:07Z", @@ -726,7 +738,10 @@ fn test_post_release() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), // TODO: target_release_id r#"{"title": "secret minimal paper", @@ -742,7 +757,10 @@ fn test_post_release() { // No work_id supplied (auto-created) helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), // TODO: target_release_id r#"{"title": "secret minimal paper the second", @@ -756,7 +774,10 @@ fn test_post_release() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), // TODO: target_release_id r#"{"title": "secret paper", @@ -918,7 +939,10 @@ fn test_accept_editgroup() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/container?editgroup_id={}", uuid2fcid(&editgroup_id)), + &format!( + "http://localhost:9411/v0/container?editgroup_id={}", + uuid2fcid(&editgroup_id) + ), headers.clone(), &format!( "{{\"name\": \"test journal 1\", \"editgroup_id\": \"{}\"}}", @@ -931,7 +955,10 @@ fn test_accept_editgroup() { ); helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/container?editgroup_id={}", uuid2fcid(&editgroup_id)), + &format!( + "http://localhost:9411/v0/container?editgroup_id={}", + uuid2fcid(&editgroup_id) + ), headers.clone(), &format!( "{{\"name\": \"test journal 2\", \"editgroup_id\": \"{}\"}}", @@ -1200,7 +1227,10 @@ fn test_abstracts() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{"title": "some paper", "doi": "10.1234/iiiiiii", @@ -1222,7 +1252,10 @@ fn test_abstracts() { // Same abstracts; checking that re-inserting works helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{"title": "some paper again", "abstracts": [ @@ -1292,7 +1325,10 @@ fn test_contribs() { helpers::check_http_response( request::post( - &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id), + &format!( + "http://localhost:9411/v0/release?editgroup_id={}", + editgroup_id + ), headers.clone(), r#"{"title": "some paper", "doi": "10.1234/iiiiiii", diff --git a/rust/tests/test_old_python_tests.rs b/rust/tests/test_old_python_tests.rs index ac9d4112..e0d15484 100644 --- a/rust/tests/test_old_python_tests.rs +++ b/rust/tests/test_old_python_tests.rs @@ -33,7 +33,7 @@ fn test_api_rich_create() { new_container.issnl = Some("2222-3333".to_string()); // extra=dict(a=2, i="zing"))), let resp = client - .create_container(new_container, Some(editgroup_id.clone())) + .create_container(new_container, editgroup_id.clone()) .wait() .unwrap(); let container_id = match resp { @@ -46,7 +46,7 @@ fn test_api_rich_create() { new_creator.orcid = Some("0000-0002-1825-0097".to_string()); // extra=dict(a=2, i="zing"))), let resp = client - .create_creator(new_creator, Some(editgroup_id.clone())) + .create_creator(new_creator, editgroup_id.clone()) .wait() .unwrap(); let creator_id = match resp { @@ -57,7 +57,7 @@ fn test_api_rich_create() { let new_work = WorkEntity::new(); // extra=dict(a=2, i="zing"))), let resp = client - .create_work(new_work, Some(editgroup_id.clone())) + .create_work(new_work, editgroup_id.clone()) .wait() .unwrap(); let work_id = match resp { @@ -79,7 +79,7 @@ fn test_api_rich_create() { new_release.refs = Some(vec![rref]); // extra=dict(a=2, i="zing"))), let resp = client - .create_release(new_release, Some(editgroup_id.clone())) + .create_release(new_release, editgroup_id.clone()) .wait() .unwrap(); let stub_release_id = match resp { @@ -102,7 +102,7 @@ fn test_api_rich_create() { new_release.refs = Some(vec![rref]); // extra=dict(f=7, b="loopy"))), let resp = client - .create_release(new_release, Some(editgroup_id.clone())) + .create_release(new_release, editgroup_id.clone()) .wait() .unwrap(); let release_id = match resp { @@ -116,7 +116,7 @@ fn test_api_rich_create() { new_file.release_ids = Some(vec![release_id.clone()]); // extra=dict(f=4, b="zing"))), let resp = client - .create_file(new_file, Some(editgroup_id.clone())) + .create_file(new_file, editgroup_id.clone()) .wait() .unwrap(); let file_id = match resp { @@ -203,7 +203,7 @@ fn test_merge_works() { // Create 2x works, each with releases; work_b has two releases let resp = client - .create_work(WorkEntity::new(), Some(editgroup_id.clone())) + .create_work(WorkEntity::new(), editgroup_id.clone()) .wait() .unwrap(); let work_a_id = match resp { @@ -216,7 +216,7 @@ fn test_merge_works() { new_release.work_id = Some(work_a_id.clone()); new_release.doi = Some("10.1234/A1".to_string()); let resp = client - .create_release(new_release, Some(editgroup_id.clone())) + .create_release(new_release, editgroup_id.clone()) .wait() .unwrap(); let _release_a1_id = match resp { @@ -225,7 +225,7 @@ fn test_merge_works() { }; let resp = client - .create_work(WorkEntity::new(), Some(editgroup_id.clone())) + .create_work(WorkEntity::new(), editgroup_id.clone()) .wait() .unwrap(); let work_b_id = match resp { @@ -239,7 +239,7 @@ fn test_merge_works() { new_release.work_id = Some(work_b_id.clone()); new_release.doi = Some("10.1234/B1".to_string()); let resp = client - .create_release(new_release, Some(editgroup_id.clone())) + .create_release(new_release, editgroup_id.clone()) .wait() .unwrap(); let _release_b1_id = match resp { @@ -253,7 +253,7 @@ fn test_merge_works() { new_release.work_id = Some(work_b_id.clone()); new_release.doi = Some("10.1234/B2".to_string()); let resp = client - .create_release(new_release, Some(editgroup_id.clone())) + .create_release(new_release, editgroup_id.clone()) .wait() .unwrap(); let _release_b2_id = match resp { -- cgit v1.2.3