From 09475b87821142c5cd36c6b90fb97deb2a058312 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 22 Jan 2019 21:41:35 -0800 Subject: allow passing description+extra to batch endpoints Pretty messy, but I needed some way to do this. In particular, requires json.dumps() in python code, for now. Blech. --- fatcat-openapi2.yml | 56 +++++++ python_client/fatcat_client/api/default_api.py | 70 ++++++++- rust/fatcat-api-spec/README.md | 2 +- rust/fatcat-api-spec/api.yaml | 56 +++++++ rust/fatcat-api-spec/api/swagger.yaml | 84 ++++++++++ rust/fatcat-api-spec/examples/client.rs | 70 ++++++++- rust/fatcat-api-spec/examples/server_lib/server.rs | 42 ++++- rust/fatcat-api-spec/src/client.rs | 70 +++++++-- rust/fatcat-api-spec/src/lib.rs | 84 ++++++++-- rust/fatcat-api-spec/src/server.rs | 49 +++++- rust/src/editing.rs | 6 +- rust/src/endpoint_handlers.rs | 172 +++++++++++---------- rust/src/endpoints.rs | 14 +- rust/tests/test_refs.rs | 6 +- 14 files changed, 638 insertions(+), 143 deletions(-) diff --git a/fatcat-openapi2.yml b/fatcat-openapi2.yml index c0411bbc..14b70c39 100644 --- a/fatcat-openapi2.yml +++ b/fatcat-openapi2.yml @@ -706,6 +706,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -964,6 +972,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1245,6 +1261,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1508,6 +1532,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1737,6 +1769,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1966,6 +2006,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -2318,6 +2366,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true diff --git a/python_client/fatcat_client/api/default_api.py b/python_client/fatcat_client/api/default_api.py index 3ddfefcc..75e5b0a8 100644 --- a/python_client/fatcat_client/api/default_api.py +++ b/python_client/fatcat_client/api/default_api.py @@ -445,6 +445,8 @@ class DefaultApi(object): :param list[ContainerEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -468,12 +470,14 @@ class DefaultApi(object): :param list[ContainerEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -502,6 +506,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -655,6 +663,8 @@ class DefaultApi(object): :param list[CreatorEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -678,12 +688,14 @@ class DefaultApi(object): :param list[CreatorEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -712,6 +724,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -1075,6 +1091,8 @@ class DefaultApi(object): :param list[FileEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -1098,12 +1116,14 @@ class DefaultApi(object): :param list[FileEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1132,6 +1152,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -1285,6 +1309,8 @@ class DefaultApi(object): :param list[FilesetEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -1308,12 +1334,14 @@ class DefaultApi(object): :param list[FilesetEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1342,6 +1370,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -1495,6 +1527,8 @@ class DefaultApi(object): :param list[ReleaseEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -1518,12 +1552,14 @@ class DefaultApi(object): :param list[ReleaseEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1552,6 +1588,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -1705,6 +1745,8 @@ class DefaultApi(object): :param list[WebcaptureEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -1728,12 +1770,14 @@ class DefaultApi(object): :param list[WebcaptureEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1762,6 +1806,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} @@ -1915,6 +1963,8 @@ class DefaultApi(object): :param list[WorkEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. @@ -1938,12 +1988,14 @@ class DefaultApi(object): :param list[WorkEntity] entity_list: (required) :param bool autoaccept: If true, and editor is authorized, batch is accepted all at once :param str editgroup_id: Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True) + :param str description: + :param str extra: :return: list[EntityEdit] If the method is called asynchronously, returns the request thread. """ - all_params = ['entity_list', 'autoaccept', 'editgroup_id'] # noqa: E501 + all_params = ['entity_list', 'autoaccept', 'editgroup_id', 'description', 'extra'] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1972,6 +2024,10 @@ class DefaultApi(object): query_params.append(('autoaccept', params['autoaccept'])) # noqa: E501 if 'editgroup_id' in params: query_params.append(('editgroup_id', params['editgroup_id'])) # noqa: E501 + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'extra' in params: + query_params.append(('extra', params['extra'])) # noqa: E501 header_params = {} diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 2ea830e9..cacded6a 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-21T20:07:57.927Z +- Build date: 2019-01-23T05:30:23.378Z 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 c0411bbc..14b70c39 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -706,6 +706,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -964,6 +972,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1245,6 +1261,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1508,6 +1532,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1737,6 +1769,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -1966,6 +2006,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true @@ -2318,6 +2366,14 @@ paths: type: string required: false description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" + - name: description + in: query + type: string + required: false + - name: extra + in: query + type: string + required: false - name: entity_list in: body required: true diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index ca5c8838..927bb941 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -135,6 +135,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -981,6 +993,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -1891,6 +1915,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -2750,6 +2786,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -3519,6 +3567,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -4288,6 +4348,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true @@ -5360,6 +5432,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"editgroup_id_example\".to_string())" + - name: "description" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"description_example\".to_string())" + - name: "extra" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"extra_example\".to_string())" - in: "body" name: "entity_list" required: true diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 196580e4..40a5a3ab 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -144,7 +144,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateContainerBatch") => { - let result = client.create_container_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_container_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -211,7 +219,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateCreatorBatch") => { - let result = client.create_creator_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_creator_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -359,7 +375,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateFileBatch") => { - let result = client.create_file_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_file_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -427,7 +451,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateFilesetBatch") => { - let result = client.create_fileset_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_fileset_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -482,7 +514,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateReleaseBatch") => { - let result = client.create_release_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_release_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -575,7 +615,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateWebcaptureBatch") => { - let result = client.create_webcapture_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_webcapture_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -624,7 +672,15 @@ fn main() { // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, Some("CreateWorkBatch") => { - let result = client.create_work_batch(&Vec::new(), Some(true), Some("editgroup_id_example".to_string())).wait(); + let result = client + .create_work_batch( + &Vec::new(), + Some(true), + Some("editgroup_id_example".to_string()), + Some("description_example".to_string()), + Some("extra_example".to_string()), + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 20336528..98f31485 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -46,14 +46,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_container_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_container_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -171,14 +175,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_creator_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_creator_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -465,14 +473,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_file_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_file_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -592,14 +604,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_fileset_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_fileset_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -697,14 +713,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_release_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_release_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -878,14 +898,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_webcapture_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_webcapture_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) @@ -972,14 +996,18 @@ impl Api for Server { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "create_work_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "create_work_batch({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", entity_list, autoaccept, editgroup_id, + description, + extra, context.x_span_id.unwrap_or(String::from("")).clone() ); Box::new(futures::failed("Generic failure".into())) diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index df9d2127..6d654146 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -272,17 +272,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/container/batch?{autoaccept}{editgroup_id}", + "{}/v0/container/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -1167,17 +1173,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/creator/batch?{autoaccept}{editgroup_id}", + "{}/v0/creator/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -3364,17 +3376,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/file/batch?{autoaccept}{editgroup_id}", + "{}/v0/file/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -4256,17 +4274,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/fileset/batch?{autoaccept}{editgroup_id}", + "{}/v0/fileset/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -5071,17 +5095,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/release/batch?{autoaccept}{editgroup_id}", + "{}/v0/release/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -6278,17 +6308,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/webcapture/batch?{autoaccept}{editgroup_id}", + "{}/v0/webcapture/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -6999,17 +7035,23 @@ impl Api for Client { param_entity_list: &Vec, param_autoaccept: Option, param_editgroup_id: Option, + param_description: Option, + param_extra: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); 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_description = param_description.map_or_else(String::new, |query| format!("description={description}&", description = query.to_string())); + let query_extra = param_extra.map_or_else(String::new, |query| format!("extra={extra}&", extra = query.to_string())); let url = format!( - "{}/v0/work/batch?{autoaccept}{editgroup_id}", + "{}/v0/work/batch?{autoaccept}{editgroup_id}{description}{extra}", self.base_path, autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET) + editgroup_id = utf8_percent_encode(&query_editgroup_id, QUERY_ENCODE_SET), + description = utf8_percent_encode(&query_description, QUERY_ENCODE_SET), + extra = utf8_percent_encode(&query_extra, QUERY_ENCODE_SET) ); let body = serde_json::to_string(¶m_entity_list).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 20e53f62..59129869 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -1345,6 +1345,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1380,6 +1382,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1473,6 +1477,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1509,6 +1515,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1535,6 +1543,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1584,6 +1594,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1608,6 +1620,8 @@ pub trait Api { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send>; @@ -1639,6 +1653,8 @@ pub trait ApiNoContext { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send>; fn delete_container(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1672,6 +1688,8 @@ pub trait ApiNoContext { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send>; fn delete_creator(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1744,7 +1762,14 @@ pub trait ApiNoContext { 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 create_file_batch( + &self, + entity_list: &Vec, + autoaccept: Option, + editgroup_id: Option, + description: Option, + extra: Option, + ) -> Box + Send>; fn delete_file(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1778,6 +1803,8 @@ pub trait ApiNoContext { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send>; fn delete_fileset(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1803,6 +1830,8 @@ pub trait ApiNoContext { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send>; fn create_work(&self, entity: models::WorkEntity, editgroup_id: String) -> Box + Send>; @@ -1850,6 +1879,8 @@ pub trait ApiNoContext { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send>; fn delete_webcapture(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1868,7 +1899,14 @@ pub trait ApiNoContext { 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 create_work_batch( + &self, + entity_list: &Vec, + autoaccept: Option, + editgroup_id: Option, + description: Option, + extra: Option, + ) -> Box + Send>; fn delete_work(&self, ident: String, editgroup_id: String) -> Box + Send>; @@ -1914,8 +1952,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send> { - self.api().create_container_batch(entity_list, autoaccept, editgroup_id, &self.context()) + self.api().create_container_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_container(&self, ident: String, editgroup_id: String) -> Box + Send> { @@ -1969,8 +2009,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send> { - self.api().create_creator_batch(entity_list, autoaccept, editgroup_id, &self.context()) + self.api().create_creator_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_creator(&self, ident: String, editgroup_id: String) -> Box + Send> { @@ -2095,8 +2137,15 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_file(entity, editgroup_id, &self.context()) } - fn create_file_batch(&self, entity_list: &Vec, autoaccept: Option, editgroup_id: Option) -> Box + Send> { - self.api().create_file_batch(entity_list, autoaccept, editgroup_id, &self.context()) + fn create_file_batch( + &self, + entity_list: &Vec, + autoaccept: Option, + editgroup_id: Option, + description: Option, + extra: Option, + ) -> Box + Send> { + self.api().create_file_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_file(&self, ident: String, editgroup_id: String) -> Box + Send> { @@ -2151,8 +2200,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send> { - self.api().create_fileset_batch(entity_list, autoaccept, editgroup_id, &self.context()) + self.api().create_fileset_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_fileset(&self, ident: String, editgroup_id: String) -> Box + Send> { @@ -2196,8 +2247,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send> { - self.api().create_release_batch(entity_list, autoaccept, editgroup_id, &self.context()) + self.api().create_release_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn create_work(&self, entity: models::WorkEntity, editgroup_id: String) -> Box + Send> { @@ -2274,8 +2327,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, ) -> Box + Send> { - self.api().create_webcapture_batch(entity_list, autoaccept, editgroup_id, &self.context()) + self.api().create_webcapture_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_webcapture(&self, ident: String, editgroup_id: String) -> Box + Send> { @@ -2310,8 +2365,15 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().update_webcapture(ident, entity, editgroup_id, &self.context()) } - fn create_work_batch(&self, entity_list: &Vec, autoaccept: Option, editgroup_id: Option) -> Box + Send> { - self.api().create_work_batch(entity_list, autoaccept, editgroup_id, &self.context()) + fn create_work_batch( + &self, + entity_list: &Vec, + autoaccept: Option, + editgroup_id: Option, + description: Option, + extra: Option, + ) -> Box + Send> { + self.api().create_work_batch(entity_list, autoaccept, editgroup_id, description, extra, &self.context()) } fn delete_work(&self, ident: String, editgroup_id: String) -> Box + Send> { diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index c3d018d1..af13948e 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -269,6 +269,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -295,7 +297,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_container_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_container_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateContainerBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1505,6 +1510,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -1531,7 +1538,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_creator_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_creator_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateCreatorBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -4594,6 +4604,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -4620,7 +4632,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_file_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_file_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateFileBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -5831,6 +5846,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -5857,7 +5874,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_fileset_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_fileset_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateFilesetBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -6986,6 +7006,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -7012,7 +7034,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_release_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_release_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateReleaseBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -8668,6 +8693,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -8694,7 +8721,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_webcapture_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_webcapture_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateWebcaptureBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -9677,6 +9707,8 @@ where .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; let param_editgroup_id = query_params.get("editgroup_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_description = query_params.get("description").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_extra = query_params.get("extra").and_then(|list| list.first()).and_then(|x| x.parse::().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 @@ -9703,7 +9735,10 @@ where }; let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; - match api.create_work_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, context).wait() { + match api + .create_work_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup_id, param_description, param_extra, context) + .wait() + { Ok(rsp) => match rsp { CreateWorkBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); diff --git a/rust/src/editing.rs b/rust/src/editing.rs index e181e8a7..c17e5964 100644 --- a/rust/src/editing.rs +++ b/rust/src/editing.rs @@ -42,6 +42,8 @@ pub fn make_edit_context( editor_id: FatcatId, editgroup_id: Option, autoaccept: bool, + description: Option, + extra: Option, ) -> Result { // *either* autoaccept is false and editgroup_id is Some, *or* autoaccept is true and // editgroup_id is None @@ -54,8 +56,8 @@ pub fn make_edit_context( editor: None, changelog_index: None, submitted: None, - description: None, - extra: None, + description: description, + extra: extra, annotations: None, edits: None, }; diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs index 4567e810..d9bd3403 100644 --- a/rust/src/endpoint_handlers.rs +++ b/rust/src/endpoint_handlers.rs @@ -26,9 +26,11 @@ macro_rules! entity_batch_handler { autoaccept: bool, editor_id: FatcatId, editgroup_id: Option, + description: Option, + extra: Option, ) -> Result> { - let edit_context = make_edit_context(conn, editor_id, editgroup_id, autoaccept)?; + let edit_context = make_edit_context(conn, editor_id, editgroup_id, autoaccept, description, extra)?; edit_context.check(&conn)?; let model_list: Vec<&models::$model> = entity_list.iter().map(|e| e).collect(); let edits = $model::db_create_batch(conn, &edit_context, model_list.as_slice())?; @@ -264,86 +266,94 @@ impl Server { expand_flags: ExpandFlags, hide_flags: HideFlags, ) -> Result { - let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) = - match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id) { - (Some(doi), None, None, None, None, None, None, None) => { - check_doi(doi)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::doi.eq(doi)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, Some(wikidata_qid), None, None, None, None, None, None) => { - check_wikidata_qid(wikidata_qid)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::wikidata_qid.eq(wikidata_qid)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, Some(isbn13), None, None, None, None, None) => { - // TODO: check_isbn13(isbn13)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::isbn13.eq(isbn13)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, None, Some(pmid), None, None, None, None) => { - check_pmid(pmid)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::pmid.eq(pmid)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, None, None, Some(pmcid), None, None, None) => { - check_pmcid(pmcid)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::pmcid.eq(pmcid)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, None, None, None, Some(core_id), None, None) => { - // TODO: check_core_id(core_id)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::core_id.eq(core_id)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, None, None, None, None, Some(arxiv_id), None) => { - // TODO: check_arxiv_id(arxiv_id)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::arxiv_id.eq(arxiv_id)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - (None, None, None, None, None, None, None, Some(jstor_id)) => { - // TODO: check_jstor_id(jstor_id)?; - release_ident::table - .inner_join(release_rev::table) - .filter(release_rev::jstor_id.eq(jstor_id)) - .filter(release_ident::is_live.eq(true)) - .filter(release_ident::redirect_id.is_null()) - .first(conn)? - } - _ => { - return Err( - FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(), - ); - } - }; + let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) = match ( + doi, + wikidata_qid, + isbn13, + pmid, + pmcid, + core_id, + arxiv_id, + jstor_id, + ) { + (Some(doi), None, None, None, None, None, None, None) => { + check_doi(doi)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::doi.eq(doi)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, Some(wikidata_qid), None, None, None, None, None, None) => { + check_wikidata_qid(wikidata_qid)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::wikidata_qid.eq(wikidata_qid)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, Some(isbn13), None, None, None, None, None) => { + // TODO: check_isbn13(isbn13)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::isbn13.eq(isbn13)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, Some(pmid), None, None, None, None) => { + check_pmid(pmid)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::pmid.eq(pmid)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, None, Some(pmcid), None, None, None) => { + check_pmcid(pmcid)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::pmcid.eq(pmcid)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, None, None, Some(core_id), None, None) => { + // TODO: check_core_id(core_id)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::core_id.eq(core_id)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, None, None, None, Some(arxiv_id), None) => { + // TODO: check_arxiv_id(arxiv_id)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::arxiv_id.eq(arxiv_id)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, None, None, None, None, Some(jstor_id)) => { + // TODO: check_jstor_id(jstor_id)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::jstor_id.eq(jstor_id)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + _ => { + return Err( + FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(), + ); + } + }; let mut entity = ReleaseEntity::db_from_row(conn, rev, Some(ident), hide_flags)?; entity.db_expand(&conn, expand_flags)?; diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs index 8c45ea75..2e467957 100644 --- a/rust/src/endpoints.rs +++ b/rust/src/endpoints.rs @@ -120,7 +120,7 @@ macro_rules! wrap_entity_handlers { let auth_context = self.auth_confectionary.require_auth(&conn, &context.auth_data, Some(stringify!($post_fn)))?; auth_context.require_role(FatcatRole::Editor)?; auth_context.require_editgroup(&conn, editgroup_id)?; - let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false, None, None)?; edit_context.check(&conn)?; entity.db_create(&conn, &edit_context)?.into_model() }).map_err(|e| FatcatError::from(e)) { @@ -138,6 +138,8 @@ macro_rules! wrap_entity_handlers { entity_list: &Vec, autoaccept: Option, editgroup_id: Option, + description: Option, + extra: Option, context: &Context, ) -> Box + Send> { let conn = self.db_pool.get().expect("db_pool error"); @@ -155,7 +157,11 @@ macro_rules! wrap_entity_handlers { auth_context.require_editgroup(&conn, eg_id)?; Some(eg_id) } else { None }; - self.$post_batch_handler(&conn, entity_list, autoaccept, auth_context.editor_id, editgroup_id) + let extra: Option = match extra { + Some(v) => serde_json::from_str(&v)?, + None => None, + }; + self.$post_batch_handler(&conn, entity_list, autoaccept, auth_context.editor_id, editgroup_id, description, extra) }).map_err(|e| FatcatError::from(e)) { Ok(edits) => { self.metrics.count("entities.created", edits.len() as i64).ok(); @@ -184,7 +190,7 @@ macro_rules! wrap_entity_handlers { auth_context.require_role(FatcatRole::Editor)?; let entity_id = FatcatId::from_str(&ident)?; auth_context.require_editgroup(&conn, editgroup_id)?; - let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false, None, None)?; edit_context.check(&conn)?; entity.db_update(&conn, &edit_context, entity_id)?.into_model() }).map_err(|e| FatcatError::from(e)) { @@ -210,7 +216,7 @@ macro_rules! wrap_entity_handlers { auth_context.require_role(FatcatRole::Editor)?; let entity_id = FatcatId::from_str(&ident)?; auth_context.require_editgroup(&conn, editgroup_id)?; - let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false)?; + let edit_context = make_edit_context(&conn, auth_context.editor_id, Some(editgroup_id), false, None, None)?; edit_context.check(&conn)?; $model::db_delete(&conn, &edit_context, entity_id)?.into_model() }).map_err(|e| FatcatError::from(e)) { diff --git a/rust/tests/test_refs.rs b/rust/tests/test_refs.rs index 262f1d85..ae4be4b5 100644 --- a/rust/tests/test_refs.rs +++ b/rust/tests/test_refs.rs @@ -17,7 +17,8 @@ fn test_refs_blob() { let conn = server.db_pool.get().expect("db_pool error"); let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap(); let editgroup_id = helpers::quick_editgroup(&conn); - let edit_context = make_edit_context(&conn, editor_id, Some(editgroup_id), false).unwrap(); + let edit_context = + make_edit_context(&conn, editor_id, Some(editgroup_id), false, None, None).unwrap(); // this release entity should be unchanged after being inserted/fetched let mut r1 = ReleaseEntity::new(); @@ -153,7 +154,8 @@ fn test_refs_blob() { // update r1 with new target_idents (r3); SHA1 row still shouldn't change accept_editgroup(&conn, editgroup_id).unwrap(); let editgroup_id = helpers::quick_editgroup(&conn); - let edit_context = make_edit_context(&conn, editor_id, Some(editgroup_id), false).unwrap(); + let edit_context = + make_edit_context(&conn, editor_id, Some(editgroup_id), false, None, None).unwrap(); let _edit4 = r3b .db_update(&conn, &edit_context, edit1.ident_id.into()) -- cgit v1.2.3