diff options
Diffstat (limited to 'rust/fatcat-api')
-rw-r--r-- | rust/fatcat-api/.cargo/config | 18 | ||||
-rw-r--r-- | rust/fatcat-api/.gitignore | 2 | ||||
-rw-r--r-- | rust/fatcat-api/Cargo.toml | 43 | ||||
-rw-r--r-- | rust/fatcat-api/README.md | 149 | ||||
-rw-r--r-- | rust/fatcat-api/api.yaml | 1280 | ||||
-rw-r--r-- | rust/fatcat-api/api/swagger.yaml | 3949 | ||||
-rw-r--r-- | rust/fatcat-api/examples/ca.pem | 17 | ||||
-rw-r--r-- | rust/fatcat-api/examples/client.rs | 325 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server-chain.pem | 66 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server-key.pem | 28 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server.rs | 64 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server_lib/mod.rs | 14 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server_lib/server.rs | 420 | ||||
-rw-r--r-- | rust/fatcat-api/rustfmt.toml | 5 | ||||
-rw-r--r-- | rust/fatcat-api/src/client.rs | 3158 | ||||
-rw-r--r-- | rust/fatcat-api/src/lib.rs | 1022 | ||||
-rw-r--r-- | rust/fatcat-api/src/mimetypes.rs | 777 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 786 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 4415 |
19 files changed, 0 insertions, 16538 deletions
diff --git a/rust/fatcat-api/.cargo/config b/rust/fatcat-api/.cargo/config deleted file mode 100644 index b8acc9c0..00000000 --- a/rust/fatcat-api/.cargo/config +++ /dev/null @@ -1,18 +0,0 @@ -[build] -rustflags = [ - "-W", "missing_docs", # detects missing documentation for public members - - "-W", "trivial_casts", # detects trivial casts which could be removed - - "-W", "trivial_numeric_casts", # detects trivial casts of numeric types which could be removed - - "-W", "unsafe_code", # usage of `unsafe` code - - "-W", "unused_qualifications", # detects unnecessarily qualified names - - "-W", "unused_extern_crates", # extern crates that are never used - - "-W", "unused_import_braces", # unnecessary braces around an imported item - - "-D", "warnings", # all warnings should be denied -] diff --git a/rust/fatcat-api/.gitignore b/rust/fatcat-api/.gitignore deleted file mode 100644 index a9d37c56..00000000 --- a/rust/fatcat-api/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/rust/fatcat-api/Cargo.toml b/rust/fatcat-api/Cargo.toml deleted file mode 100644 index 4380da96..00000000 --- a/rust/fatcat-api/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "fatcat-api" -version = "0.1.0" -authors = [] -description = "A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata" -license = "Unlicense" - -[features] -default = ["client", "server"] -client = ["serde_json", "serde_ignored", "hyper", "hyper-openssl", "uuid"] -server = ["serde_json", "serde_ignored", "hyper", "iron", "router", "bodyparser", "urlencoded", "uuid"] - -[dependencies] -# Required by example server. -# -chrono = { version = "0.4", features = ["serde"] } -futures = "0.1" -hyper = {version = "0.10", optional = true} -hyper-openssl = {version = "0.2", optional = true } -iron = {version = "0.6", optional = true} -swagger = "0.7" - -# Not required by example server. -# -bodyparser = {version = "0.8", optional = true} -url = "1.5" -lazy_static = "0.2" -log = "0.3.0" -multipart = {version = "0.13", optional = true} -router = {version = "0.6", optional = true} -serde = "1.0" -serde_derive = "1.0" -serde_ignored = {version = "0.0.4", optional = true} -serde_json = {version = "1.0", optional = true} -urlencoded = {version = "0.6", optional = true} -uuid = {version = "0.5", optional = true, features = ["serde", "v4"]} -# ToDo: this should be updated to point at the official crate once -# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream - - -[dev-dependencies] -clap = "2.25" -error-chain = "0.11" diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md deleted file mode 100644 index 1b566766..00000000 --- a/rust/fatcat-api/README.md +++ /dev/null @@ -1,149 +0,0 @@ -# Rust API for fatcat - -A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata - -## Overview -This client/server was generated by the [swagger-codegen] -(https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. -- - -To see how to make this your own, look here: - -[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - -- API version: 0.1.0 -- Build date: 2018-09-11T02:27:08.863Z - -This autogenerated project defines an API crate `fatcat` which contains: -* An `Api` trait defining the API in Rust. -* Data types representing the underlying data model. -* A `Client` type which implements `Api` and issues HTTP requests for each operation. -* A router which accepts HTTP requests and invokes the appropriate `Api` method for each operation. - -It also contains an example server and client which make use of `fatcat`: -* The example server starts up a web server using the `fatcat` router, - and supplies a trivial implementation of `Api` which returns failure for every operation. -* The example client provides a CLI which lets you invoke any single operation on the - `fatcat` client by passing appropriate arguments on the command line. - -You can use the example server and client as a basis for your own code. -See below for [more detail on implementing a server](#writing-a-server). - - -## Examples - -Run examples with: - -``` -cargo run --example <example-name> -``` - -To pass in arguments to the examples, put them after `--`, for example: - -``` -cargo run --example client -- --help -``` - -### Running the server -To run the server, follow these simple steps: - -``` -cargo run --example server -``` - -### Running a client -To run a client, follow one of the following simple steps: - -``` -cargo run --example client AcceptEditgroup -cargo run --example client CreateContainer -cargo run --example client CreateContainerBatch -cargo run --example client CreateCreator -cargo run --example client CreateCreatorBatch -cargo run --example client CreateEditgroup -cargo run --example client CreateFile -cargo run --example client CreateFileBatch -cargo run --example client CreateRelease -cargo run --example client CreateReleaseBatch -cargo run --example client CreateWork -cargo run --example client CreateWorkBatch -cargo run --example client DeleteContainer -cargo run --example client DeleteCreator -cargo run --example client DeleteFile -cargo run --example client DeleteRelease -cargo run --example client DeleteWork -cargo run --example client GetChangelog -cargo run --example client GetChangelogEntry -cargo run --example client GetContainer -cargo run --example client GetContainerHistory -cargo run --example client GetCreator -cargo run --example client GetCreatorHistory -cargo run --example client GetCreatorReleases -cargo run --example client GetEditgroup -cargo run --example client GetEditor -cargo run --example client GetEditorChangelog -cargo run --example client GetFile -cargo run --example client GetFileHistory -cargo run --example client GetRelease -cargo run --example client GetReleaseFiles -cargo run --example client GetReleaseHistory -cargo run --example client GetStats -cargo run --example client GetWork -cargo run --example client GetWorkHistory -cargo run --example client GetWorkReleases -cargo run --example client LookupContainer -cargo run --example client LookupCreator -cargo run --example client LookupFile -cargo run --example client LookupRelease -cargo run --example client UpdateContainer -cargo run --example client UpdateCreator -cargo run --example client UpdateFile -cargo run --example client UpdateRelease -cargo run --example client UpdateWork -``` - -### HTTPS -The examples can be run in HTTPS mode by passing in the flag `--https`, for example: - -``` -cargo run --example server -- --https -``` - -This will use the keys/certificates from the examples directory. Note that the server chain is signed with -`CN=localhost`. - - -## Writing a server - -The server example is designed to form the basis for implementing your own server. Simply follow these steps. - -* Set up a new Rust project, e.g., with `cargo init --bin`. -* Insert `fatcat` into the `members` array under [workspace] in the root `Cargo.toml`, e.g., `members = [ "fatcat" ]`. -* Add `fatcat = {version = "0.1.0", path = "fatcat"}` under `[dependencies]` in the root `Cargo.toml`. -* Copy the `[dependencies]` and `[dev-dependencies]` from `fatcat/Cargo.toml` into the root `Cargo.toml`'s `[dependencies]` section. - * Copy all of the `[dev-dependencies]`, but only the `[dependencies]` that are required by the example server. These should be clearly indicated by comments. - * Remove `"optional = true"` from each of these lines if present. - -Each autogenerated API will contain an implementation stub and main entry point, which should be copied into your project the first time: -``` -cp fatcat/examples/server.rs src/main.rs -cp fatcat/examples/server_lib/mod.rs src/lib.rs -cp fatcat/examples/server_lib/server.rs src/server.rs -``` - -Now - -* From `src/main.rs`, remove the `mod server_lib;` line, and uncomment and fill in the `extern crate` line with the name of this server crate. -* Move the block of imports "required by the service library" from `src/main.rs` to `src/lib.rs` and uncomment. -* Change the `let server = server::Server {};` line to `let server = SERVICE_NAME::server().unwrap();` where `SERVICE_NAME` is the name of the server crate. -* Run `cargo build` to check it builds. -* Run `cargo fmt` to reformat the code. -* Commit the result before making any further changes (lest format changes get confused with your own updates). - -Now replace the implementations in `src/server.rs` with your own code as required. - -## Updating your server to track API changes - -Later, if the API changes, you can copy new sections from the autogenerated API stub into your implementation. -Alternatively, implement the now-missing methods based on the compiler's error messages. diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml deleted file mode 100644 index 2b0615d2..00000000 --- a/rust/fatcat-api/api.yaml +++ /dev/null @@ -1,1280 +0,0 @@ ---- -swagger: "2.0" -info: - title: fatcat - description: A scalable, versioned, API-oriented catalog of bibliographic entities - and file metadata - version: 0.1.0 -schemes: [http] -basePath: /v0 -#host: api.fatcat.wiki -consumes: - - application/json -produces: - - application/json - -# don't want these to be rust types (at least for now) -x-fatcat-ident: &FATCATIDENT - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - pattern: "[a-zA-Z2-7]{26}" - minLength: 26 - maxLength: 26 - description: "base32-encoded unique identifier" -x-fatcat-uuid: &FATCATUUID - type: string - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - minLength: 36 - maxLength: 36 - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" -x-issn: &FATCATISSN - type: string - example: "1234-5678" - pattern: "\\d{4}-\\d{3}[0-9X]" - minLength: 9 - maxLength: 9 -x-orcid: &FATCATORCID - type: string - example: "0000-0002-1825-0097" - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" - minLength: 19 - maxLength: 19 - -# Common properties across entities -x-entity-props: &ENTITYPROPS - state: - type: string - enum: ["wip", "active", "redirect", "deleted"] - ident: - <<: *FATCATIDENT - revision: - <<: *FATCATUUID - redirect: - <<: *FATCATIDENT - editgroup_id: - <<: *FATCATIDENT - extra: - type: object - additionalProperties: {} -# TODO: -# edit_extra: -# type: object -# additionalProperties: {} - -definitions: - error_response: - type: object - required: - - message - properties: - message: - type: string - example: "A really confusing, totally unexpected thing happened" - success: - type: object - required: - - message - properties: - message: - type: string - example: "The computers did the thing successfully!" - container_entity: - type: object - required: - - name - properties: - <<: *ENTITYPROPS - name: - type: string - example: "Journal of Important Results" - publisher: - type: string - example: "Society of Curious Students" - issnl: - <<: *FATCATISSN - wikidata_qid: - type: string - abbrev: - type: string - coden: - type: string - creator_entity: - type: object - required: - - display_name - properties: - <<: *ENTITYPROPS - display_name: - type: string - example: "Grace Hopper" - given_name: - type: string - surname: - type: string - orcid: - <<: *FATCATORCID - wikidata_qid: - type: string - file_entity: - type: object - properties: - <<: *ENTITYPROPS - size: - type: integer - example: 1048576 - format: int64 - sha1: - type: string - #format: custom - example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" - md5: - type: string - #format: custom - example: "d41efcc592d1e40ac13905377399eb9b" - sha256: - type: string - #format: custom - example: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - urls: - type: array - items: - type: object - required: - - url - - rel - properties: - url: - type: string - format: url - example: "https://example.edu/~frau/prcding.pdf" - rel: - type: string - example: "webarchive" - mimetype: - type: string - example: "application/pdf" - releases: - type: array - items: - type: string - #format: uuid - release_entity: - type: object - required: - - title - properties: - <<: *ENTITYPROPS - title: - type: string - work_id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - container: - $ref: "#/definitions/container_entity" - description: "Optional; GET-only" - files: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/file_entity" - container_id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - release_type: - type: string - example: "book" - release_status: - type: string - example: "preprint" - release_date: - type: string - format: date - doi: - type: string - #format: custom - example: "10.1234/abcde.789" - isbn13: - type: string - #format: custom - core_id: - type: string - #format: custom - pmid: - type: string - pmcid: - type: string - wikidata_qid: - type: string - volume: - type: string - issue: - type: string - example: "12" - pages: - type: string - publisher: - type: string - language: - description: "Two-letter RFC1766/ISO639-1 language code, with extensions" - type: string - contribs: - type: array - items: - $ref: "#/definitions/release_contrib" - refs: - type: array - items: - $ref: "#/definitions/release_ref" - abstracts: - type: array - items: - type: object - properties: - sha1: - type: string - example: "3f242a192acc258bdfdb151943419437f440c313" - content: - type: string - example: "<jats:p>Some abstract thing goes here</jats:p>" - mimetype: - type: string - example: "application/xml+jats" - lang: - type: string - example: "en" - work_entity: - type: object - properties: - <<: *ENTITYPROPS - entity_history_entry: - type: object - required: - - edit - - editgroup - - changelog_entry - properties: - edit: - $ref: "#/definitions/entity_edit" - editgroup: - $ref: "#/definitions/editgroup" - changelog_entry: - $ref: "#/definitions/changelog_entry" - entity_edit: - type: object - required: - - edit_id - - ident - - editgroup_id - properties: - edit_id: - type: integer - example: 847 - format: int64 - ident: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - revision: - type: string - #format: uuid - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - prev_revision: - type: string - #format: uuid - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - redirect_ident: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - #format: ident - editgroup_id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: - type: object - additionalProperties: {} - editor: - type: object - required: - - username - properties: - id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - username: - type: string - example: "zerocool93" - editgroup: - type: object - required: - - editor_id - properties: - id: - <<: *FATCATIDENT - editor_id: - <<: *FATCATIDENT - description: - type: string - extra: - type: object - additionalProperties: {} - edits: - type: object - properties: - containers: - type: array - items: - $ref: "#/definitions/entity_edit" - creators: - type: array - items: - $ref: "#/definitions/entity_edit" - files: - type: array - items: - $ref: "#/definitions/entity_edit" - releases: - type: array - items: - $ref: "#/definitions/entity_edit" - works: - type: array - items: - $ref: "#/definitions/entity_edit" - changelog_entry: - type: object - required: - - index - - editgroup_id - - timestamp - properties: - index: - type: integer - format: int64 - editgroup_id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - timestamp: - type: string - format: date-time - editgroup: - $ref: "#/definitions/editgroup" - release_ref: - type: object - properties: - index: - type: integer - format: int64 - target_release_id: - type: string - #format: ident - extra: - type: object - additionalProperties: {} - key: - type: string - year: - type: integer - format: int64 - container_title: - type: string - title: - type: string - locator: - type: string - example: "p123" - release_contrib: - type: object - properties: - index: - type: integer - format: int64 - creator_id: - type: string - #format: ident - creator: - $ref: "#/definitions/creator_entity" - description: "Optional; GET-only" - raw_name: - type: string - extra: - type: object - additionalProperties: {} - role: - type: string - stats_response: - type: object - properties: - extra: - type: object - additionalProperties: {} - -x-entity-responses: &ENTITYRESPONSES - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - -paths: - /container: - post: - operationId: "create_container" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/container_entity" - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /container/batch: - post: - operationId: "create_container_batch" - parameters: - - name: autoaccept - in: query - type: boolean - required: false - description: "If true, and editor is authorized, batch is accepted all at once" - - name: editgroup - in: query - type: string - required: false - description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" - - name: entity_list - in: body - required: true - schema: - type: array - items: - $ref: "#/definitions/container_entity" - responses: - 201: - description: Created Entities - schema: - type: array - items: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /container/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_container" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For now, only 'all' accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/container_entity" - <<: *ENTITYRESPONSES - put: - operationId: "update_container" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/container_entity" - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - delete: - operationId: "delete_container" - parameters: - - name: editgroup - in: query - required: false - type: string - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /container/{id}/history: - parameters: - - name: id - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_container_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /container/lookup: - get: - operationId: "lookup_container" - parameters: - - name: issnl - in: query - required: true - <<: *FATCATISSN - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/container_entity" - <<: *ENTITYRESPONSES - /creator: - post: - operationId: "create_creator" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/creator_entity" - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /creator/batch: - post: - operationId: "create_creator_batch" - parameters: - - name: autoaccept - in: query - type: boolean - required: false - description: "If true, and editor is authorized, batch is accepted all at once" - - name: editgroup - in: query - type: string - required: false - description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" - - name: entity_list - in: body - required: true - schema: - type: array - items: - $ref: "#/definitions/creator_entity" - responses: - 201: - description: Created Entities - schema: - type: array - items: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /creator/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_creator" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For now, only 'all' accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/creator_entity" - <<: *ENTITYRESPONSES - put: - operationId: "update_creator" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/creator_entity" - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - delete: - operationId: "delete_creator" - parameters: - - name: editgroup - in: query - required: false - type: string - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /creator/{id}/history: - parameters: - - name: id - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_creator_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /creator/{id}/releases: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_creator_releases" - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /creator/lookup: - get: - operationId: "lookup_creator" - parameters: - - name: orcid - in: query - required: true - <<: *FATCATORCID - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/creator_entity" - <<: *ENTITYRESPONSES - /file: - post: - operationId: "create_file" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/file_entity" - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /file/batch: - post: - operationId: "create_file_batch" - parameters: - - name: autoaccept - in: query - type: boolean - required: false - description: "If true, and editor is authorized, batch is accepted all at once" - - name: editgroup - in: query - type: string - required: false - description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" - - name: entity_list - in: body - required: true - schema: - type: array - items: - $ref: "#/definitions/file_entity" - responses: - 201: - description: Created Entities - schema: - type: array - items: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /file/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_file" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For now, only 'all' accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - put: - operationId: "update_file" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/file_entity" - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - delete: - operationId: "delete_file" - parameters: - - name: editgroup - in: query - required: false - type: string - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /file/{id}/history: - parameters: - - name: id - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_file_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /file/lookup: - get: - operationId: "lookup_file" - parameters: - - name: sha1 - in: query - type: string - required: true - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /release: - post: - operationId: "create_release" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/release_entity" - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /release/batch: - post: - operationId: "create_release_batch" - parameters: - - name: autoaccept - in: query - type: boolean - required: false - description: "If true, and editor is authorized, batch is accepted all at once" - - name: editgroup - in: query - type: string - required: false - description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" - - name: entity_list - in: body - required: true - schema: - type: array - items: - $ref: "#/definitions/release_entity" - responses: - 201: - description: Created Entities - schema: - type: array - items: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /release/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_release" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For now, only 'all' accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - put: - operationId: "update_release" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/release_entity" - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - delete: - operationId: "delete_release" - parameters: - - name: editgroup - in: query - required: false - type: string - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /release/{id}/history: - parameters: - - name: id - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_release_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /release/{id}/files: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_release_files" - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /release/lookup: - get: - operationId: "lookup_release" - parameters: - - name: doi - in: query - type: string - required: true - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /work: - post: - operationId: "create_work" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/work_entity" - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /work/batch: - post: - operationId: "create_work_batch" - parameters: - - name: autoaccept - in: query - type: boolean - required: false - description: "If true, and editor is authorized, batch is accepted all at once" - - name: editgroup - in: query - type: string - required: false - description: "Editgroup to auto-accept and apply to all entities (required if 'autoaccept' is True)" - - name: entity_list - in: body - required: true - schema: - type: array - items: - $ref: "#/definitions/work_entity" - responses: - 201: - description: Created Entities - schema: - type: array - items: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /work/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_work" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For now, only 'all' accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/work_entity" - <<: *ENTITYRESPONSES - put: - operationId: "update_work" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/work_entity" - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - delete: - operationId: "delete_work" - parameters: - - name: editgroup - in: query - required: false - type: string - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /work/{id}/history: - parameters: - - name: id - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_work_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /work/{id}/releases: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_work_releases" - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /editor/{id}: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_editor" - responses: - 200: - description: Found - schema: - $ref: "#/definitions/editor" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /editor/{id}/changelog: - parameters: - - name: id - in: path - type: string - required: true - get: - operationId: "get_editor_changelog" - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/changelog_entry" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /editgroup: - post: - operationId: "create_editgroup" - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/editgroup" - responses: - 201: - description: Successfully Created - schema: - $ref: "#/definitions/editgroup" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /editgroup/{id}: - parameters: - - name: id - in: path - required: true - <<: *FATCATIDENT - get: - operationId: "get_editgroup" - responses: - 200: - description: Found - schema: - $ref: "#/definitions/editgroup" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /editgroup/{id}/accept: - parameters: - - name: id - in: path - required: true - <<: *FATCATIDENT - post: - operationId: "accept_editgroup" - responses: - 200: - description: Merged Successfully - schema: - $ref: "#/definitions/success" - 400: - description: Unmergable - schema: - $ref: "#/definitions/error_response" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 409: - description: Edit Conflict - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /changelog: - parameters: - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_changelog" - responses: - 200: - description: Success - schema: - type: array - items: - $ref: "#/definitions/changelog_entry" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /changelog/{id}: - parameters: - - name: id - in: path - type: integer - format: int64 - required: true - get: - operationId: "get_changelog_entry" - responses: - 200: - description: Found Changelog Entry - schema: - $ref: "#/definitions/changelog_entry" - 404: - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /stats: - get: - operationId: "get_stats" - parameters: - - name: more - in: query - type: string - required: false - responses: - 200: - description: Success - schema: - $ref: "#/definitions/stats_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml deleted file mode 100644 index 9bc84351..00000000 --- a/rust/fatcat-api/api/swagger.yaml +++ /dev/null @@ -1,3949 +0,0 @@ ---- -swagger: "2.0" -info: - description: "A scalable, versioned, API-oriented catalog of bibliographic entities\ - \ and file metadata" - version: "0.1.0" - title: "fatcat" -basePath: "/v0" -schemes: -- "http" -consumes: -- "application/json" -produces: -- "application/json" -paths: - /container: - post: - operationId: "create_container" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/container_entity" - uppercase_data_type: "CONTAINERENTITY" - refName: "container_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CONTAINER" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_CONTAINER" - 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: "CREATE_CONTAINER" - 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: "CREATE_CONTAINER" - 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: "CREATE_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_container" - uppercase_operation_id: "CREATE_CONTAINER" - path: "/container" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /container/batch: - post: - operationId: "create_container_batch" - parameters: - - name: "autoaccept" - in: "query" - description: "If true, and editor is authorized, batch is accepted all at\ - \ once" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - - name: "editgroup" - in: "query" - description: "Editgroup to auto-accept and apply to all entities (required\ - \ if 'autoaccept' is True)" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - - in: "body" - name: "entity_list" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/container_entity" - formatString: "{:?}" - example: "&Vec::new()" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CONTAINER_BATCH" - consumesJson: true - responses: - 201: - description: "Created Entities" - schema: - type: "array" - items: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntities" - x-uppercaseResponseId: "CREATED_ENTITIES" - uppercase_operation_id: "CREATE_CONTAINER_BATCH" - uppercase_data_type: "VEC<ENTITYEDIT>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_CONTAINER_BATCH" - 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: "CREATE_CONTAINER_BATCH" - 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: "CREATE_CONTAINER_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_container_batch" - uppercase_operation_id: "CREATE_CONTAINER_BATCH" - path: "/container/batch" - HttpMethod: "Post" - httpmethod: "post" - /container/{id}: - get: - operationId: "get_container" - 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 now, only 'all'\ - \ accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/container_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_CONTAINER" - 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" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_container" - uppercase_operation_id: "GET_CONTAINER" - path: "/container/:id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_container" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/container_entity" - uppercase_data_type: "CONTAINERENTITY" - refName: "container_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_CONTAINER" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_CONTAINER" - 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: "UPDATE_CONTAINER" - 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: "UPDATE_CONTAINER" - 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: "UPDATE_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "update_container" - uppercase_operation_id: "UPDATE_CONTAINER" - path: "/container/:id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - operationId: "delete_container" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "editgroup" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_CONTAINER" - 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: "DELETE_CONTAINER" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "delete_container" - uppercase_operation_id: "DELETE_CONTAINER" - path: "/container/:id" - HttpMethod: "Delete" - httpmethod: "delete" - /container/{id}/history: - get: - operationId: "get_container_history" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Found Entity History" - schema: - type: "array" - items: - $ref: "#/definitions/entity_history_entry" - x-responseId: "FoundEntityHistory" - x-uppercaseResponseId: "FOUND_ENTITY_HISTORY" - uppercase_operation_id: "GET_CONTAINER_HISTORY" - uppercase_data_type: "VEC<ENTITYHISTORYENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CONTAINER_HISTORY" - 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_HISTORY" - 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_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_container_history" - uppercase_operation_id: "GET_CONTAINER_HISTORY" - path: "/container/:id/history" - HttpMethod: "Get" - httpmethod: "get" - /container/lookup: - get: - operationId: "lookup_container" - parameters: - - name: "issnl" - in: "query" - required: true - type: "string" - maxLength: 9 - minLength: 9 - pattern: "\\d{4}-\\d{3}[0-9X]" - formatString: "\\\"{}\\\"" - example: "\"issnl_example\".to_string()" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/container_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "LOOKUP_CONTAINER" - 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: "LOOKUP_CONTAINER" - 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_CONTAINER" - 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_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "lookup_container" - uppercase_operation_id: "LOOKUP_CONTAINER" - path: "/container/lookup" - HttpMethod: "Get" - httpmethod: "get" - /creator: - post: - operationId: "create_creator" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/creator_entity" - uppercase_data_type: "CREATORENTITY" - refName: "creator_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CREATOR" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_CREATOR" - 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: "CREATE_CREATOR" - 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: "CREATE_CREATOR" - 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: "CREATE_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_creator" - uppercase_operation_id: "CREATE_CREATOR" - path: "/creator" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /creator/batch: - post: - operationId: "create_creator_batch" - parameters: - - name: "autoaccept" - in: "query" - description: "If true, and editor is authorized, batch is accepted all at\ - \ once" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - - name: "editgroup" - in: "query" - description: "Editgroup to auto-accept and apply to all entities (required\ - \ if 'autoaccept' is True)" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - - in: "body" - name: "entity_list" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/creator_entity" - formatString: "{:?}" - example: "&Vec::new()" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CREATOR_BATCH" - consumesJson: true - responses: - 201: - description: "Created Entities" - schema: - type: "array" - items: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntities" - x-uppercaseResponseId: "CREATED_ENTITIES" - uppercase_operation_id: "CREATE_CREATOR_BATCH" - uppercase_data_type: "VEC<ENTITYEDIT>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_CREATOR_BATCH" - 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: "CREATE_CREATOR_BATCH" - 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: "CREATE_CREATOR_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_creator_batch" - uppercase_operation_id: "CREATE_CREATOR_BATCH" - path: "/creator/batch" - HttpMethod: "Post" - httpmethod: "post" - /creator/{id}: - get: - operationId: "get_creator" - 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 now, only 'all'\ - \ accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/creator_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_CREATOR" - 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" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator" - uppercase_operation_id: "GET_CREATOR" - path: "/creator/:id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_creator" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/creator_entity" - uppercase_data_type: "CREATORENTITY" - refName: "creator_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_CREATOR" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_CREATOR" - 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: "UPDATE_CREATOR" - 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: "UPDATE_CREATOR" - 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: "UPDATE_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "update_creator" - uppercase_operation_id: "UPDATE_CREATOR" - path: "/creator/:id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - operationId: "delete_creator" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "editgroup" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_CREATOR" - 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: "DELETE_CREATOR" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "delete_creator" - uppercase_operation_id: "DELETE_CREATOR" - path: "/creator/:id" - HttpMethod: "Delete" - httpmethod: "delete" - /creator/{id}/history: - get: - operationId: "get_creator_history" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Found Entity History" - schema: - type: "array" - items: - $ref: "#/definitions/entity_history_entry" - x-responseId: "FoundEntityHistory" - x-uppercaseResponseId: "FOUND_ENTITY_HISTORY" - uppercase_operation_id: "GET_CREATOR_HISTORY" - uppercase_data_type: "VEC<ENTITYHISTORYENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CREATOR_HISTORY" - 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_HISTORY" - 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_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator_history" - uppercase_operation_id: "GET_CREATOR_HISTORY" - path: "/creator/:id/history" - HttpMethod: "Get" - httpmethod: "get" - /creator/{id}/releases: - get: - operationId: "get_creator_releases" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/release_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_CREATOR_RELEASES" - uppercase_data_type: "VEC<RELEASEENTITY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CREATOR_RELEASES" - 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_RELEASES" - 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_RELEASES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator_releases" - uppercase_operation_id: "GET_CREATOR_RELEASES" - path: "/creator/:id/releases" - HttpMethod: "Get" - httpmethod: "get" - /creator/lookup: - get: - operationId: "lookup_creator" - parameters: - - name: "orcid" - in: "query" - required: true - type: "string" - maxLength: 19 - minLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" - formatString: "\\\"{}\\\"" - example: "\"orcid_example\".to_string()" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/creator_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "LOOKUP_CREATOR" - 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: "LOOKUP_CREATOR" - 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_CREATOR" - 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_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "lookup_creator" - uppercase_operation_id: "LOOKUP_CREATOR" - path: "/creator/lookup" - HttpMethod: "Get" - httpmethod: "get" - /file: - post: - operationId: "create_file" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/file_entity" - uppercase_data_type: "FILEENTITY" - refName: "file_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_FILE" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_FILE" - 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: "CREATE_FILE" - 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: "CREATE_FILE" - 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: "CREATE_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_file" - uppercase_operation_id: "CREATE_FILE" - path: "/file" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /file/batch: - post: - operationId: "create_file_batch" - parameters: - - name: "autoaccept" - in: "query" - description: "If true, and editor is authorized, batch is accepted all at\ - \ once" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - - name: "editgroup" - in: "query" - description: "Editgroup to auto-accept and apply to all entities (required\ - \ if 'autoaccept' is True)" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - - in: "body" - name: "entity_list" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/file_entity" - formatString: "{:?}" - example: "&Vec::new()" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_FILE_BATCH" - consumesJson: true - responses: - 201: - description: "Created Entities" - schema: - type: "array" - items: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntities" - x-uppercaseResponseId: "CREATED_ENTITIES" - uppercase_operation_id: "CREATE_FILE_BATCH" - uppercase_data_type: "VEC<ENTITYEDIT>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_FILE_BATCH" - 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: "CREATE_FILE_BATCH" - 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: "CREATE_FILE_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_file_batch" - uppercase_operation_id: "CREATE_FILE_BATCH" - path: "/file/batch" - HttpMethod: "Post" - httpmethod: "post" - /file/{id}: - get: - operationId: "get_file" - 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 now, only 'all'\ - \ accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/file_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_FILE" - 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" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_file" - uppercase_operation_id: "GET_FILE" - path: "/file/:id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_file" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/file_entity" - uppercase_data_type: "FILEENTITY" - refName: "file_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_FILE" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_FILE" - 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: "UPDATE_FILE" - 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: "UPDATE_FILE" - 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: "UPDATE_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "update_file" - uppercase_operation_id: "UPDATE_FILE" - path: "/file/:id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - operationId: "delete_file" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "editgroup" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_FILE" - 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: "DELETE_FILE" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "delete_file" - uppercase_operation_id: "DELETE_FILE" - path: "/file/:id" - HttpMethod: "Delete" - httpmethod: "delete" - /file/{id}/history: - get: - operationId: "get_file_history" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Found Entity History" - schema: - type: "array" - items: - $ref: "#/definitions/entity_history_entry" - x-responseId: "FoundEntityHistory" - x-uppercaseResponseId: "FOUND_ENTITY_HISTORY" - uppercase_operation_id: "GET_FILE_HISTORY" - uppercase_data_type: "VEC<ENTITYHISTORYENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILE_HISTORY" - 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_HISTORY" - 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_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_file_history" - uppercase_operation_id: "GET_FILE_HISTORY" - path: "/file/:id/history" - HttpMethod: "Get" - httpmethod: "get" - /file/lookup: - get: - operationId: "lookup_file" - parameters: - - name: "sha1" - in: "query" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"sha1_example\".to_string()" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/file_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "LOOKUP_FILE" - 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: "LOOKUP_FILE" - 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_FILE" - 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_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "lookup_file" - uppercase_operation_id: "LOOKUP_FILE" - path: "/file/lookup" - HttpMethod: "Get" - httpmethod: "get" - /release: - post: - operationId: "create_release" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/release_entity" - uppercase_data_type: "RELEASEENTITY" - refName: "release_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_RELEASE" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_RELEASE" - 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: "CREATE_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: "CREATE_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: "CREATE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_release" - uppercase_operation_id: "CREATE_RELEASE" - path: "/release" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /release/batch: - post: - operationId: "create_release_batch" - parameters: - - name: "autoaccept" - in: "query" - description: "If true, and editor is authorized, batch is accepted all at\ - \ once" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - - name: "editgroup" - in: "query" - description: "Editgroup to auto-accept and apply to all entities (required\ - \ if 'autoaccept' is True)" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - - in: "body" - name: "entity_list" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/release_entity" - formatString: "{:?}" - example: "&Vec::new()" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_RELEASE_BATCH" - consumesJson: true - responses: - 201: - description: "Created Entities" - schema: - type: "array" - items: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntities" - x-uppercaseResponseId: "CREATED_ENTITIES" - uppercase_operation_id: "CREATE_RELEASE_BATCH" - uppercase_data_type: "VEC<ENTITYEDIT>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_RELEASE_BATCH" - 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: "CREATE_RELEASE_BATCH" - 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: "CREATE_RELEASE_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_release_batch" - uppercase_operation_id: "CREATE_RELEASE_BATCH" - path: "/release/batch" - HttpMethod: "Post" - httpmethod: "post" - /release/{id}: - get: - operationId: "get_release" - 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 now, only 'all'\ - \ accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/release_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_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: "GET_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: "GET_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: "GET_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release" - uppercase_operation_id: "GET_RELEASE" - path: "/release/:id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_release" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/release_entity" - uppercase_data_type: "RELEASEENTITY" - refName: "release_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_RELEASE" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_RELEASE" - 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: "UPDATE_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: "UPDATE_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: "UPDATE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "update_release" - uppercase_operation_id: "UPDATE_RELEASE" - path: "/release/:id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - operationId: "delete_release" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "editgroup" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_RELEASE" - 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: "DELETE_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: "DELETE_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: "DELETE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "delete_release" - uppercase_operation_id: "DELETE_RELEASE" - path: "/release/:id" - HttpMethod: "Delete" - httpmethod: "delete" - /release/{id}/history: - get: - operationId: "get_release_history" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Found Entity History" - schema: - type: "array" - items: - $ref: "#/definitions/entity_history_entry" - x-responseId: "FoundEntityHistory" - x-uppercaseResponseId: "FOUND_ENTITY_HISTORY" - uppercase_operation_id: "GET_RELEASE_HISTORY" - uppercase_data_type: "VEC<ENTITYHISTORYENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_HISTORY" - 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_HISTORY" - 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_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_history" - uppercase_operation_id: "GET_RELEASE_HISTORY" - path: "/release/:id/history" - HttpMethod: "Get" - httpmethod: "get" - /release/{id}/files: - get: - operationId: "get_release_files" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - 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<FILEENTITY>" - 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/lookup: - get: - operationId: "lookup_release" - parameters: - - name: "doi" - in: "query" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"doi_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" - /work: - post: - operationId: "create_work" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/work_entity" - uppercase_data_type: "WORKENTITY" - refName: "work_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_WORK" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_WORK" - 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: "CREATE_WORK" - 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: "CREATE_WORK" - 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: "CREATE_WORK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_work" - uppercase_operation_id: "CREATE_WORK" - path: "/work" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /work/batch: - post: - operationId: "create_work_batch" - parameters: - - name: "autoaccept" - in: "query" - description: "If true, and editor is authorized, batch is accepted all at\ - \ once" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - - name: "editgroup" - in: "query" - description: "Editgroup to auto-accept and apply to all entities (required\ - \ if 'autoaccept' is True)" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - - in: "body" - name: "entity_list" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/work_entity" - formatString: "{:?}" - example: "&Vec::new()" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_WORK_BATCH" - consumesJson: true - responses: - 201: - description: "Created Entities" - schema: - type: "array" - items: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntities" - x-uppercaseResponseId: "CREATED_ENTITIES" - uppercase_operation_id: "CREATE_WORK_BATCH" - uppercase_data_type: "VEC<ENTITYEDIT>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_WORK_BATCH" - 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: "CREATE_WORK_BATCH" - 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: "CREATE_WORK_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_work_batch" - uppercase_operation_id: "CREATE_WORK_BATCH" - path: "/work/batch" - HttpMethod: "Post" - httpmethod: "post" - /work/{id}: - get: - operationId: "get_work" - 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 now, only 'all'\ - \ accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/work_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_WORK" - 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" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work" - uppercase_operation_id: "GET_WORK" - path: "/work/:id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_work" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/work_entity" - uppercase_data_type: "WORKENTITY" - refName: "work_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_WORK" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_WORK" - 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: "UPDATE_WORK" - 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: "UPDATE_WORK" - 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: "UPDATE_WORK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "update_work" - uppercase_operation_id: "UPDATE_WORK" - path: "/work/:id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - operationId: "delete_work" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "editgroup" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"editgroup_example\".to_string())" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_WORK" - 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: "DELETE_WORK" - 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" - 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" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "delete_work" - uppercase_operation_id: "DELETE_WORK" - path: "/work/:id" - HttpMethod: "Delete" - httpmethod: "delete" - /work/{id}/history: - get: - operationId: "get_work_history" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Found Entity History" - schema: - type: "array" - items: - $ref: "#/definitions/entity_history_entry" - x-responseId: "FoundEntityHistory" - x-uppercaseResponseId: "FOUND_ENTITY_HISTORY" - uppercase_operation_id: "GET_WORK_HISTORY" - uppercase_data_type: "VEC<ENTITYHISTORYENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WORK_HISTORY" - 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_HISTORY" - 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_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work_history" - uppercase_operation_id: "GET_WORK_HISTORY" - path: "/work/:id/history" - HttpMethod: "Get" - httpmethod: "get" - /work/{id}/releases: - get: - operationId: "get_work_releases" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/release_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_WORK_RELEASES" - uppercase_data_type: "VEC<RELEASEENTITY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WORK_RELEASES" - 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_RELEASES" - 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_RELEASES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work_releases" - uppercase_operation_id: "GET_WORK_RELEASES" - path: "/work/:id/releases" - HttpMethod: "Get" - httpmethod: "get" - /editor/{id}: - get: - operationId: "get_editor" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Found" - schema: - $ref: "#/definitions/editor" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITOR" - uppercase_data_type: "EDITOR" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITOR" - 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_EDITOR" - 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_EDITOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editor" - uppercase_operation_id: "GET_EDITOR" - path: "/editor/:id" - HttpMethod: "Get" - httpmethod: "get" - /editor/{id}/changelog: - get: - operationId: "get_editor_changelog" - parameters: - - name: "id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/changelog_entry" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" - uppercase_data_type: "VEC<CHANGELOGENTRY>" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" - 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_EDITOR_CHANGELOG" - 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_EDITOR_CHANGELOG" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editor_changelog" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" - path: "/editor/:id/changelog" - HttpMethod: "Get" - httpmethod: "get" - /editgroup: - post: - operationId: "create_editgroup" - parameters: - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/editgroup" - uppercase_data_type: "EDITGROUP" - refName: "editgroup" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_EDITGROUP" - consumesJson: true - responses: - 201: - description: "Successfully Created" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "SuccessfullyCreated" - x-uppercaseResponseId: "SUCCESSFULLY_CREATED" - uppercase_operation_id: "CREATE_EDITGROUP" - uppercase_data_type: "EDITGROUP" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_EDITGROUP" - 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: "CREATE_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "create_editgroup" - uppercase_operation_id: "CREATE_EDITGROUP" - path: "/editgroup" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/{id}: - get: - operationId: "get_editgroup" - parameters: - - name: "id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Found" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITGROUP" - uppercase_data_type: "EDITGROUP" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITGROUP" - 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_EDITGROUP" - 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_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editgroup" - uppercase_operation_id: "GET_EDITGROUP" - path: "/editgroup/:id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{id}/accept: - post: - operationId: "accept_editgroup" - parameters: - - name: "id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"id_example\".to_string()" - responses: - 200: - description: "Merged Successfully" - schema: - $ref: "#/definitions/success" - x-responseId: "MergedSuccessfully" - x-uppercaseResponseId: "MERGED_SUCCESSFULLY" - uppercase_operation_id: "ACCEPT_EDITGROUP" - 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: "ACCEPT_EDITGROUP" - 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: "ACCEPT_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 409: - description: "Edit Conflict" - schema: - $ref: "#/definitions/error_response" - x-responseId: "EditConflict" - x-uppercaseResponseId: "EDIT_CONFLICT" - uppercase_operation_id: "ACCEPT_EDITGROUP" - 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: "ACCEPT_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "accept_editgroup" - uppercase_operation_id: "ACCEPT_EDITGROUP" - path: "/editgroup/:id/accept" - HttpMethod: "Post" - httpmethod: "post" - /changelog: - get: - operationId: "get_changelog" - parameters: - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - responses: - 200: - description: "Success" - schema: - type: "array" - items: - $ref: "#/definitions/changelog_entry" - x-responseId: "Success" - x-uppercaseResponseId: "SUCCESS" - uppercase_operation_id: "GET_CHANGELOG" - uppercase_data_type: "VEC<CHANGELOGENTRY>" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CHANGELOG" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_changelog" - uppercase_operation_id: "GET_CHANGELOG" - path: "/changelog" - HttpMethod: "Get" - httpmethod: "get" - /changelog/{id}: - get: - operationId: "get_changelog_entry" - parameters: - - name: "id" - in: "path" - required: true - type: "integer" - format: "int64" - formatString: "{}" - example: "789" - responses: - 200: - description: "Found Changelog Entry" - schema: - $ref: "#/definitions/changelog_entry" - x-responseId: "FoundChangelogEntry" - x-uppercaseResponseId: "FOUND_CHANGELOG_ENTRY" - uppercase_operation_id: "GET_CHANGELOG_ENTRY" - uppercase_data_type: "CHANGELOGENTRY" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CHANGELOG_ENTRY" - 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_CHANGELOG_ENTRY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_changelog_entry" - uppercase_operation_id: "GET_CHANGELOG_ENTRY" - path: "/changelog/:id" - HttpMethod: "Get" - httpmethod: "get" - /stats: - get: - operationId: "get_stats" - parameters: - - name: "more" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"more_example\".to_string())" - responses: - 200: - description: "Success" - schema: - $ref: "#/definitions/stats_response" - x-responseId: "Success" - x-uppercaseResponseId: "SUCCESS" - uppercase_operation_id: "GET_STATS" - uppercase_data_type: "STATSRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_STATS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_stats" - uppercase_operation_id: "GET_STATS" - path: "/stats" - HttpMethod: "Get" - httpmethod: "get" -definitions: - error_response: - type: "object" - required: - - "message" - properties: - message: - type: "string" - example: "A really confusing, totally unexpected thing happened" - upperCaseName: "ERROR_RESPONSE" - success: - type: "object" - required: - - "message" - properties: - message: - type: "string" - example: "The computers did the thing successfully!" - example: - message: "The computers did the thing successfully!" - upperCaseName: "SUCCESS" - container_entity: - type: "object" - required: - - "name" - properties: - coden: - type: "string" - abbrev: - type: "string" - wikidata_qid: - type: "string" - issnl: - type: "string" - example: "1234-5678" - minLength: 9 - maxLength: 9 - pattern: "\\d{4}-\\d{3}[0-9X]" - publisher: - type: "string" - example: "Society of Curious Students" - name: - type: "string" - example: "Journal of Important Results" - extra: - type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - minLength: 36 - maxLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - coden: "coden" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - name: "Journal of Important Results" - publisher: "Society of Curious Students" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - issnl: "1234-5678" - abbrev: "abbrev" - wikidata_qid: "wikidata_qid" - state: "wip" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "CONTAINER_ENTITY" - creator_entity: - type: "object" - required: - - "display_name" - properties: - wikidata_qid: - type: "string" - orcid: - type: "string" - example: "0000-0002-1825-0097" - minLength: 19 - maxLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" - surname: - type: "string" - given_name: - type: "string" - display_name: - type: "string" - example: "Grace Hopper" - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - minLength: 36 - maxLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - extra: - type: "object" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "CREATOR_ENTITY" - file_entity: - type: "object" - properties: - releases: - type: "array" - items: - type: "string" - mimetype: - type: "string" - example: "application/pdf" - urls: - type: "array" - items: - $ref: "#/definitions/file_entity_urls" - sha256: - type: "string" - example: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - md5: - type: "string" - example: "d41efcc592d1e40ac13905377399eb9b" - sha1: - type: "string" - example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" - size: - type: "integer" - format: "int64" - example: 1048576 - extra: - type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - minLength: 36 - maxLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - sha256: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - "releases" - - "releases" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - mimetype: "application/pdf" - state: "wip" - md5: "d41efcc592d1e40ac13905377399eb9b" - upperCaseName: "FILE_ENTITY" - release_entity: - type: "object" - required: - - "title" - properties: - abstracts: - type: "array" - items: - $ref: "#/definitions/release_entity_abstracts" - refs: - type: "array" - items: - $ref: "#/definitions/release_ref" - contribs: - type: "array" - items: - $ref: "#/definitions/release_contrib" - language: - type: "string" - description: "Two-letter RFC1766/ISO639-1 language code, with extensions" - publisher: - type: "string" - pages: - type: "string" - issue: - type: "string" - example: "12" - volume: - type: "string" - wikidata_qid: - type: "string" - pmcid: - type: "string" - pmid: - type: "string" - core_id: - type: "string" - isbn13: - type: "string" - doi: - type: "string" - example: "10.1234/abcde.789" - release_date: - type: "string" - format: "date" - release_status: - type: "string" - example: "preprint" - release_type: - type: "string" - example: "book" - container_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - files: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/file_entity" - container: - description: "Optional; GET-only" - $ref: "#/definitions/container_entity" - work_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - title: - type: "string" - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - minLength: 36 - maxLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - extra: - type: "object" - example: - container: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - coden: "coden" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - name: "Journal of Important Results" - publisher: "Society of Curious Students" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - issnl: "1234-5678" - abbrev: "abbrev" - wikidata_qid: "wikidata_qid" - state: "wip" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - language: "language" - title: "title" - contribs: - - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - extra: "{}" - creator_id: "creator_id" - index: 1 - - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - extra: "{}" - creator_id: "creator_id" - index: 1 - pages: "pages" - core_id: "core_id" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - state: "wip" - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - work_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - issue: "12" - abstracts: - - sha1: "3f242a192acc258bdfdb151943419437f440c313" - mimetype: "application/xml+jats" - lang: "en" - content: "<jats:p>Some abstract thing goes here</jats:p>" - - sha1: "3f242a192acc258bdfdb151943419437f440c313" - mimetype: "application/xml+jats" - lang: "en" - content: "<jats:p>Some abstract thing goes here</jats:p>" - release_type: "book" - wikidata_qid: "wikidata_qid" - pmid: "pmid" - release_status: "preprint" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - volume: "volume" - refs: - - target_release_id: "target_release_id" - year: 6 - container_title: "container_title" - extra: "{}" - index: 0 - title: "title" - locator: "p123" - key: "key" - - target_release_id: "target_release_id" - year: 6 - container_title: "container_title" - extra: "{}" - index: 0 - title: "title" - locator: "p123" - key: "key" - release_date: "2000-01-23" - isbn13: "isbn13" - publisher: "publisher" - files: - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - sha256: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - "releases" - - "releases" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - mimetype: "application/pdf" - state: "wip" - md5: "d41efcc592d1e40ac13905377399eb9b" - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - sha256: "a77e4c11a57f1d757fca5754a8f83b5d4ece49a2d28596889127c1a2f3f28832" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - "releases" - - "releases" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - mimetype: "application/pdf" - state: "wip" - md5: "d41efcc592d1e40ac13905377399eb9b" - pmcid: "pmcid" - container_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - doi: "10.1234/abcde.789" - upperCaseName: "RELEASE_ENTITY" - work_entity: - type: "object" - properties: - extra: - type: "object" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - minLength: 36 - maxLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - state: "wip" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "WORK_ENTITY" - entity_history_entry: - type: "object" - required: - - "changelog_entry" - - "edit" - - "editgroup" - properties: - edit: - $ref: "#/definitions/entity_edit" - editgroup: - $ref: "#/definitions/editgroup" - changelog_entry: - $ref: "#/definitions/changelog_entry" - example: - editgroup: - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - creators: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - files: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - containers: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - releases: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "description" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - id: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit: - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - changelog_entry: - editgroup: - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - creators: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - files: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - containers: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - releases: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "description" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - id: "q3nouwy3nnbsvo3h5klxsx4a7y" - index: 0 - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - timestamp: "2000-01-23T04:56:07.000+00:00" - upperCaseName: "ENTITY_HISTORY_ENTRY" - entity_edit: - type: "object" - required: - - "edit_id" - - "editgroup_id" - - "ident" - properties: - edit_id: - type: "integer" - format: "int64" - example: 847 - ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - prev_revision: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - redirect_ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: - type: "object" - example: - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "ENTITY_EDIT" - editor: - type: "object" - required: - - "username" - properties: - id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - username: - type: "string" - example: "zerocool93" - example: - id: "q3nouwy3nnbsvo3h5klxsx4a7y" - username: "zerocool93" - upperCaseName: "EDITOR" - editgroup: - type: "object" - required: - - "editor_id" - properties: - id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - editor_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - description: - type: "string" - extra: - type: "object" - edits: - $ref: "#/definitions/editgroup_edits" - example: - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - creators: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - files: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - containers: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - releases: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "description" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - id: "q3nouwy3nnbsvo3h5klxsx4a7y" - upperCaseName: "EDITGROUP" - changelog_entry: - type: "object" - required: - - "editgroup_id" - - "index" - - "timestamp" - properties: - index: - type: "integer" - format: "int64" - editgroup_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - timestamp: - type: "string" - format: "date-time" - editgroup: - $ref: "#/definitions/editgroup" - example: - editgroup: - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - creators: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - files: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - containers: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - releases: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - description: "description" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - id: "q3nouwy3nnbsvo3h5klxsx4a7y" - index: 0 - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - timestamp: "2000-01-23T04:56:07.000+00:00" - upperCaseName: "CHANGELOG_ENTRY" - release_ref: - type: "object" - properties: - index: - type: "integer" - format: "int64" - target_release_id: - type: "string" - extra: - type: "object" - key: - type: "string" - year: - type: "integer" - format: "int64" - container_title: - type: "string" - title: - type: "string" - locator: - type: "string" - example: "p123" - example: - target_release_id: "target_release_id" - year: 6 - container_title: "container_title" - extra: "{}" - index: 0 - title: "title" - locator: "p123" - key: "key" - upperCaseName: "RELEASE_REF" - release_contrib: - type: "object" - properties: - index: - type: "integer" - format: "int64" - creator_id: - type: "string" - creator: - description: "Optional; GET-only" - $ref: "#/definitions/creator_entity" - raw_name: - type: "string" - extra: - type: "object" - role: - type: "string" - example: - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - extra: "{}" - creator_id: "creator_id" - index: 1 - upperCaseName: "RELEASE_CONTRIB" - stats_response: - type: "object" - properties: - extra: - type: "object" - example: - extra: "{}" - upperCaseName: "STATS_RESPONSE" - file_entity_urls: - required: - - "rel" - - "url" - properties: - url: - type: "string" - format: "url" - example: "https://example.edu/~frau/prcding.pdf" - rel: - type: "string" - example: "webarchive" - example: - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - upperCaseName: "FILE_ENTITY_URLS" - release_entity_abstracts: - properties: - sha1: - type: "string" - example: "3f242a192acc258bdfdb151943419437f440c313" - content: - type: "string" - example: "<jats:p>Some abstract thing goes here</jats:p>" - mimetype: - type: "string" - example: "application/xml+jats" - lang: - type: "string" - example: "en" - example: - sha1: "3f242a192acc258bdfdb151943419437f440c313" - mimetype: "application/xml+jats" - lang: "en" - content: "<jats:p>Some abstract thing goes here</jats:p>" - upperCaseName: "RELEASE_ENTITY_ABSTRACTS" - editgroup_edits: - properties: - containers: - type: "array" - items: - $ref: "#/definitions/entity_edit" - creators: - type: "array" - items: - $ref: "#/definitions/entity_edit" - files: - type: "array" - items: - $ref: "#/definitions/entity_edit" - releases: - type: "array" - items: - $ref: "#/definitions/entity_edit" - works: - type: "array" - items: - $ref: "#/definitions/entity_edit" - example: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - creators: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - files: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - containers: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - releases: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: 847 - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "EDITGROUP_EDITS" -x-fatcat-ident: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - pattern: "[a-zA-Z2-7]{26}" - minLength: 26 - maxLength: 26 - description: "base32-encoded unique identifier" -x-fatcat-uuid: - type: "string" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - minLength: 36 - maxLength: 36 - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" -x-issn: - type: "string" - example: "1234-5678" - pattern: "\\d{4}-\\d{3}[0-9X]" - minLength: 9 - maxLength: 9 -x-orcid: - type: "string" - example: "0000-0002-1825-0097" - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" - minLength: 19 - maxLength: 19 -x-entity-props: - state: - type: "string" - enum: - - "wip" - - "active" - - "redirect" - - "deleted" - ident: - description: "base32-encoded unique identifier" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - type: "string" - revision: - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - maxLength: 36 - minLength: 36 - pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - type: "string" - redirect: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - pattern: "[a-zA-Z2-7]{26}" - minLength: 26 - maxLength: 26 - description: "base32-encoded unique identifier" - editgroup_id: - description: "base32-encoded unique identifier" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - type: "string" - extra: - type: "object" - additionalProperties: {} -x-entity-responses: - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" diff --git a/rust/fatcat-api/examples/ca.pem b/rust/fatcat-api/examples/ca.pem deleted file mode 100644 index d2317fb5..00000000 --- a/rust/fatcat-api/examples/ca.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICtjCCAZ4CCQDpKecRERZ0xDANBgkqhkiG9w0BAQsFADAdMQswCQYDVQQGEwJV -UzEOMAwGA1UEAxMFTXkgQ0EwHhcNMTcwNTIzMTYwMDIzWhcNMTcwNjIyMTYwMDIz -WjAdMQswCQYDVQQGEwJVUzEOMAwGA1UEAxMFTXkgQ0EwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQCt66py3x7sCSASRF2D05L5wkNDxAUjQKYx23W8Gbwv -GMGykk89BIdU5LX1JB1cKiUOkoIxfwAYuWc2V/wzTvVV7+11besnk3uX1c9KiqUF -LIX7kn/z5hzS4aelhKvH+MJlSZCSlp1ytpZbwo5GB5Pi2SGH56jDBiBoDRNBVdWL -z4wH7TdrQjqWwNxIZumD5OGMtcfJyuX08iPiEOaslOeoMqzObhvjc9aUgjVjhqyA -FkJGTXsi0oaD7oml+NE+mTNfEeZvEJQpLSjBY0OvQHzuHkyGBShBnfu/9x7/NRwd -WaqsLiF7/re9KDGYdJwP7Cu6uxYfKAyWarp6h2mG/GIdAgMBAAEwDQYJKoZIhvcN -AQELBQADggEBAGIl/VVIafeq/AJOQ9r7TzzB2ABJYr7NZa6bTu5O1jSp1Fonac15 -SZ8gvRxODgH22ZYSqghPG4xzq4J3hkytlQqm57ZEt2I2M3OqIp17Ndcc1xDYzpLl -tA0FrVn6crQTM8vQkTDtGesaCWX+7Fir5dK7HnYWzfpSmsOpST07PfbNisEXKOxG -Dj4lBL1OnhTjsJeymVS1pFvkKkrcEJO+IxFiHL3CDsWjcXB0Z+E1zBtPoYyYsNsO -rBrjUxcZewF4xqWZhpW90Mt61fY2nRgU0uUwHcvDQUqvmzKcsqYa4mPKzfBI5mxo -01Ta96cDD6pS5Y1hOflZ0g84f2g/7xBLLDA= ------END CERTIFICATE----- diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs deleted file mode 100644 index cc94af11..00000000 --- a/rust/fatcat-api/examples/client.rs +++ /dev/null @@ -1,325 +0,0 @@ -#![allow(missing_docs, unused_variables, trivial_casts)] - -extern crate clap; -extern crate fatcat; -#[allow(unused_extern_crates)] -extern crate futures; -#[allow(unused_extern_crates)] -extern crate swagger; -#[allow(unused_extern_crates)] -extern crate uuid; - -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, -}; -#[allow(unused_imports)] -use futures::{future, stream, Future, Stream}; - -fn main() { - let matches = App::new("client") - .arg( - Arg::with_name("operation") - .help("Sets the operation to run") - .possible_values(&[ - "AcceptEditgroup", - "CreateContainerBatch", - "CreateCreatorBatch", - "CreateFileBatch", - "CreateReleaseBatch", - "CreateWorkBatch", - "DeleteContainer", - "DeleteCreator", - "DeleteFile", - "DeleteRelease", - "DeleteWork", - "GetChangelog", - "GetChangelogEntry", - "GetContainer", - "GetContainerHistory", - "GetCreator", - "GetCreatorHistory", - "GetCreatorReleases", - "GetEditgroup", - "GetEditor", - "GetEditorChangelog", - "GetFile", - "GetFileHistory", - "GetRelease", - "GetReleaseFiles", - "GetReleaseHistory", - "GetStats", - "GetWork", - "GetWorkHistory", - "GetWorkReleases", - "LookupContainer", - "LookupCreator", - "LookupFile", - "LookupRelease", - ]) - .required(true) - .index(1), - ) - .arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) - .arg(Arg::with_name("host").long("host").takes_value(true).default_value("localhost").help("Hostname to contact")) - .arg(Arg::with_name("port").long("port").takes_value(true).default_value("8080").help("Port to contact")) - .get_matches(); - - let is_https = matches.is_present("https"); - let base_url = format!( - "{}://{}:{}", - if is_https { "https" } else { "http" }, - matches.value_of("host").unwrap(), - matches.value_of("port").unwrap() - ); - let client = if is_https { - // Using Simple HTTPS - fatcat::Client::try_new_https(&base_url, "examples/ca.pem").expect("Failed to create HTTPS client") - } else { - // Using HTTP - fatcat::Client::try_new_http(&base_url).expect("Failed to create HTTP client") - }; - - // Using a non-default `Context` is not required; this is just an example! - let client = client.with_context(fatcat::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string())); - - match matches.value_of("operation") { - Some("AcceptEditgroup") => { - let result = client.accept_editgroup("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateContainer") => { - // let result = client.create_container(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateContainerBatch") => { - let result = client.create_container_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateCreator") => { - // let result = client.create_creator(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateCreatorBatch") => { - let result = client.create_creator_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateEditgroup") => { - // let result = client.create_editgroup(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("CreateFile") => { - // let result = client.create_file(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateFileBatch") => { - let result = client.create_file_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateRelease") => { - // let result = client.create_release(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateReleaseBatch") => { - let result = client.create_release_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("CreateWork") => { - // let result = client.create_work(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateWorkBatch") => { - let result = client.create_work_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteContainer") => { - let result = client.delete_container("id_example".to_string(), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteCreator") => { - let result = client.delete_creator("id_example".to_string(), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteFile") => { - let result = client.delete_file("id_example".to_string(), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteRelease") => { - let result = client.delete_release("id_example".to_string(), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("DeleteWork") => { - let result = client.delete_work("id_example".to_string(), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetChangelog") => { - let result = client.get_changelog(Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetChangelogEntry") => { - let result = client.get_changelog_entry(789).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetContainer") => { - let result = client.get_container("id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - 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("<none>"))); - } - - Some("GetCreator") => { - let result = client.get_creator("id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - 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("<none>"))); - } - - Some("GetCreatorReleases") => { - let result = client.get_creator_releases("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditgroup") => { - let result = client.get_editgroup("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditor") => { - let result = client.get_editor("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetEditorChangelog") => { - let result = client.get_editor_changelog("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetFile") => { - let result = client.get_file("id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - 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("<none>"))); - } - - Some("GetRelease") => { - let result = client.get_release("id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseFiles") => { - let result = client.get_release_files("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetReleaseHistory") => { - let result = client.get_release_history("id_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetStats") => { - let result = client.get_stats(Some("more_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("GetWork") => { - let result = client.get_work("id_example".to_string(), Some("expand_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - 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("<none>"))); - } - - Some("GetWorkReleases") => { - let result = client.get_work_releases("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupContainer") => { - let result = client.lookup_container("issnl_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupCreator") => { - let result = client.lookup_creator("orcid_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupFile") => { - let result = client.lookup_file("sha1_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - Some("LookupRelease") => { - let result = client.lookup_release("doi_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - - // Disabled because there's no example. - // Some("UpdateContainer") => { - // let result = client.update_container("id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateCreator") => { - // let result = client.update_creator("id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateFile") => { - // let result = client.update_file("id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateRelease") => { - // let result = client.update_release("id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateWork") => { - // let result = client.update_work("id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - _ => panic!("Invalid operation provided"), - } -} diff --git a/rust/fatcat-api/examples/server-chain.pem b/rust/fatcat-api/examples/server-chain.pem deleted file mode 100644 index 47d7e201..00000000 --- a/rust/fatcat-api/examples/server-chain.pem +++ /dev/null @@ -1,66 +0,0 @@ -Certificate: - Data: - Version: 1 (0x0) - Serial Number: 4096 (0x1000) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, CN=My CA - Validity - Not Before: May 23 16:00:23 2017 GMT - Not After : Apr 29 16:00:23 2117 GMT - Subject: CN=localhost, C=US - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:c9:d4:43:60:50:fc:d6:0f:38:4d:5d:5e:aa:7c: - c0:5e:a9:ec:d9:93:78:d3:93:72:28:41:f5:08:a5: - ea:ac:67:07:d7:1f:f7:7d:74:69:7e:46:89:20:4b: - 7a:2d:9b:02:08:e7:6f:0f:1d:0c:0f:c7:60:69:19: - 4b:df:7e:ca:75:94:0b:49:71:e3:6d:f2:e8:79:fd: - ed:0a:94:67:55:f3:ca:6b:61:ba:58:b7:2e:dd:7b: - ca:b9:02:9f:24:36:ac:26:8f:04:8f:81:c8:35:10: - f4:aa:33:b2:24:16:f8:f7:1e:ea:f7:16:fe:fa:34: - c3:dd:bb:2c:ba:7a:df:4d:e2:da:1e:e5:d2:28:44: - 6e:c8:96:e0:fd:09:0c:14:0c:31:dc:e0:ca:c1:a7: - 9b:bf:16:8c:f7:36:3f:1b:2e:dd:90:eb:45:78:51: - bf:59:22:1e:c6:8c:0a:69:88:e5:03:5e:73:b7:fc: - 93:7f:1b:46:1b:97:68:c5:c0:8b:35:1f:bb:1e:67: - 7f:55:b7:3b:55:3f:ea:f2:ca:db:cc:52:cd:16:89: - db:15:47:bd:f2:cd:6c:7a:d7:b4:1a:ac:c8:15:6c: - 6a:fb:77:c4:e9:f2:30:e0:14:24:66:65:6f:2a:e5: - 2d:cc:f6:81:ae:57:c8:d1:9b:38:90:dc:60:93:02: - 5e:cb - Exponent: 65537 (0x10001) - Signature Algorithm: sha256WithRSAEncryption - 1c:7c:39:e8:3d:49:b2:09:1e:68:5a:2f:74:18:f4:63:b5:8c: - f6:e6:a1:e3:4d:95:90:99:ef:32:5c:34:40:e8:55:13:0e:e0: - 1c:be:cd:ab:3f:64:38:99:5e:2b:c1:81:53:a0:18:a8:f6:ee: - 6a:33:73:6c:9a:73:9d:86:08:5d:c7:11:38:46:4c:cd:a0:47: - 37:8f:fe:a6:50:a9:02:21:99:42:86:5e:47:fe:65:56:60:1d: - 16:53:86:bd:e4:63:c5:69:cf:fa:30:51:ab:a1:c3:50:53:cc: - 66:1c:4c:ff:3f:2a:39:4d:a2:8f:9d:d1:a7:8b:22:e4:78:69: - 24:06:83:4d:cc:0a:c0:87:69:9b:bc:80:a9:d2:b7:a5:23:84: - 7e:a2:32:26:7c:78:0e:bd:db:cd:3b:69:18:33:b8:44:ef:96: - b4:99:86:ee:06:bd:51:1c:c7:a1:a4:0c:c4:4c:51:a0:df:ac: - 14:07:88:8e:d7:39:45:fe:52:e0:a3:4c:db:5d:7a:ab:4d:e4: - ca:06:e8:bd:74:6f:46:e7:93:4a:4f:1b:67:e7:a5:9f:ef:9c: - 02:49:d1:f2:d5:e9:53:ee:09:21:ac:08:c8:15:f7:af:35:b9: - 4f:11:0f:43:ae:46:8e:fd:5b:8d:a3:4e:a7:2c:b7:25:ed:e4: - e5:94:1d:e3 ------BEGIN CERTIFICATE----- -MIICtTCCAZ0CAhAAMA0GCSqGSIb3DQEBCwUAMB0xCzAJBgNVBAYTAlVTMQ4wDAYD -VQQDEwVNeSBDQTAgFw0xNzA1MjMxNjAwMjNaGA8yMTE3MDQyOTE2MDAyM1owITES -MBAGA1UEAxMJbG9jYWxob3N0MQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEB -BQADggEPADCCAQoCggEBAMnUQ2BQ/NYPOE1dXqp8wF6p7NmTeNOTcihB9Qil6qxn -B9cf9310aX5GiSBLei2bAgjnbw8dDA/HYGkZS99+ynWUC0lx423y6Hn97QqUZ1Xz -ymthuli3Lt17yrkCnyQ2rCaPBI+ByDUQ9KozsiQW+Pce6vcW/vo0w927LLp6303i -2h7l0ihEbsiW4P0JDBQMMdzgysGnm78WjPc2Pxsu3ZDrRXhRv1kiHsaMCmmI5QNe -c7f8k38bRhuXaMXAizUfux5nf1W3O1U/6vLK28xSzRaJ2xVHvfLNbHrXtBqsyBVs -avt3xOnyMOAUJGZlbyrlLcz2ga5XyNGbOJDcYJMCXssCAwEAATANBgkqhkiG9w0B -AQsFAAOCAQEAHHw56D1JsgkeaFovdBj0Y7WM9uah402VkJnvMlw0QOhVEw7gHL7N -qz9kOJleK8GBU6AYqPbuajNzbJpznYYIXccROEZMzaBHN4/+plCpAiGZQoZeR/5l -VmAdFlOGveRjxWnP+jBRq6HDUFPMZhxM/z8qOU2ij53Rp4si5HhpJAaDTcwKwIdp -m7yAqdK3pSOEfqIyJnx4Dr3bzTtpGDO4RO+WtJmG7ga9URzHoaQMxExRoN+sFAeI -jtc5Rf5S4KNM2116q03kygbovXRvRueTSk8bZ+eln++cAknR8tXpU+4JIawIyBX3 -rzW5TxEPQ65Gjv1bjaNOpyy3Je3k5ZQd4w== ------END CERTIFICATE----- diff --git a/rust/fatcat-api/examples/server-key.pem b/rust/fatcat-api/examples/server-key.pem deleted file mode 100644 index 29c00682..00000000 --- a/rust/fatcat-api/examples/server-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDJ1ENgUPzWDzhN -XV6qfMBeqezZk3jTk3IoQfUIpeqsZwfXH/d9dGl+RokgS3otmwII528PHQwPx2Bp -GUvffsp1lAtJceNt8uh5/e0KlGdV88prYbpYty7de8q5Ap8kNqwmjwSPgcg1EPSq -M7IkFvj3Hur3Fv76NMPduyy6et9N4toe5dIoRG7IluD9CQwUDDHc4MrBp5u/Foz3 -Nj8bLt2Q60V4Ub9ZIh7GjAppiOUDXnO3/JN/G0Ybl2jFwIs1H7seZ39VtztVP+ry -ytvMUs0WidsVR73yzWx617QarMgVbGr7d8Tp8jDgFCRmZW8q5S3M9oGuV8jRmziQ -3GCTAl7LAgMBAAECggEBAKEd1q9j14KWYc64s6KLthGbutyxsinMMbxbct11fdIk -6YhdF3fJ35ETg9IJDr6rWEN9ZRX+jStncNpVfFEs6ThVd3Eo/nI+EEGaaIkikR93 -X2a7fEPn7/yVHu70XdBN6L1bPDvHUeiy4W2hmRrgT90OjGm1rNRWHOm7yugOwIZu -HclzbR9Ca7EInFnotUiDQm9sw9VKHbJHqWx6OORdZrxR2ytYs0Qkq0XpGMvti2HW -7WAmKTg5QM8myXW7+/4iqb/u68wVBR2BBalShKmIf7lim9O3W2a1RjDdsvm/wNe9 -I+D+Iq825vpqkKXcrxYlpVg7hYiaQaW/MNsEb7lQRjECgYEA/RJYby0POW+/k0Jn -jO8UmJVEMiuGa8WIUu/JJWMOmzRCukjSRNQOkt7niQrZPJYE8W6clM6RJTolWf9L -IL6mIb+mRaoudUk8SHGDq7ho1iMg9GK8lhYxvKh1Q6uv8EyVSkgLknAEY0NANKC1 -zNdU5Dhven9aRX2gq9vP4XwMz2MCgYEAzCogQ7IFk+gkp3k491dOZnrGRoRCfuzo -4CJtyKFgOSd7BjmpcKkj0IPfVBjw6GjMIxfQRMTQmxAjjWevH45vG8l0Iiwz/gSp -81b5nsDEX5uv2Olcmcz5zxRFy36jOZ9ihMWinxcIlT2oDbyCdbruDKZq9ieJ9S8g -4qGx0OkwE3kCgYEA7CmAiU89U9YqqttfEq/RQoqY91CSwmO10d+ej9seuEtOsdRf -FIfnibulycdr7hP5TOxyBpO1802NqayJiWcgVYIpQf2MGTtcnCYCP+95NcvWZvj1 -EAJqK6nwtFO1fcOZ1ZXh5qfOEGujsPkAbsXLnKXlsiTCMvMHSxl3pu5Cbg0CgYBf -JjbZNctRrjv+7Qj2hPLd4dQsIxGWc7ToWENP4J2mpVa5hQAJqFovoHXhjKohtk2F -AWEn243Y5oGbMjo0e74edhmwn2cvuF64MM2vBem/ISCn98IXT6cQskMA3qkVfsl8 -VVs/x41ReGWs2TD3y0GMFbb9t1mdMfSiincDhNnKCQKBgGfeT4jKyYeCoCw4OLI1 -G75Gd0METt/IkppwODPpNwj3Rp9I5jctWZFA/3wCX/zk0HgBeou5AFNS4nQZ/X/L -L9axbSdR7UJTGkT1r4gu3rLkPV4Tk+8XM03/JT2cofMlzQBuhvl1Pn4SgKowz7hl -lS76ECw4Av3T0S34VW9Z5oye ------END PRIVATE KEY----- diff --git a/rust/fatcat-api/examples/server.rs b/rust/fatcat-api/examples/server.rs deleted file mode 100644 index 8d2e9b64..00000000 --- a/rust/fatcat-api/examples/server.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! Main binary entry point for fatcat implementation. - -#![allow(missing_docs)] - -// Imports required by this file. -// extern crate <name of this crate>; -extern crate clap; -extern crate fatcat; -extern crate hyper_openssl; -extern crate iron; -extern crate swagger; - -// Imports required by server library. -// extern crate fatcat; -// extern crate swagger; -extern crate chrono; -extern crate futures; -#[macro_use] -extern crate error_chain; - -use clap::{App, Arg}; -use hyper_openssl::openssl::error::ErrorStack; -use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod}; -use hyper_openssl::openssl::x509::X509_FILETYPE_PEM; -use hyper_openssl::OpensslServer; -use iron::{Chain, Iron}; -use swagger::auth::AllowAllMiddleware; - -mod server_lib; - -/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names -fn ssl() -> Result<OpensslServer, ErrorStack> { - let mut ssl = SslAcceptorBuilder::mozilla_intermediate_raw(SslMethod::tls())?; - - // Server authentication - ssl.set_private_key_file("examples/server-key.pem", X509_FILETYPE_PEM)?; - ssl.set_certificate_chain_file("examples/server-chain.pem")?; - ssl.check_private_key()?; - - Ok(OpensslServer::from(ssl.build())) -} - -/// Create custom server, wire it to the autogenerated router, -/// and pass it to the web server. -fn main() { - let matches = App::new("server").arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")).get_matches(); - - let server = server_lib::server().unwrap(); - let router = fatcat::router(server); - - let mut chain = Chain::new(router); - chain.link_before(fatcat::server::ExtractAuthData); - // add authentication middlewares into the chain here - // for the purpose of this example, pretend we have authenticated a user - chain.link_before(AllowAllMiddleware::new("cosmo")); - - if matches.is_present("https") { - // Using Simple HTTPS - Iron::new(chain).https("localhost:8080", ssl().expect("Failed to load SSL keys")).expect("Failed to start HTTPS server"); - } else { - // Using HTTP - Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server"); - } -} diff --git a/rust/fatcat-api/examples/server_lib/mod.rs b/rust/fatcat-api/examples/server_lib/mod.rs deleted file mode 100644 index 5291637e..00000000 --- a/rust/fatcat-api/examples/server_lib/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! Main library entry point for fatcat implementation. - -mod server; - -mod errors { - error_chain!{} -} - -pub use self::errors::*; - -/// Instantiate a new server. -pub fn server() -> Result<server::Server> { - Ok(server::Server {}) -} diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs deleted file mode 100644 index ab08f594..00000000 --- a/rust/fatcat-api/examples/server_lib/server.rs +++ /dev/null @@ -1,420 +0,0 @@ -//! Server implementation of fatcat. - -#![allow(unused_imports)] - -use chrono; -use futures::{self, Future}; - -use std::collections::HashMap; - -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, -}; - -#[derive(Copy, Clone)] -pub struct Server; - -impl Api for Server { - fn accept_editgroup(&self, id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_container(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_container({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_container_batch( - &self, - entity_list: &Vec<models::ContainerEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_container_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", - entity_list, - autoaccept, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator(&self, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_creator({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator_batch( - &self, - entity_list: &Vec<models::CreatorEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_creator_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", - entity_list, - autoaccept, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup(&self, entity: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_editgroup({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_file({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file_batch( - &self, - entity_list: &Vec<models::FileEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_file_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", - entity_list, - autoaccept, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_release({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release_batch( - &self, - entity_list: &Vec<models::ReleaseEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_release_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", - entity_list, - autoaccept, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("create_work({:?}) - X-Span-ID: {:?}", entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work_batch( - &self, - entity_list: &Vec<models::WorkEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "create_work_batch({:?}, {:?}, {:?}) - X-Span-ID: {:?}", - entity_list, - autoaccept, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_container(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_container(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_creator(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_creator(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_file(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_file(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_release(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_release(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_work(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "delete_work(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - editgroup, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog_entry(&self, id: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_changelog_entry({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_container(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_creator(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_creator_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup(&self, id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor(&self, id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_editor(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor_changelog(&self, id: String, context: &Context) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_editor_changelog(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_file(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_release(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_files(&self, id: String, context: &Context) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_release_files(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_stats(&self, more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_stats({:?}) - X-Span-ID: {:?}", more, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_work(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - limit, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("get_work_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_container(&self, issnl: String, context: &Context) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("lookup_container(\"{}\") - X-Span-ID: {:?}", issnl, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_creator(&self, orcid: String, context: &Context) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("lookup_creator(\"{}\") - X-Span-ID: {:?}", orcid, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_file(&self, sha1: String, context: &Context) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("lookup_file(\"{}\") - X-Span-ID: {:?}", sha1, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_release(&self, doi: String, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("lookup_release(\"{}\") - X-Span-ID: {:?}", doi, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_container(&self, id: String, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_container(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_creator(&self, id: String, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_creator(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_file(&self, id: String, entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("update_file(\"{}\", {:?}) - X-Span-ID: {:?}", id, entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_release(&self, id: String, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!( - "update_release(\"{}\", {:?}) - X-Span-ID: {:?}", - id, - entity, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_work(&self, id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - let context = context.clone(); - println!("update_work(\"{}\", {:?}) - X-Span-ID: {:?}", id, entity, context.x_span_id.unwrap_or(String::from("<none>")).clone()); - Box::new(futures::failed("Generic failure".into())) - } -} diff --git a/rust/fatcat-api/rustfmt.toml b/rust/fatcat-api/rustfmt.toml deleted file mode 100644 index cba42c2b..00000000 --- a/rust/fatcat-api/rustfmt.toml +++ /dev/null @@ -1,5 +0,0 @@ -# 'ignore' requires nightly rust -#ignore = ['src/server.rs'] - -# For now just make the width really wide -max_width = 200 diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs deleted file mode 100644 index a08e3cfe..00000000 --- a/rust/fatcat-api/src/client.rs +++ /dev/null @@ -1,3158 +0,0 @@ -#![allow(unused_extern_crates)] -extern crate chrono; -extern crate hyper_openssl; -extern crate url; - -use self::hyper_openssl::openssl; -use self::url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; -use futures; -use futures::{future, stream}; -use futures::{Future, Stream}; -use hyper; -use hyper::client::IntoUrl; -use hyper::header::{ContentType, Headers}; -use hyper::mime; -use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value}; -use hyper::Url; -use std::borrow::Cow; -use std::error; -use std::fmt; -use std::io::{Error, Read}; -use std::path::Path; -use std::str; -use std::sync::Arc; - -use mimetypes; - -use serde_json; - -#[allow(unused_imports)] -use std::collections::{BTreeMap, HashMap}; -#[allow(unused_imports)] -use swagger; - -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, -}; - -/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. -fn into_base_path<T: IntoUrl>(input: T, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> { - // First convert to Url, since a base path is a subset of Url. - let url = input.into_url()?; - - let scheme = url.scheme(); - - // Check the scheme if necessary - if let Some(correct_scheme) = correct_scheme { - if scheme != correct_scheme { - return Err(ClientInitError::InvalidScheme); - } - } - - let host = url.host().ok_or_else(|| ClientInitError::MissingHost)?; - let port = url.port().map(|x| format!(":{}", x)).unwrap_or_default(); - Ok(format!("{}://{}{}", scheme, host, port)) -} - -/// A client that implements the API by making HTTP calls out to a server. -#[derive(Clone)] -pub struct Client { - base_path: String, - hyper_client: Arc<Fn() -> hyper::client::Client + Sync + Send>, -} - -impl fmt::Debug for Client { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Client {{ base_path: {} }}", self.base_path) - } -} - -impl Client { - pub fn try_new_http<T>(base_path: T) -> Result<Client, ClientInitError> - where - T: IntoUrl, - { - Ok(Client { - base_path: into_base_path(base_path, Some("http"))?, - hyper_client: Arc::new(hyper::client::Client::new), - }) - } - - pub fn try_new_https<T, CA>(base_path: T, ca_certificate: CA) -> Result<Client, ClientInitError> - where - T: IntoUrl, - CA: AsRef<Path>, - { - let ca_certificate = ca_certificate.as_ref().to_owned(); - - let https_hyper_client = move || { - // SSL implementation - let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); - - // Server authentication - ssl.set_ca_file(ca_certificate.clone()).unwrap(); - - let ssl = hyper_openssl::OpensslClient::from(ssl.build()); - let connector = hyper::net::HttpsConnector::new(ssl); - hyper::client::Client::with_connector(connector) - }; - - Ok(Client { - base_path: into_base_path(base_path, Some("https"))?, - hyper_client: Arc::new(https_hyper_client), - }) - } - - pub fn try_new_https_mutual<T, CA, K, C>(base_path: T, ca_certificate: CA, client_key: K, client_certificate: C) -> Result<Client, ClientInitError> - where - T: IntoUrl, - CA: AsRef<Path>, - K: AsRef<Path>, - C: AsRef<Path>, - { - let ca_certificate = ca_certificate.as_ref().to_owned(); - let client_key = client_key.as_ref().to_owned(); - let client_certificate = client_certificate.as_ref().to_owned(); - - let https_mutual_hyper_client = move || { - // SSL implementation - let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); - - // Server authentication - ssl.set_ca_file(ca_certificate.clone()).unwrap(); - - // Client authentication - ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM).unwrap(); - ssl.set_certificate_chain_file(client_certificate.clone()).unwrap(); - ssl.check_private_key().unwrap(); - - let ssl = hyper_openssl::OpensslClient::from(ssl.build()); - let connector = hyper::net::HttpsConnector::new(ssl); - hyper::client::Client::with_connector(connector) - }; - - Ok(Client { - base_path: into_base_path(base_path, Some("https"))?, - hyper_client: Arc::new(https_mutual_hyper_client), - }) - } - - /// Constructor for creating a `Client` by passing in a pre-made `hyper` client. - /// - /// One should avoid relying on this function if possible, since it adds a dependency on the underlying transport - /// implementation, which it would be better to abstract away. Therefore, using this function may lead to a loss of - /// code generality, which may make it harder to move the application to a serverless environment, for example. - /// - /// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer. - /// This is not a recommended way to write new tests. If other reasons are found for using this function, they - /// should be mentioned here. - pub fn try_new_with_hyper_client<T>(base_path: T, hyper_client: Arc<Fn() -> hyper::client::Client + Sync + Send>) -> Result<Client, ClientInitError> - where - T: IntoUrl, - { - Ok(Client { - base_path: into_base_path(base_path, None)?, - hyper_client: hyper_client, - }) - } -} - -impl Api for Client { - fn accept_editgroup(&self, param_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/editgroup/{id}/accept", 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::Post, &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<AcceptEditgroupResponse, ApiError> { - 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::<models::Success>(&buf)?; - - Ok(AcceptEditgroupResponse::MergedSuccessfully(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::<models::ErrorResponse>(&buf)?; - - Ok(AcceptEditgroupResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(AcceptEditgroupResponse::NotFound(body)) - } - 409 => { - 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::<models::ErrorResponse>(&buf)?; - - Ok(AcceptEditgroupResponse::EditConflict(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::<models::ErrorResponse>(&buf)?; - - Ok(AcceptEditgroupResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_container(&self, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/container", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_CONTAINER.clone())); - 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<CreateContainerResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::EntityEdit>(&buf)?; - - Ok(CreateContainerResponse::CreatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_container_batch( - &self, - param_entity_list: &Vec<models::ContainerEntity>, - param_autoaccept: Option<bool>, - param_editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send> { - // Query parameters - let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/container/batch?{autoaccept}{editgroup}", - self.base_path, - autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_CONTAINER_BATCH.clone())); - 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<CreateContainerBatchResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<Vec<models::EntityEdit>>(&buf)?; - - Ok(CreateContainerBatchResponse::CreatedEntities(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateContainerBatchResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_creator(&self, param_entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_CREATOR.clone())); - 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<CreateCreatorResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::EntityEdit>(&buf)?; - - Ok(CreateCreatorResponse::CreatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_creator_batch( - &self, - param_entity_list: &Vec<models::CreatorEntity>, - param_autoaccept: Option<bool>, - param_editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send> { - // Query parameters - let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/creator/batch?{autoaccept}{editgroup}", - self.base_path, - autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_CREATOR_BATCH.clone())); - 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<CreateCreatorBatchResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<Vec<models::EntityEdit>>(&buf)?; - - Ok(CreateCreatorBatchResponse::CreatedEntities(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateCreatorBatchResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_editgroup(&self, param_entity: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/editgroup", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP.clone())); - 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<CreateEditgroupResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::Editgroup>(&buf)?; - - Ok(CreateEditgroupResponse::SuccessfullyCreated(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateEditgroupResponse::BadRequest(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateEditgroupResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_file(&self, param_entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/file", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_FILE.clone())); - 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<CreateFileResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::EntityEdit>(&buf)?; - - Ok(CreateFileResponse::CreatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_file_batch( - &self, - param_entity_list: &Vec<models::FileEntity>, - param_autoaccept: Option<bool>, - param_editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { - // Query parameters - let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/file/batch?{autoaccept}{editgroup}", - self.base_path, - autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_FILE_BATCH.clone())); - 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<CreateFileBatchResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<Vec<models::EntityEdit>>(&buf)?; - - Ok(CreateFileBatchResponse::CreatedEntities(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateFileBatchResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_release(&self, param_entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_RELEASE.clone())); - 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<CreateReleaseResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::EntityEdit>(&buf)?; - - Ok(CreateReleaseResponse::CreatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_release_batch( - &self, - param_entity_list: &Vec<models::ReleaseEntity>, - param_autoaccept: Option<bool>, - param_editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send> { - // Query parameters - let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/release/batch?{autoaccept}{editgroup}", - self.base_path, - autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_RELEASE_BATCH.clone())); - 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<CreateReleaseBatchResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<Vec<models::EntityEdit>>(&buf)?; - - Ok(CreateReleaseBatchResponse::CreatedEntities(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateReleaseBatchResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_work(&self, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work", self.base_path); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_WORK.clone())); - 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<CreateWorkResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<models::EntityEdit>(&buf)?; - - Ok(CreateWorkResponse::CreatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 create_work_batch( - &self, - param_entity_list: &Vec<models::WorkEntity>, - param_autoaccept: Option<bool>, - param_editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { - // Query parameters - let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/work/batch?{autoaccept}{editgroup}", - self.base_path, - autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_WORK_BATCH.clone())); - 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<CreateWorkBatchResponse, ApiError> { - match response.status.to_u16() { - 201 => { - 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::<Vec<models::EntityEdit>>(&buf)?; - - Ok(CreateWorkBatchResponse::CreatedEntities(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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkBatchResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(CreateWorkBatchResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 delete_container(&self, param_id: String, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteContainerResponse, Error = ApiError> + Send> { - // Query parameters - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/container/{id}?{editgroup}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let 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<DeleteContainerResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(DeleteContainerResponse::DeletedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteContainerResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 delete_creator(&self, param_id: String, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> { - // Query parameters - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/creator/{id}?{editgroup}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let 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<DeleteCreatorResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(DeleteCreatorResponse::DeletedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteCreatorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 delete_file(&self, param_id: String, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteFileResponse, Error = ApiError> + Send> { - // Query parameters - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/file/{id}?{editgroup}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let 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<DeleteFileResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(DeleteFileResponse::DeletedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteFileResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 delete_release(&self, param_id: String, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> { - // Query parameters - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/release/{id}?{editgroup}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let 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<DeleteReleaseResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(DeleteReleaseResponse::DeletedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteReleaseResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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 delete_work(&self, param_id: String, param_editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send> { - // Query parameters - let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - - let url = format!( - "{}/v0/work/{id}?{editgroup}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) - ); - - let 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<DeleteWorkResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(DeleteWorkResponse::DeletedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(DeleteWorkResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_changelog(&self, param_limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + 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/changelog?{limit}", self.base_path, 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<GetChangelogResponse, ApiError> { - 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::<Vec<models::ChangelogEntry>>(&buf)?; - - Ok(GetChangelogResponse::Success(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::<models::ErrorResponse>(&buf)?; - - Ok(GetChangelogResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_changelog_entry(&self, param_id: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/changelog/{id}", 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<GetChangelogEntryResponse, ApiError> { - 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::<models::ChangelogEntry>(&buf)?; - - Ok(GetChangelogEntryResponse::FoundChangelogEntry(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::<models::ErrorResponse>(&buf)?; - - Ok(GetChangelogEntryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetChangelogEntryResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<String>, context: &Context) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/container/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, 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<GetContainerResponse, ApiError> { - 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::<models::ContainerEntity>(&buf)?; - - Ok(GetContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<i64>, context: &Context) -> Box<Future<Item = GetContainerHistoryResponse, Error = ApiError> + 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/container/{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<GetContainerHistoryResponse, ApiError> { - 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::<Vec<models::EntityHistoryEntry>>(&buf)?; - - Ok(GetContainerHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetContainerHistoryResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<String>, context: &Context) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/creator/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, 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<GetCreatorResponse, ApiError> { - 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::<models::CreatorEntity>(&buf)?; - - Ok(GetCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetCreatorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<i64>, context: &Context) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + 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/creator/{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<GetCreatorHistoryResponse, ApiError> { - 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::<Vec<models::EntityHistoryEntry>>(&buf)?; - - Ok(GetCreatorHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetCreatorHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - 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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator/{id}/releases", 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<GetCreatorReleasesResponse, ApiError> { - 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::<Vec<models::ReleaseEntity>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?; - - Ok(GetCreatorReleasesResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_editgroup(&self, param_id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/editgroup/{id}", 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<GetEditgroupResponse, ApiError> { - 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::<models::Editgroup>(&buf)?; - - Ok(GetEditgroupResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditgroupResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditgroupResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditgroupResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_editor(&self, param_id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/editor/{id}", 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<GetEditorResponse, ApiError> { - 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::<models::Editor>(&buf)?; - - Ok(GetEditorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_editor_changelog(&self, param_id: String, context: &Context) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/editor/{id}/changelog", 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<GetEditorChangelogResponse, ApiError> { - 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::<Vec<models::ChangelogEntry>>(&buf)?; - - Ok(GetEditorChangelogResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorChangelogResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorChangelogResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetEditorChangelogResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<String>, context: &Context) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/file/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, 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<GetFileResponse, ApiError> { - 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::<models::FileEntity>(&buf)?; - - 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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<i64>, context: &Context) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + 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<GetFileHistoryResponse, ApiError> { - 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::<Vec<models::EntityHistoryEntry>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<String>, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/release/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, 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<GetReleaseResponse, ApiError> { - 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::<models::ReleaseEntity>(&buf)?; - - Ok(GetReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetReleaseResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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, context: &Context) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release/{id}/files", 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<GetReleaseFilesResponse, ApiError> { - 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::<Vec<models::FileEntity>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<i64>, context: &Context) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + 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<GetReleaseHistoryResponse, ApiError> { - 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::<Vec<models::EntityHistoryEntry>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_stats(&self, param_more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> { - // Query parameters - let query_more = param_more.map_or_else(String::new, |query| format!("more={more}&", more = query.to_string())); - - let url = format!("{}/v0/stats?{more}", self.base_path, more = utf8_percent_encode(&query_more, 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<GetStatsResponse, ApiError> { - 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::<models::StatsResponse>(&buf)?; - - Ok(GetStatsResponse::Success(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::<models::ErrorResponse>(&buf)?; - - Ok(GetStatsResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<String>, context: &Context) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/work/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, 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<GetWorkResponse, ApiError> { - 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::<models::WorkEntity>(&buf)?; - - Ok(GetWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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<i64>, context: &Context) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + 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/work/{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<GetWorkHistoryResponse, ApiError> { - 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::<Vec<models::EntityHistoryEntry>>(&buf)?; - - Ok(GetWorkHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkHistoryResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkHistoryResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work/{id}/releases", 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<GetWorkReleasesResponse, ApiError> { - 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::<Vec<models::ReleaseEntity>>(&buf)?; - - Ok(GetWorkReleasesResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkReleasesResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkReleasesResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(GetWorkReleasesResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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: String, context: &Context) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> { - // Query parameters - let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); - - let url = format!("{}/v0/container/lookup?{issnl}", self.base_path, issnl = utf8_percent_encode(&query_issnl, 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<LookupContainerResponse, ApiError> { - 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::<models::ContainerEntity>(&buf)?; - - Ok(LookupContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupContainerResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_creator(&self, param_orcid: String, context: &Context) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send> { - // Query parameters - let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string()); - - let url = format!("{}/v0/creator/lookup?{orcid}", self.base_path, orcid = utf8_percent_encode(&query_orcid, 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<LookupCreatorResponse, ApiError> { - 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::<models::CreatorEntity>(&buf)?; - - Ok(LookupCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupCreatorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_file(&self, param_sha1: String, context: &Context) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send> { - // Query parameters - let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string()); - - let url = format!("{}/v0/file/lookup?{sha1}", self.base_path, sha1 = utf8_percent_encode(&query_sha1, 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<LookupFileResponse, ApiError> { - 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::<models::FileEntity>(&buf)?; - - Ok(LookupFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupFileResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_release(&self, param_doi: String, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { - // Query parameters - let query_doi = format!("doi={doi}&", doi = param_doi.to_string()); - - let url = format!("{}/v0/release/lookup?{doi}", self.base_path, doi = utf8_percent_encode(&query_doi, 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<LookupReleaseResponse, ApiError> { - 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::<models::ReleaseEntity>(&buf)?; - - Ok(LookupReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(LookupReleaseResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_container(&self, param_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/container/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Put, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::UPDATE_CONTAINER.clone())); - 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<UpdateContainerResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(UpdateContainerResponse::UpdatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateContainerResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateContainerResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_creator(&self, param_id: String, param_entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Put, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::UPDATE_CREATOR.clone())); - 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<UpdateCreatorResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(UpdateCreatorResponse::UpdatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateCreatorResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateCreatorResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_file(&self, param_id: String, param_entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/file/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Put, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::UPDATE_FILE.clone())); - 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<UpdateFileResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(UpdateFileResponse::UpdatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateFileResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateFileResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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_release(&self, param_id: String, param_entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Put, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::UPDATE_RELEASE.clone())); - 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<UpdateReleaseResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(UpdateReleaseResponse::UpdatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateReleaseResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateReleaseResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - - let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Put, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::UPDATE_WORK.clone())); - 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<UpdateWorkResponse, ApiError> { - 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::<models::EntityEdit>(&buf)?; - - Ok(UpdateWorkResponse::UpdatedEntity(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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateWorkResponse::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::<models::ErrorResponse>(&buf)?; - - Ok(UpdateWorkResponse::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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("<Failed to read body: {}>", 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)) - } -} - -#[derive(Debug)] -pub enum ClientInitError { - InvalidScheme, - InvalidUrl(hyper::error::ParseError), - MissingHost, - SslError(openssl::error::ErrorStack), -} - -impl From<hyper::error::ParseError> for ClientInitError { - fn from(err: hyper::error::ParseError) -> ClientInitError { - ClientInitError::InvalidUrl(err) - } -} - -impl From<openssl::error::ErrorStack> for ClientInitError { - fn from(err: openssl::error::ErrorStack) -> ClientInitError { - ClientInitError::SslError(err) - } -} - -impl fmt::Display for ClientInitError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (self as &fmt::Debug).fmt(f) - } -} - -impl error::Error for ClientInitError { - fn description(&self) -> &str { - "Failed to produce a hyper client." - } -} diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs deleted file mode 100644 index a08c6e04..00000000 --- a/rust/fatcat-api/src/lib.rs +++ /dev/null @@ -1,1022 +0,0 @@ -#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate serde_json; - -extern crate chrono; -extern crate futures; - -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; - -// Logically this should be in the client and server modules, but rust doesn't allow `macro_use` from a module. -#[cfg(any(feature = "client", feature = "server"))] -#[macro_use] -extern crate hyper; - -extern crate swagger; - -use futures::Stream; -use std::io::Error; - -#[allow(unused_imports)] -use std::collections::HashMap; - -pub use futures::Future; - -#[cfg(any(feature = "client", feature = "server"))] -mod mimetypes; - -pub use swagger::{ApiError, Context, ContextWrapper}; - -#[derive(Debug, PartialEq)] -pub enum AcceptEditgroupResponse { - /// Merged Successfully - MergedSuccessfully(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Edit Conflict - EditConflict(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateContainerResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateContainerBatchResponse { - /// Created Entities - CreatedEntities(Vec<models::EntityEdit>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateCreatorResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateCreatorBatchResponse { - /// Created Entities - CreatedEntities(Vec<models::EntityEdit>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateEditgroupResponse { - /// Successfully Created - SuccessfullyCreated(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFileResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFileBatchResponse { - /// Created Entities - CreatedEntities(Vec<models::EntityEdit>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateReleaseResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateReleaseBatchResponse { - /// Created Entities - CreatedEntities(Vec<models::EntityEdit>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateWorkResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateWorkBatchResponse { - /// Created Entities - CreatedEntities(Vec<models::EntityEdit>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteContainerResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteCreatorResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteFileResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteReleaseResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteWorkResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetChangelogResponse { - /// Success - Success(Vec<models::ChangelogEntry>), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetChangelogEntryResponse { - /// Found Changelog Entry - FoundChangelogEntry(models::ChangelogEntry), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetContainerResponse { - /// Found Entity - FoundEntity(models::ContainerEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetContainerHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec<models::EntityHistoryEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorResponse { - /// Found Entity - FoundEntity(models::CreatorEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec<models::EntityHistoryEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorReleasesResponse { - /// Found - Found(Vec<models::ReleaseEntity>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetEditgroupResponse { - /// Found - Found(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetEditorResponse { - /// Found - Found(models::Editor), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetEditorChangelogResponse { - /// Found - Found(Vec<models::ChangelogEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFileResponse { - /// Found Entity - FoundEntity(models::FileEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFileHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec<models::EntityHistoryEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseResponse { - /// Found Entity - FoundEntity(models::ReleaseEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseFilesResponse { - /// Found - Found(Vec<models::FileEntity>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec<models::EntityHistoryEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetStatsResponse { - /// Success - Success(models::StatsResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkResponse { - /// Found Entity - FoundEntity(models::WorkEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec<models::EntityHistoryEntry>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkReleasesResponse { - /// Found - Found(Vec<models::ReleaseEntity>), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupContainerResponse { - /// Found Entity - FoundEntity(models::ContainerEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupCreatorResponse { - /// Found Entity - FoundEntity(models::CreatorEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupFileResponse { - /// Found Entity - FoundEntity(models::FileEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupReleaseResponse { - /// Found Entity - FoundEntity(models::ReleaseEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateContainerResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateCreatorResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateFileResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateReleaseResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateWorkResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -/// API -pub trait Api { - fn accept_editgroup(&self, id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>; - - fn create_container(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; - - fn create_container_batch( - &self, - entity_list: &Vec<models::ContainerEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send>; - - fn create_creator(&self, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; - - fn create_creator_batch( - &self, - entity_list: &Vec<models::CreatorEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send>; - - fn create_editgroup(&self, entity: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>; - - fn create_file(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; - - fn create_file_batch( - &self, - entity_list: &Vec<models::FileEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send>; - - fn create_release(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; - - fn create_release_batch( - &self, - entity_list: &Vec<models::ReleaseEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send>; - - fn create_work(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; - - fn create_work_batch( - &self, - entity_list: &Vec<models::WorkEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - context: &Context, - ) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send>; - - fn delete_container(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteContainerResponse, Error = ApiError> + Send>; - - fn delete_creator(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>; - - fn delete_file(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteFileResponse, Error = ApiError> + Send>; - - fn delete_release(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>; - - fn delete_work(&self, id: String, editgroup: Option<String>, context: &Context) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send>; - - fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>; - - fn get_changelog_entry(&self, id: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>; - - fn get_container(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send>; - - fn get_container_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>; - - fn get_creator(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send>; - - fn get_creator_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>; - - fn get_creator_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>; - - fn get_editgroup(&self, id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>; - - fn get_editor(&self, id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send>; - - fn get_editor_changelog(&self, id: String, context: &Context) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send>; - - fn get_file(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send>; - - fn get_file_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>; - - fn get_release(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send>; - - fn get_release_files(&self, id: String, context: &Context) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>; - - fn get_release_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>; - - fn get_stats(&self, more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send>; - - fn get_work(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send>; - - fn get_work_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>; - - fn get_work_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>; - - fn lookup_container(&self, issnl: String, context: &Context) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send>; - - fn lookup_creator(&self, orcid: String, context: &Context) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send>; - - fn lookup_file(&self, sha1: String, context: &Context) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send>; - - fn lookup_release(&self, doi: String, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send>; - - fn update_container(&self, id: String, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; - - fn update_creator(&self, id: String, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; - - fn update_file(&self, id: String, entity: models::FileEntity, context: &Context) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; - - fn update_release(&self, id: String, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; - - fn update_work(&self, id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; -} - -/// API without a `Context` -pub trait ApiNoContext { - fn accept_editgroup(&self, id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>; - - fn create_container(&self, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>; - - fn create_container_batch( - &self, - entity_list: &Vec<models::ContainerEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send>; - - fn create_creator(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send>; - - fn create_creator_batch( - &self, - entity_list: &Vec<models::CreatorEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send>; - - fn create_editgroup(&self, entity: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>; - - fn create_file(&self, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>; - - fn create_file_batch(&self, entity_list: &Vec<models::FileEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send>; - - fn create_release(&self, entity: models::ReleaseEntity) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send>; - - fn create_release_batch( - &self, - entity_list: &Vec<models::ReleaseEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send>; - - fn create_work(&self, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>; - - fn create_work_batch(&self, entity_list: &Vec<models::WorkEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send>; - - fn delete_container(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteContainerResponse, Error = ApiError> + Send>; - - fn delete_creator(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>; - - fn delete_file(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteFileResponse, Error = ApiError> + Send>; - - fn delete_release(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>; - - fn delete_work(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send>; - - fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>; - - fn get_changelog_entry(&self, id: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>; - - fn get_container(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send>; - - fn get_container_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>; - - fn get_creator(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send>; - - fn get_creator_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>; - - fn get_creator_releases(&self, id: String) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>; - - fn get_editgroup(&self, id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>; - - fn get_editor(&self, id: String) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send>; - - fn get_editor_changelog(&self, id: String) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send>; - - fn get_file(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send>; - - fn get_file_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>; - - fn get_release(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send>; - - fn get_release_files(&self, id: String) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>; - - fn get_release_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>; - - fn get_stats(&self, more: Option<String>) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send>; - - fn get_work(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send>; - - fn get_work_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>; - - fn get_work_releases(&self, id: String) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>; - - fn lookup_container(&self, issnl: String) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send>; - - fn lookup_creator(&self, orcid: String) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send>; - - fn lookup_file(&self, sha1: String) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send>; - - fn lookup_release(&self, doi: String) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send>; - - fn update_container(&self, id: String, entity: models::ContainerEntity) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send>; - - fn update_creator(&self, id: String, entity: models::CreatorEntity) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>; - - fn update_file(&self, id: String, entity: models::FileEntity) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send>; - - fn update_release(&self, id: String, entity: models::ReleaseEntity) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>; - - fn update_work(&self, id: String, entity: models::WorkEntity) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send>; -} - -/// Trait to extend an API to make it easy to bind it to a context. -pub trait ContextWrapperExt<'a> -where - Self: Sized, -{ - /// Binds this API to a context. - fn with_context(self: &'a Self, context: Context) -> ContextWrapper<'a, Self>; -} - -impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T { - fn with_context(self: &'a T, context: Context) -> ContextWrapper<'a, T> { - ContextWrapper::<T>::new(self, context) - } -} - -impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { - fn accept_editgroup(&self, id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> { - self.api().accept_editgroup(id, &self.context()) - } - - fn create_container(&self, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> { - self.api().create_container(entity, &self.context()) - } - - fn create_container_batch( - &self, - entity_list: &Vec<models::ContainerEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send> { - self.api().create_container_batch(entity_list, autoaccept, editgroup, &self.context()) - } - - fn create_creator(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreateCreatorResponse, Error = ApiError> + Send> { - self.api().create_creator(entity, &self.context()) - } - - fn create_creator_batch( - &self, - entity_list: &Vec<models::CreatorEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send> { - self.api().create_creator_batch(entity_list, autoaccept, editgroup, &self.context()) - } - - fn create_editgroup(&self, entity: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> { - self.api().create_editgroup(entity, &self.context()) - } - - fn create_file(&self, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> { - self.api().create_file(entity, &self.context()) - } - - fn create_file_batch(&self, entity_list: &Vec<models::FileEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { - self.api().create_file_batch(entity_list, autoaccept, editgroup, &self.context()) - } - - fn create_release(&self, entity: models::ReleaseEntity) -> Box<Future<Item = CreateReleaseResponse, Error = ApiError> + Send> { - self.api().create_release(entity, &self.context()) - } - - fn create_release_batch( - &self, - entity_list: &Vec<models::ReleaseEntity>, - autoaccept: Option<bool>, - editgroup: Option<String>, - ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send> { - self.api().create_release_batch(entity_list, autoaccept, editgroup, &self.context()) - } - - fn create_work(&self, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> { - self.api().create_work(entity, &self.context()) - } - - fn create_work_batch(&self, entity_list: &Vec<models::WorkEntity>, autoaccept: Option<bool>, editgroup: Option<String>) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { - self.api().create_work_batch(entity_list, autoaccept, editgroup, &self.context()) - } - - fn delete_container(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteContainerResponse, Error = ApiError> + Send> { - self.api().delete_container(id, editgroup, &self.context()) - } - - fn delete_creator(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> { - self.api().delete_creator(id, editgroup, &self.context()) - } - - fn delete_file(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteFileResponse, Error = ApiError> + Send> { - self.api().delete_file(id, editgroup, &self.context()) - } - - fn delete_release(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> { - self.api().delete_release(id, editgroup, &self.context()) - } - - fn delete_work(&self, id: String, editgroup: Option<String>) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send> { - self.api().delete_work(id, editgroup, &self.context()) - } - - fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> { - self.api().get_changelog(limit, &self.context()) - } - - fn get_changelog_entry(&self, id: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> { - self.api().get_changelog_entry(id, &self.context()) - } - - fn get_container(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send> { - self.api().get_container(id, expand, &self.context()) - } - - fn get_container_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> { - self.api().get_container_history(id, limit, &self.context()) - } - - fn get_creator(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send> { - self.api().get_creator(id, expand, &self.context()) - } - - fn get_creator_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> { - self.api().get_creator_history(id, limit, &self.context()) - } - - fn get_creator_releases(&self, id: String) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> { - self.api().get_creator_releases(id, &self.context()) - } - - fn get_editgroup(&self, id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> { - self.api().get_editgroup(id, &self.context()) - } - - fn get_editor(&self, id: String) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> { - self.api().get_editor(id, &self.context()) - } - - fn get_editor_changelog(&self, id: String) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send> { - self.api().get_editor_changelog(id, &self.context()) - } - - fn get_file(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send> { - self.api().get_file(id, expand, &self.context()) - } - - fn get_file_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> { - self.api().get_file_history(id, limit, &self.context()) - } - - fn get_release(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> { - self.api().get_release(id, expand, &self.context()) - } - - fn get_release_files(&self, id: String) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> { - self.api().get_release_files(id, &self.context()) - } - - fn get_release_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> { - self.api().get_release_history(id, limit, &self.context()) - } - - fn get_stats(&self, more: Option<String>) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> { - self.api().get_stats(more, &self.context()) - } - - fn get_work(&self, id: String, expand: Option<String>) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send> { - self.api().get_work(id, expand, &self.context()) - } - - fn get_work_history(&self, id: String, limit: Option<i64>) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> { - self.api().get_work_history(id, limit, &self.context()) - } - - fn get_work_releases(&self, id: String) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> { - self.api().get_work_releases(id, &self.context()) - } - - fn lookup_container(&self, issnl: String) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> { - self.api().lookup_container(issnl, &self.context()) - } - - fn lookup_creator(&self, orcid: String) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send> { - self.api().lookup_creator(orcid, &self.context()) - } - - fn lookup_file(&self, sha1: String) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send> { - self.api().lookup_file(sha1, &self.context()) - } - - fn lookup_release(&self, doi: String) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> { - self.api().lookup_release(doi, &self.context()) - } - - fn update_container(&self, id: String, entity: models::ContainerEntity) -> Box<Future<Item = UpdateContainerResponse, Error = ApiError> + Send> { - self.api().update_container(id, entity, &self.context()) - } - - fn update_creator(&self, id: String, entity: models::CreatorEntity) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> { - self.api().update_creator(id, entity, &self.context()) - } - - fn update_file(&self, id: String, entity: models::FileEntity) -> Box<Future<Item = UpdateFileResponse, Error = ApiError> + Send> { - self.api().update_file(id, entity, &self.context()) - } - - fn update_release(&self, id: String, entity: models::ReleaseEntity) -> Box<Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> { - self.api().update_release(id, entity, &self.context()) - } - - fn update_work(&self, id: String, entity: models::WorkEntity) -> Box<Future<Item = UpdateWorkResponse, Error = ApiError> + Send> { - self.api().update_work(id, entity, &self.context()) - } -} - -#[cfg(feature = "client")] -pub mod client; - -// Re-export Client as a top-level name -#[cfg(feature = "client")] -pub use self::client::Client; - -#[cfg(feature = "server")] -pub mod server; - -// Re-export router() as a top-level name -#[cfg(feature = "server")] -pub use self::server::router; - -pub mod models; diff --git a/rust/fatcat-api/src/mimetypes.rs b/rust/fatcat-api/src/mimetypes.rs deleted file mode 100644 index ff2c12ce..00000000 --- a/rust/fatcat-api/src/mimetypes.rs +++ /dev/null @@ -1,777 +0,0 @@ -/// mime types for requests and responses - -pub mod responses { - use hyper::mime::*; - - // The macro is called per-operation to beat the recursion limit - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_EDIT_CONFLICT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerBatch - lazy_static! { - pub static ref CREATE_CONTAINER_BATCH_CREATED_ENTITIES: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerBatch - lazy_static! { - pub static ref CREATE_CONTAINER_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerBatch - lazy_static! { - pub static ref CREATE_CONTAINER_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerBatch - lazy_static! { - pub static ref CREATE_CONTAINER_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorBatch - lazy_static! { - pub static ref CREATE_CREATOR_BATCH_CREATED_ENTITIES: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorBatch - lazy_static! { - pub static ref CREATE_CREATOR_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorBatch - lazy_static! { - pub static ref CREATE_CREATOR_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorBatch - lazy_static! { - pub static ref CREATE_CREATOR_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP_SUCCESSFULLY_CREATED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileBatch - lazy_static! { - pub static ref CREATE_FILE_BATCH_CREATED_ENTITIES: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileBatch - lazy_static! { - pub static ref CREATE_FILE_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileBatch - lazy_static! { - pub static ref CREATE_FILE_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileBatch - lazy_static! { - pub static ref CREATE_FILE_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseBatch - lazy_static! { - pub static ref CREATE_RELEASE_BATCH_CREATED_ENTITIES: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseBatch - lazy_static! { - pub static ref CREATE_RELEASE_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseBatch - lazy_static! { - pub static ref CREATE_RELEASE_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseBatch - lazy_static! { - pub static ref CREATE_RELEASE_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkBatch - lazy_static! { - pub static ref CREATE_WORK_BATCH_CREATED_ENTITIES: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkBatch - lazy_static! { - pub static ref CREATE_WORK_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkBatch - lazy_static! { - pub static ref CREATE_WORK_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkBatch - lazy_static! { - pub static ref CREATE_WORK_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainer - lazy_static! { - pub static ref DELETE_CONTAINER_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainer - lazy_static! { - pub static ref DELETE_CONTAINER_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainer - lazy_static! { - pub static ref DELETE_CONTAINER_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainer - lazy_static! { - pub static ref DELETE_CONTAINER_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreator - lazy_static! { - pub static ref DELETE_CREATOR_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreator - lazy_static! { - pub static ref DELETE_CREATOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreator - lazy_static! { - pub static ref DELETE_CREATOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreator - lazy_static! { - pub static ref DELETE_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFile - lazy_static! { - pub static ref DELETE_FILE_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFile - lazy_static! { - pub static ref DELETE_FILE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFile - lazy_static! { - pub static ref DELETE_FILE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFile - lazy_static! { - pub static ref DELETE_FILE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteRelease - lazy_static! { - pub static ref DELETE_RELEASE_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteRelease - lazy_static! { - pub static ref DELETE_RELEASE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteRelease - lazy_static! { - pub static ref DELETE_RELEASE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteRelease - lazy_static! { - pub static ref DELETE_RELEASE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWork - lazy_static! { - pub static ref DELETE_WORK_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWork - lazy_static! { - pub static ref DELETE_WORK_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWork - lazy_static! { - pub static ref DELETE_WORK_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWork - lazy_static! { - pub static ref DELETE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetChangelog - lazy_static! { - pub static ref GET_CHANGELOG_SUCCESS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetChangelog - lazy_static! { - pub static ref GET_CHANGELOG_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetChangelogEntry - lazy_static! { - pub static ref GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetChangelogEntry - lazy_static! { - pub static ref GET_CHANGELOG_ENTRY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetChangelogEntry - lazy_static! { - pub static ref GET_CHANGELOG_ENTRY_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); - } - /// Create Mime objects for the response content types for GetContainer - lazy_static! { - pub static ref GET_CONTAINER_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainer - lazy_static! { - pub static ref GET_CONTAINER_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainer - lazy_static! { - pub static ref GET_CONTAINER_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); - } - /// Create Mime objects for the response content types for GetContainerHistory - lazy_static! { - pub static ref GET_CONTAINER_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerHistory - lazy_static! { - pub static ref GET_CONTAINER_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerHistory - lazy_static! { - pub static ref GET_CONTAINER_HISTORY_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); - } - /// Create Mime objects for the response content types for GetCreator - lazy_static! { - pub static ref GET_CREATOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreator - lazy_static! { - pub static ref GET_CREATOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreator - lazy_static! { - pub static ref GET_CREATOR_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); - } - /// Create Mime objects for the response content types for GetCreatorHistory - lazy_static! { - pub static ref GET_CREATOR_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorHistory - lazy_static! { - pub static ref GET_CREATOR_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorHistory - lazy_static! { - pub static ref GET_CREATOR_HISTORY_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); - } - /// Create Mime objects for the response content types for GetCreatorReleases - lazy_static! { - pub static ref GET_CREATOR_RELEASES_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorReleases - lazy_static! { - pub static ref GET_CREATOR_RELEASES_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorReleases - lazy_static! { - pub static ref GET_CREATOR_RELEASES_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroup - lazy_static! { - pub static ref GET_EDITGROUP_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroup - lazy_static! { - pub static ref GET_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroup - lazy_static! { - pub static ref GET_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroup - lazy_static! { - pub static ref GET_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditor - lazy_static! { - pub static ref GET_EDITOR_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditor - lazy_static! { - pub static ref GET_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditor - lazy_static! { - pub static ref GET_EDITOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditor - lazy_static! { - pub static ref GET_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorChangelog - lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorChangelog - lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorChangelog - lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorChangelog - lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_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); - } - /// Create Mime objects for the response content types for GetFile - lazy_static! { - pub static ref GET_FILE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFile - lazy_static! { - pub static ref GET_FILE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFile - lazy_static! { - pub static ref GET_FILE_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); - } - /// Create Mime objects for the response content types for GetFileHistory - lazy_static! { - pub static ref GET_FILE_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileHistory - lazy_static! { - pub static ref GET_FILE_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileHistory - lazy_static! { - pub static ref GET_FILE_HISTORY_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); - } - /// Create Mime objects for the response content types for GetRelease - lazy_static! { - pub static ref GET_RELEASE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetRelease - lazy_static! { - pub static ref GET_RELEASE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetRelease - lazy_static! { - pub static ref GET_RELEASE_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); - } - /// Create Mime objects for the response content types for GetReleaseFiles - lazy_static! { - pub static ref GET_RELEASE_FILES_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFiles - lazy_static! { - pub static ref GET_RELEASE_FILES_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFiles - lazy_static! { - pub static ref GET_RELEASE_FILES_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseHistory - lazy_static! { - pub static ref GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseHistory - lazy_static! { - pub static ref GET_RELEASE_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseHistory - lazy_static! { - pub static ref GET_RELEASE_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseHistory - lazy_static! { - pub static ref GET_RELEASE_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetStats - lazy_static! { - pub static ref GET_STATS_SUCCESS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetStats - lazy_static! { - pub static ref GET_STATS_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); - } - /// Create Mime objects for the response content types for GetWork - lazy_static! { - pub static ref GET_WORK_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWork - lazy_static! { - pub static ref GET_WORK_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWork - lazy_static! { - pub static ref GET_WORK_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); - } - /// Create Mime objects for the response content types for GetWorkHistory - lazy_static! { - pub static ref GET_WORK_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkHistory - lazy_static! { - pub static ref GET_WORK_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkHistory - lazy_static! { - pub static ref GET_WORK_HISTORY_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); - } - /// Create Mime objects for the response content types for GetWorkReleases - lazy_static! { - pub static ref GET_WORK_RELEASES_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkReleases - lazy_static! { - pub static ref GET_WORK_RELEASES_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkReleases - lazy_static! { - pub static ref GET_WORK_RELEASES_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); - } - /// Create Mime objects for the response content types for LookupContainer - lazy_static! { - pub static ref LOOKUP_CONTAINER_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupContainer - lazy_static! { - pub static ref LOOKUP_CONTAINER_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupContainer - lazy_static! { - pub static ref LOOKUP_CONTAINER_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); - } - /// Create Mime objects for the response content types for LookupCreator - lazy_static! { - pub static ref LOOKUP_CREATOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupCreator - lazy_static! { - pub static ref LOOKUP_CREATOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupCreator - lazy_static! { - pub static ref LOOKUP_CREATOR_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); - } - /// Create Mime objects for the response content types for LookupFile - lazy_static! { - pub static ref LOOKUP_FILE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupFile - lazy_static! { - pub static ref LOOKUP_FILE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupFile - lazy_static! { - pub static ref LOOKUP_FILE_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); - } - /// Create Mime objects for the response content types for LookupRelease - lazy_static! { - pub static ref LOOKUP_RELEASE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupRelease - lazy_static! { - pub static ref LOOKUP_RELEASE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupRelease - lazy_static! { - pub static ref LOOKUP_RELEASE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE_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); - } - /// Create Mime objects for the response content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json); - } - -} - -pub mod requests { - use hyper::mime::*; - /// Create Mime objects for the request content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateContainerBatch - lazy_static! { - pub static ref CREATE_CONTAINER_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateCreatorBatch - lazy_static! { - pub static ref CREATE_CREATOR_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateFileBatch - lazy_static! { - pub static ref CREATE_FILE_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateReleaseBatch - lazy_static! { - pub static ref CREATE_RELEASE_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateWorkBatch - lazy_static! { - pub static ref CREATE_WORK_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK: Mime = mime!(Application / Json); - } - -} diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs deleted file mode 100644 index 81701b70..00000000 --- a/rust/fatcat-api/src/models.rs +++ /dev/null @@ -1,786 +0,0 @@ -#![allow(unused_imports, unused_qualifications, unused_extern_crates)] -extern crate chrono; -extern crate serde_json; -extern crate uuid; - -use serde::ser::Serializer; - -use models; -use std::collections::HashMap; -use swagger; - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ChangelogEntry { - #[serde(rename = "index")] - pub index: i64, - - #[serde(rename = "editgroup_id")] - pub editgroup_id: String, - - #[serde(rename = "timestamp")] - pub timestamp: chrono::DateTime<chrono::Utc>, - - #[serde(rename = "editgroup")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup: Option<models::Editgroup>, -} - -impl ChangelogEntry { - pub fn new(index: i64, editgroup_id: String, timestamp: chrono::DateTime<chrono::Utc>) -> ChangelogEntry { - ChangelogEntry { - index: index, - editgroup_id: editgroup_id, - timestamp: timestamp, - editgroup: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ContainerEntity { - #[serde(rename = "coden")] - #[serde(skip_serializing_if = "Option::is_none")] - pub coden: Option<String>, - - #[serde(rename = "abbrev")] - #[serde(skip_serializing_if = "Option::is_none")] - pub abbrev: Option<String>, - - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option<String>, - - #[serde(rename = "issnl")] - #[serde(skip_serializing_if = "Option::is_none")] - pub issnl: Option<String>, - - #[serde(rename = "publisher")] - #[serde(skip_serializing_if = "Option::is_none")] - pub publisher: Option<String>, - - #[serde(rename = "name")] - pub name: String, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option<String>, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option<String>, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<String>, -} - -impl ContainerEntity { - pub fn new(name: String) -> ContainerEntity { - ContainerEntity { - coden: None, - abbrev: None, - wikidata_qid: None, - issnl: None, - publisher: None, - name: name, - extra: None, - editgroup_id: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct CreatorEntity { - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option<String>, - - #[serde(rename = "orcid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub orcid: Option<String>, - - #[serde(rename = "surname")] - #[serde(skip_serializing_if = "Option::is_none")] - pub surname: Option<String>, - - #[serde(rename = "given_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub given_name: Option<String>, - - #[serde(rename = "display_name")] - pub display_name: String, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option<String>, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, -} - -impl CreatorEntity { - pub fn new(display_name: String) -> CreatorEntity { - CreatorEntity { - wikidata_qid: None, - orcid: None, - surname: None, - given_name: None, - display_name: display_name, - state: None, - ident: None, - revision: None, - redirect: None, - editgroup_id: None, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Editgroup { - /// base32-encoded unique identifier - #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub id: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "editor_id")] - pub editor_id: String, - - #[serde(rename = "description")] - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<String>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - #[serde(rename = "edits")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edits: Option<models::EditgroupEdits>, -} - -impl Editgroup { - pub fn new(editor_id: String) -> Editgroup { - Editgroup { - id: None, - editor_id: editor_id, - description: None, - extra: None, - edits: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EditgroupEdits { - #[serde(rename = "containers")] - #[serde(skip_serializing_if = "Option::is_none")] - pub containers: Option<Vec<models::EntityEdit>>, - - #[serde(rename = "creators")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creators: Option<Vec<models::EntityEdit>>, - - #[serde(rename = "files")] - #[serde(skip_serializing_if = "Option::is_none")] - pub files: Option<Vec<models::EntityEdit>>, - - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option<Vec<models::EntityEdit>>, - - #[serde(rename = "works")] - #[serde(skip_serializing_if = "Option::is_none")] - pub works: Option<Vec<models::EntityEdit>>, -} - -impl EditgroupEdits { - pub fn new() -> EditgroupEdits { - EditgroupEdits { - containers: None, - creators: None, - files: None, - releases: None, - works: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Editor { - #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub id: Option<String>, - - #[serde(rename = "username")] - pub username: String, -} - -impl Editor { - pub fn new(username: String) -> Editor { - Editor { id: None, username: username } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EntityEdit { - #[serde(rename = "edit_id")] - pub edit_id: i64, - - #[serde(rename = "ident")] - pub ident: String, - - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - #[serde(rename = "prev_revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prev_revision: Option<String>, - - #[serde(rename = "redirect_ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect_ident: Option<String>, - - #[serde(rename = "editgroup_id")] - pub editgroup_id: String, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, -} - -impl EntityEdit { - pub fn new(edit_id: i64, ident: String, editgroup_id: String) -> EntityEdit { - EntityEdit { - edit_id: edit_id, - ident: ident, - revision: None, - prev_revision: None, - redirect_ident: None, - editgroup_id: editgroup_id, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EntityHistoryEntry { - #[serde(rename = "edit")] - pub edit: models::EntityEdit, - - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "changelog_entry")] - pub changelog_entry: models::ChangelogEntry, -} - -impl EntityHistoryEntry { - pub fn new(edit: models::EntityEdit, editgroup: models::Editgroup, changelog_entry: models::ChangelogEntry) -> EntityHistoryEntry { - EntityHistoryEntry { - edit: edit, - editgroup: editgroup, - changelog_entry: changelog_entry, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ErrorResponse { - #[serde(rename = "message")] - pub message: String, -} - -impl ErrorResponse { - pub fn new(message: String) -> ErrorResponse { - ErrorResponse { message: message } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FileEntity { - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option<Vec<String>>, - - #[serde(rename = "mimetype")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mimetype: Option<String>, - - #[serde(rename = "urls")] - #[serde(skip_serializing_if = "Option::is_none")] - pub urls: Option<Vec<models::FileEntityUrls>>, - - #[serde(rename = "sha256")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha256: Option<String>, - - #[serde(rename = "md5")] - #[serde(skip_serializing_if = "Option::is_none")] - pub md5: Option<String>, - - #[serde(rename = "sha1")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha1: Option<String>, - - #[serde(rename = "size")] - #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option<i64>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option<String>, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option<String>, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<String>, -} - -impl FileEntity { - pub fn new() -> FileEntity { - FileEntity { - releases: None, - mimetype: None, - urls: None, - sha256: None, - md5: None, - sha1: None, - size: None, - extra: None, - editgroup_id: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FileEntityUrls { - #[serde(rename = "url")] - pub url: String, - - #[serde(rename = "rel")] - pub rel: String, -} - -impl FileEntityUrls { - pub fn new(url: String, rel: String) -> FileEntityUrls { - FileEntityUrls { url: url, rel: rel } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseContrib { - #[serde(rename = "index")] - #[serde(skip_serializing_if = "Option::is_none")] - pub index: Option<i64>, - - #[serde(rename = "creator_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creator_id: Option<String>, - - /// Optional; GET-only - #[serde(rename = "creator")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creator: Option<models::CreatorEntity>, - - #[serde(rename = "raw_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub raw_name: Option<String>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - #[serde(rename = "role")] - #[serde(skip_serializing_if = "Option::is_none")] - pub role: Option<String>, -} - -impl ReleaseContrib { - pub fn new() -> ReleaseContrib { - ReleaseContrib { - index: None, - creator_id: None, - creator: None, - raw_name: None, - extra: None, - role: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseEntity { - #[serde(rename = "abstracts")] - #[serde(skip_serializing_if = "Option::is_none")] - pub abstracts: Option<Vec<models::ReleaseEntityAbstracts>>, - - #[serde(rename = "refs")] - #[serde(skip_serializing_if = "Option::is_none")] - pub refs: Option<Vec<models::ReleaseRef>>, - - #[serde(rename = "contribs")] - #[serde(skip_serializing_if = "Option::is_none")] - pub contribs: Option<Vec<models::ReleaseContrib>>, - - /// Two-letter RFC1766/ISO639-1 language code, with extensions - #[serde(rename = "language")] - #[serde(skip_serializing_if = "Option::is_none")] - pub language: Option<String>, - - #[serde(rename = "publisher")] - #[serde(skip_serializing_if = "Option::is_none")] - pub publisher: Option<String>, - - #[serde(rename = "pages")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pages: Option<String>, - - #[serde(rename = "issue")] - #[serde(skip_serializing_if = "Option::is_none")] - pub issue: Option<String>, - - #[serde(rename = "volume")] - #[serde(skip_serializing_if = "Option::is_none")] - pub volume: Option<String>, - - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option<String>, - - #[serde(rename = "pmcid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmcid: Option<String>, - - #[serde(rename = "pmid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmid: Option<String>, - - #[serde(rename = "core_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub core_id: Option<String>, - - #[serde(rename = "isbn13")] - #[serde(skip_serializing_if = "Option::is_none")] - pub isbn13: Option<String>, - - #[serde(rename = "doi")] - #[serde(skip_serializing_if = "Option::is_none")] - pub doi: Option<String>, - - #[serde(rename = "release_date")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_date: Option<chrono::DateTime<chrono::Utc>>, - - #[serde(rename = "release_status")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_status: Option<String>, - - #[serde(rename = "release_type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_type: Option<String>, - - #[serde(rename = "container_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container_id: Option<String>, - - /// Optional; GET-only - #[serde(rename = "files")] - #[serde(skip_serializing_if = "Option::is_none")] - pub files: Option<Vec<models::FileEntity>>, - - /// Optional; GET-only - #[serde(rename = "container")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container: Option<models::ContainerEntity>, - - #[serde(rename = "work_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub work_id: Option<String>, - - #[serde(rename = "title")] - pub title: String, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option<String>, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, -} - -impl ReleaseEntity { - pub fn new(title: String) -> ReleaseEntity { - ReleaseEntity { - abstracts: None, - refs: None, - contribs: None, - language: None, - publisher: None, - pages: None, - issue: None, - volume: None, - wikidata_qid: None, - pmcid: None, - pmid: None, - core_id: None, - isbn13: None, - doi: None, - release_date: None, - release_status: None, - release_type: None, - container_id: None, - files: None, - container: None, - work_id: None, - title: title, - state: None, - ident: None, - revision: None, - redirect: None, - editgroup_id: None, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseEntityAbstracts { - #[serde(rename = "sha1")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha1: Option<String>, - - #[serde(rename = "content")] - #[serde(skip_serializing_if = "Option::is_none")] - pub content: Option<String>, - - #[serde(rename = "mimetype")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mimetype: Option<String>, - - #[serde(rename = "lang")] - #[serde(skip_serializing_if = "Option::is_none")] - pub lang: Option<String>, -} - -impl ReleaseEntityAbstracts { - pub fn new() -> ReleaseEntityAbstracts { - ReleaseEntityAbstracts { - sha1: None, - content: None, - mimetype: None, - lang: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseRef { - #[serde(rename = "index")] - #[serde(skip_serializing_if = "Option::is_none")] - pub index: Option<i64>, - - #[serde(rename = "target_release_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub target_release_id: Option<String>, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - #[serde(rename = "key")] - #[serde(skip_serializing_if = "Option::is_none")] - pub key: Option<String>, - - #[serde(rename = "year")] - #[serde(skip_serializing_if = "Option::is_none")] - pub year: Option<i64>, - - #[serde(rename = "container_title")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container_title: Option<String>, - - #[serde(rename = "title")] - #[serde(skip_serializing_if = "Option::is_none")] - pub title: Option<String>, - - #[serde(rename = "locator")] - #[serde(skip_serializing_if = "Option::is_none")] - pub locator: Option<String>, -} - -impl ReleaseRef { - pub fn new() -> ReleaseRef { - ReleaseRef { - index: None, - target_release_id: None, - extra: None, - key: None, - year: None, - container_title: None, - title: None, - locator: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct StatsResponse { - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, -} - -impl StatsResponse { - pub fn new() -> StatsResponse { - StatsResponse { extra: None } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Success { - #[serde(rename = "message")] - pub message: String, -} - -impl Success { - pub fn new(message: String) -> Success { - Success { message: message } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WorkEntity { - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option<String>, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option<String>, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option<String>, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<String>, -} - -impl WorkEntity { - pub fn new() -> WorkEntity { - WorkEntity { - extra: None, - editgroup_id: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs deleted file mode 100644 index dfc94a81..00000000 --- a/rust/fatcat-api/src/server.rs +++ /dev/null @@ -1,4415 +0,0 @@ -#![allow(unused_extern_crates)] -extern crate bodyparser; -extern crate chrono; -extern crate iron; -extern crate router; -extern crate serde_ignored; -extern crate urlencoded; -extern crate uuid; - -use self::iron::prelude::*; -use self::iron::url::percent_encoding::percent_decode; -use self::iron::{modifiers, status, BeforeMiddleware}; -use self::router::Router; -use self::urlencoded::UrlEncodedQuery; -use futures::future; -use futures::Future; -use futures::{stream, Stream}; -use hyper; -use hyper::header::{ContentType, Headers}; -use mimetypes; - -use serde_json; - -#[allow(unused_imports)] -use std::collections::{BTreeMap, HashMap}; -use std::io::Error; -#[allow(unused_imports)] -use swagger; - -#[allow(unused_imports)] -use std::collections::BTreeSet; - -pub use swagger::auth::Authorization; -use swagger::auth::{AuthData, Scopes}; -use swagger::{ApiError, Context, XSpanId}; - -#[allow(unused_imports)] -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, -}; - -header! { (Warning, "Warning") => [String] } - -/// Create a new router for `Api` -pub fn router<T>(api: T) -> Router -where - T: Api + Send + Sync + Clone + 'static, -{ - let mut router = Router::new(); - add_routes(&mut router, api); - router -} - -/// Add routes for `Api` to a provided router. -/// -/// Note that these routes are added straight onto the router. This means that if the router -/// already has a route for an endpoint which clashes with those provided by this API, then the -/// old route will be lost. -/// -/// It is generally a bad idea to add routes in this way to an existing router, which may have -/// routes on it for other APIs. Distinct APIs should be behind distinct paths to encourage -/// separation of interfaces, which this function does not enforce. APIs should not overlap. -/// -/// Alternative approaches include: -/// -/// - generate an `iron::middleware::Handler` (usually a `router::Router` or -/// `iron::middleware::chain`) for each interface, and add those handlers inside an existing -/// router, mounted at different paths - so the interfaces are separated by path -/// - use a different instance of `iron::Iron` for each interface - so the interfaces are -/// separated by the address/port they listen on -/// -/// This function exists to allow legacy code, which doesn't separate its APIs properly, to make -/// use of this crate. -#[deprecated(note = "APIs should not overlap - only for use in legacy code.")] -pub fn route<T>(router: &mut Router, api: T) -where - T: Api + Send + Sync + Clone + 'static, -{ - add_routes(router, api) -} - -/// Add routes for `Api` to a provided router -fn add_routes<T>(router: &mut Router, api: T) -where - T: Api + Send + Sync + Clone + 'static, -{ - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:id/accept", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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.accept_editgroup(param_id, context).wait() { - Ok(rsp) => match rsp { - 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::ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::ACCEPT_EDITGROUP_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::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())); - - 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::ACCEPT_EDITGROUP_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) - }) - }, - "AcceptEditgroup", - ); - - let api_clone = api.clone(); - router.post( - "/v0/container", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::ContainerEntity> = - 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_container(param_entity, context).wait() { - Ok(rsp) => match rsp { - CreateContainerResponse::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_CONTAINER_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) - } - CreateContainerResponse::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_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) - } - CreateContainerResponse::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_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) - } - CreateContainerResponse::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_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) - } - }, - 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) - }) - }, - "CreateContainer", - ); - - let api_clone = api.clone(); - router.post( - "/v0/container/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::<bool>().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_entity_list = req.get::<bodyparser::Raw>() - .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<Vec<models::ContainerEntity>> = - 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_container_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - CreateContainerBatchResponse::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_CONTAINER_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) - } - CreateContainerBatchResponse::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_CONTAINER_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) - } - CreateContainerBatchResponse::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_CONTAINER_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) - } - CreateContainerBatchResponse::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_CONTAINER_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) - }) - }, - "CreateContainerBatch", - ); - - let api_clone = api.clone(); - router.post( - "/v0/creator", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::CreatorEntity> = - 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, context).wait() { - Ok(rsp) => match rsp { - 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(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) - } - 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::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) - } - 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::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) - } - 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::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) - } - }, - 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) - }) - }, - "CreateCreator", - ); - - let api_clone = api.clone(); - router.post( - "/v0/creator/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::<bool>().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_entity_list = req.get::<bodyparser::Raw>() - .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<Vec<models::CreatorEntity>> = - 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) - } - 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) => { - 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())); - - 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) => { - 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())); - - 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) - }) - }, - "CreateCreatorBatch", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::Editgroup> = 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_editgroup(param_entity, 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(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) - } - 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(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) - } - 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.post( - "/v0/file", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::FileEntity> = - 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_file(param_entity, context).wait() { - Ok(rsp) => match rsp { - 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_FILE_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) - } - 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_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) - } - 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_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) - } - 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_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) - }) - }, - "CreateFile", - ); - - let api_clone = api.clone(); - router.post( - "/v0/file/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::<bool>().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_entity_list = req.get::<bodyparser::Raw>() - .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<Vec<models::FileEntity>> = - 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_file_batch(param_entity_list.as_ref(), param_autoaccept, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - 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_FILE_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) - } - 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_FILE_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) - } - 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_FILE_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) - } - 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_FILE_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) - }) - }, - "CreateFileBatch", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::ReleaseEntity> = - 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, 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::<bool>().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_entity_list = req.get::<bodyparser::Raw>() - .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<Vec<models::ReleaseEntity>> = - 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(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // 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::<bodyparser::Raw>() - .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<models::WorkEntity> = - 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, 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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_autoaccept = query_params.get("autoaccept").and_then(|list| list.first()).and_then(|x| x.parse::<bool>().ok()); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_entity_list = req.get::<bodyparser::Raw>() - .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<Vec<models::WorkEntity>> = - 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) - } - }, - 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) - }) - }, - "CreateWorkBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/container/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.delete_container(param_id, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - DeleteContainerResponse::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_CONTAINER_DELETED_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerResponse::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_CONTAINER_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerResponse::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_CONTAINER_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerResponse::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_CONTAINER_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) - }) - }, - "DeleteContainer", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/creator/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.delete_creator(param_id, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - 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::DELETE_CREATOR_DELETED_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_CREATOR_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_CREATOR_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_CREATOR_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) - }) - }, - "DeleteCreator", - ); - - let api_clone = api.clone(); - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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/work/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_editgroup = query_params.get("editgroup").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.delete_work(param_id, param_editgroup, context).wait() { - Ok(rsp) => match rsp { - 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::DELETE_WORK_DELETED_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_WORK_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_WORK_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::DELETE_WORK_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) - }) - }, - "DeleteWork", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().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(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_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"); - - 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())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetChangelogEntryResponse::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())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - 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/container/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_container(param_id, param_expand, context).wait() { - Ok(rsp) => match rsp { - 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_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_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) - }) - }, - "GetContainer", - ); - - let api_clone = api.clone(); - router.get( - "/v0/container/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().ok()); - - match api.get_container_history(param_id, param_limit, context).wait() { - Ok(rsp) => match rsp { - 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::GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_CONTAINER_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_CONTAINER_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_CONTAINER_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) - }) - }, - "GetContainerHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_creator(param_id, param_expand, context).wait() { - Ok(rsp) => match rsp { - 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_CREATOR_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_CREATOR_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_CREATOR_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_CREATOR_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) - }) - }, - "GetCreator", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().ok()); - - match api.get_creator_history(param_id, param_limit, context).wait() { - Ok(rsp) => match rsp { - 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_CREATOR_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_CREATOR_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) - }) - }, - "GetCreatorHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/:id/releases", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_creator_releases(param_id, context).wait() { - Ok(rsp) => match rsp { - 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(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()))); - - Ok(response) - } - 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::GET_CREATOR_RELEASES_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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(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) - } - 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_CREATOR_RELEASES_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) - }) - }, - "GetCreatorReleases", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_editgroup(param_id, context).wait() { - Ok(rsp) => match rsp { - 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::GET_EDITGROUP_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITGROUP_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITGROUP_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITGROUP_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) - }) - }, - "GetEditgroup", - ); - - let api_clone = api.clone(); - router.get( - "/v0/editor/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_editor(param_id, context).wait() { - Ok(rsp) => match rsp { - 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(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()))); - - Ok(response) - } - 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::GET_EDITOR_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITOR_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITOR_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) - }) - }, - "GetEditor", - ); - - let api_clone = api.clone(); - router.get( - "/v0/editor/:id/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_editor_changelog(param_id, context).wait() { - Ok(rsp) => match rsp { - 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::GET_EDITOR_CHANGELOG_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITOR_CHANGELOG_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITOR_CHANGELOG_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_EDITOR_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) - }) - }, - "GetEditorChangelog", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_file(param_id, param_expand, 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/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_release(param_id, param_expand, 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/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_files(param_id, context).wait() { - Ok(rsp) => match rsp { - 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(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()))); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().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/stats", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_more = query_params.get("more").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_stats(param_more, context).wait() { - Ok(rsp) => match rsp { - 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_STATS_SUCCESS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_STATS_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) - }) - }, - "GetStats", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok()); - - match api.get_work(param_id, param_expand, context).wait() { - Ok(rsp) => match rsp { - 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::GET_WORK_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_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) - }) - }, - "GetWork", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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::<UrlEncodedQuery>().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::<i64>().ok()); - - match api.get_work_history(param_id, param_limit, context).wait() { - Ok(rsp) => match rsp { - 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::GET_WORK_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::GET_WORK_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) - }) - }, - "GetWorkHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/:id/releases", - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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_work_releases(param_id, context).wait() { - Ok(rsp) => match rsp { - 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_RELEASES_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_RELEASES_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_RELEASES_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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_RELEASES_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) - }) - }, - "GetWorkReleases", - ); - - let api_clone = api.clone(); - router.get( - "/v0/container/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_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::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issnl - doesn't match schema: {}", e))))?; - - match api.lookup_container(param_issnl, context).wait() { - Ok(rsp) => match rsp { - 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::LOOKUP_CONTAINER_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CONTAINER_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CONTAINER_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CONTAINER_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) - }) - }, - "LookupContainer", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_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::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter orcid - doesn't match schema: {}", e))))?; - - match api.lookup_creator(param_orcid, context).wait() { - Ok(rsp) => match rsp { - 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::LOOKUP_CREATOR_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CREATOR_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CREATOR_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_CREATOR_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) - }) - }, - "LookupCreator", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_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::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter sha1 - doesn't match schema: {}", e))))?; - - match api.lookup_file(param_sha1, 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.get( - "/v0/release/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_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::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter doi - doesn't match schema: {}", e))))?; - - match api.lookup_release(param_doi, context).wait() { - Ok(rsp) => match rsp { - 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::LOOKUP_RELEASE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_RELEASE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_RELEASE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - 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::LOOKUP_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) - }) - }, - "LookupRelease", - ); - - let api_clone = api.clone(); - router.put( - "/v0/container/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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))))? - }; - - // 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::<bodyparser::Raw>() - .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<models::ContainerEntity> = - 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, context).wait() { - Ok(rsp) => match rsp { - 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::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) - } - 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::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) - } - 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::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) - } - 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::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) - } - }, - 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) - }) - }, - "UpdateContainer", - ); - - let api_clone = api.clone(); - router.put( - "/v0/creator/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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))))? - }; - - // 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::<bodyparser::Raw>() - .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<models::CreatorEntity> = - 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_creator(param_id, param_entity, context).wait() { - Ok(rsp) => match rsp { - 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(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() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - 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::UPDATE_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) - } - 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::UPDATE_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) - } - 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::UPDATE_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) - } - }, - 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) - }) - }, - "UpdateCreator", - ); - - 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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))))? - }; - - // 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::<bodyparser::Raw>() - .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<models::FileEntity> = - 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, 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.put( - "/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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))))? - }; - - // 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::<bodyparser::Raw>() - .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<models::ReleaseEntity> = - 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, context).wait() { - Ok(rsp) => match rsp { - 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::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) - } - 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::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) - } - 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::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) - } - 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::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.put( - "/v0/work/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response> - where - T: Api, - { - context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::<AuthData>(); - context.authorization = req.extensions.remove::<Authorization>(); - - // Path parameters - let param_id = { - let param = req.extensions - .get::<Router>() - .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))))? - }; - - // 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::<bodyparser::Raw>() - .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<models::WorkEntity> = - 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_work(param_id, param_entity, context).wait() { - Ok(rsp) => match rsp { - UpdateWorkResponse::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_WORK_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) - } - UpdateWorkResponse::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_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) - } - UpdateWorkResponse::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_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) - } - UpdateWorkResponse::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_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) - }) - }, - "UpdateWork", - ); -} - -/// Middleware to extract authentication data from request -pub struct ExtractAuthData; - -impl BeforeMiddleware for ExtractAuthData { - fn before(&self, req: &mut Request) -> IronResult<()> { - Ok(()) - } -} |