diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-11 16:10:47 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-11 16:10:47 -0700 |
commit | 91c080a2e82ec4e8908cb8e3916a543519151847 (patch) | |
tree | 1d6f450546bcd0d0888bd0f4ec52d66a8a3cfd0f /rust/fatcat-api-spec | |
parent | 6315c314969d4e66db4da09a8c2ff245aafe0fc1 (diff) | |
download | fatcat-91c080a2e82ec4e8908cb8e3916a543519151847.tar.gz fatcat-91c080a2e82ec4e8908cb8e3916a543519151847.zip |
implement new editgroup_id behavior
Diffstat (limited to 'rust/fatcat-api-spec')
-rw-r--r-- | rust/fatcat-api-spec/README.md | 2 | ||||
-rw-r--r-- | rust/fatcat-api-spec/api.yaml | 49 | ||||
-rw-r--r-- | rust/fatcat-api-spec/api/swagger.yaml | 137 | ||||
-rw-r--r-- | rust/fatcat-api-spec/examples/client.rs | 20 | ||||
-rw-r--r-- | rust/fatcat-api-spec/examples/server_lib/server.rs | 80 | ||||
-rw-r--r-- | rust/fatcat-api-spec/src/client.rs | 113 | ||||
-rw-r--r-- | rust/fatcat-api-spec/src/lib.rs | 80 | ||||
-rw-r--r-- | rust/fatcat-api-spec/src/models.rs | 55 | ||||
-rw-r--r-- | rust/fatcat-api-spec/src/server.rs | 60 |
9 files changed, 406 insertions, 190 deletions
diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 4c613ba7..6945d13d 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: 2018-09-11T20:55:46.846Z +- Build date: 2018-09-11T22:56:39.846Z 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 2b0615d2..d5414405 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -52,15 +52,12 @@ x-entity-props: &ENTITYPROPS <<: *FATCATUUID redirect: <<: *FATCATIDENT - editgroup_id: - <<: *FATCATIDENT extra: type: object additionalProperties: {} -# TODO: -# edit_extra: -# type: object -# additionalProperties: {} + edit_extra: + type: object + additionalProperties: {} definitions: error_response: @@ -432,6 +429,10 @@ paths: required: true schema: $ref: "#/definitions/container_entity" + - name: editgroup + in: query + required: false + type: string responses: 201: description: Created Entity @@ -495,6 +496,10 @@ paths: required: true schema: $ref: "#/definitions/container_entity" + - name: editgroup + in: query + required: false + type: string responses: 200: description: Updated Entity @@ -558,6 +563,10 @@ paths: required: true schema: $ref: "#/definitions/creator_entity" + - name: editgroup + in: query + required: false + type: string responses: 201: description: Created Entity @@ -621,6 +630,10 @@ paths: required: true schema: $ref: "#/definitions/creator_entity" + - name: editgroup + in: query + required: false + type: string responses: 200: description: Updated Entity @@ -700,6 +713,10 @@ paths: required: true schema: $ref: "#/definitions/file_entity" + - name: editgroup + in: query + required: false + type: string responses: 201: description: Created Entity @@ -763,6 +780,10 @@ paths: required: true schema: $ref: "#/definitions/file_entity" + - name: editgroup + in: query + required: false + type: string responses: 200: description: Updated Entity @@ -826,6 +847,10 @@ paths: required: true schema: $ref: "#/definitions/release_entity" + - name: editgroup + in: query + required: false + type: string responses: 201: description: Created Entity @@ -889,6 +914,10 @@ paths: required: true schema: $ref: "#/definitions/release_entity" + - name: editgroup + in: query + required: false + type: string responses: 200: description: Updated Entity @@ -968,6 +997,10 @@ paths: required: true schema: $ref: "#/definitions/work_entity" + - name: editgroup + in: query + required: false + type: string responses: 201: description: Created Entity @@ -1031,6 +1064,10 @@ paths: required: true schema: $ref: "#/definitions/work_entity" + - name: editgroup + in: query + required: false + type: string responses: 200: description: Updated Entity diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 9bc84351..5f54c5b4 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -29,6 +29,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "CREATE_CONTAINER" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 201: description: "Created Entity" @@ -229,6 +235,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "UPDATE_CONTAINER" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 200: description: "Updated Entity" @@ -461,6 +473,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "CREATE_CREATOR" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 201: description: "Created Entity" @@ -661,6 +679,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "UPDATE_CREATOR" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 200: description: "Updated Entity" @@ -947,6 +971,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "CREATE_FILE" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 201: description: "Created Entity" @@ -1147,6 +1177,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "UPDATE_FILE" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 200: description: "Updated Entity" @@ -1376,6 +1412,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "CREATE_RELEASE" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 201: description: "Created Entity" @@ -1576,6 +1618,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "UPDATE_RELEASE" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 200: description: "Updated Entity" @@ -1859,6 +1907,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "CREATE_WORK" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 201: description: "Created Entity" @@ -2059,6 +2113,12 @@ paths: model_key: "editgroup_edits" uppercase_operation_id: "UPDATE_WORK" consumesJson: true + - name: "editgroup" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"editgroup_example\".to_string())" responses: 200: description: "Updated Entity" @@ -2710,15 +2770,10 @@ definitions: name: type: "string" example: "Journal of Important Results" + edit_extra: + type: "object" extra: type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" redirect: type: "string" example: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -2754,11 +2809,11 @@ definitions: extra: "{}" name: "Journal of Important Results" publisher: "Society of Curious Students" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" issnl: "1234-5678" abbrev: "abbrev" wikidata_qid: "wikidata_qid" state: "wip" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" upperCaseName: "CONTAINER_ENTITY" creator_entity: @@ -2809,26 +2864,21 @@ definitions: minLength: 26 maxLength: 26 pattern: "[a-zA-Z2-7]{26}" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" extra: type: "object" + edit_extra: + type: "object" example: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" surname: "surname" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" orcid: "0000-0002-1825-0097" wikidata_qid: "wikidata_qid" state: "wip" given_name: "given_name" display_name: "Grace Hopper" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" upperCaseName: "CREATOR_ENTITY" file_entity: @@ -2858,15 +2908,10 @@ definitions: type: "integer" format: "int64" example: 1048576 + edit_extra: + type: "object" extra: type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" redirect: type: "string" example: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -2911,9 +2956,9 @@ definitions: url: "https://example.edu/~frau/prcding.pdf" size: 1048576 extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" mimetype: "application/pdf" state: "wip" + edit_extra: "{}" md5: "d41efcc592d1e40ac13905377399eb9b" upperCaseName: "FILE_ENTITY" release_entity: @@ -3011,15 +3056,10 @@ definitions: minLength: 26 maxLength: 26 pattern: "[a-zA-Z2-7]{26}" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" extra: type: "object" + edit_extra: + type: "object" example: container: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -3028,11 +3068,11 @@ definitions: extra: "{}" name: "Journal of Important Results" publisher: "Society of Curious Students" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" issnl: "1234-5678" abbrev: "abbrev" wikidata_qid: "wikidata_qid" state: "wip" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" language: "language" @@ -3043,12 +3083,12 @@ definitions: surname: "surname" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" orcid: "0000-0002-1825-0097" wikidata_qid: "wikidata_qid" state: "wip" given_name: "given_name" display_name: "Grace Hopper" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" @@ -3060,12 +3100,12 @@ definitions: surname: "surname" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" orcid: "0000-0002-1825-0097" wikidata_qid: "wikidata_qid" state: "wip" given_name: "given_name" display_name: "Grace Hopper" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" @@ -3075,8 +3115,8 @@ definitions: pages: "pages" core_id: "core_id" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" state: "wip" + edit_extra: "{}" redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" work_id: "q3nouwy3nnbsvo3h5klxsx4a7y" issue: "12" @@ -3131,9 +3171,9 @@ definitions: url: "https://example.edu/~frau/prcding.pdf" size: 1048576 extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" mimetype: "application/pdf" state: "wip" + edit_extra: "{}" md5: "d41efcc592d1e40ac13905377399eb9b" - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" sha256: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" @@ -3150,9 +3190,9 @@ definitions: url: "https://example.edu/~frau/prcding.pdf" size: 1048576 extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" mimetype: "application/pdf" state: "wip" + edit_extra: "{}" md5: "d41efcc592d1e40ac13905377399eb9b" pmcid: "pmcid" container_id: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -3161,15 +3201,10 @@ definitions: work_entity: type: "object" properties: + edit_extra: + type: "object" extra: type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" redirect: type: "string" example: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -3202,8 +3237,8 @@ definitions: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" state: "wip" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" upperCaseName: "WORK_ENTITY" entity_history_entry: @@ -3713,12 +3748,12 @@ definitions: surname: "surname" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" orcid: "0000-0002-1825-0097" wikidata_qid: "wikidata_qid" state: "wip" given_name: "given_name" display_name: "Grace Hopper" + edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" @@ -3924,16 +3959,12 @@ x-entity-props: minLength: 26 maxLength: 26 description: "base32-encoded unique identifier" - editgroup_id: - description: "base32-encoded unique identifier" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - type: "string" extra: type: "object" additionalProperties: {} + edit_extra: + type: "object" + additionalProperties: {} x-entity-responses: 400: description: "Bad Request" diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index cc94af11..5d600965 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -97,7 +97,7 @@ fn main() { // Disabled because there's no example. // Some("CreateContainer") => { - // let result = client.create_container(???).wait(); + // let result = client.create_container(???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, Some("CreateContainerBatch") => { @@ -107,7 +107,7 @@ fn main() { // Disabled because there's no example. // Some("CreateCreator") => { - // let result = client.create_creator(???).wait(); + // let result = client.create_creator(???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, Some("CreateCreatorBatch") => { @@ -123,7 +123,7 @@ fn main() { // Disabled because there's no example. // Some("CreateFile") => { - // let result = client.create_file(???).wait(); + // let result = client.create_file(???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, Some("CreateFileBatch") => { @@ -133,7 +133,7 @@ fn main() { // Disabled because there's no example. // Some("CreateRelease") => { - // let result = client.create_release(???).wait(); + // let result = client.create_release(???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, Some("CreateReleaseBatch") => { @@ -143,7 +143,7 @@ fn main() { // Disabled because there's no example. // Some("CreateWork") => { - // let result = client.create_work(???).wait(); + // let result = client.create_work(???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, Some("CreateWorkBatch") => { @@ -293,31 +293,31 @@ fn main() { // Disabled because there's no example. // Some("UpdateContainer") => { - // let result = client.update_container("id_example".to_string(), ???).wait(); + // let result = client.update_container("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, // Disabled because there's no example. // Some("UpdateCreator") => { - // let result = client.update_creator("id_example".to_string(), ???).wait(); + // let result = client.update_creator("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, // Disabled because there's no example. // Some("UpdateFile") => { - // let result = client.update_file("id_example".to_string(), ???).wait(); + // let result = client.update_file("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, // Disabled because there's no example. // Some("UpdateRelease") => { - // let result = client.update_release("id_example".to_string(), ???).wait(); + // let result = client.update_release("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, // Disabled because there's no example. // Some("UpdateWork") => { - // let result = client.update_work("id_example".to_string(), ???).wait(); + // let result = client.update_work("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, _ => panic!("Invalid operation provided"), diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index ab08f594..2ca8eb3b 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -29,9 +29,14 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_container(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { + fn create_container(&self, entity: models::ContainerEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("create_container({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "create_container({:?}, {:?}) - X-Span-ID: {:?}", + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -53,9 +58,14 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_creator(&self, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { + fn create_creator(&self, entity: models::CreatorEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("create_creator({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "create_creator({:?}, {:?}) - X-Span-ID: {:?}", + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -83,9 +93,14 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_file(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { + fn create_file(&self, entity: models::FileEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("create_file({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "create_file({:?}, {:?}) - X-Span-ID: {:?}", + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -107,9 +122,14 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_release(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { + fn create_release(&self, entity: models::ReleaseEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("create_release({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "create_release({:?}, {:?}) - X-Span-ID: {:?}", + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -131,9 +151,14 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn create_work(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { + fn create_work(&self, entity: models::WorkEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("create_work({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "create_work({:?}, {:?}) - X-Span-ID: {:?}", + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -373,48 +398,63 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn update_container(&self, id: String, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { + fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { let context = context.clone(); println!( - "update_container(\"{}\", {:?}) - X-Span-ID: {:?}", + "update_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", id, entity, + editgroup, context.x_span_id.unwrap_or(String::from("<none>")).clone() ); Box::new(futures::failed("Generic failure".into())) } - fn update_creator(&self, id: String, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { + fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { let context = context.clone(); println!( - "update_creator(\"{}\", {:?}) - X-Span-ID: {:?}", + "update_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", id, entity, + editgroup, context.x_span_id.unwrap_or(String::from("<none>")).clone() ); Box::new(futures::failed("Generic failure".into())) } - fn update_file(&self, id: String, entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { + fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("update_file(\"{}\", {:?}) - X-Span-ID: {:?}", id, entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "update_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } - fn update_release(&self, id: String, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { + fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { let context = context.clone(); println!( - "update_release(\"{}\", {:?}) - X-Span-ID: {:?}", + "update_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", id, entity, + editgroup, context.x_span_id.unwrap_or(String::from("<none>")).clone() ); Box::new(futures::failed("Generic failure".into())) } - fn update_work(&self, id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("update_work(\"{}\", {:?}) - X-Span-ID: {:?}", id, entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!( + "update_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + entity, + editgroup, + context.x_span_id.unwrap_or(String::from("<none>")).clone() + ); Box::new(futures::failed("Generic failure".into())) } } diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index a08e3cfe..c403515b 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -233,8 +233,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_container(&self, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/container", self.base_path); + fn create_container(&self, param_entity: models::ContainerEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!("{}/v0/container?{editgroup}", self.base_path, editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET)); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -378,8 +381,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_creator(&self, param_entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator", self.base_path); + fn create_creator(&self, param_entity: models::CreatorEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!("{}/v0/creator?{editgroup}", self.base_path, editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET)); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -581,8 +587,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_file(&self, param_entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/file", self.base_path); + fn create_file(&self, param_entity: models::FileEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!("{}/v0/file?{editgroup}", self.base_path, editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET)); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -726,8 +735,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_release(&self, param_entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release", self.base_path); + fn create_release(&self, param_entity: models::ReleaseEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!("{}/v0/release?{editgroup}", self.base_path, editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET)); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -871,8 +883,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_work(&self, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work", self.base_path); + fn create_work(&self, param_entity: models::WorkEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!("{}/v0/work?{editgroup}", self.base_path, editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET)); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -2799,8 +2814,22 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_container(&self, param_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/container/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_container( + &self, + param_id: String, + param_entity: models::ContainerEntity, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/container/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -2864,8 +2893,22 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_creator(&self, param_id: String, param_entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_creator( + &self, + param_id: String, + param_entity: models::CreatorEntity, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/creator/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -2929,8 +2972,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_file(&self, param_id: String, param_entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/file/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_file(&self, param_id: String, param_entity: models::FileEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/file/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -2994,8 +3045,22 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_release(&self, param_id: String, param_entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_release( + &self, + param_id: String, + param_entity: models::ReleaseEntity, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/release/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); @@ -3059,8 +3124,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn update_work(&self, param_id: String, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_work(&self, param_id: String, param_entity: models::WorkEntity, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { + // Query parameters + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/work/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index a08c6e04..a246bb43 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -566,7 +566,7 @@ pub enum UpdateWorkResponse { pub trait Api { fn accept_editgroup(&self, id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>; - fn create_container(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; + fn create_container(&self, entity: models::ContainerEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; fn create_container_batch( &self, @@ -576,7 +576,7 @@ pub trait Api { context: &Context, ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send>; - fn create_creator(&self, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; + fn create_creator(&self, entity: models::CreatorEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; fn create_creator_batch( &self, @@ -588,7 +588,7 @@ pub trait Api { fn create_editgroup(&self, entity: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>; - fn create_file(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; fn create_file_batch( &self, @@ -598,7 +598,7 @@ pub trait Api { context: &Context, ) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send>; - fn create_release(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; + fn create_release(&self, entity: models::ReleaseEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; fn create_release_batch( &self, @@ -608,7 +608,7 @@ pub trait Api { context: &Context, ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send>; - fn create_work(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; + fn create_work(&self, entity: models::WorkEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; fn create_work_batch( &self, @@ -674,22 +674,22 @@ pub trait Api { fn lookup_release(&self, doi: String, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send>; - fn update_container(&self, id: String, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; + fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; - fn update_creator(&self, id: String, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; + fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; - fn update_file(&self, id: String, entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; + fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; - fn update_release(&self, id: String, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; + fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; - fn update_work(&self, id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option<String>, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; } /// API without a `Context` pub trait ApiNoContext { fn accept_editgroup(&self, id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>; - fn create_container(&self, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; + fn create_container(&self, entity: models::ContainerEntity, editgroup: Option<String>) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; fn create_container_batch( &self, @@ -698,7 +698,7 @@ pub trait ApiNoContext { editgroup: Option<String>, ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send>; - fn create_creator(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; + fn create_creator(&self, entity: models::CreatorEntity, editgroup: Option<String>) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; fn create_creator_batch( &self, @@ -709,11 +709,11 @@ pub trait ApiNoContext { fn create_editgroup(&self, entity: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>; - fn create_file(&self, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup: Option<String>) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; fn create_file_batch(&self, entity_list: &Vec<models::FileEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send>; - fn create_release(&self, entity: models::ReleaseEntity) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; + fn create_release(&self, entity: models::ReleaseEntity, editgroup: Option<String>) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; fn create_release_batch( &self, @@ -722,7 +722,7 @@ pub trait ApiNoContext { editgroup: Option<String>, ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send>; - fn create_work(&self, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; + fn create_work(&self, entity: models::WorkEntity, editgroup: Option<String>) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; fn create_work_batch(&self, entity_list: &Vec<models::WorkEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send>; @@ -782,15 +782,15 @@ pub trait ApiNoContext { fn lookup_release(&self, doi: String) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send>; - fn update_container(&self, id: String, entity: models::ContainerEntity) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; + fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; - fn update_creator(&self, id: String, entity: models::CreatorEntity) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; + fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; - fn update_file(&self, id: String, entity: models::FileEntity) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; + fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; - fn update_release(&self, id: String, entity: models::ReleaseEntity) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; + fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; - fn update_work(&self, id: String, entity: models::WorkEntity) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; } /// Trait to extend an API to make it easy to bind it to a context. @@ -813,8 +813,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().accept_editgroup(id, &self.context()) } - fn create_container(&self, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - self.api().create_container(entity, &self.context()) + fn create_container(&self, entity: models::ContainerEntity, editgroup: Option<String>) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { + self.api().create_container(entity, editgroup, &self.context()) } fn create_container_batch( @@ -826,8 +826,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_container_batch(entity_list, autoaccept, editgroup, &self.context()) } - fn create_creator(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - self.api().create_creator(entity, &self.context()) + fn create_creator(&self, entity: models::CreatorEntity, editgroup: Option<String>) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { + self.api().create_creator(entity, editgroup, &self.context()) } fn create_creator_batch( @@ -843,16 +843,16 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_editgroup(entity, &self.context()) } - fn create_file(&self, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { - self.api().create_file(entity, &self.context()) + fn create_file(&self, entity: models::FileEntity, editgroup: Option<String>) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { + self.api().create_file(entity, editgroup, &self.context()) } fn create_file_batch(&self, entity_list: &Vec<models::FileEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { self.api().create_file_batch(entity_list, autoaccept, editgroup, &self.context()) } - fn create_release(&self, entity: models::ReleaseEntity) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - self.api().create_release(entity, &self.context()) + fn create_release(&self, entity: models::ReleaseEntity, editgroup: Option<String>) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { + self.api().create_release(entity, editgroup, &self.context()) } fn create_release_batch( @@ -864,8 +864,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_release_batch(entity_list, autoaccept, editgroup, &self.context()) } - fn create_work(&self, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - self.api().create_work(entity, &self.context()) + fn create_work(&self, entity: models::WorkEntity, editgroup: Option<String>) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { + self.api().create_work(entity, editgroup, &self.context()) } fn create_work_batch(&self, entity_list: &Vec<models::WorkEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { @@ -984,24 +984,24 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().lookup_release(doi, &self.context()) } - fn update_container(&self, id: String, entity: models::ContainerEntity) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - self.api().update_container(id, entity, &self.context()) + fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { + self.api().update_container(id, entity, editgroup, &self.context()) } - fn update_creator(&self, id: String, entity: models::CreatorEntity) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - self.api().update_creator(id, entity, &self.context()) + fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { + self.api().update_creator(id, entity, editgroup, &self.context()) } - fn update_file(&self, id: String, entity: models::FileEntity) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - self.api().update_file(id, entity, &self.context()) + fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { + self.api().update_file(id, entity, editgroup, &self.context()) } - fn update_release(&self, id: String, entity: models::ReleaseEntity) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - self.api().update_release(id, entity, &self.context()) + fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { + self.api().update_release(id, entity, editgroup, &self.context()) } - fn update_work(&self, id: String, entity: models::WorkEntity) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - self.api().update_work(id, entity, &self.context()) + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option<String>) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { + self.api().update_work(id, entity, editgroup, &self.context()) } } diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs index 81701b70..980d3059 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -61,14 +61,13 @@ pub struct ContainerEntity { #[serde(rename = "name")] pub name: String, - #[serde(rename = "extra")] + #[serde(rename = "edit_extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, + pub edit_extra: Option<serde_json::Value>, - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] + #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, + pub extra: Option<serde_json::Value>, /// base32-encoded unique identifier #[serde(rename = "redirect")] @@ -100,8 +99,8 @@ impl ContainerEntity { issnl: None, publisher: None, name: name, + edit_extra: None, extra: None, - editgroup_id: None, redirect: None, revision: None, ident: None, @@ -151,14 +150,13 @@ pub struct CreatorEntity { #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<String>, - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] pub extra: Option<serde_json::Value>, + + #[serde(rename = "edit_extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub edit_extra: Option<serde_json::Value>, } impl CreatorEntity { @@ -173,8 +171,8 @@ impl CreatorEntity { ident: None, revision: None, redirect: None, - editgroup_id: None, extra: None, + edit_extra: None, } } } @@ -372,14 +370,13 @@ pub struct FileEntity { #[serde(skip_serializing_if = "Option::is_none")] pub size: Option<i64>, - #[serde(rename = "extra")] + #[serde(rename = "edit_extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, + pub edit_extra: Option<serde_json::Value>, - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] + #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, + pub extra: Option<serde_json::Value>, /// base32-encoded unique identifier #[serde(rename = "redirect")] @@ -412,8 +409,8 @@ impl FileEntity { md5: None, sha1: None, size: None, + edit_extra: None, extra: None, - editgroup_id: None, redirect: None, revision: None, ident: None, @@ -590,14 +587,13 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<String>, - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] pub extra: Option<serde_json::Value>, + + #[serde(rename = "edit_extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub edit_extra: Option<serde_json::Value>, } impl ReleaseEntity { @@ -629,8 +625,8 @@ impl ReleaseEntity { ident: None, revision: None, redirect: None, - editgroup_id: None, extra: None, + edit_extra: None, } } } @@ -742,14 +738,13 @@ impl Success { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct WorkEntity { - #[serde(rename = "extra")] + #[serde(rename = "edit_extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, + pub edit_extra: Option<serde_json::Value>, - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] + #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, + pub extra: Option<serde_json::Value>, /// base32-encoded unique identifier #[serde(rename = "redirect")] @@ -775,8 +770,8 @@ pub struct WorkEntity { impl WorkEntity { pub fn new() -> WorkEntity { WorkEntity { + edit_extra: None, extra: None, - editgroup_id: None, redirect: None, revision: None, ident: None, diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index 5510b34d..8c699065 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -204,6 +204,10 @@ where context.auth_data = req.extensions.remove::<AuthData>(); context.authorization = req.extensions.remove::<Authorization>(); + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -229,7 +233,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.create_container(param_entity, context).wait() { + match api.create_container(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { CreateContainerResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -423,6 +427,10 @@ where context.auth_data = req.extensions.remove::<AuthData>(); context.authorization = req.extensions.remove::<Authorization>(); + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -448,7 +456,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.create_creator(param_entity, context).wait() { + match api.create_creator(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { CreateCreatorResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -736,6 +744,10 @@ where context.auth_data = req.extensions.remove::<AuthData>(); context.authorization = req.extensions.remove::<Authorization>(); + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -761,7 +773,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.create_file(param_entity, context).wait() { + match api.create_file(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { CreateFileResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -955,6 +967,10 @@ where context.auth_data = req.extensions.remove::<AuthData>(); context.authorization = req.extensions.remove::<Authorization>(); + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -980,7 +996,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.create_release(param_entity, context).wait() { + match api.create_release(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { CreateReleaseResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1174,6 +1190,10 @@ where context.auth_data = req.extensions.remove::<AuthData>(); context.authorization = req.extensions.remove::<Authorization>(); + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1199,7 +1219,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.create_work(param_entity, context).wait() { + match api.create_work(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { CreateWorkResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -3868,6 +3888,10 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -3893,7 +3917,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.update_container(param_id, param_entity, context).wait() { + match api.update_container(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { UpdateContainerResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -3990,6 +4014,10 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -4015,7 +4043,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.update_creator(param_id, param_entity, context).wait() { + match api.update_creator(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { UpdateCreatorResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -4112,6 +4140,10 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -4137,7 +4169,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.update_file(param_id, param_entity, context).wait() { + match api.update_file(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { UpdateFileResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -4234,6 +4266,10 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -4259,7 +4295,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.update_release(param_id, param_entity, context).wait() { + match api.update_release(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { UpdateReleaseResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -4356,6 +4392,10 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; + // 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::<UrlEncodedQuery>().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); + // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -4381,7 +4421,7 @@ where }; let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.update_work(param_id, param_entity, context).wait() { + match api.update_work(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { UpdateWorkResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); |