From 061e66c4c41063e6b7321f1f421b5152e9e5a84d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 13 Dec 2018 19:36:25 +0800 Subject: schema tweaks, and rust codegen --- fatcat-openapi2.yml | 28 +- rust/fatcat-api-spec/README.md | 22 +- rust/fatcat-api-spec/api.yaml | 458 ++- rust/fatcat-api-spec/api/swagger.yaml | 1364 ++++++- rust/fatcat-api-spec/examples/client.rs | 169 +- rust/fatcat-api-spec/examples/server_lib/server.rs | 213 +- rust/fatcat-api-spec/src/client.rs | 1473 ++++++- rust/fatcat-api-spec/src/lib.rs | 464 ++- rust/fatcat-api-spec/src/mimetypes.rs | 320 ++ rust/fatcat-api-spec/src/models.rs | 34 +- rust/fatcat-api-spec/src/server.rs | 4018 ++++++++++++++------ 11 files changed, 7239 insertions(+), 1324 deletions(-) diff --git a/fatcat-openapi2.yml b/fatcat-openapi2.yml index f7deb6d4..e452e945 100644 --- a/fatcat-openapi2.yml +++ b/fatcat-openapi2.yml @@ -135,14 +135,14 @@ definitions: type: integer example: 1048576 format: int64 - sha1: - type: string - #format: custom - example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" md5: type: string #format: custom example: "d41efcc592d1e40ac13905377399eb9b" + sha1: + type: string + #format: custom + example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" sha256: type: string #format: custom @@ -673,7 +673,7 @@ paths: 200: description: Deleted Edit schema: - $ref: "#/definitions/entity_edit" + $ref: "#/definitions/success" <<: *ENTITYRESPONSES /creator: post: @@ -863,7 +863,7 @@ paths: items: $ref: "#/definitions/release_entity" <<: *ENTITYRESPONSES - /release/{id}/redirects: + /creator/{id}/redirects: parameters: - name: id in: path @@ -871,8 +871,8 @@ paths: required: true get: tags: # TAGLINE - - releases # TAGLINE - operationId: "get_release_redirects" + - creators # TAGLINE + operationId: "get_creator_redirects" responses: 200: description: Found Entity Redirects @@ -937,7 +937,7 @@ paths: 200: description: Deleted Edit schema: - $ref: "#/definitions/entity_edit" + $ref: "#/definitions/success" <<: *ENTITYRESPONSES /file: post: @@ -1129,11 +1129,11 @@ paths: tags: # TAGLINE - files # TAGLINE parameters: - - name: sha1 + - name: md5 in: query type: string required: false - - name: md5 + - name: sha1 in: query type: string required: false @@ -1183,7 +1183,7 @@ paths: 200: description: Deleted Edit schema: - $ref: "#/definitions/entity_edit" + $ref: "#/definitions/success" <<: *ENTITYRESPONSES /release: post: @@ -1460,7 +1460,7 @@ paths: 200: description: Deleted Edit schema: - $ref: "#/definitions/entity_edit" + $ref: "#/definitions/success" <<: *ENTITYRESPONSES /work: post: @@ -1700,7 +1700,7 @@ paths: 200: description: Deleted Edit schema: - $ref: "#/definitions/entity_edit" + $ref: "#/definitions/success" <<: *ENTITYRESPONSES /editor/{id}: parameters: diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 0be0b94c..f0466320 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-11-27T07:17:13.513Z +- Build date: 2018-12-13T11:34:47.140Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. @@ -59,16 +59,24 @@ To run a client, follow one of the following simple steps: cargo run --example client CreateContainer cargo run --example client CreateContainerBatch cargo run --example client DeleteContainer +cargo run --example client DeleteContainerEdit cargo run --example client GetContainer +cargo run --example client GetContainerEdit cargo run --example client GetContainerHistory +cargo run --example client GetContainerRedirects +cargo run --example client GetContainerRevision cargo run --example client LookupContainer cargo run --example client UpdateContainer cargo run --example client CreateCreator cargo run --example client CreateCreatorBatch cargo run --example client DeleteCreator +cargo run --example client DeleteCreatorEdit cargo run --example client GetCreator +cargo run --example client GetCreatorEdit cargo run --example client GetCreatorHistory +cargo run --example client GetCreatorRedirects cargo run --example client GetCreatorReleases +cargo run --example client GetCreatorRevision cargo run --example client LookupCreator cargo run --example client UpdateCreator cargo run --example client GetEditor @@ -82,24 +90,36 @@ cargo run --example client GetEditgroup cargo run --example client CreateFile cargo run --example client CreateFileBatch cargo run --example client DeleteFile +cargo run --example client DeleteFileEdit cargo run --example client GetFile +cargo run --example client GetFileEdit cargo run --example client GetFileHistory +cargo run --example client GetFileRedirects +cargo run --example client GetFileRevision cargo run --example client LookupFile cargo run --example client UpdateFile cargo run --example client CreateRelease cargo run --example client CreateReleaseBatch cargo run --example client CreateWork cargo run --example client DeleteRelease +cargo run --example client DeleteReleaseEdit cargo run --example client GetRelease +cargo run --example client GetReleaseEdit cargo run --example client GetReleaseFiles cargo run --example client GetReleaseHistory +cargo run --example client GetReleaseRedirects +cargo run --example client GetReleaseRevision cargo run --example client LookupRelease cargo run --example client UpdateRelease cargo run --example client CreateWorkBatch cargo run --example client DeleteWork +cargo run --example client DeleteWorkEdit cargo run --example client GetWork +cargo run --example client GetWorkEdit cargo run --example client GetWorkHistory +cargo run --example client GetWorkRedirects cargo run --example client GetWorkReleases +cargo run --example client GetWorkRevision cargo run --example client UpdateWork ``` diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml index d998b63b..e452e945 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -92,13 +92,13 @@ definitions: example: "The computers did the thing successfully!" container_entity: type: object - required: - - name + # required for creation: name properties: <<: *ENTITYPROPS name: type: string example: "Journal of Important Results" + description: "Required for valid entities" publisher: type: string example: "Society of Curious Students" @@ -112,13 +112,13 @@ definitions: type: string creator_entity: type: object - required: - - display_name + # required for creation: display_name properties: <<: *ENTITYPROPS display_name: type: string example: "Grace Hopper" + description: "Required for valid entities" given_name: type: string surname: @@ -135,14 +135,14 @@ definitions: type: integer example: 1048576 format: int64 - sha1: - type: string - #format: custom - example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" md5: type: string #format: custom example: "d41efcc592d1e40ac13905377399eb9b" + sha1: + type: string + #format: custom + example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" sha256: type: string #format: custom @@ -172,12 +172,12 @@ definitions: #format: uuid release_entity: type: object - required: - - title + # required for creation: title properties: <<: *ENTITYPROPS title: type: string + description: "Required for valid entities" work_id: type: string example: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -548,6 +548,34 @@ paths: schema: $ref: "#/definitions/entity_edit" <<: *ENTITYRESPONSES + /container/rev/{id}: + parameters: + - name: id + in: path + type: string + #format: uuid + required: true + get: + operationId: "get_container_revision" + tags: # TAGLINE + - containers # TAGLINE + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For containers, none accepted (yet)." + - name: hide + in: query + type: string + required: false + description: "List of entity fields to elide in response. For containers, none accepted (yet)." + responses: + 200: + description: Found Entity Revision + schema: + $ref: "#/definitions/container_entity" + <<: *ENTITYRESPONSES /container/{id}/history: parameters: - name: id @@ -571,6 +599,25 @@ paths: items: $ref: "#/definitions/entity_history_entry" <<: *ENTITYRESPONSES + /container/{id}/redirects: + parameters: + - name: id + in: path + type: string + required: true + get: + tags: # TAGLINE + - containers # TAGLINE + operationId: "get_container_redirects" + responses: + 200: + description: Found Entity Redirects + schema: + type: array + items: + type: string + #format: ident + <<: *ENTITYRESPONSES /container/lookup: get: operationId: "lookup_container" @@ -579,8 +626,11 @@ paths: parameters: - name: issnl in: query - required: true + required: false <<: *FATCATISSN + - name: wikidata_qid + in: query + required: false - name: hide in: query type: string @@ -592,6 +642,39 @@ paths: schema: $ref: "#/definitions/container_entity" <<: *ENTITYRESPONSES + /container/edit/{edit_id}: + get: + operationId: "get_container_edit" + tags: # TAGLINE + - containers # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Found Edit + schema: + $ref: "#/definitions/entity_edit" + <<: *ENTITYRESPONSES + delete: + operationId: "delete_container_edit" + tags: # TAGLINE + - containers # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Deleted Edit + schema: + $ref: "#/definitions/success" + <<: *ENTITYRESPONSES /creator: post: operationId: "create_creator" @@ -706,6 +789,34 @@ paths: schema: $ref: "#/definitions/entity_edit" <<: *ENTITYRESPONSES + /creator/rev/{id}: + parameters: + - name: id + in: path + type: string + #format: uuid + required: true + get: + operationId: "get_creator_revision" + tags: # TAGLINE + - creators # TAGLINE + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For creators, none accepted (yet)." + - name: hide + in: query + type: string + required: false + description: "List of entity fields to elide in response. For creators, none accepted (yet)." + responses: + 200: + description: Found Entity Revision + schema: + $ref: "#/definitions/creator_entity" + <<: *ENTITYRESPONSES /creator/{id}/history: parameters: - name: id @@ -752,6 +863,25 @@ paths: items: $ref: "#/definitions/release_entity" <<: *ENTITYRESPONSES + /creator/{id}/redirects: + parameters: + - name: id + in: path + type: string + required: true + get: + tags: # TAGLINE + - creators # TAGLINE + operationId: "get_creator_redirects" + responses: + 200: + description: Found Entity Redirects + schema: + type: array + items: + type: string + #format: ident + <<: *ENTITYRESPONSES /creator/lookup: get: operationId: "lookup_creator" @@ -760,8 +890,11 @@ paths: parameters: - name: orcid in: query - required: true + required: false <<: *FATCATORCID + - name: wikidata_qid + in: query + required: false - name: hide in: query type: string @@ -773,6 +906,39 @@ paths: schema: $ref: "#/definitions/creator_entity" <<: *ENTITYRESPONSES + /creator/edit/{edit_id}: + get: + operationId: "get_creator_edit" + tags: # TAGLINE + - creators # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Found Edit + schema: + $ref: "#/definitions/entity_edit" + <<: *ENTITYRESPONSES + delete: + operationId: "delete_creator_edit" + tags: # TAGLINE + - creators # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Deleted Edit + schema: + $ref: "#/definitions/success" + <<: *ENTITYRESPONSES /file: post: operationId: "create_file" @@ -887,6 +1053,34 @@ paths: schema: $ref: "#/definitions/entity_edit" <<: *ENTITYRESPONSES + /file/rev/{id}: + parameters: + - name: id + in: path + type: string + #format: uuid + required: true + get: + operationId: "get_file_revision" + tags: # TAGLINE + - files # TAGLINE + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For files, none accepted (yet)." + - name: hide + in: query + type: string + required: false + description: "List of entity fields to elide in response. For files, none accepted (yet)." + responses: + 200: + description: Found Entity Revision + schema: + $ref: "#/definitions/file_entity" + <<: *ENTITYRESPONSES /file/{id}/history: parameters: - name: id @@ -910,16 +1104,43 @@ paths: items: $ref: "#/definitions/entity_history_entry" <<: *ENTITYRESPONSES + /file/{id}/redirects: + parameters: + - name: id + in: path + type: string + required: true + get: + tags: # TAGLINE + - files # TAGLINE + operationId: "get_file_redirects" + responses: + 200: + description: Found Entity Redirects + schema: + type: array + items: + type: string + #format: ident + <<: *ENTITYRESPONSES /file/lookup: get: operationId: "lookup_file" tags: # TAGLINE - files # TAGLINE parameters: + - name: md5 + in: query + type: string + required: false - name: sha1 in: query type: string - required: true + required: false + - name: sha256 + in: query + type: string + required: false - name: hide in: query type: string @@ -931,6 +1152,39 @@ paths: schema: $ref: "#/definitions/file_entity" <<: *ENTITYRESPONSES + /file/edit/{edit_id}: + get: + operationId: "get_file_edit" + tags: # TAGLINE + - files # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Found Edit + schema: + $ref: "#/definitions/entity_edit" + <<: *ENTITYRESPONSES + delete: + operationId: "delete_file_edit" + tags: # TAGLINE + - files # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Deleted Edit + schema: + $ref: "#/definitions/success" + <<: *ENTITYRESPONSES /release: post: operationId: "create_release" @@ -1045,6 +1299,34 @@ paths: schema: $ref: "#/definitions/entity_edit" <<: *ENTITYRESPONSES + /release/rev/{id}: + parameters: + - name: id + in: path + type: string + #format: uuid + required: true + get: + operationId: "get_release_revision" + tags: # TAGLINE + - releases # TAGLINE + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For releases, none accepted (yet)." + - name: hide + in: query + type: string + required: false + description: "List of entity fields to elide in response. For releases, none accepted (yet)." + responses: + 200: + description: Found Entity Revision + schema: + $ref: "#/definitions/release_entity" + <<: *ENTITYRESPONSES /release/{id}/history: parameters: - name: id @@ -1091,6 +1373,25 @@ paths: items: $ref: "#/definitions/file_entity" <<: *ENTITYRESPONSES + /release/{id}/redirects: + parameters: + - name: id + in: path + type: string + required: true + get: + tags: # TAGLINE + - releases # TAGLINE + operationId: "get_release_redirects" + responses: + 200: + description: Found Entity Redirects + schema: + type: array + items: + type: string + #format: ident + <<: *ENTITYRESPONSES /release/lookup: get: operationId: "lookup_release" @@ -1100,7 +1401,23 @@ paths: - name: doi in: query type: string - required: true + required: false + - name: wikidata_qid + in: query + type: string + required: false + - name: isbn13 + in: query + type: string + required: false + - name: pmid + in: query + type: string + required: false + - name: pmcid + in: query + type: string + required: false - name: hide in: query type: string @@ -1112,6 +1429,39 @@ paths: schema: $ref: "#/definitions/release_entity" <<: *ENTITYRESPONSES + /release/edit/{edit_id}: + get: + operationId: "get_release_edit" + tags: # TAGLINE + - releases # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Found Edit + schema: + $ref: "#/definitions/entity_edit" + <<: *ENTITYRESPONSES + delete: + operationId: "delete_release_edit" + tags: # TAGLINE + - releases # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Deleted Edit + schema: + $ref: "#/definitions/success" + <<: *ENTITYRESPONSES /work: post: operationId: "create_work" @@ -1226,6 +1576,34 @@ paths: schema: $ref: "#/definitions/entity_edit" <<: *ENTITYRESPONSES + /work/rev/{id}: + parameters: + - name: id + in: path + type: string + #format: uuid + required: true + get: + operationId: "get_work_revision" + tags: # TAGLINE + - works # TAGLINE + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For works, none accepted (yet)." + - name: hide + in: query + type: string + required: false + description: "List of entity fields to elide in response. For works, none accepted (yet)." + responses: + 200: + description: Found Entity Revision + schema: + $ref: "#/definitions/work_entity" + <<: *ENTITYRESPONSES /work/{id}/history: parameters: - name: id @@ -1249,6 +1627,25 @@ paths: items: $ref: "#/definitions/entity_history_entry" <<: *ENTITYRESPONSES + /work/{id}/redirects: + parameters: + - name: id + in: path + type: string + required: true + get: + tags: # TAGLINE + - works # TAGLINE + operationId: "get_work_redirects" + responses: + 200: + description: Found Entity Redirects + schema: + type: array + items: + type: string + #format: ident + <<: *ENTITYRESPONSES /work/{id}/releases: parameters: - name: id @@ -1272,6 +1669,39 @@ paths: items: $ref: "#/definitions/release_entity" <<: *ENTITYRESPONSES + /work/edit/{edit_id}: + get: + operationId: "get_work_edit" + tags: # TAGLINE + - works # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Found Edit + schema: + $ref: "#/definitions/entity_edit" + <<: *ENTITYRESPONSES + delete: + operationId: "delete_work_edit" + tags: # TAGLINE + - works # TAGLINE + parameters: + - name: edit_id + in: path + type: integer + format: int64 + required: true + responses: + 200: + description: Deleted Edit + schema: + $ref: "#/definitions/success" + <<: *ENTITYRESPONSES /editor/{id}: parameters: - name: id diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 51f0630e..5891a24e 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -367,6 +367,76 @@ paths: path: "/container/:id" HttpMethod: "Delete" httpmethod: "delete" + /container/rev/{id}: + get: + tags: + - "containers" + operationId: "get_container_revision" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For containers,\ + \ none accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For containers,\ + \ none accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity Revision" + schema: + $ref: "#/definitions/container_entity" + x-responseId: "FoundEntityRevision" + x-uppercaseResponseId: "FOUND_ENTITY_REVISION" + uppercase_operation_id: "GET_CONTAINER_REVISION" + uppercase_data_type: "CONTAINERENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CONTAINER_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CONTAINER_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CONTAINER_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_container_revision" + uppercase_operation_id: "GET_CONTAINER_REVISION" + path: "/container/rev/:id" + HttpMethod: "Get" + httpmethod: "get" /container/{id}/history: get: tags: @@ -430,6 +500,62 @@ paths: path: "/container/:id/history" HttpMethod: "Get" httpmethod: "get" + /container/{id}/redirects: + get: + tags: + - "containers" + operationId: "get_container_redirects" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + responses: + 200: + description: "Found Entity Redirects" + schema: + type: "array" + items: + type: "string" + x-responseId: "FoundEntityRedirects" + x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" + uppercase_operation_id: "GET_CONTAINER_REDIRECTS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CONTAINER_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CONTAINER_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CONTAINER_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_container_redirects" + uppercase_operation_id: "GET_CONTAINER_REDIRECTS" + path: "/container/:id/redirects" + HttpMethod: "Get" + httpmethod: "get" /container/lookup: get: tags: @@ -438,13 +564,18 @@ paths: parameters: - name: "issnl" in: "query" - required: true + required: false type: "string" maxLength: 9 minLength: 9 pattern: "\\d{4}-\\d{3}[0-9X]" - formatString: "\\\"{}\\\"" - example: "\"issnl_example\".to_string()" + formatString: "{:?}" + example: "Some(\"issnl_example\".to_string())" + - name: "wikidata_qid" + in: "query" + required: false + formatString: "{:?}" + example: "Some(\"wikidata_qid_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For container, none\ @@ -495,6 +626,115 @@ paths: path: "/container/lookup" HttpMethod: "Get" httpmethod: "get" + /container/edit/{edit_id}: + get: + tags: + - "containers" + operationId: "get_container_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Found Edit" + schema: + $ref: "#/definitions/entity_edit" + x-responseId: "FoundEdit" + x-uppercaseResponseId: "FOUND_EDIT" + uppercase_operation_id: "GET_CONTAINER_EDIT" + uppercase_data_type: "ENTITYEDIT" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_container_edit" + uppercase_operation_id: "GET_CONTAINER_EDIT" + path: "/container/edit/:edit_id" + HttpMethod: "Get" + httpmethod: "get" + delete: + tags: + - "containers" + operationId: "delete_container_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Deleted Edit" + schema: + $ref: "#/definitions/success" + x-responseId: "DeletedEdit" + x-uppercaseResponseId: "DELETED_EDIT" + uppercase_operation_id: "DELETE_CONTAINER_EDIT" + uppercase_data_type: "SUCCESS" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "DELETE_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "DELETE_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "DELETE_CONTAINER_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "delete_container_edit" + uppercase_operation_id: "DELETE_CONTAINER_EDIT" + path: "/container/edit/:edit_id" + HttpMethod: "Delete" + httpmethod: "delete" /creator: post: tags: @@ -841,6 +1081,76 @@ paths: path: "/creator/:id" HttpMethod: "Delete" httpmethod: "delete" + /creator/rev/{id}: + get: + tags: + - "creators" + operationId: "get_creator_revision" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For creators, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For creators, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity Revision" + schema: + $ref: "#/definitions/creator_entity" + x-responseId: "FoundEntityRevision" + x-uppercaseResponseId: "FOUND_ENTITY_REVISION" + uppercase_operation_id: "GET_CREATOR_REVISION" + uppercase_data_type: "CREATORENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CREATOR_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CREATOR_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CREATOR_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_creator_revision" + uppercase_operation_id: "GET_CREATOR_REVISION" + path: "/creator/rev/:id" + HttpMethod: "Get" + httpmethod: "get" /creator/{id}/history: get: tags: @@ -968,21 +1278,82 @@ paths: path: "/creator/:id/releases" HttpMethod: "Get" httpmethod: "get" - /creator/lookup: + /creator/{id}/redirects: get: tags: - "creators" - operationId: "lookup_creator" + operationId: "get_creator_redirects" parameters: - - name: "orcid" - in: "query" + - name: "id" + in: "path" required: true type: "string" - maxLength: 19 - minLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" formatString: "\\\"{}\\\"" - example: "\"orcid_example\".to_string()" + example: "\"id_example\".to_string()" + responses: + 200: + description: "Found Entity Redirects" + schema: + type: "array" + items: + type: "string" + x-responseId: "FoundEntityRedirects" + x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" + uppercase_operation_id: "GET_CREATOR_REDIRECTS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CREATOR_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CREATOR_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CREATOR_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_creator_redirects" + uppercase_operation_id: "GET_CREATOR_REDIRECTS" + path: "/creator/:id/redirects" + HttpMethod: "Get" + httpmethod: "get" + /creator/lookup: + get: + tags: + - "creators" + operationId: "lookup_creator" + parameters: + - name: "orcid" + in: "query" + required: false + type: "string" + maxLength: 19 + minLength: 19 + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" + formatString: "{:?}" + example: "Some(\"orcid_example\".to_string())" + - name: "wikidata_qid" + in: "query" + required: false + formatString: "{:?}" + example: "Some(\"wikidata_qid_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For creator, none\ @@ -1033,6 +1404,115 @@ paths: path: "/creator/lookup" HttpMethod: "Get" httpmethod: "get" + /creator/edit/{edit_id}: + get: + tags: + - "creators" + operationId: "get_creator_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Found Edit" + schema: + $ref: "#/definitions/entity_edit" + x-responseId: "FoundEdit" + x-uppercaseResponseId: "FOUND_EDIT" + uppercase_operation_id: "GET_CREATOR_EDIT" + uppercase_data_type: "ENTITYEDIT" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_creator_edit" + uppercase_operation_id: "GET_CREATOR_EDIT" + path: "/creator/edit/:edit_id" + HttpMethod: "Get" + httpmethod: "get" + delete: + tags: + - "creators" + operationId: "delete_creator_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Deleted Edit" + schema: + $ref: "#/definitions/success" + x-responseId: "DeletedEdit" + x-uppercaseResponseId: "DELETED_EDIT" + uppercase_operation_id: "DELETE_CREATOR_EDIT" + uppercase_data_type: "SUCCESS" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "DELETE_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "DELETE_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "DELETE_CREATOR_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "delete_creator_edit" + uppercase_operation_id: "DELETE_CREATOR_EDIT" + path: "/creator/edit/:edit_id" + HttpMethod: "Delete" + httpmethod: "delete" /file: post: tags: @@ -1379,6 +1859,76 @@ paths: path: "/file/:id" HttpMethod: "Delete" httpmethod: "delete" + /file/rev/{id}: + get: + tags: + - "files" + operationId: "get_file_revision" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For files, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For files, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity Revision" + schema: + $ref: "#/definitions/file_entity" + x-responseId: "FoundEntityRevision" + x-uppercaseResponseId: "FOUND_ENTITY_REVISION" + uppercase_operation_id: "GET_FILE_REVISION" + uppercase_data_type: "FILEENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_FILE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_FILE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_FILE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_file_revision" + uppercase_operation_id: "GET_FILE_REVISION" + path: "/file/rev/:id" + HttpMethod: "Get" + httpmethod: "get" /file/{id}/history: get: tags: @@ -1442,18 +1992,86 @@ paths: path: "/file/:id/history" HttpMethod: "Get" httpmethod: "get" + /file/{id}/redirects: + get: + tags: + - "files" + operationId: "get_file_redirects" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + responses: + 200: + description: "Found Entity Redirects" + schema: + type: "array" + items: + type: "string" + x-responseId: "FoundEntityRedirects" + x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" + uppercase_operation_id: "GET_FILE_REDIRECTS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_FILE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_FILE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_FILE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_file_redirects" + uppercase_operation_id: "GET_FILE_REDIRECTS" + path: "/file/:id/redirects" + HttpMethod: "Get" + httpmethod: "get" /file/lookup: get: tags: - "files" operationId: "lookup_file" parameters: + - name: "md5" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"md5_example\".to_string())" - name: "sha1" in: "query" - required: true + required: false type: "string" - formatString: "\\\"{}\\\"" - example: "\"sha1_example\".to_string()" + formatString: "{:?}" + example: "Some(\"sha1_example\".to_string())" + - name: "sha256" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"sha256_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For files, none\ @@ -1504,14 +2122,123 @@ paths: path: "/file/lookup" HttpMethod: "Get" httpmethod: "get" - /release: - post: + /file/edit/{edit_id}: + get: tags: - - "releases" - operationId: "create_release" + - "files" + operationId: "get_file_edit" parameters: - - in: "body" - name: "entity" + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Found Edit" + schema: + $ref: "#/definitions/entity_edit" + x-responseId: "FoundEdit" + x-uppercaseResponseId: "FOUND_EDIT" + uppercase_operation_id: "GET_FILE_EDIT" + uppercase_data_type: "ENTITYEDIT" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_file_edit" + uppercase_operation_id: "GET_FILE_EDIT" + path: "/file/edit/:edit_id" + HttpMethod: "Get" + httpmethod: "get" + delete: + tags: + - "files" + operationId: "delete_file_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Deleted Edit" + schema: + $ref: "#/definitions/success" + x-responseId: "DeletedEdit" + x-uppercaseResponseId: "DELETED_EDIT" + uppercase_operation_id: "DELETE_FILE_EDIT" + uppercase_data_type: "SUCCESS" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "DELETE_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "DELETE_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "DELETE_FILE_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "delete_file_edit" + uppercase_operation_id: "DELETE_FILE_EDIT" + path: "/file/edit/:edit_id" + HttpMethod: "Delete" + httpmethod: "delete" + /release: + post: + tags: + - "releases" + operationId: "create_release" + parameters: + - in: "body" + name: "entity" required: true schema: $ref: "#/definitions/release_entity" @@ -1850,6 +2577,76 @@ paths: path: "/release/:id" HttpMethod: "Delete" httpmethod: "delete" + /release/rev/{id}: + get: + tags: + - "releases" + operationId: "get_release_revision" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For releases, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For releases, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity Revision" + schema: + $ref: "#/definitions/release_entity" + x-responseId: "FoundEntityRevision" + x-uppercaseResponseId: "FOUND_ENTITY_REVISION" + uppercase_operation_id: "GET_RELEASE_REVISION" + uppercase_data_type: "RELEASEENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_RELEASE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_RELEASE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_RELEASE_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_release_revision" + uppercase_operation_id: "GET_RELEASE_REVISION" + path: "/release/rev/:id" + HttpMethod: "Get" + httpmethod: "get" /release/{id}/history: get: tags: @@ -1935,15 +2732,212 @@ paths: example: "Some(\"hide_example\".to_string())" responses: 200: - description: "Found" + description: "Found" + schema: + type: "array" + items: + $ref: "#/definitions/file_entity" + x-responseId: "Found" + x-uppercaseResponseId: "FOUND" + uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_release_files" + uppercase_operation_id: "GET_RELEASE_FILES" + path: "/release/:id/files" + HttpMethod: "Get" + httpmethod: "get" + /release/{id}/redirects: + get: + tags: + - "releases" + operationId: "get_release_redirects" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + responses: + 200: + description: "Found Entity Redirects" + schema: + type: "array" + items: + type: "string" + x-responseId: "FoundEntityRedirects" + x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" + uppercase_operation_id: "GET_RELEASE_REDIRECTS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_RELEASE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_RELEASE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_RELEASE_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_release_redirects" + uppercase_operation_id: "GET_RELEASE_REDIRECTS" + path: "/release/:id/redirects" + HttpMethod: "Get" + httpmethod: "get" + /release/lookup: + get: + tags: + - "releases" + operationId: "lookup_release" + parameters: + - name: "doi" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"doi_example\".to_string())" + - name: "wikidata_qid" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"wikidata_qid_example\".to_string())" + - name: "isbn13" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"isbn13_example\".to_string())" + - name: "pmid" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"pmid_example\".to_string())" + - name: "pmcid" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"pmcid_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For releases, 'abstracts',\ + \ 'refs', and 'contribs' are valid." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity" + schema: + $ref: "#/definitions/release_entity" + x-responseId: "FoundEntity" + x-uppercaseResponseId: "FOUND_ENTITY" + uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_data_type: "RELEASEENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "lookup_release" + uppercase_operation_id: "LOOKUP_RELEASE" + path: "/release/lookup" + HttpMethod: "Get" + httpmethod: "get" + /release/edit/{edit_id}: + get: + tags: + - "releases" + operationId: "get_release_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Found Edit" schema: - type: "array" - items: - $ref: "#/definitions/file_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_RELEASE_FILES" - uppercase_data_type: "VEC" + $ref: "#/definitions/entity_edit" + x-responseId: "FoundEdit" + x-uppercaseResponseId: "FOUND_EDIT" + uppercase_operation_id: "GET_RELEASE_EDIT" + uppercase_data_type: "ENTITYEDIT" producesJson: true 400: description: "Bad Request" @@ -1951,7 +2945,7 @@ paths: $ref: "#/definitions/error_response" x-responseId: "BadRequest" x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_operation_id: "GET_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true 404: @@ -1960,7 +2954,7 @@ paths: $ref: "#/definitions/error_response" x-responseId: "NotFound" x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_operation_id: "GET_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true 500: @@ -1969,43 +2963,35 @@ paths: $ref: "#/definitions/error_response" x-responseId: "GenericError" x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_RELEASE_FILES" + uppercase_operation_id: "GET_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true - operation_id: "get_release_files" - uppercase_operation_id: "GET_RELEASE_FILES" - path: "/release/:id/files" + operation_id: "get_release_edit" + uppercase_operation_id: "GET_RELEASE_EDIT" + path: "/release/edit/:edit_id" HttpMethod: "Get" httpmethod: "get" - /release/lookup: - get: + delete: tags: - "releases" - operationId: "lookup_release" + operationId: "delete_release_edit" parameters: - - name: "doi" - in: "query" + - name: "edit_id" + in: "path" required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"doi_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For releases, 'abstracts',\ - \ 'refs', and 'contribs' are valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" + type: "integer" + format: "int64" + formatString: "{}" + example: "789" responses: 200: - description: "Found Entity" + description: "Deleted Edit" schema: - $ref: "#/definitions/release_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "LOOKUP_RELEASE" - uppercase_data_type: "RELEASEENTITY" + $ref: "#/definitions/success" + x-responseId: "DeletedEdit" + x-uppercaseResponseId: "DELETED_EDIT" + uppercase_operation_id: "DELETE_RELEASE_EDIT" + uppercase_data_type: "SUCCESS" producesJson: true 400: description: "Bad Request" @@ -2013,7 +2999,7 @@ paths: $ref: "#/definitions/error_response" x-responseId: "BadRequest" x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_operation_id: "DELETE_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true 404: @@ -2022,7 +3008,7 @@ paths: $ref: "#/definitions/error_response" x-responseId: "NotFound" x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_operation_id: "DELETE_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true 500: @@ -2031,14 +3017,14 @@ paths: $ref: "#/definitions/error_response" x-responseId: "GenericError" x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "LOOKUP_RELEASE" + uppercase_operation_id: "DELETE_RELEASE_EDIT" uppercase_data_type: "ERRORRESPONSE" producesJson: true - operation_id: "lookup_release" - uppercase_operation_id: "LOOKUP_RELEASE" - path: "/release/lookup" - HttpMethod: "Get" - httpmethod: "get" + operation_id: "delete_release_edit" + uppercase_operation_id: "DELETE_RELEASE_EDIT" + path: "/release/edit/:edit_id" + HttpMethod: "Delete" + httpmethod: "delete" /work: post: tags: @@ -2385,6 +3371,76 @@ paths: path: "/work/:id" HttpMethod: "Delete" httpmethod: "delete" + /work/rev/{id}: + get: + tags: + - "works" + operationId: "get_work_revision" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For works, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "hide" + in: "query" + description: "List of entity fields to elide in response. For works, none\ + \ accepted (yet)." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"hide_example\".to_string())" + responses: + 200: + description: "Found Entity Revision" + schema: + $ref: "#/definitions/work_entity" + x-responseId: "FoundEntityRevision" + x-uppercaseResponseId: "FOUND_ENTITY_REVISION" + uppercase_operation_id: "GET_WORK_REVISION" + uppercase_data_type: "WORKENTITY" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_WORK_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_WORK_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_WORK_REVISION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_work_revision" + uppercase_operation_id: "GET_WORK_REVISION" + path: "/work/rev/:id" + HttpMethod: "Get" + httpmethod: "get" /work/{id}/history: get: tags: @@ -2448,6 +3504,62 @@ paths: path: "/work/:id/history" HttpMethod: "Get" httpmethod: "get" + /work/{id}/redirects: + get: + tags: + - "works" + operationId: "get_work_redirects" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + formatString: "\\\"{}\\\"" + example: "\"id_example\".to_string()" + responses: + 200: + description: "Found Entity Redirects" + schema: + type: "array" + items: + type: "string" + x-responseId: "FoundEntityRedirects" + x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" + uppercase_operation_id: "GET_WORK_REDIRECTS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_WORK_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_WORK_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_WORK_REDIRECTS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_work_redirects" + uppercase_operation_id: "GET_WORK_REDIRECTS" + path: "/work/:id/redirects" + HttpMethod: "Get" + httpmethod: "get" /work/{id}/releases: get: tags: @@ -2512,6 +3624,115 @@ paths: path: "/work/:id/releases" HttpMethod: "Get" httpmethod: "get" + /work/edit/{edit_id}: + get: + tags: + - "works" + operationId: "get_work_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Found Edit" + schema: + $ref: "#/definitions/entity_edit" + x-responseId: "FoundEdit" + x-uppercaseResponseId: "FOUND_EDIT" + uppercase_operation_id: "GET_WORK_EDIT" + uppercase_data_type: "ENTITYEDIT" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_work_edit" + uppercase_operation_id: "GET_WORK_EDIT" + path: "/work/edit/:edit_id" + HttpMethod: "Get" + httpmethod: "get" + delete: + tags: + - "works" + operationId: "delete_work_edit" + parameters: + - name: "edit_id" + in: "path" + required: true + type: "integer" + format: "int64" + formatString: "{}" + example: "789" + responses: + 200: + description: "Deleted Edit" + schema: + $ref: "#/definitions/success" + x-responseId: "DeletedEdit" + x-uppercaseResponseId: "DELETED_EDIT" + uppercase_operation_id: "DELETE_WORK_EDIT" + uppercase_data_type: "SUCCESS" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "DELETE_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "DELETE_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "DELETE_WORK_EDIT" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "delete_work_edit" + uppercase_operation_id: "DELETE_WORK_EDIT" + path: "/work/edit/:edit_id" + HttpMethod: "Delete" + httpmethod: "delete" /editor/{id}: get: operationId: "get_editor" @@ -2937,8 +4158,6 @@ definitions: upperCaseName: "SUCCESS" container_entity: type: "object" - required: - - "name" properties: coden: type: "string" @@ -2958,6 +4177,7 @@ definitions: name: type: "string" example: "Journal of Important Results" + description: "Required for valid entities" edit_extra: type: "object" extra: @@ -3006,8 +4226,6 @@ definitions: upperCaseName: "CONTAINER_ENTITY" creator_entity: type: "object" - required: - - "display_name" properties: wikidata_qid: type: "string" @@ -3024,6 +4242,7 @@ definitions: display_name: type: "string" example: "Grace Hopper" + description: "Required for valid entities" state: type: "string" enum: @@ -3086,12 +4305,12 @@ definitions: sha256: type: "string" example: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - md5: - type: "string" - example: "d41efcc592d1e40ac13905377399eb9b" sha1: type: "string" example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" + md5: + type: "string" + example: "d41efcc592d1e40ac13905377399eb9b" size: type: "integer" format: "int64" @@ -3151,8 +4370,6 @@ definitions: upperCaseName: "FILE_ENTITY" release_entity: type: "object" - required: - - "title" properties: abstracts: type: "array" @@ -3216,6 +4433,7 @@ definitions: example: "q3nouwy3nnbsvo3h5klxsx4a7y" title: type: "string" + description: "Required for valid entities" state: type: "string" enum: diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 1273d892..f2d7a859 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -13,11 +13,14 @@ use clap::{App, Arg}; #[allow(unused_imports)] use fatcat::{ AcceptEditgroupResponse, ApiError, ApiNoContext, ContextWrapperExt, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, - CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerResponse, - DeleteCreatorResponse, DeleteFileResponse, DeleteReleaseResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, GetContainerResponse, - GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, GetFileResponse, - GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, - LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, + CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, + DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWorkEditResponse, + DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, + GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, + GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, + GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, + GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, + LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, }; #[allow(unused_imports)] use futures::{future, stream, Future, Stream}; @@ -30,14 +33,22 @@ fn main() { .possible_values(&[ "CreateContainerBatch", "DeleteContainer", + "DeleteContainerEdit", "GetContainer", + "GetContainerEdit", "GetContainerHistory", + "GetContainerRedirects", + "GetContainerRevision", "LookupContainer", "CreateCreatorBatch", "DeleteCreator", + "DeleteCreatorEdit", "GetCreator", + "GetCreatorEdit", "GetCreatorHistory", + "GetCreatorRedirects", "GetCreatorReleases", + "GetCreatorRevision", "LookupCreator", "GetEditor", "GetEditorChangelog", @@ -48,20 +59,32 @@ fn main() { "GetEditgroup", "CreateFileBatch", "DeleteFile", + "DeleteFileEdit", "GetFile", + "GetFileEdit", "GetFileHistory", + "GetFileRedirects", + "GetFileRevision", "LookupFile", "CreateReleaseBatch", "DeleteRelease", + "DeleteReleaseEdit", "GetRelease", + "GetReleaseEdit", "GetReleaseFiles", "GetReleaseHistory", + "GetReleaseRedirects", + "GetReleaseRevision", "LookupRelease", "CreateWorkBatch", "DeleteWork", + "DeleteWorkEdit", "GetWork", + "GetWorkEdit", "GetWorkHistory", + "GetWorkRedirects", "GetWorkReleases", + "GetWorkRevision", ]).required(true) .index(1), ).arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) @@ -103,6 +126,11 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("DeleteContainerEdit") => { + let result = client.delete_container_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetContainer") => { let result = client .get_container("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) @@ -110,13 +138,32 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetContainerEdit") => { + let result = client.get_container_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetContainerHistory") => { let result = client.get_container_history("id_example".to_string(), Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetContainerRedirects") => { + let result = client.get_container_redirects("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + + Some("GetContainerRevision") => { + let result = client + .get_container_revision("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) + .wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("LookupContainer") => { - let result = client.lookup_container("issnl_example".to_string(), Some("hide_example".to_string())).wait(); + let result = client + .lookup_container(Some("issnl_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -141,6 +188,11 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("DeleteCreatorEdit") => { + let result = client.delete_creator_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetCreator") => { let result = client .get_creator("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) @@ -148,18 +200,37 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetCreatorEdit") => { + let result = client.get_creator_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetCreatorHistory") => { let result = client.get_creator_history("id_example".to_string(), Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetCreatorRedirects") => { + let result = client.get_creator_redirects("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetCreatorReleases") => { let result = client.get_creator_releases("id_example".to_string(), Some("hide_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetCreatorRevision") => { + let result = client + .get_creator_revision("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) + .wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("LookupCreator") => { - let result = client.lookup_creator("orcid_example".to_string(), Some("hide_example".to_string())).wait(); + let result = client + .lookup_creator(Some("orcid_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -223,18 +294,46 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("DeleteFileEdit") => { + let result = client.delete_file_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetFile") => { let result = client.get_file("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetFileEdit") => { + let result = client.get_file_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetFileHistory") => { let result = client.get_file_history("id_example".to_string(), Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetFileRedirects") => { + let result = client.get_file_redirects("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + + Some("GetFileRevision") => { + let result = client + .get_file_revision("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) + .wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("LookupFile") => { - let result = client.lookup_file("sha1_example".to_string(), Some("hide_example".to_string())).wait(); + let result = client + .lookup_file( + Some("md5_example".to_string()), + Some("sha1_example".to_string()), + Some("sha256_example".to_string()), + Some("hide_example".to_string()), + ).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -264,6 +363,11 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("DeleteReleaseEdit") => { + let result = client.delete_release_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetRelease") => { let result = client .get_release("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) @@ -271,6 +375,11 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetReleaseEdit") => { + let result = client.get_release_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetReleaseFiles") => { let result = client.get_release_files("id_example".to_string(), Some("hide_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); @@ -281,8 +390,28 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetReleaseRedirects") => { + let result = client.get_release_redirects("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + + Some("GetReleaseRevision") => { + let result = client + .get_release_revision("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) + .wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("LookupRelease") => { - let result = client.lookup_release("doi_example".to_string(), Some("hide_example".to_string())).wait(); + let result = client + .lookup_release( + Some("doi_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("isbn13_example".to_string()), + Some("pmid_example".to_string()), + Some("pmcid_example".to_string()), + Some("hide_example".to_string()), + ).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -301,21 +430,43 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("DeleteWorkEdit") => { + let result = client.delete_work_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetWork") => { let result = client.get_work("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetWorkEdit") => { + let result = client.get_work_edit(789).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetWorkHistory") => { let result = client.get_work_history("id_example".to_string(), Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetWorkRedirects") => { + let result = client.get_work_redirects("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetWorkReleases") => { let result = client.get_work_releases("id_example".to_string(), Some("hide_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetWorkRevision") => { + let result = client + .get_work_revision("id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) + .wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + // Disabled because there's no example. // Some("UpdateWork") => { // let result = client.update_work("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index b11f26c3..7341e528 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -12,11 +12,14 @@ use swagger; use fatcat::models; use fatcat::{ AcceptEditgroupResponse, Api, ApiError, Context, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, - CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerResponse, DeleteCreatorResponse, - DeleteFileResponse, DeleteReleaseResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, GetContainerResponse, GetCreatorHistoryResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, - GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, - LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, + CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWorkEditResponse, DeleteWorkResponse, + GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, + GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, + GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse, + GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse, + GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, }; #[derive(Copy, Clone)] @@ -63,6 +66,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn delete_container_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("delete_container_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_container(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -75,6 +84,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_container_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_container_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_container_history(&self, id: String, limit: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -86,11 +101,30 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_container(&self, issnl: String, hide: Option, context: &Context) -> Box + Send> { + fn get_container_redirects(&self, id: String, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_container_redirects(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_container_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "lookup_container(\"{}\", {:?}) - X-Span-ID: {:?}", + "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + expand, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "lookup_container({:?}, {:?}, {:?}) - X-Span-ID: {:?}", issnl, + wikidata_qid, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -149,6 +183,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn delete_creator_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("delete_creator_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_creator(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -161,6 +201,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_creator_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_creator_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_creator_history(&self, id: String, limit: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -172,6 +218,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_creator_redirects(&self, id: String, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_creator_redirects(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_creator_releases(&self, id: String, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -183,11 +235,24 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_creator(&self, orcid: String, hide: Option, context: &Context) -> Box + Send> { + fn get_creator_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( - "lookup_creator(\"{}\", {:?}) - X-Span-ID: {:?}", + "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + expand, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "lookup_creator({:?}, {:?}, {:?}) - X-Span-ID: {:?}", orcid, + wikidata_qid, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -294,6 +359,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn delete_file_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("delete_file_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_file(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -306,6 +377,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_file_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_file_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_file_history(&self, id: String, limit: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -317,9 +394,41 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_file(&self, sha1: String, hide: Option, context: &Context) -> Box + Send> { + fn get_file_redirects(&self, id: String, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_file_redirects(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_file_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + expand, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn lookup_file( + &self, + md5: Option, + sha1: Option, + sha256: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { let context = context.clone(); - println!("lookup_file(\"{}\", {:?}) - X-Span-ID: {:?}", sha1, hide, context.x_span_id.unwrap_or(String::from("")).clone()); + println!( + "lookup_file({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + md5, + sha1, + sha256, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -386,6 +495,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn delete_release_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("delete_release_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_release(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -398,6 +513,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_release_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_release_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_release_files(&self, id: String, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -420,9 +541,45 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_release(&self, doi: String, hide: Option, context: &Context) -> Box + Send> { + fn get_release_redirects(&self, id: String, context: &Context) -> Box + Send> { let context = context.clone(); - println!("lookup_release(\"{}\", {:?}) - X-Span-ID: {:?}", doi, hide, context.x_span_id.unwrap_or(String::from("")).clone()); + println!("get_release_redirects(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_release_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + expand, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn lookup_release( + &self, + doi: Option, + wikidata_qid: Option, + isbn13: Option, + pmid: Option, + pmcid: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { + let context = context.clone(); + println!( + "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + doi, + wikidata_qid, + isbn13, + pmid, + pmcid, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -467,6 +624,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn delete_work_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("delete_work_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_work(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -479,6 +642,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_work_edit(&self, edit_id: i64, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_work_edit({}) - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_work_history(&self, id: String, limit: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -490,6 +659,12 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_work_redirects(&self, id: String, context: &Context) -> Box + Send> { + let context = context.clone(); + println!("get_work_redirects(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("")).clone()); + Box::new(futures::failed("Generic failure".into())) + } + fn get_work_releases(&self, id: String, hide: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( @@ -501,6 +676,18 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_work_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + id, + expand, + hide, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!( diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index bc325361..5a5f4693 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -36,11 +36,14 @@ use swagger::{ApiError, Context, XSpanId}; use models; use { AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, - CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerResponse, DeleteCreatorResponse, DeleteFileResponse, - DeleteReleaseResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, GetContainerResponse, GetCreatorHistoryResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, - GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, - LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, + CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWorkEditResponse, DeleteWorkResponse, + GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, + GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, + GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse, + GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse, + GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, }; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. @@ -382,6 +385,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn delete_container_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/container/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Delete, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteContainerEditResponse::DeletedEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteContainerEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteContainerEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteContainerEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_container(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); @@ -452,6 +519,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_container_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/container/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerEditResponse::FoundEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_container_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { // Query parameters let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); @@ -520,15 +651,163 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_container(&self, param_issnl: String, param_hide: Option, context: &Context) -> Box + Send> { + fn get_container_redirects(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/container/{id}/redirects", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetContainerRedirectsResponse::FoundEntityRedirects(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRedirectsResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRedirectsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRedirectsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_container_revision( + &self, + param_id: String, + param_expand: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters - let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/container/lookup?{issnl}{hide}", + "{}/v0/container/rev/{id}?{expand}{hide}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), + hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRevisionResponse::FoundEntityRevision(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRevisionResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRevisionResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetContainerRevisionResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn lookup_container( + &self, + param_issnl: Option, + param_wikidata_qid: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { + // Query parameters + let query_issnl = param_issnl.map_or_else(String::new, |query| format!("issnl={issnl}&", issnl = query.to_string())); + let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); + let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); + + let url = format!( + "{}/v0/container/lookup?{issnl}{wikidata_qid}{hide}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET), + wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -884,6 +1163,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn delete_creator_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/creator/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Delete, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteCreatorEditResponse::DeletedEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteCreatorEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteCreatorEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteCreatorEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_creator(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); @@ -954,6 +1297,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_creator_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/creator/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorEditResponse::FoundEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_creator_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { // Query parameters let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); @@ -995,14 +1402,142 @@ impl Api for Client { response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorHistoryResponse::NotFound(body)) + Ok(GetCreatorHistoryResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorHistoryResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_creator_redirects(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/creator/{id}/redirects", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetCreatorRedirectsResponse::FoundEntityRedirects(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorRedirectsResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorRedirectsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorRedirectsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_creator_releases(&self, param_id: String, param_hide: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); + + let url = format!( + "{}/v0/creator/{id}/releases?{hide}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetCreatorReleasesResponse::Found(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorReleasesResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetCreatorReleasesResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorHistoryResponse::GenericError(body)) + Ok(GetCreatorReleasesResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1022,14 +1557,22 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_creator_releases(&self, param_id: String, param_hide: Option, context: &Context) -> Box + Send> { + fn get_creator_revision( + &self, + param_id: String, + param_expand: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/creator/{id}/releases?{hide}", + "{}/v0/creator/rev/{id}?{expand}{hide}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -1042,35 +1585,35 @@ impl Api for Client { let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorReleasesResponse::Found(body)) + Ok(GetCreatorRevisionResponse::FoundEntityRevision(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorReleasesResponse::BadRequest(body)) + Ok(GetCreatorRevisionResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorReleasesResponse::NotFound(body)) + Ok(GetCreatorRevisionResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorReleasesResponse::GenericError(body)) + Ok(GetCreatorRevisionResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1090,15 +1633,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_creator(&self, param_orcid: String, param_hide: Option, context: &Context) -> Box + Send> { + fn lookup_creator( + &self, + param_orcid: Option, + param_wikidata_qid: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters - let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string()); + let query_orcid = param_orcid.map_or_else(String::new, |query| format!("orcid={orcid}&", orcid = query.to_string())); + let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/creator/lookup?{orcid}{hide}", + "{}/v0/creator/lookup?{orcid}{wikidata_qid}{hide}", self.base_path, orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET), + wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -1910,6 +2461,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn delete_file_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/file/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Delete, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteFileEditResponse::DeletedEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteFileEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteFileEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteFileEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_file(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); @@ -1939,28 +2554,220 @@ impl Api for Client { response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileResponse::FoundEntity(body)) + Ok(GetFileResponse::FoundEntity(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_file_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/file/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileEditResponse::FoundEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_file_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + + let url = format!( + "{}/v0/file/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetFileHistoryResponse::FoundEntityHistory(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileHistoryResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileHistoryResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetFileHistoryResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_file_redirects(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/file/{id}/redirects", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetFileRedirectsResponse::FoundEntityRedirects(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileResponse::BadRequest(body)) + Ok(GetFileRedirectsResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileResponse::NotFound(body)) + Ok(GetFileRedirectsResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileResponse::GenericError(body)) + Ok(GetFileRedirectsResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1980,15 +2787,17 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_file_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn get_file_revision(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/file/{id}/history?{limit}", + "{}/v0/file/rev/{id}?{expand}{hide}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), + hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); let hyper_client = (self.hyper_client)(); @@ -2000,35 +2809,35 @@ impl Api for Client { let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetFileHistoryResponse::FoundEntityHistory(body)) + Ok(GetFileRevisionResponse::FoundEntityRevision(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileHistoryResponse::BadRequest(body)) + Ok(GetFileRevisionResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileHistoryResponse::NotFound(body)) + Ok(GetFileRevisionResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetFileHistoryResponse::GenericError(body)) + Ok(GetFileRevisionResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2048,15 +2857,26 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_file(&self, param_sha1: String, param_hide: Option, context: &Context) -> Box + Send> { + fn lookup_file( + &self, + param_md5: Option, + param_sha1: Option, + param_sha256: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters - let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string()); + let query_md5 = param_md5.map_or_else(String::new, |query| format!("md5={md5}&", md5 = query.to_string())); + let query_sha1 = param_sha1.map_or_else(String::new, |query| format!("sha1={sha1}&", sha1 = query.to_string())); + let query_sha256 = param_sha256.map_or_else(String::new, |query| format!("sha256={sha256}&", sha256 = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/file/lookup?{sha1}{hide}", + "{}/v0/file/lookup?{md5}{sha1}{sha256}{hide}", self.base_path, + md5 = utf8_percent_encode(&query_md5, QUERY_ENCODE_SET), sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET), + sha256 = utf8_percent_encode(&query_sha256, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -2474,6 +3294,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn delete_release_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/release/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Delete, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteReleaseEditResponse::DeletedEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteReleaseEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteReleaseEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteReleaseEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_release(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); @@ -2544,6 +3428,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_release_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/release/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseEditResponse::FoundEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_release_files(&self, param_id: String, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); @@ -2564,35 +3512,163 @@ impl Api for Client { let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetReleaseFilesResponse::Found(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseFilesResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseFilesResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseFilesResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_release_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + + let url = format!( + "{}/v0/release/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetReleaseHistoryResponse::FoundEntityHistory(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseHistoryResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseHistoryResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetReleaseHistoryResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_release_redirects(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/release/{id}/redirects", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; + let body = serde_json::from_str::>(&buf)?; - Ok(GetReleaseFilesResponse::Found(body)) + Ok(GetReleaseRedirectsResponse::FoundEntityRedirects(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseFilesResponse::BadRequest(body)) + Ok(GetReleaseRedirectsResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseFilesResponse::NotFound(body)) + Ok(GetReleaseRedirectsResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseFilesResponse::GenericError(body)) + Ok(GetReleaseRedirectsResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2612,15 +3688,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_release_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn get_release_revision( + &self, + param_id: String, + param_expand: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/release/{id}/history?{limit}", + "{}/v0/release/rev/{id}?{expand}{hide}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), + hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); let hyper_client = (self.hyper_client)(); @@ -2632,35 +3716,35 @@ impl Api for Client { let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseHistoryResponse::FoundEntityHistory(body)) + Ok(GetReleaseRevisionResponse::FoundEntityRevision(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseHistoryResponse::BadRequest(body)) + Ok(GetReleaseRevisionResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseHistoryResponse::NotFound(body)) + Ok(GetReleaseRevisionResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseHistoryResponse::GenericError(body)) + Ok(GetReleaseRevisionResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2680,15 +3764,32 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_release(&self, param_doi: String, param_hide: Option, context: &Context) -> Box + Send> { + fn lookup_release( + &self, + param_doi: Option, + param_wikidata_qid: Option, + param_isbn13: Option, + param_pmid: Option, + param_pmcid: Option, + param_hide: Option, + context: &Context, + ) -> Box + Send> { // Query parameters - let query_doi = format!("doi={doi}&", doi = param_doi.to_string()); + let query_doi = param_doi.map_or_else(String::new, |query| format!("doi={doi}&", doi = query.to_string())); + let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); + let query_isbn13 = param_isbn13.map_or_else(String::new, |query| format!("isbn13={isbn13}&", isbn13 = query.to_string())); + let query_pmid = param_pmid.map_or_else(String::new, |query| format!("pmid={pmid}&", pmid = query.to_string())); + let query_pmcid = param_pmcid.map_or_else(String::new, |query| format!("pmcid={pmcid}&", pmcid = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/release/lookup?{doi}{hide}", + "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{hide}", self.base_path, doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET), + wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), + isbn13 = utf8_percent_encode(&query_isbn13, QUERY_ENCODE_SET), + pmid = utf8_percent_encode(&query_pmid, QUERY_ENCODE_SET), + pmcid = utf8_percent_encode(&query_pmcid, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -2976,6 +4077,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn delete_work_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/work/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Delete, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteWorkEditResponse::DeletedEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteWorkEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteWorkEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(DeleteWorkEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_work(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); @@ -3046,6 +4211,70 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_work_edit(&self, param_edit_id: i64, context: &Context) -> Box + Send> { + let url = format!( + "{}/v0/work/edit/{edit_id}", + self.base_path, + edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkEditResponse::FoundEdit(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkEditResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkEditResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkEditResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_work_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { // Query parameters let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); @@ -3114,6 +4343,66 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_work_redirects(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/work/{id}/redirects", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetWorkRedirectsResponse::FoundEntityRedirects(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRedirectsResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRedirectsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRedirectsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_work_releases(&self, param_id: String, param_hide: Option, context: &Context) -> Box + Send> { // Query parameters let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); @@ -3182,6 +4471,76 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_work_revision(&self, param_id: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); + + let url = format!( + "{}/v0/work/rev/{id}?{expand}{hide}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), + hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRevisionResponse::FoundEntityRevision(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRevisionResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRevisionResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetWorkRevisionResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn update_work(&self, param_id: String, param_entity: models::WorkEntity, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index 1650fbe6..dcc6e813 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -68,6 +68,18 @@ pub enum DeleteContainerResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum DeleteContainerEditResponse { + /// Deleted Edit + DeletedEdit(models::Success), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetContainerResponse { /// Found Entity @@ -80,6 +92,18 @@ pub enum GetContainerResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetContainerEditResponse { + /// Found Edit + FoundEdit(models::EntityEdit), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetContainerHistoryResponse { /// Found Entity History @@ -92,6 +116,30 @@ pub enum GetContainerHistoryResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetContainerRedirectsResponse { + /// Found Entity Redirects + FoundEntityRedirects(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + +#[derive(Debug, PartialEq)] +pub enum GetContainerRevisionResponse { + /// Found Entity Revision + FoundEntityRevision(models::ContainerEntity), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum LookupContainerResponse { /// Found Entity @@ -152,6 +200,18 @@ pub enum DeleteCreatorResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum DeleteCreatorEditResponse { + /// Deleted Edit + DeletedEdit(models::Success), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetCreatorResponse { /// Found Entity @@ -164,6 +224,18 @@ pub enum GetCreatorResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetCreatorEditResponse { + /// Found Edit + FoundEdit(models::EntityEdit), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetCreatorHistoryResponse { /// Found Entity History @@ -176,6 +248,18 @@ pub enum GetCreatorHistoryResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetCreatorRedirectsResponse { + /// Found Entity Redirects + FoundEntityRedirects(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetCreatorReleasesResponse { /// Found @@ -188,6 +272,18 @@ pub enum GetCreatorReleasesResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetCreatorRevisionResponse { + /// Found Entity Revision + FoundEntityRevision(models::CreatorEntity), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum LookupCreatorResponse { /// Found Entity @@ -334,6 +430,18 @@ pub enum DeleteFileResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum DeleteFileEditResponse { + /// Deleted Edit + DeletedEdit(models::Success), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetFileResponse { /// Found Entity @@ -346,6 +454,18 @@ pub enum GetFileResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetFileEditResponse { + /// Found Edit + FoundEdit(models::EntityEdit), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetFileHistoryResponse { /// Found Entity History @@ -358,6 +478,30 @@ pub enum GetFileHistoryResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetFileRedirectsResponse { + /// Found Entity Redirects + FoundEntityRedirects(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + +#[derive(Debug, PartialEq)] +pub enum GetFileRevisionResponse { + /// Found Entity Revision + FoundEntityRevision(models::FileEntity), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum LookupFileResponse { /// Found Entity @@ -430,6 +574,18 @@ pub enum DeleteReleaseResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum DeleteReleaseEditResponse { + /// Deleted Edit + DeletedEdit(models::Success), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetReleaseResponse { /// Found Entity @@ -442,6 +598,18 @@ pub enum GetReleaseResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetReleaseEditResponse { + /// Found Edit + FoundEdit(models::EntityEdit), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetReleaseFilesResponse { /// Found @@ -466,6 +634,30 @@ pub enum GetReleaseHistoryResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetReleaseRedirectsResponse { + /// Found Entity Redirects + FoundEntityRedirects(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + +#[derive(Debug, PartialEq)] +pub enum GetReleaseRevisionResponse { + /// Found Entity Revision + FoundEntityRevision(models::ReleaseEntity), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum LookupReleaseResponse { /// Found Entity @@ -514,6 +706,18 @@ pub enum DeleteWorkResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum DeleteWorkEditResponse { + /// Deleted Edit + DeletedEdit(models::Success), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetWorkResponse { /// Found Entity @@ -526,6 +730,18 @@ pub enum GetWorkResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetWorkEditResponse { + /// Found Edit + FoundEdit(models::EntityEdit), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetWorkHistoryResponse { /// Found Entity History @@ -538,6 +754,18 @@ pub enum GetWorkHistoryResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetWorkRedirectsResponse { + /// Found Entity Redirects + FoundEntityRedirects(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetWorkReleasesResponse { /// Found @@ -550,6 +778,18 @@ pub enum GetWorkReleasesResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetWorkRevisionResponse { + /// Found Entity Revision + FoundEntityRevision(models::WorkEntity), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum UpdateWorkResponse { /// Updated Entity @@ -576,11 +816,19 @@ pub trait Api { fn delete_container(&self, id: String, editgroup: Option, context: &Context) -> Box + Send>; + fn delete_container_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_container(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn get_container_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_container_history(&self, id: String, limit: Option, context: &Context) -> Box + Send>; - fn lookup_container(&self, issnl: String, hide: Option, context: &Context) -> Box + Send>; + fn get_container_redirects(&self, id: String, context: &Context) -> Box + Send>; + + fn get_container_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + + fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send>; fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -596,13 +844,21 @@ pub trait Api { fn delete_creator(&self, id: String, editgroup: Option, context: &Context) -> Box + Send>; + fn delete_creator_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_creator(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn get_creator_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_creator_history(&self, id: String, limit: Option, context: &Context) -> Box + Send>; + fn get_creator_redirects(&self, id: String, context: &Context) -> Box + Send>; + fn get_creator_releases(&self, id: String, hide: Option, context: &Context) -> Box + Send>; - fn lookup_creator(&self, orcid: String, hide: Option, context: &Context) -> Box + Send>; + fn get_creator_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send>; fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -634,11 +890,26 @@ pub trait Api { fn delete_file(&self, id: String, editgroup: Option, context: &Context) -> Box + Send>; + fn delete_file_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_file(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn get_file_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_file_history(&self, id: String, limit: Option, context: &Context) -> Box + Send>; - fn lookup_file(&self, sha1: String, hide: Option, context: &Context) -> Box + Send>; + fn get_file_redirects(&self, id: String, context: &Context) -> Box + Send>; + + fn get_file_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + + fn lookup_file( + &self, + md5: Option, + sha1: Option, + sha256: Option, + hide: Option, + context: &Context, + ) -> Box + Send>; fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -656,13 +927,30 @@ pub trait Api { fn delete_release(&self, id: String, editgroup: Option, context: &Context) -> Box + Send>; + fn delete_release_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_release(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn get_release_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_release_files(&self, id: String, hide: Option, context: &Context) -> Box + Send>; fn get_release_history(&self, id: String, limit: Option, context: &Context) -> Box + Send>; - fn lookup_release(&self, doi: String, hide: Option, context: &Context) -> Box + Send>; + fn get_release_redirects(&self, id: String, context: &Context) -> Box + Send>; + + fn get_release_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + + fn lookup_release( + &self, + doi: Option, + wikidata_qid: Option, + isbn13: Option, + pmid: Option, + pmcid: Option, + hide: Option, + context: &Context, + ) -> Box + Send>; fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -676,12 +964,20 @@ pub trait Api { fn delete_work(&self, id: String, editgroup: Option, context: &Context) -> Box + Send>; + fn delete_work_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_work(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn get_work_edit(&self, edit_id: i64, context: &Context) -> Box + Send>; + fn get_work_history(&self, id: String, limit: Option, context: &Context) -> Box + Send>; + fn get_work_redirects(&self, id: String, context: &Context) -> Box + Send>; + fn get_work_releases(&self, id: String, hide: Option, context: &Context) -> Box + Send>; + fn get_work_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option, context: &Context) -> Box + Send>; } @@ -698,11 +994,19 @@ pub trait ApiNoContext { fn delete_container(&self, id: String, editgroup: Option) -> Box + Send>; + fn delete_container_edit(&self, edit_id: i64) -> Box + Send>; + fn get_container(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn get_container_edit(&self, edit_id: i64) -> Box + Send>; + fn get_container_history(&self, id: String, limit: Option) -> Box + Send>; - fn lookup_container(&self, issnl: String, hide: Option) -> Box + Send>; + fn get_container_redirects(&self, id: String) -> Box + Send>; + + fn get_container_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + + fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option) -> Box + Send>; fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option) -> Box + Send>; @@ -717,13 +1021,21 @@ pub trait ApiNoContext { fn delete_creator(&self, id: String, editgroup: Option) -> Box + Send>; + fn delete_creator_edit(&self, edit_id: i64) -> Box + Send>; + fn get_creator(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn get_creator_edit(&self, edit_id: i64) -> Box + Send>; + fn get_creator_history(&self, id: String, limit: Option) -> Box + Send>; + fn get_creator_redirects(&self, id: String) -> Box + Send>; + fn get_creator_releases(&self, id: String, hide: Option) -> Box + Send>; - fn lookup_creator(&self, orcid: String, hide: Option) -> Box + Send>; + fn get_creator_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option) -> Box + Send>; fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option) -> Box + Send>; @@ -749,11 +1061,19 @@ pub trait ApiNoContext { fn delete_file(&self, id: String, editgroup: Option) -> Box + Send>; + fn delete_file_edit(&self, edit_id: i64) -> Box + Send>; + fn get_file(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn get_file_edit(&self, edit_id: i64) -> Box + Send>; + fn get_file_history(&self, id: String, limit: Option) -> Box + Send>; - fn lookup_file(&self, sha1: String, hide: Option) -> Box + Send>; + fn get_file_redirects(&self, id: String) -> Box + Send>; + + fn get_file_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + + fn lookup_file(&self, md5: Option, sha1: Option, sha256: Option, hide: Option) -> Box + Send>; fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option) -> Box + Send>; @@ -770,13 +1090,29 @@ pub trait ApiNoContext { fn delete_release(&self, id: String, editgroup: Option) -> Box + Send>; + fn delete_release_edit(&self, edit_id: i64) -> Box + Send>; + fn get_release(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn get_release_edit(&self, edit_id: i64) -> Box + Send>; + fn get_release_files(&self, id: String, hide: Option) -> Box + Send>; fn get_release_history(&self, id: String, limit: Option) -> Box + Send>; - fn lookup_release(&self, doi: String, hide: Option) -> Box + Send>; + fn get_release_redirects(&self, id: String) -> Box + Send>; + + fn get_release_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + + fn lookup_release( + &self, + doi: Option, + wikidata_qid: Option, + isbn13: Option, + pmid: Option, + pmcid: Option, + hide: Option, + ) -> Box + Send>; fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option) -> Box + Send>; @@ -784,12 +1120,20 @@ pub trait ApiNoContext { fn delete_work(&self, id: String, editgroup: Option) -> Box + Send>; + fn delete_work_edit(&self, edit_id: i64) -> Box + Send>; + fn get_work(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn get_work_edit(&self, edit_id: i64) -> Box + Send>; + fn get_work_history(&self, id: String, limit: Option) -> Box + Send>; + fn get_work_redirects(&self, id: String) -> Box + Send>; + fn get_work_releases(&self, id: String, hide: Option) -> Box + Send>; + fn get_work_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option) -> Box + Send>; } @@ -826,16 +1170,32 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().delete_container(id, editgroup, &self.context()) } + fn delete_container_edit(&self, edit_id: i64) -> Box + Send> { + self.api().delete_container_edit(edit_id, &self.context()) + } + fn get_container(&self, id: String, expand: Option, hide: Option) -> Box + Send> { self.api().get_container(id, expand, hide, &self.context()) } + fn get_container_edit(&self, edit_id: i64) -> Box + Send> { + self.api().get_container_edit(edit_id, &self.context()) + } + fn get_container_history(&self, id: String, limit: Option) -> Box + Send> { self.api().get_container_history(id, limit, &self.context()) } - fn lookup_container(&self, issnl: String, hide: Option) -> Box + Send> { - self.api().lookup_container(issnl, hide, &self.context()) + fn get_container_redirects(&self, id: String) -> Box + Send> { + self.api().get_container_redirects(id, &self.context()) + } + + fn get_container_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send> { + self.api().get_container_revision(id, expand, hide, &self.context()) + } + + fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option) -> Box + Send> { + self.api().lookup_container(issnl, wikidata_qid, hide, &self.context()) } fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option) -> Box + Send> { @@ -859,20 +1219,36 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().delete_creator(id, editgroup, &self.context()) } + fn delete_creator_edit(&self, edit_id: i64) -> Box + Send> { + self.api().delete_creator_edit(edit_id, &self.context()) + } + fn get_creator(&self, id: String, expand: Option, hide: Option) -> Box + Send> { self.api().get_creator(id, expand, hide, &self.context()) } + fn get_creator_edit(&self, edit_id: i64) -> Box + Send> { + self.api().get_creator_edit(edit_id, &self.context()) + } + fn get_creator_history(&self, id: String, limit: Option) -> Box + Send> { self.api().get_creator_history(id, limit, &self.context()) } + fn get_creator_redirects(&self, id: String) -> Box + Send> { + self.api().get_creator_redirects(id, &self.context()) + } + fn get_creator_releases(&self, id: String, hide: Option) -> Box + Send> { self.api().get_creator_releases(id, hide, &self.context()) } - fn lookup_creator(&self, orcid: String, hide: Option) -> Box + Send> { - self.api().lookup_creator(orcid, hide, &self.context()) + fn get_creator_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send> { + self.api().get_creator_revision(id, expand, hide, &self.context()) + } + + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option) -> Box + Send> { + self.api().lookup_creator(orcid, wikidata_qid, hide, &self.context()) } fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option) -> Box + Send> { @@ -923,16 +1299,32 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().delete_file(id, editgroup, &self.context()) } + fn delete_file_edit(&self, edit_id: i64) -> Box + Send> { + self.api().delete_file_edit(edit_id, &self.context()) + } + fn get_file(&self, id: String, expand: Option, hide: Option) -> Box + Send> { self.api().get_file(id, expand, hide, &self.context()) } + fn get_file_edit(&self, edit_id: i64) -> Box + Send> { + self.api().get_file_edit(edit_id, &self.context()) + } + fn get_file_history(&self, id: String, limit: Option) -> Box + Send> { self.api().get_file_history(id, limit, &self.context()) } - fn lookup_file(&self, sha1: String, hide: Option) -> Box + Send> { - self.api().lookup_file(sha1, hide, &self.context()) + fn get_file_redirects(&self, id: String) -> Box + Send> { + self.api().get_file_redirects(id, &self.context()) + } + + fn get_file_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send> { + self.api().get_file_revision(id, expand, hide, &self.context()) + } + + fn lookup_file(&self, md5: Option, sha1: Option, sha256: Option, hide: Option) -> Box + Send> { + self.api().lookup_file(md5, sha1, sha256, hide, &self.context()) } fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option) -> Box + Send> { @@ -960,10 +1352,18 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().delete_release(id, editgroup, &self.context()) } + fn delete_release_edit(&self, edit_id: i64) -> Box + Send> { + self.api().delete_release_edit(edit_id, &self.context()) + } + fn get_release(&self, id: String, expand: Option, hide: Option) -> Box + Send> { self.api().get_release(id, expand, hide, &self.context()) } + fn get_release_edit(&self, edit_id: i64) -> Box + Send> { + self.api().get_release_edit(edit_id, &self.context()) + } + fn get_release_files(&self, id: String, hide: Option) -> Box + Send> { self.api().get_release_files(id, hide, &self.context()) } @@ -972,8 +1372,24 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_release_history(id, limit, &self.context()) } - fn lookup_release(&self, doi: String, hide: Option) -> Box + Send> { - self.api().lookup_release(doi, hide, &self.context()) + fn get_release_redirects(&self, id: String) -> Box + Send> { + self.api().get_release_redirects(id, &self.context()) + } + + fn get_release_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send> { + self.api().get_release_revision(id, expand, hide, &self.context()) + } + + fn lookup_release( + &self, + doi: Option, + wikidata_qid: Option, + isbn13: Option, + pmid: Option, + pmcid: Option, + hide: Option, + ) -> Box + Send> { + self.api().lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, hide, &self.context()) } fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option) -> Box + Send> { @@ -988,18 +1404,34 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().delete_work(id, editgroup, &self.context()) } + fn delete_work_edit(&self, edit_id: i64) -> Box + Send> { + self.api().delete_work_edit(edit_id, &self.context()) + } + fn get_work(&self, id: String, expand: Option, hide: Option) -> Box + Send> { self.api().get_work(id, expand, hide, &self.context()) } + fn get_work_edit(&self, edit_id: i64) -> Box + Send> { + self.api().get_work_edit(edit_id, &self.context()) + } + fn get_work_history(&self, id: String, limit: Option) -> Box + Send> { self.api().get_work_history(id, limit, &self.context()) } + fn get_work_redirects(&self, id: String) -> Box + Send> { + self.api().get_work_redirects(id, &self.context()) + } + fn get_work_releases(&self, id: String, hide: Option) -> Box + Send> { self.api().get_work_releases(id, hide, &self.context()) } + fn get_work_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send> { + self.api().get_work_revision(id, expand, hide, &self.context()) + } + fn update_work(&self, id: String, entity: models::WorkEntity, editgroup: Option) -> Box + Send> { self.api().update_work(id, entity, editgroup, &self.context()) } diff --git a/rust/fatcat-api-spec/src/mimetypes.rs b/rust/fatcat-api-spec/src/mimetypes.rs index dcf13f7a..b94aa6f6 100644 --- a/rust/fatcat-api-spec/src/mimetypes.rs +++ b/rust/fatcat-api-spec/src/mimetypes.rs @@ -52,6 +52,22 @@ pub mod responses { lazy_static! { pub static ref DELETE_CONTAINER_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for DeleteContainerEdit + lazy_static! { + pub static ref DELETE_CONTAINER_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteContainerEdit + lazy_static! { + pub static ref DELETE_CONTAINER_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteContainerEdit + lazy_static! { + pub static ref DELETE_CONTAINER_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteContainerEdit + lazy_static! { + pub static ref DELETE_CONTAINER_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetContainer lazy_static! { pub static ref GET_CONTAINER_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -68,6 +84,22 @@ pub mod responses { lazy_static! { pub static ref GET_CONTAINER_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetContainerEdit + lazy_static! { + pub static ref GET_CONTAINER_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerEdit + lazy_static! { + pub static ref GET_CONTAINER_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerEdit + lazy_static! { + pub static ref GET_CONTAINER_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerEdit + lazy_static! { + pub static ref GET_CONTAINER_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetContainerHistory lazy_static! { pub static ref GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); @@ -84,6 +116,38 @@ pub mod responses { lazy_static! { pub static ref GET_CONTAINER_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetContainerRedirects + lazy_static! { + pub static ref GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRedirects + lazy_static! { + pub static ref GET_CONTAINER_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRedirects + lazy_static! { + pub static ref GET_CONTAINER_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRedirects + lazy_static! { + pub static ref GET_CONTAINER_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRevision + lazy_static! { + pub static ref GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRevision + lazy_static! { + pub static ref GET_CONTAINER_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRevision + lazy_static! { + pub static ref GET_CONTAINER_REVISION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetContainerRevision + lazy_static! { + pub static ref GET_CONTAINER_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for LookupContainer lazy_static! { pub static ref LOOKUP_CONTAINER_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -164,6 +228,22 @@ pub mod responses { lazy_static! { pub static ref DELETE_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for DeleteCreatorEdit + lazy_static! { + pub static ref DELETE_CREATOR_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteCreatorEdit + lazy_static! { + pub static ref DELETE_CREATOR_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteCreatorEdit + lazy_static! { + pub static ref DELETE_CREATOR_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteCreatorEdit + lazy_static! { + pub static ref DELETE_CREATOR_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetCreator lazy_static! { pub static ref GET_CREATOR_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -180,6 +260,22 @@ pub mod responses { lazy_static! { pub static ref GET_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetCreatorEdit + lazy_static! { + pub static ref GET_CREATOR_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorEdit + lazy_static! { + pub static ref GET_CREATOR_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorEdit + lazy_static! { + pub static ref GET_CREATOR_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorEdit + lazy_static! { + pub static ref GET_CREATOR_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetCreatorHistory lazy_static! { pub static ref GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); @@ -196,6 +292,22 @@ pub mod responses { lazy_static! { pub static ref GET_CREATOR_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetCreatorRedirects + lazy_static! { + pub static ref GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRedirects + lazy_static! { + pub static ref GET_CREATOR_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRedirects + lazy_static! { + pub static ref GET_CREATOR_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRedirects + lazy_static! { + pub static ref GET_CREATOR_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetCreatorReleases lazy_static! { pub static ref GET_CREATOR_RELEASES_FOUND: Mime = mime!(Application / Json); @@ -212,6 +324,22 @@ pub mod responses { lazy_static! { pub static ref GET_CREATOR_RELEASES_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetCreatorRevision + lazy_static! { + pub static ref GET_CREATOR_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRevision + lazy_static! { + pub static ref GET_CREATOR_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRevision + lazy_static! { + pub static ref GET_CREATOR_REVISION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetCreatorRevision + lazy_static! { + pub static ref GET_CREATOR_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for LookupCreator lazy_static! { pub static ref LOOKUP_CREATOR_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -400,6 +528,22 @@ pub mod responses { lazy_static! { pub static ref DELETE_FILE_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for DeleteFileEdit + lazy_static! { + pub static ref DELETE_FILE_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteFileEdit + lazy_static! { + pub static ref DELETE_FILE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteFileEdit + lazy_static! { + pub static ref DELETE_FILE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteFileEdit + lazy_static! { + pub static ref DELETE_FILE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetFile lazy_static! { pub static ref GET_FILE_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -416,6 +560,22 @@ pub mod responses { lazy_static! { pub static ref GET_FILE_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetFileEdit + lazy_static! { + pub static ref GET_FILE_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileEdit + lazy_static! { + pub static ref GET_FILE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileEdit + lazy_static! { + pub static ref GET_FILE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileEdit + lazy_static! { + pub static ref GET_FILE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetFileHistory lazy_static! { pub static ref GET_FILE_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); @@ -432,6 +592,38 @@ pub mod responses { lazy_static! { pub static ref GET_FILE_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetFileRedirects + lazy_static! { + pub static ref GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRedirects + lazy_static! { + pub static ref GET_FILE_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRedirects + lazy_static! { + pub static ref GET_FILE_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRedirects + lazy_static! { + pub static ref GET_FILE_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRevision + lazy_static! { + pub static ref GET_FILE_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRevision + lazy_static! { + pub static ref GET_FILE_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRevision + lazy_static! { + pub static ref GET_FILE_REVISION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetFileRevision + lazy_static! { + pub static ref GET_FILE_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for LookupFile lazy_static! { pub static ref LOOKUP_FILE_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -528,6 +720,22 @@ pub mod responses { lazy_static! { pub static ref DELETE_RELEASE_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for DeleteReleaseEdit + lazy_static! { + pub static ref DELETE_RELEASE_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteReleaseEdit + lazy_static! { + pub static ref DELETE_RELEASE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteReleaseEdit + lazy_static! { + pub static ref DELETE_RELEASE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteReleaseEdit + lazy_static! { + pub static ref DELETE_RELEASE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetRelease lazy_static! { pub static ref GET_RELEASE_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -544,6 +752,22 @@ pub mod responses { lazy_static! { pub static ref GET_RELEASE_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetReleaseEdit + lazy_static! { + pub static ref GET_RELEASE_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseEdit + lazy_static! { + pub static ref GET_RELEASE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseEdit + lazy_static! { + pub static ref GET_RELEASE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseEdit + lazy_static! { + pub static ref GET_RELEASE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetReleaseFiles lazy_static! { pub static ref GET_RELEASE_FILES_FOUND: Mime = mime!(Application / Json); @@ -576,6 +800,38 @@ pub mod responses { lazy_static! { pub static ref GET_RELEASE_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetReleaseRedirects + lazy_static! { + pub static ref GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRedirects + lazy_static! { + pub static ref GET_RELEASE_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRedirects + lazy_static! { + pub static ref GET_RELEASE_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRedirects + lazy_static! { + pub static ref GET_RELEASE_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRevision + lazy_static! { + pub static ref GET_RELEASE_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRevision + lazy_static! { + pub static ref GET_RELEASE_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRevision + lazy_static! { + pub static ref GET_RELEASE_REVISION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetReleaseRevision + lazy_static! { + pub static ref GET_RELEASE_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for LookupRelease lazy_static! { pub static ref LOOKUP_RELEASE_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -640,6 +896,22 @@ pub mod responses { lazy_static! { pub static ref DELETE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for DeleteWorkEdit + lazy_static! { + pub static ref DELETE_WORK_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteWorkEdit + lazy_static! { + pub static ref DELETE_WORK_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteWorkEdit + lazy_static! { + pub static ref DELETE_WORK_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for DeleteWorkEdit + lazy_static! { + pub static ref DELETE_WORK_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetWork lazy_static! { pub static ref GET_WORK_FOUND_ENTITY: Mime = mime!(Application / Json); @@ -656,6 +928,22 @@ pub mod responses { lazy_static! { pub static ref GET_WORK_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetWorkEdit + lazy_static! { + pub static ref GET_WORK_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkEdit + lazy_static! { + pub static ref GET_WORK_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkEdit + lazy_static! { + pub static ref GET_WORK_EDIT_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkEdit + lazy_static! { + pub static ref GET_WORK_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetWorkHistory lazy_static! { pub static ref GET_WORK_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); @@ -672,6 +960,22 @@ pub mod responses { lazy_static! { pub static ref GET_WORK_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetWorkRedirects + lazy_static! { + pub static ref GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRedirects + lazy_static! { + pub static ref GET_WORK_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRedirects + lazy_static! { + pub static ref GET_WORK_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRedirects + lazy_static! { + pub static ref GET_WORK_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetWorkReleases lazy_static! { pub static ref GET_WORK_RELEASES_FOUND: Mime = mime!(Application / Json); @@ -688,6 +992,22 @@ pub mod responses { lazy_static! { pub static ref GET_WORK_RELEASES_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetWorkRevision + lazy_static! { + pub static ref GET_WORK_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRevision + lazy_static! { + pub static ref GET_WORK_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRevision + lazy_static! { + pub static ref GET_WORK_REVISION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetWorkRevision + lazy_static! { + pub static ref GET_WORK_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for UpdateWork lazy_static! { pub static ref UPDATE_WORK_UPDATED_ENTITY: Mime = mime!(Application / Json); diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs index 73418c45..6e374746 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -58,8 +58,10 @@ pub struct ContainerEntity { #[serde(skip_serializing_if = "Option::is_none")] pub publisher: Option, + /// Required for valid entities #[serde(rename = "name")] - pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option, #[serde(rename = "edit_extra")] #[serde(skip_serializing_if = "Option::is_none")] @@ -91,14 +93,14 @@ pub struct ContainerEntity { } impl ContainerEntity { - pub fn new(name: String) -> ContainerEntity { + pub fn new() -> ContainerEntity { ContainerEntity { coden: None, abbrev: None, wikidata_qid: None, issnl: None, publisher: None, - name: name, + name: None, edit_extra: None, extra: None, redirect: None, @@ -127,8 +129,10 @@ pub struct CreatorEntity { #[serde(skip_serializing_if = "Option::is_none")] pub given_name: Option, + /// Required for valid entities #[serde(rename = "display_name")] - pub display_name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub display_name: Option, // Note: inline enums are not fully supported by swagger-codegen #[serde(rename = "state")] @@ -160,13 +164,13 @@ pub struct CreatorEntity { } impl CreatorEntity { - pub fn new(display_name: String) -> CreatorEntity { + pub fn new() -> CreatorEntity { CreatorEntity { wikidata_qid: None, orcid: None, surname: None, given_name: None, - display_name: display_name, + display_name: None, state: None, ident: None, revision: None, @@ -358,14 +362,14 @@ pub struct FileEntity { #[serde(skip_serializing_if = "Option::is_none")] pub sha256: Option, - #[serde(rename = "md5")] - #[serde(skip_serializing_if = "Option::is_none")] - pub md5: Option, - #[serde(rename = "sha1")] #[serde(skip_serializing_if = "Option::is_none")] pub sha1: Option, + #[serde(rename = "md5")] + #[serde(skip_serializing_if = "Option::is_none")] + pub md5: Option, + #[serde(rename = "size")] #[serde(skip_serializing_if = "Option::is_none")] pub size: Option, @@ -406,8 +410,8 @@ impl FileEntity { mimetype: None, urls: None, sha256: None, - md5: None, sha1: None, + md5: None, size: None, edit_extra: None, extra: None, @@ -564,8 +568,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub work_id: Option, + /// Required for valid entities #[serde(rename = "title")] - pub title: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub title: Option, // Note: inline enums are not fully supported by swagger-codegen #[serde(rename = "state")] @@ -597,7 +603,7 @@ pub struct ReleaseEntity { } impl ReleaseEntity { - pub fn new(title: String) -> ReleaseEntity { + pub fn new() -> ReleaseEntity { ReleaseEntity { abstracts: None, refs: None, @@ -620,7 +626,7 @@ impl ReleaseEntity { files: None, container: None, work_id: None, - title: title, + title: None, state: None, ident: None, revision: None, diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index c4f491de..e8d8e1eb 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -38,11 +38,14 @@ use swagger::{ApiError, Context, XSpanId}; use models; use { AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, - CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerResponse, DeleteCreatorResponse, DeleteFileResponse, - DeleteReleaseResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, GetContainerResponse, GetCreatorHistoryResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, - GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, - LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, + CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWorkEditResponse, DeleteWorkResponse, + GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, + GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, + GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse, + GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse, + GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, }; header! { (Warning, "Warning") => [String] } @@ -405,8 +408,8 @@ where ); let api_clone = api.clone(); - router.get( - "/v0/container/:id", + router.delete( + "/v0/container/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -420,62 +423,57 @@ where context.authorization = req.extensions.remove::(); // Path parameters - let param_id = { + let param_edit_id = { let param = req .extensions .get::() .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; percent_decode(param.as_bytes()) .decode_utf8() .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_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::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_container(param_id, param_expand, param_hide, context).wait() { + match api.delete_container_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - GetContainerResponse::FoundEntity(body) => { + DeleteContainerEditResponse::DeletedEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_DELETED_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerResponse::BadRequest(body) => { + DeleteContainerEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerResponse::NotFound(body) => { + DeleteContainerEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerResponse::GenericError(body) => { + DeleteContainerEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -495,12 +493,12 @@ where Ok(response) }) }, - "GetContainer", + "DeleteContainerEdit", ); let api_clone = api.clone(); router.get( - "/v0/container/:id/history", + "/v0/container/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -530,45 +528,46 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_container_history(param_id, param_limit, context).wait() { + match api.get_container(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - GetContainerHistoryResponse::FoundEntityHistory(body) => { + GetContainerResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerHistoryResponse::BadRequest(body) => { + GetContainerResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerHistoryResponse::NotFound(body) => { + GetContainerResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetContainerHistoryResponse::GenericError(body) => { + GetContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -588,12 +587,12 @@ where Ok(response) }) }, - "GetContainerHistory", + "GetContainer", ); let api_clone = api.clone(); router.get( - "/v0/container/lookup", + "/v0/container/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -606,54 +605,58 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_issnl = query_params - .get("issnl") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issnl".to_string())))? - .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issnl was empty".to_string())))? - .parse::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issnl - doesn't match schema: {}", e))))?; - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; - match api.lookup_container(param_issnl, param_hide, context).wait() { + match api.get_container_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - LookupContainerResponse::FoundEntity(body) => { + GetContainerEditResponse::FoundEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_FOUND_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupContainerResponse::BadRequest(body) => { + GetContainerEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupContainerResponse::NotFound(body) => { + GetContainerEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupContainerResponse::GenericError(body) => { + GetContainerEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -673,12 +676,12 @@ where Ok(response) }) }, - "LookupContainer", + "GetContainerEdit", ); let api_clone = api.clone(); - router.put( - "/v0/container/:id", + router.get( + "/v0/container/:id/history", move |req: &mut Request| { let mut context = Context::default(); @@ -708,80 +711,48 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.update_container(param_id, param_entity, param_editgroup, context).wait() { + match api.get_container_history(param_id, param_limit, context).wait() { Ok(rsp) => match rsp { - UpdateContainerResponse::UpdatedEntity(body) => { + GetContainerHistoryResponse::FoundEntityHistory(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_UPDATED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateContainerResponse::BadRequest(body) => { + GetContainerHistoryResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateContainerResponse::NotFound(body) => { + GetContainerHistoryResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateContainerResponse::GenericError(body) => { + GetContainerHistoryResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_HISTORY_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -798,12 +769,12 @@ where Ok(response) }) }, - "UpdateContainer", + "GetContainerHistory", ); let api_clone = api.clone(); - router.post( - "/v0/creator", + router.get( + "/v0/container/:id/redirects", move |req: &mut Request| { let mut context = Context::default(); @@ -816,82 +787,61 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - 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, param_editgroup, context).wait() { + match api.get_container_redirects(param_id, context).wait() { Ok(rsp) => match rsp { - CreateCreatorResponse::CreatedEntity(body) => { + GetContainerRedirectsResponse::FoundEntityRedirects(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_CREATED_ENTITY.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateCreatorResponse::BadRequest(body) => { + GetContainerRedirectsResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateCreatorResponse::NotFound(body) => { + GetContainerRedirectsResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateCreatorResponse::GenericError(body) => { + GetContainerRedirectsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -908,12 +858,12 @@ where Ok(response) }) }, - "CreateCreator", + "GetContainerRedirects", ); let api_clone = api.clone(); - router.post( - "/v0/creator/batch", + router.get( + "/v0/container/rev/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -926,83 +876,66 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").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 - // any unused fields. + match api.get_container_revision(param_id, param_expand, param_hide, context).wait() { + Ok(rsp) => match rsp { + GetContainerRevisionResponse::FoundEntityRevision(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let param_entity_list = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION.clone())); - let mut unused_elements = Vec::new(); + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); + Ok(response) + } + GetContainerRevisionResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_BAD_REQUEST.clone())); - param_entity_list - } else { - None - }; - let param_entity_list = param_entity_list.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity_list".to_string())))?; + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - match api.create_creator_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - CreateCreatorBatchResponse::CreatedEntities(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_CREATED_ENTITIES.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - CreateCreatorBatchResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } Ok(response) } - CreateCreatorBatchResponse::NotFound(body) => { + GetContainerRevisionResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateCreatorBatchResponse::GenericError(body) => { + GetContainerRevisionResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -1019,12 +952,12 @@ where Ok(response) }) }, - "CreateCreatorBatch", + "GetContainerRevision", ); let api_clone = api.clone(); - router.delete( - "/v0/creator/:id", + router.get( + "/v0/container/lookup", move |req: &mut Request| { let mut context = Context::default(); @@ -1037,62 +970,49 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_issnl = query_params.get("issnl").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.delete_creator(param_id, param_editgroup, context).wait() { + match api.lookup_container(param_issnl, param_wikidata_qid, param_hide, context).wait() { Ok(rsp) => match rsp { - DeleteCreatorResponse::DeletedEntity(body) => { + LookupContainerResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_DELETED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteCreatorResponse::BadRequest(body) => { + LookupContainerResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteCreatorResponse::NotFound(body) => { + LookupContainerResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteCreatorResponse::GenericError(body) => { + LookupContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1112,12 +1032,12 @@ where Ok(response) }) }, - "DeleteCreator", + "LookupContainer", ); let api_clone = api.clone(); - router.get( - "/v0/creator/:id", + router.put( + "/v0/container/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -1147,49 +1067,80 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_creator(param_id, param_expand, param_hide, context).wait() { + // 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. + + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, param_editgroup, context).wait() { Ok(rsp) => match rsp { - GetCreatorResponse::FoundEntity(body) => { + UpdateContainerResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_UPDATED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorResponse::BadRequest(body) => { + UpdateContainerResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorResponse::NotFound(body) => { + UpdateContainerResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorResponse::GenericError(body) => { + UpdateContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -1206,12 +1157,12 @@ where Ok(response) }) }, - "GetCreator", + "UpdateContainer", ); let api_clone = api.clone(); - router.get( - "/v0/creator/:id/history", + router.post( + "/v0/creator", move |req: &mut Request| { let mut context = Context::default(); @@ -1224,65 +1175,82 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_creator_history(param_id, param_limit, context).wait() { + // 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. + + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, param_editgroup, context).wait() { Ok(rsp) => match rsp { - GetCreatorHistoryResponse::FoundEntityHistory(body) => { + CreateCreatorResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY.clone())); + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_CREATED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorHistoryResponse::BadRequest(body) => { + CreateCreatorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorHistoryResponse::NotFound(body) => { + CreateCreatorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorHistoryResponse::GenericError(body) => { + CreateCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -1299,12 +1267,12 @@ where Ok(response) }) }, - "GetCreatorHistory", + "CreateCreator", ); let api_clone = api.clone(); - router.get( - "/v0/creator/:id/releases", + router.post( + "/v0/creator/batch", move |req: &mut Request| { let mut context = Context::default(); @@ -1317,65 +1285,83 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_creator_releases(param_id, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetCreatorReleasesResponse::Found(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + // 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. - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_FOUND.clone())); + let param_entity_list = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + let mut unused_elements = Vec::new(); + + let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); + + let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; + + param_entity_list + } else { + None + }; + 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, context).wait() { + Ok(rsp) => match rsp { + CreateCreatorBatchResponse::CreatedEntities(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_CREATED_ENTITIES.clone())); + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorReleasesResponse::BadRequest(body) => { + CreateCreatorBatchResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorReleasesResponse::NotFound(body) => { + CreateCreatorBatchResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetCreatorReleasesResponse::GenericError(body) => { + CreateCreatorBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -1392,12 +1378,12 @@ where Ok(response) }) }, - "GetCreatorReleases", + "CreateCreatorBatch", ); let api_clone = api.clone(); - router.get( - "/v0/creator/lookup", + router.delete( + "/v0/creator/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -1410,54 +1396,62 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); - let param_orcid = query_params - .get("orcid") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter orcid".to_string())))? - .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter orcid was empty".to_string())))? - .parse::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter orcid - doesn't match schema: {}", e))))?; - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.lookup_creator(param_orcid, param_hide, context).wait() { + match api.delete_creator(param_id, param_editgroup, context).wait() { Ok(rsp) => match rsp { - LookupCreatorResponse::FoundEntity(body) => { + DeleteCreatorResponse::DeletedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_DELETED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupCreatorResponse::BadRequest(body) => { + DeleteCreatorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupCreatorResponse::NotFound(body) => { + DeleteCreatorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupCreatorResponse::GenericError(body) => { + DeleteCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1477,12 +1471,12 @@ where Ok(response) }) }, - "LookupCreator", + "DeleteCreator", ); let api_clone = api.clone(); - router.put( - "/v0/creator/:id", + router.delete( + "/v0/creator/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -1496,96 +1490,60 @@ where context.authorization = req.extensions.remove::(); // Path parameters - let param_id = { + let param_edit_id = { let param = req .extensions .get::() .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; percent_decode(param.as_bytes()) .decode_utf8() .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? .parse() - .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::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? }; - 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, param_editgroup, context).wait() { + match api.delete_creator_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - UpdateCreatorResponse::UpdatedEntity(body) => { + DeleteCreatorEditResponse::DeletedEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_UPDATED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_DELETED_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateCreatorResponse::BadRequest(body) => { + DeleteCreatorEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateCreatorResponse::NotFound(body) => { + DeleteCreatorEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateCreatorResponse::GenericError(body) => { + DeleteCreatorEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -1602,12 +1560,12 @@ where Ok(response) }) }, - "UpdateCreator", + "DeleteCreatorEdit", ); let api_clone = api.clone(); router.get( - "/v0/editor/:id", + "/v0/creator/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -1635,43 +1593,48 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - match api.get_editor(param_id, context).wait() { + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_creator(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - GetEditorResponse::Found(body) => { + GetCreatorResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorResponse::BadRequest(body) => { + GetCreatorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorResponse::NotFound(body) => { + GetCreatorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorResponse::GenericError(body) => { + GetCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1691,12 +1654,12 @@ where Ok(response) }) }, - "GetEditor", + "GetCreator", ); let api_clone = api.clone(); router.get( - "/v0/editor/:id/changelog", + "/v0/creator/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -1710,57 +1673,57 @@ where context.authorization = req.extensions.remove::(); // Path parameters - let param_id = { + let param_edit_id = { let param = req .extensions .get::() .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; percent_decode(param.as_bytes()) .decode_utf8() .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? }; - match api.get_editor_changelog(param_id, context).wait() { + match api.get_creator_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - GetEditorChangelogResponse::Found(body) => { + GetCreatorEditResponse::FoundEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_FOUND_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::BadRequest(body) => { + GetCreatorEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::NotFound(body) => { + GetCreatorEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::GenericError(body) => { + GetCreatorEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1780,12 +1743,12 @@ where Ok(response) }) }, - "GetEditorChangelog", + "GetCreatorEdit", ); let api_clone = api.clone(); router.get( - "/v0/stats", + "/v0/creator/:id/history", move |req: &mut Request| { let mut context = Context::default(); @@ -1798,27 +1761,62 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); - let param_more = query_params.get("more").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_stats(param_more, context).wait() { + match api.get_creator_history(param_id, param_limit, context).wait() { Ok(rsp) => match rsp { - GetStatsResponse::Success(body) => { + GetCreatorHistoryResponse::FoundEntityHistory(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_STATS_SUCCESS.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetStatsResponse::GenericError(body) => { + GetCreatorHistoryResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetCreatorHistoryResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetCreatorHistoryResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_STATS_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_HISTORY_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1838,12 +1836,12 @@ where Ok(response) }) }, - "GetStats", + "GetCreatorHistory", ); let api_clone = api.clone(); - router.post( - "/v0/editgroup/:id/accept", + router.get( + "/v0/creator/:id/redirects", move |req: &mut Request| { let mut context = Context::default(); @@ -1871,53 +1869,43 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - match api.accept_editgroup(param_id, context).wait() { + match api.get_creator_redirects(param_id, context).wait() { Ok(rsp) => match rsp { - AcceptEditgroupResponse::MergedSuccessfully(body) => { + GetCreatorRedirectsResponse::FoundEntityRedirects(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - AcceptEditgroupResponse::BadRequest(body) => { + GetCreatorRedirectsResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - AcceptEditgroupResponse::NotFound(body) => { + GetCreatorRedirectsResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AcceptEditgroupResponse::EditConflict(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(409), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_EDIT_CONFLICT.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - AcceptEditgroupResponse::GenericError(body) => { + GetCreatorRedirectsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1937,12 +1925,12 @@ where Ok(response) }) }, - "AcceptEditgroup", + "GetCreatorRedirects", ); let api_clone = api.clone(); - router.post( - "/v0/editgroup", + router.get( + "/v0/creator/:id/releases", move |req: &mut Request| { let mut context = Context::default(); @@ -1955,121 +1943,62 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // 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. - - let param_editgroup = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_editgroup_raw); - - let param_editgroup: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; - - param_editgroup - } else { - None + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?; - match api.create_editgroup(param_editgroup, context).wait() { + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_creator_releases(param_id, param_hide, context).wait() { Ok(rsp) => match rsp { - CreateEditgroupResponse::SuccessfullyCreated(body) => { + GetCreatorReleasesResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_SUCCESSFULLY_CREATED.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateEditgroupResponse::BadRequest(body) => { + GetCreatorReleasesResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - CreateEditgroupResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_GENERIC_ERROR.clone())); - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } Ok(response) } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "CreateEditgroup", - ); - - let api_clone = api.clone(); - router.get( - "/v0/changelog", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_changelog(param_limit, context).wait() { - Ok(rsp) => match rsp { - GetChangelogResponse::Success(body) => { + GetCreatorReleasesResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone())); + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetChangelogResponse::GenericError(body) => { + GetCreatorReleasesResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2089,12 +2018,12 @@ where Ok(response) }) }, - "GetChangelog", + "GetCreatorReleases", ); let api_clone = api.clone(); router.get( - "/v0/changelog/:id", + "/v0/creator/rev/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -2122,33 +2051,48 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - match api.get_changelog_entry(param_id, context).wait() { + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_creator_revision(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - GetChangelogEntryResponse::FoundChangelogEntry(body) => { + GetCreatorRevisionResponse::FoundEntityRevision(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_FOUND_ENTITY_REVISION.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetChangelogEntryResponse::NotFound(body) => { + GetCreatorRevisionResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetCreatorRevisionResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetChangelogEntryResponse::GenericError(body) => { + GetCreatorRevisionResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2168,12 +2112,12 @@ where Ok(response) }) }, - "GetChangelogEntry", + "GetCreatorRevision", ); let api_clone = api.clone(); router.get( - "/v0/editgroup/:id", + "/v0/creator/lookup", move |req: &mut Request| { let mut context = Context::default(); @@ -2186,58 +2130,49 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); + let param_orcid = query_params.get("orcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_editgroup(param_id, context).wait() { + match api.lookup_creator(param_orcid, param_wikidata_qid, param_hide, context).wait() { Ok(rsp) => match rsp { - GetEditgroupResponse::Found(body) => { + LookupCreatorResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditgroupResponse::BadRequest(body) => { + LookupCreatorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditgroupResponse::NotFound(body) => { + LookupCreatorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditgroupResponse::GenericError(body) => { + LookupCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2257,12 +2192,12 @@ where Ok(response) }) }, - "GetEditgroup", + "LookupCreator", ); let api_clone = api.clone(); - router.post( - "/v0/file", + router.put( + "/v0/creator/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -2275,6 +2210,21 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); @@ -2292,7 +2242,7 @@ where let param_entity = if let Some(param_entity_raw) = param_entity { let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; @@ -2303,13 +2253,13 @@ 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, param_editgroup, context).wait() { + match api.update_creator(param_id, param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { - CreateFileResponse::CreatedEntity(body) => { + UpdateCreatorResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_CREATED_ENTITY.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_UPDATED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -2317,11 +2267,11 @@ where } Ok(response) } - CreateFileResponse::BadRequest(body) => { + UpdateCreatorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -2329,11 +2279,11 @@ where } Ok(response) } - CreateFileResponse::NotFound(body) => { + UpdateCreatorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -2341,11 +2291,11 @@ where } Ok(response) } - CreateFileResponse::GenericError(body) => { + UpdateCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -2367,12 +2317,12 @@ where Ok(response) }) }, - "CreateFile", + "UpdateCreator", ); let api_clone = api.clone(); - router.post( - "/v0/file/batch", + router.get( + "/v0/editor/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -2385,83 +2335,61 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity_list = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); - - let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; - - param_entity_list - } else { - None + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - 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, context).wait() { + match api.get_editor(param_id, context).wait() { Ok(rsp) => match rsp { - CreateFileBatchResponse::CreatedEntities(body) => { + GetEditorResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_CREATED_ENTITIES.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateFileBatchResponse::BadRequest(body) => { + GetEditorResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateFileBatchResponse::NotFound(body) => { + GetEditorResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateFileBatchResponse::GenericError(body) => { + GetEditorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -2478,12 +2406,12 @@ where Ok(response) }) }, - "CreateFileBatch", + "GetEditor", ); let api_clone = api.clone(); - router.delete( - "/v0/file/:id", + router.get( + "/v0/editor/:id/changelog", move |req: &mut Request| { let mut context = Context::default(); @@ -2511,47 +2439,43 @@ 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::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.delete_file(param_id, param_editgroup, context).wait() { + match api.get_editor_changelog(param_id, context).wait() { Ok(rsp) => match rsp { - DeleteFileResponse::DeletedEntity(body) => { + GetEditorChangelogResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_DELETED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteFileResponse::BadRequest(body) => { + GetEditorChangelogResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteFileResponse::NotFound(body) => { + GetEditorChangelogResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteFileResponse::GenericError(body) => { + GetEditorChangelogResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2571,12 +2495,12 @@ where Ok(response) }) }, - "DeleteFile", + "GetEditorChangelog", ); let api_clone = api.clone(); router.get( - "/v0/file/:id", + "/v0/stats", move |req: &mut Request| { let mut context = Context::default(); @@ -2589,63 +2513,27 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_more = query_params.get("more").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_file(param_id, param_expand, param_hide, context).wait() { + match api.get_stats(param_more, context).wait() { Ok(rsp) => match rsp { - GetFileResponse::FoundEntity(body) => { + GetStatsResponse::Success(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_STATS_SUCCESS.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetFileResponse::GenericError(body) => { + GetStatsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_STATS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2665,12 +2553,12 @@ where Ok(response) }) }, - "GetFile", + "GetStats", ); let api_clone = api.clone(); - router.get( - "/v0/file/:id/history", + router.post( + "/v0/editgroup/:id/accept", move |req: &mut Request| { let mut context = Context::default(); @@ -2698,47 +2586,53 @@ 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::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_file_history(param_id, param_limit, context).wait() { + match api.accept_editgroup(param_id, context).wait() { Ok(rsp) => match rsp { - GetFileHistoryResponse::FoundEntityHistory(body) => { + AcceptEditgroupResponse::MergedSuccessfully(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_FOUND_ENTITY_HISTORY.clone())); + response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetFileHistoryResponse::BadRequest(body) => { + AcceptEditgroupResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetFileHistoryResponse::NotFound(body) => { + AcceptEditgroupResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetFileHistoryResponse::GenericError(body) => { + AcceptEditgroupResponse::EditConflict(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(409), body_string)); + response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_EDIT_CONFLICT.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + AcceptEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2758,12 +2652,12 @@ where Ok(response) }) }, - "GetFileHistory", + "AcceptEditgroup", ); let api_clone = api.clone(); - router.get( - "/v0/file/lookup", + router.post( + "/v0/editgroup", move |req: &mut Request| { let mut context = Context::default(); @@ -2776,57 +2670,66 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_sha1 = query_params - .get("sha1") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter sha1".to_string())))? - .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter sha1 was empty".to_string())))? - .parse::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter sha1 - doesn't match schema: {}", e))))?; - let param_hide = query_params.get("hide").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 + // any unused fields. - match api.lookup_file(param_sha1, param_hide, context).wait() { - Ok(rsp) => match rsp { - LookupFileResponse::FoundEntity(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + let param_editgroup = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?; - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_FOUND_ENTITY.clone())); + let mut unused_elements = Vec::new(); - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_editgroup_raw); - Ok(response) - } - LookupFileResponse::BadRequest(body) => { + let param_editgroup: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; + + param_editgroup + } else { + None + }; + let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?; + + match api.create_editgroup(param_editgroup, context).wait() { + Ok(rsp) => match rsp { + CreateEditgroupResponse::SuccessfullyCreated(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_BAD_REQUEST.clone())); + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_SUCCESSFULLY_CREATED.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - LookupFileResponse::NotFound(body) => { + CreateEditgroupResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_NOT_FOUND.clone())); + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - LookupFileResponse::GenericError(body) => { + CreateEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -2843,12 +2746,70 @@ where Ok(response) }) }, - "LookupFile", + "CreateEditgroup", ); let api_clone = api.clone(); - router.put( - "/v0/file/:id", + router.get( + "/v0/changelog", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_changelog(param_limit, context).wait() { + Ok(rsp) => match rsp { + GetChangelogResponse::Success(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetChangelogResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetChangelog", + ); + + let api_clone = api.clone(); + router.get( + "/v0/changelog/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -2876,82 +2837,125 @@ 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::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + match api.get_changelog_entry(param_id, context).wait() { + Ok(rsp) => match rsp { + GetChangelogEntryResponse::FoundChangelogEntry(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - // 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. + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY.clone())); - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - let mut unused_elements = Vec::new(); + Ok(response) + } + GetChangelogEntryResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_NOT_FOUND.clone())); - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - param_entity - } else { - None + Ok(response) + } + GetChangelogEntryResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetChangelogEntry", + ); + + let api_clone = api.clone(); + router.get( + "/v0/editgroup/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - 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, param_editgroup, context).wait() { + match api.get_editgroup(param_id, context).wait() { Ok(rsp) => match rsp { - UpdateFileResponse::UpdatedEntity(body) => { + GetEditgroupResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_UPDATED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateFileResponse::BadRequest(body) => { + GetEditgroupResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateFileResponse::NotFound(body) => { + GetEditgroupResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateFileResponse::GenericError(body) => { + GetEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -2968,12 +2972,12 @@ where Ok(response) }) }, - "UpdateFile", + "GetEditgroup", ); let api_clone = api.clone(); router.post( - "/v0/release", + "/v0/file", move |req: &mut Request| { let mut context = Context::default(); @@ -3003,7 +3007,7 @@ where let param_entity = if let Some(param_entity_raw) = param_entity { let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; @@ -3014,13 +3018,13 @@ 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, param_editgroup, context).wait() { + match api.create_file(param_entity, param_editgroup, context).wait() { Ok(rsp) => match rsp { - CreateReleaseResponse::CreatedEntity(body) => { + CreateFileResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_CREATED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_CREATED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3028,11 +3032,11 @@ where } Ok(response) } - CreateReleaseResponse::BadRequest(body) => { + CreateFileResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3040,11 +3044,11 @@ where } Ok(response) } - CreateReleaseResponse::NotFound(body) => { + CreateFileResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3052,11 +3056,11 @@ where } Ok(response) } - CreateReleaseResponse::GenericError(body) => { + CreateFileResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3078,12 +3082,12 @@ where Ok(response) }) }, - "CreateRelease", + "CreateFile", ); let api_clone = api.clone(); router.post( - "/v0/release/batch", + "/v0/file/batch", move |req: &mut Request| { let mut context = Context::default(); @@ -3114,7 +3118,7 @@ where let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); - let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { + let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; @@ -3125,13 +3129,13 @@ 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, context).wait() { + match api.create_file_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup, context).wait() { Ok(rsp) => match rsp { - CreateReleaseBatchResponse::CreatedEntities(body) => { + CreateFileBatchResponse::CreatedEntities(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_CREATED_ENTITIES.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_CREATED_ENTITIES.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3139,11 +3143,11 @@ where } Ok(response) } - CreateReleaseBatchResponse::BadRequest(body) => { + CreateFileBatchResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3151,11 +3155,11 @@ where } Ok(response) } - CreateReleaseBatchResponse::NotFound(body) => { + CreateFileBatchResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3163,11 +3167,11 @@ where } Ok(response) } - CreateReleaseBatchResponse::GenericError(body) => { + CreateFileBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); if !unused_elements.is_empty() { @@ -3189,12 +3193,1080 @@ where Ok(response) }) }, - "CreateReleaseBatch", + "CreateFileBatch", ); let api_clone = api.clone(); - router.post( - "/v0/work", + router.delete( + "/v0/file/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.delete_file(param_id, param_editgroup, context).wait() { + Ok(rsp) => match rsp { + DeleteFileResponse::DeletedEntity(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_DELETED_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "DeleteFile", + ); + + let api_clone = api.clone(); + router.delete( + "/v0/file/edit/:edit_id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; + + match api.delete_file_edit(param_edit_id, context).wait() { + Ok(rsp) => match rsp { + DeleteFileEditResponse::DeletedEdit(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_DELETED_EDIT.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileEditResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileEditResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteFileEditResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "DeleteFileEdit", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_file(param_id, param_expand, param_hide, context).wait() { + Ok(rsp) => match rsp { + GetFileResponse::FoundEntity(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_FOUND_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetFile", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/edit/:edit_id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; + + match api.get_file_edit(param_edit_id, context).wait() { + Ok(rsp) => match rsp { + GetFileEditResponse::FoundEdit(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_FOUND_EDIT.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileEditResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileEditResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileEditResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetFileEdit", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/:id/history", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_file_history(param_id, param_limit, context).wait() { + Ok(rsp) => match rsp { + GetFileHistoryResponse::FoundEntityHistory(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_FOUND_ENTITY_HISTORY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileHistoryResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileHistoryResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileHistoryResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetFileHistory", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/:id/redirects", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? + }; + + match api.get_file_redirects(param_id, context).wait() { + Ok(rsp) => match rsp { + GetFileRedirectsResponse::FoundEntityRedirects(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRedirectsResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRedirectsResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRedirectsResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetFileRedirects", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/rev/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_file_revision(param_id, param_expand, param_hide, context).wait() { + Ok(rsp) => match rsp { + GetFileRevisionResponse::FoundEntityRevision(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_FOUND_ENTITY_REVISION.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRevisionResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRevisionResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetFileRevisionResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetFileRevision", + ); + + let api_clone = api.clone(); + router.get( + "/v0/file/lookup", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_md5 = query_params.get("md5").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_sha1 = query_params.get("sha1").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_sha256 = query_params.get("sha256").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.lookup_file(param_md5, param_sha1, param_sha256, param_hide, context).wait() { + Ok(rsp) => match rsp { + LookupFileResponse::FoundEntity(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_FOUND_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + LookupFileResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + LookupFileResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + LookupFileResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "LookupFile", + ); + + let api_clone = api.clone(); + router.put( + "/v0/file/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").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 + // any unused fields. + + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, 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"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_UPDATED_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateFileResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateFileResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateFileResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "UpdateFile", + ); + + let api_clone = api.clone(); + router.post( + "/v0/release", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").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 + // any unused fields. + + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, 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"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_CREATED_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "CreateRelease", + ); + + let api_clone = api.clone(); + router.post( + "/v0/release/batch", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").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 + // any unused fields. + + let param_entity_list = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); + + let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; + + param_entity_list + } else { + None + }; + 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, context).wait() { + Ok(rsp) => match rsp { + CreateReleaseBatchResponse::CreatedEntities(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_CREATED_ENTITIES.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseBatchResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseBatchResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateReleaseBatchResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "CreateReleaseBatch", + ); + + let api_clone = api.clone(); + router.post( + "/v0/work", move |req: &mut Request| { let mut context = Context::default(); @@ -3215,74 +4287,714 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, 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"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_CREATED_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "CreateWork", + ); + + let api_clone = api.clone(); + router.delete( + "/v0/release/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.delete_release(param_id, param_editgroup, context).wait() { + Ok(rsp) => match rsp { + DeleteReleaseResponse::DeletedEntity(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_DELETED_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "DeleteRelease", + ); + + let api_clone = api.clone(); + router.delete( + "/v0/release/edit/:edit_id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; + + match api.delete_release_edit(param_edit_id, context).wait() { + Ok(rsp) => match rsp { + DeleteReleaseEditResponse::DeletedEdit(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_DELETED_EDIT.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseEditResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseEditResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + DeleteReleaseEditResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "DeleteReleaseEdit", + ); + + let api_clone = api.clone(); + router.get( + "/v0/release/:id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_release(param_id, param_expand, param_hide, context).wait() { + Ok(rsp) => match rsp { + GetReleaseResponse::FoundEntity(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FOUND_ENTITY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetRelease", + ); + + let api_clone = api.clone(); + router.get( + "/v0/release/edit/:edit_id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; + + match api.get_release_edit(param_edit_id, context).wait() { + Ok(rsp) => match rsp { + GetReleaseEditResponse::FoundEdit(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_FOUND_EDIT.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseEditResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseEditResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseEditResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut unused_elements = Vec::new(); + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_GENERIC_ERROR.clone())); - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } - param_entity - } else { - None + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetReleaseEdit", + ); + + let api_clone = api.clone(); + router.get( + "/v0/release/:id/files", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? }; - 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, param_editgroup, context).wait() { + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_release_files(param_id, param_hide, context).wait() { Ok(rsp) => match rsp { - CreateWorkResponse::CreatedEntity(body) => { + GetReleaseFilesResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_CREATED_ENTITY.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + + Ok(response) + } + GetReleaseFilesResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseFilesResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseFilesResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetReleaseFiles", + ); + + let api_clone = api.clone(); + router.get( + "/v0/release/:id/history", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .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::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_release_history(param_id, param_limit, context).wait() { + Ok(rsp) => match rsp { + GetReleaseHistoryResponse::FoundEntityHistory(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseHistoryResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseHistoryResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetReleaseHistoryResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetReleaseHistory", + ); + + let api_clone = api.clone(); + router.get( + "/v0/release/:id/redirects", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter id: {}", e))))? + }; + + match api.get_release_redirects(param_id, context).wait() { + Ok(rsp) => match rsp { + GetReleaseRedirectsResponse::FoundEntityRedirects(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) } - CreateWorkResponse::BadRequest(body) => { + GetReleaseRedirectsResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateWorkResponse::NotFound(body) => { + GetReleaseRedirectsResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateWorkResponse::GenericError(body) => { + GetReleaseRedirectsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -3299,12 +5011,12 @@ where Ok(response) }) }, - "CreateWork", + "GetReleaseRedirects", ); let api_clone = api.clone(); - router.delete( - "/v0/release/:id", + router.get( + "/v0/release/rev/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -3334,45 +5046,46 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.delete_release(param_id, param_editgroup, context).wait() { + match api.get_release_revision(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - DeleteReleaseResponse::DeletedEntity(body) => { + GetReleaseRevisionResponse::FoundEntityRevision(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_DELETED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_FOUND_ENTITY_REVISION.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteReleaseResponse::BadRequest(body) => { + GetReleaseRevisionResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteReleaseResponse::NotFound(body) => { + GetReleaseRevisionResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteReleaseResponse::GenericError(body) => { + GetReleaseRevisionResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -3392,12 +5105,12 @@ where Ok(response) }) }, - "DeleteRelease", + "GetReleaseRevision", ); let api_clone = api.clone(); router.get( - "/v0/release/:id", + "/v0/release/lookup", move |req: &mut Request| { let mut context = Context::default(); @@ -3410,63 +5123,52 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Path parameters - let param_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .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::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_doi = query_params.get("doi").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_isbn13 = query_params.get("isbn13").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_pmid = query_params.get("pmid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_pmcid = query_params.get("pmcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_release(param_id, param_expand, param_hide, context).wait() { + match api.lookup_release(param_doi, param_wikidata_qid, param_isbn13, param_pmid, param_pmcid, param_hide, context).wait() { Ok(rsp) => match rsp { - GetReleaseResponse::FoundEntity(body) => { + LookupReleaseResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseResponse::BadRequest(body) => { + LookupReleaseResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseResponse::NotFound(body) => { + LookupReleaseResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseResponse::GenericError(body) => { + LookupReleaseResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -3486,12 +5188,12 @@ where Ok(response) }) }, - "GetRelease", + "LookupRelease", ); let api_clone = api.clone(); - router.get( - "/v0/release/:id/files", + router.put( + "/v0/release/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -3521,48 +5223,191 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_release_files(param_id, param_hide, context).wait() { + // 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. + + let param_entity = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); + + let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; + + param_entity + } else { + None + }; + 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, param_editgroup, context).wait() { Ok(rsp) => match rsp { - GetReleaseFilesResponse::Found(body) => { + UpdateReleaseResponse::UpdatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_UPDATED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetReleaseFilesResponse::BadRequest(body) => { + UpdateReleaseResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetReleaseFilesResponse::NotFound(body) => { + UpdateReleaseResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } - GetReleaseFilesResponse::GenericError(body) => { + UpdateReleaseResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "UpdateRelease", + ); + + let api_clone = api.clone(); + router.post( + "/v0/work/batch", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").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 + // any unused fields. + + let param_entity_list = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); + + let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; + + param_entity_list + } else { + None + }; + 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, context).wait() { + Ok(rsp) => match rsp { + CreateWorkBatchResponse::CreatedEntities(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_CREATED_ENTITIES.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkBatchResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkBatchResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateWorkBatchResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -3579,12 +5424,12 @@ where Ok(response) }) }, - "GetReleaseFiles", + "CreateWorkBatch", ); let api_clone = api.clone(); - router.get( - "/v0/release/:id/history", + router.delete( + "/v0/work/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -3614,45 +5459,45 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_release_history(param_id, param_limit, context).wait() { + match api.delete_work(param_id, param_editgroup, context).wait() { Ok(rsp) => match rsp { - GetReleaseHistoryResponse::FoundEntityHistory(body) => { + DeleteWorkResponse::DeletedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_DELETED_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseHistoryResponse::BadRequest(body) => { + DeleteWorkResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseHistoryResponse::NotFound(body) => { + DeleteWorkResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetReleaseHistoryResponse::GenericError(body) => { + DeleteWorkResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -3672,12 +5517,12 @@ where Ok(response) }) }, - "GetReleaseHistory", + "DeleteWork", ); let api_clone = api.clone(); - router.get( - "/v0/release/lookup", + router.delete( + "/v0/work/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -3690,54 +5535,58 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_doi = query_params - .get("doi") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter doi".to_string())))? - .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter doi was empty".to_string())))? - .parse::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter doi - doesn't match schema: {}", e))))?; - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? + }; - match api.lookup_release(param_doi, param_hide, context).wait() { + match api.delete_work_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - LookupReleaseResponse::FoundEntity(body) => { + DeleteWorkEditResponse::DeletedEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_DELETED_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupReleaseResponse::BadRequest(body) => { + DeleteWorkEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupReleaseResponse::NotFound(body) => { + DeleteWorkEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - LookupReleaseResponse::GenericError(body) => { + DeleteWorkEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -3757,12 +5606,12 @@ where Ok(response) }) }, - "LookupRelease", + "DeleteWorkEdit", ); let api_clone = api.clone(); - router.put( - "/v0/release/:id", + router.get( + "/v0/work/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -3792,80 +5641,49 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.update_release(param_id, param_entity, param_editgroup, context).wait() { + match api.get_work(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - UpdateReleaseResponse::UpdatedEntity(body) => { + GetWorkResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_UPDATED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_FOUND_ENTITY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateReleaseResponse::BadRequest(body) => { + GetWorkResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateReleaseResponse::NotFound(body) => { + GetWorkResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - UpdateReleaseResponse::GenericError(body) => { + GetWorkResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -3882,12 +5700,12 @@ where Ok(response) }) }, - "UpdateRelease", + "GetWork", ); let api_clone = api.clone(); - router.post( - "/v0/work/batch", + router.get( + "/v0/work/edit/:edit_id", move |req: &mut Request| { let mut context = Context::default(); @@ -3900,83 +5718,61 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_editgroup = query_params.get("editgroup").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 - // any unused fields. - - let param_entity_list = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity_list = if let Some(param_entity_list_raw) = param_entity_list { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_list_raw); - - let param_entity_list: Option> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; - - param_entity_list - } else { - None + // Path parameters + let param_edit_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("edit_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? }; - 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, context).wait() { + match api.get_work_edit(param_edit_id, context).wait() { Ok(rsp) => match rsp { - CreateWorkBatchResponse::CreatedEntities(body) => { + GetWorkEditResponse::FoundEdit(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(201), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_CREATED_ENTITIES.clone())); + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_FOUND_EDIT.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateWorkBatchResponse::BadRequest(body) => { + GetWorkEditResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateWorkBatchResponse::NotFound(body) => { + GetWorkEditResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } - CreateWorkBatchResponse::GenericError(body) => { + GetWorkEditResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } + Ok(response) } }, @@ -3993,12 +5789,12 @@ where Ok(response) }) }, - "CreateWorkBatch", + "GetWorkEdit", ); let api_clone = api.clone(); - router.delete( - "/v0/work/:id", + router.get( + "/v0/work/:id/history", move |req: &mut Request| { let mut context = Context::default(); @@ -4028,45 +5824,45 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.delete_work(param_id, param_editgroup, context).wait() { + match api.get_work_history(param_id, param_limit, context).wait() { Ok(rsp) => match rsp { - DeleteWorkResponse::DeletedEntity(body) => { + GetWorkHistoryResponse::FoundEntityHistory(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_DELETED_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_FOUND_ENTITY_HISTORY.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteWorkResponse::BadRequest(body) => { + GetWorkHistoryResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteWorkResponse::NotFound(body) => { + GetWorkHistoryResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - DeleteWorkResponse::GenericError(body) => { + GetWorkHistoryResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -4086,12 +5882,12 @@ where Ok(response) }) }, - "DeleteWork", + "GetWorkHistory", ); let api_clone = api.clone(); router.get( - "/v0/work/:id", + "/v0/work/:id/redirects", move |req: &mut Request| { let mut context = Context::default(); @@ -4119,48 +5915,43 @@ 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::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_work(param_id, param_expand, param_hide, context).wait() { + match api.get_work_redirects(param_id, context).wait() { Ok(rsp) => match rsp { - GetWorkResponse::FoundEntity(body) => { + GetWorkRedirectsResponse::FoundEntityRedirects(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_FOUND_ENTITY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkResponse::BadRequest(body) => { + GetWorkRedirectsResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkResponse::NotFound(body) => { + GetWorkRedirectsResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkResponse::GenericError(body) => { + GetWorkRedirectsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -4180,12 +5971,12 @@ where Ok(response) }) }, - "GetWork", + "GetWorkRedirects", ); let api_clone = api.clone(); router.get( - "/v0/work/:id/history", + "/v0/work/:id/releases", move |req: &mut Request| { let mut context = Context::default(); @@ -4215,45 +6006,45 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_work_history(param_id, param_limit, context).wait() { + match api.get_work_releases(param_id, param_hide, context).wait() { Ok(rsp) => match rsp { - GetWorkHistoryResponse::FoundEntityHistory(body) => { + GetWorkReleasesResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_FOUND_ENTITY_HISTORY.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkHistoryResponse::BadRequest(body) => { + GetWorkReleasesResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkHistoryResponse::NotFound(body) => { + GetWorkReleasesResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkHistoryResponse::GenericError(body) => { + GetWorkReleasesResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_HISTORY_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -4273,12 +6064,12 @@ where Ok(response) }) }, - "GetWorkHistory", + "GetWorkReleases", ); let api_clone = api.clone(); router.get( - "/v0/work/:id/releases", + "/v0/work/rev/:id", move |req: &mut Request| { let mut context = Context::default(); @@ -4308,45 +6099,46 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.get_work_releases(param_id, param_hide, context).wait() { + match api.get_work_revision(param_id, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { - GetWorkReleasesResponse::Found(body) => { + GetWorkRevisionResponse::FoundEntityRevision(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_FOUND_ENTITY_REVISION.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkReleasesResponse::BadRequest(body) => { + GetWorkRevisionResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkReleasesResponse::NotFound(body) => { + GetWorkRevisionResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetWorkReleasesResponse::GenericError(body) => { + GetWorkRevisionResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -4366,7 +6158,7 @@ where Ok(response) }) }, - "GetWorkReleases", + "GetWorkRevision", ); let api_clone = api.clone(); -- cgit v1.2.3