From ba722671b4791524384010705bef0aaa83c22c0b Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 5 Sep 2019 19:04:34 -0700 Subject: rename rust crate fatcat-api-spec -> fatcat-openapi --- rust/fatcat-api-spec/.cargo/config | 18 - rust/fatcat-api-spec/.gitignore | 2 - rust/fatcat-api-spec/Cargo.toml | 43 - rust/fatcat-api-spec/README.md | 198 - rust/fatcat-api-spec/api.yaml | 3129 ------ rust/fatcat-api-spec/api/swagger.yaml | 9627 ---------------- rust/fatcat-api-spec/examples/ca.pem | 17 - rust/fatcat-api-spec/examples/client.rs | 685 -- rust/fatcat-api-spec/examples/server-chain.pem | 66 - rust/fatcat-api-spec/examples/server-key.pem | 28 - rust/fatcat-api-spec/examples/server.rs | 64 - rust/fatcat-api-spec/examples/server_lib/mod.rs | 14 - rust/fatcat-api-spec/examples/server_lib/server.rs | 1057 -- rust/fatcat-api-spec/rustfmt.toml | 5 - rust/fatcat-api-spec/src/client.rs | 7664 ------------- rust/fatcat-api-spec/src/lib.rs | 2282 ---- rust/fatcat-api-spec/src/mimetypes.rs | 1973 ---- rust/fatcat-api-spec/src/models.rs | 1433 --- rust/fatcat-api-spec/src/server.rs | 10872 ------------------- 19 files changed, 39177 deletions(-) delete mode 100644 rust/fatcat-api-spec/.cargo/config delete mode 100644 rust/fatcat-api-spec/.gitignore delete mode 100644 rust/fatcat-api-spec/Cargo.toml delete mode 100644 rust/fatcat-api-spec/README.md delete mode 100644 rust/fatcat-api-spec/api.yaml delete mode 100644 rust/fatcat-api-spec/api/swagger.yaml delete mode 100644 rust/fatcat-api-spec/examples/ca.pem delete mode 100644 rust/fatcat-api-spec/examples/client.rs delete mode 100644 rust/fatcat-api-spec/examples/server-chain.pem delete mode 100644 rust/fatcat-api-spec/examples/server-key.pem delete mode 100644 rust/fatcat-api-spec/examples/server.rs delete mode 100644 rust/fatcat-api-spec/examples/server_lib/mod.rs delete mode 100644 rust/fatcat-api-spec/examples/server_lib/server.rs delete mode 100644 rust/fatcat-api-spec/rustfmt.toml delete mode 100644 rust/fatcat-api-spec/src/client.rs delete mode 100644 rust/fatcat-api-spec/src/lib.rs delete mode 100644 rust/fatcat-api-spec/src/mimetypes.rs delete mode 100644 rust/fatcat-api-spec/src/models.rs delete mode 100644 rust/fatcat-api-spec/src/server.rs (limited to 'rust/fatcat-api-spec') diff --git a/rust/fatcat-api-spec/.cargo/config b/rust/fatcat-api-spec/.cargo/config deleted file mode 100644 index b8acc9c0..00000000 --- a/rust/fatcat-api-spec/.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-spec/.gitignore b/rust/fatcat-api-spec/.gitignore deleted file mode 100644 index a9d37c56..00000000 --- a/rust/fatcat-api-spec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/rust/fatcat-api-spec/Cargo.toml b/rust/fatcat-api-spec/Cargo.toml deleted file mode 100644 index 9d416bd9..00000000 --- a/rust/fatcat-api-spec/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "fatcat-api-spec" -version = "0.3.0" -authors = ["Bryan Newbold "] -description = "HTTP API models, endpoints, and other auto-generated types" -license = "CC-0" - -[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-spec/README.md b/rust/fatcat-api-spec/README.md deleted file mode 100644 index b175a762..00000000 --- a/rust/fatcat-api-spec/README.md +++ /dev/null @@ -1,198 +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.3.0 -- Build date: 2019-05-21T18:36:07.221Z - -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 -``` - -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 CreateContainer -cargo run --example client CreateContainerAutoBatch -cargo run --example client DeleteContainer -cargo run --example client DeleteContainerEdit -cargo run --example client GetContainer -cargo run --example client GetContainerEdit -cargo run --example client GetContainerHistory -cargo run --example client GetContainerRedirects -cargo run --example client GetContainerRevision -cargo run --example client LookupContainer -cargo run --example client UpdateContainer -cargo run --example client CreateCreator -cargo run --example client CreateCreatorAutoBatch -cargo run --example client DeleteCreator -cargo run --example client DeleteCreatorEdit -cargo run --example client GetCreator -cargo run --example client GetCreatorEdit -cargo run --example client GetCreatorHistory -cargo run --example client GetCreatorRedirects -cargo run --example client GetCreatorReleases -cargo run --example client GetCreatorRevision -cargo run --example client LookupCreator -cargo run --example client UpdateCreator -cargo run --example client AuthCheck -cargo run --example client AuthOidc -cargo run --example client GetEditgroupsReviewable -cargo run --example client GetEditor -cargo run --example client GetEditorEditgroups -cargo run --example client UpdateEditgroup -cargo run --example client UpdateEditor -cargo run --example client AcceptEditgroup -cargo run --example client CreateEditgroup -cargo run --example client CreateEditgroupAnnotation -cargo run --example client GetChangelog -cargo run --example client GetChangelogEntry -cargo run --example client GetEditgroup -cargo run --example client GetEditgroupAnnotations -cargo run --example client GetEditorAnnotations -cargo run --example client CreateFile -cargo run --example client CreateFileAutoBatch -cargo run --example client DeleteFile -cargo run --example client DeleteFileEdit -cargo run --example client GetFile -cargo run --example client GetFileEdit -cargo run --example client GetFileHistory -cargo run --example client GetFileRedirects -cargo run --example client GetFileRevision -cargo run --example client LookupFile -cargo run --example client UpdateFile -cargo run --example client CreateFileset -cargo run --example client CreateFilesetAutoBatch -cargo run --example client DeleteFileset -cargo run --example client DeleteFilesetEdit -cargo run --example client GetFileset -cargo run --example client GetFilesetEdit -cargo run --example client GetFilesetHistory -cargo run --example client GetFilesetRedirects -cargo run --example client GetFilesetRevision -cargo run --example client UpdateFileset -cargo run --example client CreateRelease -cargo run --example client CreateReleaseAutoBatch -cargo run --example client CreateWork -cargo run --example client DeleteRelease -cargo run --example client DeleteReleaseEdit -cargo run --example client GetRelease -cargo run --example client GetReleaseEdit -cargo run --example client GetReleaseFiles -cargo run --example client GetReleaseFilesets -cargo run --example client GetReleaseHistory -cargo run --example client GetReleaseRedirects -cargo run --example client GetReleaseRevision -cargo run --example client GetReleaseWebcaptures -cargo run --example client LookupRelease -cargo run --example client UpdateRelease -cargo run --example client CreateWebcapture -cargo run --example client CreateWebcaptureAutoBatch -cargo run --example client DeleteWebcapture -cargo run --example client DeleteWebcaptureEdit -cargo run --example client GetWebcapture -cargo run --example client GetWebcaptureEdit -cargo run --example client GetWebcaptureHistory -cargo run --example client GetWebcaptureRedirects -cargo run --example client GetWebcaptureRevision -cargo run --example client UpdateWebcapture -cargo run --example client CreateWorkAutoBatch -cargo run --example client DeleteWork -cargo run --example client DeleteWorkEdit -cargo run --example client GetWork -cargo run --example client GetWorkEdit -cargo run --example client GetWorkHistory -cargo run --example client GetWorkRedirects -cargo run --example client GetWorkReleases -cargo run --example client GetWorkRevision -cargo run --example client UpdateWork -``` - -### 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.3.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-spec/api.yaml b/rust/fatcat-api-spec/api.yaml deleted file mode 100644 index 95ef4c6b..00000000 --- a/rust/fatcat-api-spec/api.yaml +++ /dev/null @@ -1,3129 +0,0 @@ ---- -swagger: "2.0" -info: - title: fatcat - description: A scalable, versioned, API-oriented catalog of bibliographic entities - and file metadata - version: 0.3.0 -schemes: [https] -basePath: /v0 -host: api.fatcat.wiki -consumes: - - application/json -produces: - - application/json - -securityDefinitions: - Bearer: - type: apiKey - name: Authorization - in: header - -tags: # TAGLINE - - name: containers # TAGLINE - descriptions: "Container entities: such as journals, conferences, book series" # TAGLINE - - name: creators # TAGLINE - descriptions: "Creator entities: such as authors" # TAGLINE - - name: files # TAGLINE - descriptions: "File entities" # TAGLINE - - name: filesets # TAGLINE - descriptions: "Fileset entities" # TAGLINE - - name: webcaptures # TAGLINE - descriptions: "Webcapture entities" # TAGLINE - - name: releases # TAGLINE - descriptions: "Release entities: individual articles, pre-prints, books" # TAGLINE - - name: works # TAGLINE - descriptions: "Work entities: grouping releases which are variants of the same work" # TAGLINE - - name: edit-lifecycle # TAGLINE - descriptions: "Endpoints relating to global edit submission and history" # TAGLINE - -# 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 -x-md5: &FATCATMD5 - type: string - example: "1b39813549077b2347c0f370c3864b40" - pattern: "[a-f0-9]{32}" - minLength: 32 - maxLength: 32 -x-sha1: &FATCATSHA1 - type: string - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - pattern: "[a-f0-9]{40}" - minLength: 40 - maxLength: 40 -x-sha256: &FATCATSHA256 - type: string - example: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - pattern: "[a-f0-9]{64}" - minLength: 64 - maxLength: 64 - -# Common properties across entities -x-entity-props: &ENTITYPROPS - state: - type: string - enum: ["wip", "active", "redirect", "deleted"] - ident: - <<: *FATCATIDENT - revision: - <<: *FATCATUUID - redirect: - <<: *FATCATIDENT - extra: - type: object - additionalProperties: {} - edit_extra: - type: object - additionalProperties: {} - -definitions: - error_response: - type: object - required: - - success - - error - - message - properties: - success: - type: boolean - error: - type: string - message: - type: string - example: "A really confusing, totally unexpected thing happened" - success: - type: object - required: - - success - - message - properties: - success: - type: boolean - message: - type: string - example: "The computers did the thing successfully!" - container_entity: - type: object - # required for creation: name - properties: - <<: *ENTITYPROPS - name: - type: string - example: "Journal of Important Results" - description: "Required for valid entities" - container_type: - type: string - description: "Eg, 'journal'" - publisher: - type: string - example: "Society of Curious Students" - issnl: - <<: *FATCATISSN - wikidata_qid: - type: string - creator_entity: - type: object - # required for creation: display_name - properties: - <<: *ENTITYPROPS - display_name: - type: string - example: "Grace Hopper" - description: "Required for valid entities" - 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 - md5: - <<: *FATCATMD5 - sha1: - <<: *FATCATSHA1 - sha256: - <<: *FATCATSHA256 - urls: - type: array - items: - $ref: "#/definitions/file_url" - mimetype: - type: string - example: "application/pdf" - release_ids: - type: array - items: - <<: *FATCATIDENT - releases: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/release_entity" - file_url: - type: object - required: - - url - - rel - properties: - url: - type: string - format: url - example: "https://example.edu/~frau/prcding.pdf" - rel: - type: string - example: "webarchive" - fileset_entity: - type: object - properties: - <<: *ENTITYPROPS - manifest: - # limit of 200 files, at least to start - type: array - items: - $ref: "#/definitions/fileset_file" - urls: - type: array - items: - $ref: "#/definitions/fileset_url" - release_ids: - type: array - items: - <<: *FATCATIDENT - releases: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/release_entity" - fileset_url: - type: object - required: - - url - - rel - properties: - url: - type: string - format: url - example: "https://example.edu/~frau/prcding.pdf" - rel: - type: string - example: "webarchive" - fileset_file: - type: object - required: - - path - - size - properties: - path: - type: string - example: "img/cat.png" - size: - type: integer - example: 1048576 - format: int64 - md5: - <<: *FATCATMD5 - sha1: - <<: *FATCATSHA1 - sha256: - <<: *FATCATSHA256 - extra: - type: object - additionalProperties: {} - webcapture_entity: - type: object - properties: - <<: *ENTITYPROPS - cdx: - # limit of 200 CDX lines, at least to start? - type: array - items: - $ref: "#/definitions/webcapture_cdx_line" - archive_urls: - type: array - items: - $ref: "#/definitions/webcapture_url" - original_url: - type: string - format: url - example: "http://asheesh.org" - timestamp: - type: string - format: date-time - description: "same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Can be the earliest or average of CDX timestamps if that makes sense." - release_ids: - type: array - items: - <<: *FATCATIDENT - releases: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/release_entity" - webcapture_cdx_line: - type: object - required: - - surt - - timestamp - - url - - sha1 - properties: - surt: - type: string - example: "org,asheesh)/apus/ch1/node15.html" - timestamp: - type: string - format: date-time - example: "2016-09-19T17:20:24Z" - description: "UTC, 'Z'-terminated, second (or better) precision" - url: - type: string - # NOTE: not format:url to allow alternatives - example: "http://www.asheesh.org:80/APUS/ch1/node15.html" - mimetype: - type: string - example: "text/html" - status_code: - type: integer - example: 200 - format: int64 - size: - type: integer - example: 1048576 - format: int64 - sha1: - <<: *FATCATSHA1 - sha256: - <<: *FATCATSHA256 - webcapture_url: - type: object - required: - - url - - rel - properties: - url: - type: string - format: url - example: "https://web.archive.org/web/" - rel: - type: string - example: "wayback" - release_entity: - type: object - # required for creation: title - required: - - ext_ids - properties: - <<: *ENTITYPROPS - title: - type: string - description: "Required for valid entities. The title used in citations and for display; usually English" - subtitle: - type: string - description: "Avoid this field if possible, and merge with title; usually English" - original_title: - type: string - description: "Title in original language (or, the language of the full text of this release)" - 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" - filesets: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/fileset_entity" - webcaptures: - description: "Optional; GET-only" - type: array - items: - $ref: "#/definitions/webcapture_entity" - container_id: - type: string - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - release_type: - type: string - example: "book" - release_stage: - type: string - example: "preprint, retracted" - release_date: - type: string - format: date - release_year: - type: integer - example: 2014 - format: int64 - withdrawn_status: - type: string - withdrawn_date: - type: string - format: date - withdrawn_year: - type: integer - example: 2014 - format: int64 - ext_ids: - $ref: "#/definitions/release_ext_ids" - volume: - type: string - issue: - type: string - example: "12" - pages: - type: string - number: - type: string - version: - type: string - publisher: - type: string - language: - description: "Two-letter RFC1766/ISO639-1 language code, with extensions" - type: string - license_slug: - type: string - description: "Short version of license name. Eg, 'CC-BY'" - contribs: - type: array - items: - $ref: "#/definitions/release_contrib" - refs: - type: array - items: - $ref: "#/definitions/release_ref" - abstracts: - type: array - items: - $ref: "#/definitions/release_abstract" - release_ext_ids: - type: object - properties: - doi: - type: string - #format: custom - example: "10.1234/abcde.789" - wikidata_qid: - type: string - isbn13: - type: string - #format: custom - pmid: - type: string - pmcid: - type: string - core: - type: string - #format: custom - arxiv: - type: string - jstor: - type: string - ark: - type: string - mag: - type: string - release_abstract: - type: object - properties: - sha1: - <<: *FATCATSHA1 - content: - type: string - example: "Some abstract thing goes here" - 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: - <<: *FATCATUUID - ident: - <<: *FATCATIDENT - revision: - <<: *FATCATUUID - prev_revision: - <<: *FATCATUUID - redirect_ident: - <<: *FATCATIDENT - editgroup_id: - <<: *FATCATIDENT - extra: - type: object - additionalProperties: {} - editor: - type: object - required: - - username - properties: - editor_id: - <<: *FATCATIDENT - username: - type: string - example: "zerocool93" - is_admin: - type: boolean - is_bot: - type: boolean - is_active: - type: boolean - editgroup: - type: object - properties: - editgroup_id: - <<: *FATCATIDENT - editor_id: - <<: *FATCATIDENT - editor: - $ref: "#/definitions/editor" - changelog_index: # not returned in all contexts... - type: integer - example: 1048576 - format: int64 - created: - type: string - format: date-time - submitted: - type: string - format: date-time - description: - type: string - extra: - type: object - additionalProperties: {} - annotations: - type: array - items: - $ref: "#/definitions/editgroup_annotation" - 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" - filesets: - type: array - items: - $ref: "#/definitions/entity_edit" - webcaptures: - type: array - items: - $ref: "#/definitions/entity_edit" - releases: - type: array - items: - $ref: "#/definitions/entity_edit" - works: - type: array - items: - $ref: "#/definitions/entity_edit" - editgroup_annotation: - type: object - properties: - annotation_id: - <<: *FATCATUUID - editgroup_id: - <<: *FATCATIDENT - editor_id: - <<: *FATCATIDENT - editor: - $ref: "#/definitions/editor" - created: - type: string - format: date-time - comment_markdown: - type: string - extra: - type: object - additionalProperties: {} - 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: - <<: *FATCATIDENT - extra: - type: object - additionalProperties: {} - key: - type: string - year: - type: integer - format: int64 - container_name: - type: string - title: - type: string - locator: - type: string - example: "p123" - release_contrib: - type: object - properties: - index: - type: integer - format: int64 - creator_id: - <<: *FATCATIDENT - creator: - $ref: "#/definitions/creator_entity" - description: "Optional; GET-only" - raw_name: - type: string - given_name: - type: string - surname: - type: string - role: - type: string - raw_affiliation: - type: string - description: "Raw affiliation string as displayed in text" - extra: - type: object - additionalProperties: {} - container_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/container_entity" - creator_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/creator_entity" - file_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/file_entity" - fileset_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/fileset_entity" - webcapture_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/webcapture_entity" - release_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/release_entity" - work_auto_batch: - type: object - required: - - editgroup - - entity_list - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: array - items: - $ref: "#/definitions/work_entity" - auth_oidc: - type: object - required: - - provider - - sub - - iss - - preferred_username - properties: - provider: - type: string - sub: - type: string - iss: - type: string - preferred_username: - type: string - auth_oidc_result: - type: object - required: - - editor - - token - properties: - editor: - $ref: "#/definitions/editor" - token: - type: string - -x-auth-responses: &AUTHRESPONSES - 401: - description: Not Authorized # "Authentication information is missing or invalid" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: string - 403: - description: Forbidden - schema: - $ref: "#/definitions/error_response" -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: - /editgroup/{editgroup_id}/container: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_container" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/container_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/container/batch: - post: - operationId: "create_container_auto_batch" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/container_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /container/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_container" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For containers, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For containers, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/container_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/container/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_container" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/container_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_container" - tags: # TAGLINE - - containers # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /container/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_container_revision" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For containers, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For containers, none accepted (yet)." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/container_entity" - <<: *ENTITYRESPONSES - /container/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - tags: # TAGLINE - - containers # TAGLINE - operationId: "get_container_history" - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /container/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - containers # TAGLINE - operationId: "get_container_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /container/lookup: - get: - operationId: "lookup_container" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: issnl - in: query - required: false - <<: *FATCATISSN - - name: wikidata_qid - in: query - required: false - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For container, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/container_entity" - <<: *ENTITYRESPONSES - /container/edit/{edit_id}: - get: - operationId: "get_container_edit" - tags: # TAGLINE - - containers # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/container/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_container_edit" - tags: # TAGLINE - - containers # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/creator: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_creator" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/creator_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/creator/batch: - post: - operationId: "create_creator_auto_batch" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/creator_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /creator/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_creator" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For creators, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For containers, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/creator_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/creator/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_creator" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/creator_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_creator" - tags: # TAGLINE - - creators # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /creator/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_creator_revision" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For creators, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For creators, none accepted (yet)." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/creator_entity" - <<: *ENTITYRESPONSES - /creator/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_creator_history" - tags: # TAGLINE - - creators # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /creator/{ident}/releases: - parameters: - - name: ident - in: path - type: string - required: true - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For creators, none implemented yet." - get: - operationId: "get_creator_releases" - tags: # TAGLINE - - creators # TAGLINE - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /creator/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - creators # TAGLINE - operationId: "get_creator_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /creator/lookup: - get: - operationId: "lookup_creator" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: orcid - in: query - required: false - <<: *FATCATORCID - - name: wikidata_qid - in: query - required: false - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For creator, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/creator_entity" - <<: *ENTITYRESPONSES - /creator/edit/{edit_id}: - get: - operationId: "get_creator_edit" - tags: # TAGLINE - - creators # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/creator/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_creator_edit" - tags: # TAGLINE - - creators # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/file: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_file" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/file_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/file/batch: - post: - operationId: "create_file_auto_batch" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/file_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /file/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_file" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For files, `releases` is accepted." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For files, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/file/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_file" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/file_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_file" - tags: # TAGLINE - - files # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /file/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_file_revision" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For files, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For files, none accepted (yet)." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /file/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_file_history" - tags: # TAGLINE - - files # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /file/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - files # TAGLINE - operationId: "get_file_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /file/lookup: - get: - operationId: "lookup_file" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: md5 - in: query - required: false - <<: *FATCATMD5 - - name: sha1 - in: query - required: false - <<: *FATCATSHA1 - - name: sha256 - in: query - required: false - <<: *FATCATSHA256 - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For files, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /file/edit/{edit_id}: - get: - operationId: "get_file_edit" - tags: # TAGLINE - - files # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/file/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_file_edit" - tags: # TAGLINE - - files # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/fileset: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_fileset" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/fileset_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/fileset/batch: - post: - operationId: "create_fileset_auto_batch" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/fileset_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /fileset/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_fileset" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For filesets, `releases` is accepted." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For filesets, 'manifest' is accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/fileset_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/fileset/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_fileset" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/fileset_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_fileset" - tags: # TAGLINE - - filesets # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /fileset/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_fileset_revision" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For filesets, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For filesets, 'manifest' is accepted." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/fileset_entity" - <<: *ENTITYRESPONSES - /fileset/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_fileset_history" - tags: # TAGLINE - - filesets # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /fileset/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - filesets # TAGLINE - operationId: "get_fileset_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /fileset/edit/{edit_id}: - get: - operationId: "get_fileset_edit" - tags: # TAGLINE - - filesets # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/fileset/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_fileset_edit" - tags: # TAGLINE - - filesets # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/webcapture: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_webcapture" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/webcapture_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/webcapture/batch: - post: - operationId: "create_webcapture_auto_batch" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/webcapture_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /webcapture/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_webcapture" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For webcaptures, `releases` is accepted." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For webcaptures, 'cdx' is accepted." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/webcapture_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/webcapture/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_webcapture" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/webcapture_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_webcapture" - tags: # TAGLINE - - webcaptures # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /webcapture/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_webcapture_revision" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For webcaptures, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For webcaptures, 'cdx' is accepted." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/webcapture_entity" - <<: *ENTITYRESPONSES - /webcapture/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_webcapture_history" - tags: # TAGLINE - - webcaptures # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /webcapture/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - webcaptures # TAGLINE - operationId: "get_webcapture_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /webcapture/edit/{edit_id}: - get: - operationId: "get_webcapture_edit" - tags: # TAGLINE - - webcaptures # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/webcapture/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_webcapture_edit" - tags: # TAGLINE - - webcaptures # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/release: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_release" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/release_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/release/batch: - post: - operationId: "create_release_auto_batch" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/release_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /release/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_release" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For releases, 'files', 'filesets, 'webcaptures', 'container', and 'creators' are valid." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For releases, 'abstracts', 'refs', and 'contribs' are valid." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/release/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_release" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/release_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_release" - tags: # TAGLINE - - releases # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /release/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_release_revision" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For releases, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For releases, none accepted (yet)." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /release/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_release_history" - tags: # TAGLINE - - releases # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /release/{ident}/files: - parameters: - - name: ident - in: path - type: string - required: true - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For files, none accepted (yet)." - get: - operationId: "get_release_files" - tags: # TAGLINE - - releases # TAGLINE - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/file_entity" - <<: *ENTITYRESPONSES - /release/{ident}/filesets: - parameters: - - name: ident - in: path - type: string - required: true - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For filesets, 'manifest' is valid." - get: - operationId: "get_release_filesets" - tags: # TAGLINE - - releases # TAGLINE - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/fileset_entity" - <<: *ENTITYRESPONSES - /release/{ident}/webcaptures: - parameters: - - name: ident - in: path - type: string - required: true - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For webcaptures, 'cdx' is valid." - get: - operationId: "get_release_webcaptures" - tags: # TAGLINE - - releases # TAGLINE - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/webcapture_entity" - <<: *ENTITYRESPONSES - /release/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - releases # TAGLINE - operationId: "get_release_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /release/lookup: - get: - operationId: "lookup_release" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: doi - in: query - type: string - required: false - - name: wikidata_qid - in: query - type: string - required: false - - name: isbn13 - in: query - type: string - required: false - - name: pmid - in: query - type: string - required: false - - name: pmcid - in: query - type: string - required: false - - name: core - in: query - type: string - required: false - - name: arxiv - in: query - type: string - required: false - - name: jstor - in: query - type: string - required: false - - name: ark - in: query - type: string - required: false - - name: mag - in: query - type: string - required: false - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response." - - name: hide - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For releases, 'files', 'filesets, 'webcaptures', 'container', and 'creators' are valid." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /release/edit/{edit_id}: - get: - operationId: "get_release_edit" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/release/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_release_edit" - tags: # TAGLINE - - releases # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/work: - parameters: - - name: editgroup_id - in: path - type: string - required: true - post: - operationId: "create_work" - tags: # TAGLINE - - releases # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/work_entity" - security: - - Bearer: [] - responses: - 201: - description: Created Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editgroup/auto/work/batch: - post: - operationId: "create_work_auto_batch" - tags: # TAGLINE - - works # TAGLINE - parameters: - - name: auto_batch - in: body - required: true - schema: - $ref: "#/definitions/work_auto_batch" - security: - - Bearer: [] - responses: - 201: - description: Created Editgroup - schema: - $ref: "#/definitions/editgroup" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /work/{ident}: - parameters: - - name: ident - in: path - type: string - required: true - get: - operationId: "get_work" - tags: # TAGLINE - - works # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For works, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For works, none accepted (yet)." - responses: - 200: - description: Found Entity - schema: - $ref: "#/definitions/work_entity" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/work/{ident}: - parameters: - - name: editgroup_id - in: path - type: string - required: true - - name: ident - in: path - type: string - required: true - put: - operationId: "update_work" - tags: # TAGLINE - - works # TAGLINE - parameters: - - name: entity - in: body - required: true - schema: - $ref: "#/definitions/work_entity" - security: - - Bearer: [] - responses: - 200: - description: Updated Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - delete: - operationId: "delete_work" - tags: # TAGLINE - - works # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Entity - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /work/rev/{rev_id}: - parameters: - - name: rev_id - in: path - required: true - <<: *FATCATUUID - get: - operationId: "get_work_revision" - tags: # TAGLINE - - works # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For works, none accepted (yet)." - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For works, none accepted (yet)." - responses: - 200: - description: Found Entity Revision - schema: - $ref: "#/definitions/work_entity" - <<: *ENTITYRESPONSES - /work/{ident}/history: - parameters: - - name: ident - in: path - type: string - required: true - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_work_history" - tags: # TAGLINE - - works # TAGLINE - responses: - 200: - description: Found Entity History - schema: - type: array - items: - $ref: "#/definitions/entity_history_entry" - <<: *ENTITYRESPONSES - /work/{ident}/redirects: - parameters: - - name: ident - in: path - type: string - required: true - get: - tags: # TAGLINE - - works # TAGLINE - operationId: "get_work_redirects" - responses: - 200: - description: Found Entity Redirects - schema: - type: array - items: - <<: *FATCATIDENT - <<: *ENTITYRESPONSES - /work/{ident}/releases: - parameters: - - name: ident - in: path - type: string - required: true - - name: hide - in: query - type: string - required: false - description: "List of entity fields to elide in response. For works, none implemented yet." - get: - operationId: "get_work_releases" - tags: # TAGLINE - - works # TAGLINE - responses: - 200: - description: Found - schema: - type: array - items: - $ref: "#/definitions/release_entity" - <<: *ENTITYRESPONSES - /work/edit/{edit_id}: - get: - operationId: "get_work_edit" - tags: # TAGLINE - - works # TAGLINE - parameters: - - name: edit_id - in: path - required: true - <<: *FATCATUUID - responses: - 200: - description: Found Edit - schema: - $ref: "#/definitions/entity_edit" - <<: *ENTITYRESPONSES - /editgroup/{editgroup_id}/work/edit/{edit_id}: - parameters: - - name: editgroup_id - in: path - required: true - type: string - - name: edit_id - in: path - required: true - <<: *FATCATUUID - delete: - operationId: "delete_work_edit" - tags: # TAGLINE - - works # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Deleted Edit - schema: - $ref: "#/definitions/success" - <<: *ENTITYRESPONSES - <<: *AUTHRESPONSES - /editor/{editor_id}: - parameters: - - name: editor_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" - put: - operationId: "update_editor" - parameters: - - name: editor - in: body - required: true - schema: - $ref: "#/definitions/editor" - security: - - Bearer: [] - responses: - 200: - description: Updated Editor - 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" - <<: *AUTHRESPONSES - /editor/{editor_id}/editgroups: - parameters: - - name: editor_id - in: path - type: string - required: true - get: - operationId: "get_editor_editgroups" - parameters: - - name: limit - in: query - type: integer - format: int64 - required: false - - name: before - in: query - type: string - format: date-time - required: false - - name: since - in: query - type: string - format: date-time - required: false - responses: - 200: - description: Found - schema: - type: array - items: - $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" - /editor/{editor_id}/annotations: - parameters: - - name: editor_id - in: path - required: true - <<: *FATCATIDENT - get: - operationId: "get_editor_annotations" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - parameters: - - name: limit - in: query - type: integer - format: int64 - required: false - - name: before - in: query - type: string - format: date-time - required: false - - name: since - in: query - type: string - format: date-time - required: false - responses: - 200: - description: Success - schema: - type: array - items: - $ref: "#/definitions/editgroup_annotation" - 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" - <<: *AUTHRESPONSES - /editgroup: - post: - operationId: "create_editgroup" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - parameters: - - name: editgroup - in: body - required: true - schema: - $ref: "#/definitions/editgroup" - security: - - Bearer: [] - responses: - 201: - description: Successfully Created - schema: - $ref: "#/definitions/editgroup" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 404: # added only for response type consistency - description: Not Found - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}: - parameters: - - name: editgroup_id - in: path - required: true - <<: *FATCATIDENT - get: - operationId: "get_editgroup" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - 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" - put: - operationId: "update_editgroup" - security: - - Bearer: [] - parameters: - - name: editgroup - in: body - required: true - schema: - $ref: "#/definitions/editgroup" - - name: submit - in: query - type: boolean - required: false - responses: - 200: - description: Updated Editgroup - 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" - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/accept: - parameters: - - name: editgroup_id - in: path - required: true - <<: *FATCATIDENT - post: - operationId: "accept_editgroup" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - security: - - Bearer: [] - responses: - 200: - description: Merged Successfully - schema: - $ref: "#/definitions/success" - 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" - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/annotations: - parameters: - - name: editgroup_id - in: path - required: true - <<: *FATCATIDENT - get: - operationId: "get_editgroup_annotations" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For editgroups: 'editors'" - responses: - 200: - description: Success - schema: - type: array - items: - $ref: "#/definitions/editgroup_annotation" - 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" - <<: *AUTHRESPONSES - /editgroup/{editgroup_id}/annotation: - parameters: - - name: editgroup_id - in: path - required: true - <<: *FATCATIDENT - post: - operationId: "create_editgroup_annotation" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - security: - - Bearer: [] - parameters: - - name: annotation - in: body - required: true - schema: - $ref: "#/definitions/editgroup_annotation" - responses: - 201: - description: Created - schema: - $ref: "#/definitions/editgroup_annotation" - 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" - <<: *AUTHRESPONSES - /editgroup/reviewable: - get: - operationId: "get_editgroups_reviewable" - parameters: - - name: expand - in: query - type: string - required: false - description: "List of sub-entities to expand in response. For editgroups: 'editors'" - - name: limit - in: query - type: integer - format: int64 - required: false - - name: before - in: query - type: string - format: date-time - required: false - - name: since - in: query - type: string - format: date-time - required: false - responses: - 200: - description: Found - schema: - type: array - items: - $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" - /changelog: - parameters: - - name: limit - in: query - type: integer - format: int64 - required: false - get: - operationId: "get_changelog" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - responses: - 200: - description: Success - schema: - type: array - items: - $ref: "#/definitions/changelog_entry" - 400: # added only for response type consistency - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - /changelog/{index}: - parameters: - - name: index - in: path - type: integer - format: int64 - required: true - get: - operationId: "get_changelog_entry" - tags: # TAGLINE - - edit-lifecycle # TAGLINE - responses: - 200: - description: Found Changelog Entry - schema: - $ref: "#/definitions/changelog_entry" - 400: # added only for response type consistency - 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" - /auth/oidc: - post: - operationId: "auth_oidc" - tags: # TAGLINE - security: - # required admin privs - - Bearer: [] - parameters: - - name: oidc_params - in: body - required: true - schema: - $ref: "#/definitions/auth_oidc" - responses: - 200: - description: Found - schema: - $ref: "#/definitions/auth_oidc_result" - 201: - description: Created - schema: - $ref: "#/definitions/auth_oidc_result" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 409: - description: Conflict - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - <<: *AUTHRESPONSES - /auth/check: - get: - operationId: "auth_check" - tags: # TAGLINE - security: - # required admin privs - - Bearer: [] - parameters: - - name: role - in: query - required: false - type: string - responses: - 200: - description: Success - schema: - $ref: "#/definitions/success" - 400: - description: Bad Request - schema: - $ref: "#/definitions/error_response" - 500: - description: Generic Error - schema: - $ref: "#/definitions/error_response" - <<: *AUTHRESPONSES - diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml deleted file mode 100644 index b4c5e657..00000000 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ /dev/null @@ -1,9627 +0,0 @@ ---- -swagger: "2.0" -info: - description: "A scalable, versioned, API-oriented catalog of bibliographic entities\ - \ and file metadata" - version: "0.3.0" - title: "fatcat" -host: "api.fatcat.wiki" -basePath: "/v0" -tags: -- name: "containers" -- name: "creators" -- name: "files" -- name: "filesets" -- name: "webcaptures" -- name: "releases" -- name: "works" -- name: "edit-lifecycle" -schemes: -- "https" -consumes: -- "application/json" -produces: -- "application/json" -paths: - /editgroup/{editgroup_id}/container: - post: - tags: - - "containers" - operationId: "create_container" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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: "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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "create_container" - uppercase_operation_id: "CREATE_CONTAINER" - path: "/editgroup/:editgroup_id/container" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/container/batch: - post: - tags: - - "containers" - operationId: "create_container_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/container_auto_batch" - uppercase_data_type: "CONTAINERAUTOBATCH" - refName: "container_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CONTAINER_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_CONTAINER_AUTO_BATCH" - 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_CONTAINER_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_CONTAINER_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_CONTAINER_AUTO_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_AUTO_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_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_container_auto_batch" - uppercase_operation_id: "CREATE_CONTAINER_AUTO_BATCH" - path: "/editgroup/auto/container/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /container/{ident}: - get: - tags: - - "containers" - operationId: "get_container" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For containers,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For containers,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - 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/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/container/{ident}: - put: - tags: - - "containers" - operationId: "update_container" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "update_container" - uppercase_operation_id: "UPDATE_CONTAINER" - path: "/editgroup/:editgroup_id/container/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "containers" - operationId: "delete_container" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_CONTAINER" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "delete_container" - uppercase_operation_id: "DELETE_CONTAINER" - path: "/editgroup/:editgroup_id/container/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /container/rev/{rev_id}: - get: - tags: - - "containers" - operationId: "get_container_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For containers,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For containers,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/container_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_CONTAINER_REVISION" - uppercase_data_type: "CONTAINERENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CONTAINER_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CONTAINER_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CONTAINER_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_container_revision" - uppercase_operation_id: "GET_CONTAINER_REVISION" - path: "/container/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /container/{ident}/history: - get: - tags: - - "containers" - operationId: "get_container_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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" - 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/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /container/{ident}/redirects: - get: - tags: - - "containers" - operationId: "get_container_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_CONTAINER_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CONTAINER_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CONTAINER_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CONTAINER_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_container_redirects" - uppercase_operation_id: "GET_CONTAINER_REDIRECTS" - path: "/container/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /container/lookup: - get: - tags: - - "containers" - operationId: "lookup_container" - parameters: - - name: "issnl" - in: "query" - required: false - type: "string" - maxLength: 9 - minLength: 9 - pattern: "\\d{4}-\\d{3}[0-9X]" - formatString: "{:?}" - example: "Some(\"issnl_example\".to_string())" - - name: "wikidata_qid" - in: "query" - required: false - formatString: "{:?}" - example: "Some(\"wikidata_qid_example\".to_string())" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For container, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_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" - /container/edit/{edit_id}: - get: - tags: - - "containers" - operationId: "get_container_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_CONTAINER_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_container_edit" - uppercase_operation_id: "GET_CONTAINER_EDIT" - path: "/container/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/container/edit/{edit_id}: - delete: - tags: - - "containers" - operationId: "delete_container_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_container_edit" - uppercase_operation_id: "DELETE_CONTAINER_EDIT" - path: "/editgroup/:editgroup_id/container/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/creator: - post: - tags: - - "creators" - operationId: "create_creator" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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: "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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "create_creator" - uppercase_operation_id: "CREATE_CREATOR" - path: "/editgroup/:editgroup_id/creator" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/creator/batch: - post: - tags: - - "creators" - operationId: "create_creator_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/creator_auto_batch" - uppercase_data_type: "CREATORAUTOBATCH" - refName: "creator_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_CREATOR_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_CREATOR_AUTO_BATCH" - 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_CREATOR_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_CREATOR_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_CREATOR_AUTO_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_AUTO_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_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_creator_auto_batch" - uppercase_operation_id: "CREATE_CREATOR_AUTO_BATCH" - path: "/editgroup/auto/creator/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /creator/{ident}: - get: - tags: - - "creators" - operationId: "get_creator" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For creators, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For containers,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_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/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/creator/{ident}: - put: - tags: - - "creators" - operationId: "update_creator" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "update_creator" - uppercase_operation_id: "UPDATE_CREATOR" - path: "/editgroup/:editgroup_id/creator/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "creators" - operationId: "delete_creator" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_CREATOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "delete_creator" - uppercase_operation_id: "DELETE_CREATOR" - path: "/editgroup/:editgroup_id/creator/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /creator/rev/{rev_id}: - get: - tags: - - "creators" - operationId: "get_creator_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For creators, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For creators, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/creator_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_CREATOR_REVISION" - uppercase_data_type: "CREATORENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CREATOR_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CREATOR_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CREATOR_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator_revision" - uppercase_operation_id: "GET_CREATOR_REVISION" - path: "/creator/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /creator/{ident}/history: - get: - tags: - - "creators" - operationId: "get_creator_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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" - 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/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /creator/{ident}/releases: - get: - tags: - - "creators" - operationId: "get_creator_releases" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For creators, none\ - \ implemented yet." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_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" - 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/:ident/releases" - HttpMethod: "Get" - httpmethod: "get" - /creator/{ident}/redirects: - get: - tags: - - "creators" - operationId: "get_creator_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_CREATOR_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CREATOR_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CREATOR_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CREATOR_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator_redirects" - uppercase_operation_id: "GET_CREATOR_REDIRECTS" - path: "/creator/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /creator/lookup: - get: - tags: - - "creators" - operationId: "lookup_creator" - parameters: - - name: "orcid" - in: "query" - required: false - type: "string" - maxLength: 19 - minLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" - formatString: "{:?}" - example: "Some(\"orcid_example\".to_string())" - - name: "wikidata_qid" - in: "query" - required: false - formatString: "{:?}" - example: "Some(\"wikidata_qid_example\".to_string())" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For creator, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_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" - /creator/edit/{edit_id}: - get: - tags: - - "creators" - operationId: "get_creator_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_CREATOR_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_creator_edit" - uppercase_operation_id: "GET_CREATOR_EDIT" - path: "/creator/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/creator/edit/{edit_id}: - delete: - tags: - - "creators" - operationId: "delete_creator_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_creator_edit" - uppercase_operation_id: "DELETE_CREATOR_EDIT" - path: "/editgroup/:editgroup_id/creator/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/file: - post: - tags: - - "files" - operationId: "create_file" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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: "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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "create_file" - uppercase_operation_id: "CREATE_FILE" - path: "/editgroup/:editgroup_id/file" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/file/batch: - post: - tags: - - "files" - operationId: "create_file_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/file_auto_batch" - uppercase_data_type: "FILEAUTOBATCH" - refName: "file_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_FILE_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_FILE_AUTO_BATCH" - 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_FILE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_FILE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_FILE_AUTO_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_AUTO_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_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_file_auto_batch" - uppercase_operation_id: "CREATE_FILE_AUTO_BATCH" - path: "/editgroup/auto/file/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /file/{ident}: - get: - tags: - - "files" - operationId: "get_file" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For files, `releases`\ - \ is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For files, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - 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/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/file/{ident}: - put: - tags: - - "files" - operationId: "update_file" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "update_file" - uppercase_operation_id: "UPDATE_FILE" - path: "/editgroup/:editgroup_id/file/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "files" - operationId: "delete_file" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_FILE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "delete_file" - uppercase_operation_id: "DELETE_FILE" - path: "/editgroup/:editgroup_id/file/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /file/rev/{rev_id}: - get: - tags: - - "files" - operationId: "get_file_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For files, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For files, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/file_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_FILE_REVISION" - uppercase_data_type: "FILEENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_file_revision" - uppercase_operation_id: "GET_FILE_REVISION" - path: "/file/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /file/{ident}/history: - get: - tags: - - "files" - operationId: "get_file_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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" - 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/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /file/{ident}/redirects: - get: - tags: - - "files" - operationId: "get_file_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_FILE_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_file_redirects" - uppercase_operation_id: "GET_FILE_REDIRECTS" - path: "/file/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /file/lookup: - get: - tags: - - "files" - operationId: "lookup_file" - parameters: - - name: "md5" - in: "query" - required: false - type: "string" - maxLength: 32 - minLength: 32 - pattern: "[a-f0-9]{32}" - formatString: "{:?}" - example: "Some(\"md5_example\".to_string())" - - name: "sha1" - in: "query" - required: false - type: "string" - maxLength: 40 - minLength: 40 - pattern: "[a-f0-9]{40}" - formatString: "{:?}" - example: "Some(\"sha1_example\".to_string())" - - name: "sha256" - in: "query" - required: false - type: "string" - maxLength: 64 - minLength: 64 - pattern: "[a-f0-9]{64}" - formatString: "{:?}" - example: "Some(\"sha256_example\".to_string())" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For files, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - 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" - /file/edit/{edit_id}: - get: - tags: - - "files" - operationId: "get_file_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_FILE_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_file_edit" - uppercase_operation_id: "GET_FILE_EDIT" - path: "/file/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/file/edit/{edit_id}: - delete: - tags: - - "files" - operationId: "delete_file_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_FILE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_file_edit" - uppercase_operation_id: "DELETE_FILE_EDIT" - path: "/editgroup/:editgroup_id/file/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/fileset: - post: - tags: - - "filesets" - operationId: "create_fileset" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/fileset_entity" - uppercase_data_type: "FILESETENTITY" - refName: "fileset_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_FILESET" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_FILESET" - 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_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_fileset" - uppercase_operation_id: "CREATE_FILESET" - path: "/editgroup/:editgroup_id/fileset" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/fileset/batch: - post: - tags: - - "filesets" - operationId: "create_fileset_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/fileset_auto_batch" - uppercase_data_type: "FILESETAUTOBATCH" - refName: "fileset_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_FILESET_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_FILESET_AUTO_BATCH" - 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_FILESET_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_FILESET_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_FILESET_AUTO_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_FILESET_AUTO_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_FILESET_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_fileset_auto_batch" - uppercase_operation_id: "CREATE_FILESET_AUTO_BATCH" - path: "/editgroup/auto/fileset/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /fileset/{ident}: - get: - tags: - - "filesets" - operationId: "get_fileset" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For filesets, `releases`\ - \ is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For filesets, 'manifest'\ - \ is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/fileset_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_FILESET" - uppercase_data_type: "FILESETENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILESET" - 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_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_fileset" - uppercase_operation_id: "GET_FILESET" - path: "/fileset/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/fileset/{ident}: - put: - tags: - - "filesets" - operationId: "update_fileset" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/fileset_entity" - uppercase_data_type: "FILESETENTITY" - refName: "fileset_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_FILESET" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "UPDATE_FILESET" - 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_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "update_fileset" - uppercase_operation_id: "UPDATE_FILESET" - path: "/editgroup/:editgroup_id/fileset/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "filesets" - operationId: "delete_fileset" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_FILESET" - 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_FILESET" - 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_FILESET" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_fileset" - uppercase_operation_id: "DELETE_FILESET" - path: "/editgroup/:editgroup_id/fileset/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /fileset/rev/{rev_id}: - get: - tags: - - "filesets" - operationId: "get_fileset_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For filesets, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For filesets, 'manifest'\ - \ is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/fileset_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_FILESET_REVISION" - uppercase_data_type: "FILESETENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILESET_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILESET_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILESET_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_fileset_revision" - uppercase_operation_id: "GET_FILESET_REVISION" - path: "/fileset/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /fileset/{ident}/history: - get: - tags: - - "filesets" - operationId: "get_fileset_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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_FILESET_HISTORY" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILESET_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_FILESET_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_FILESET_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_fileset_history" - uppercase_operation_id: "GET_FILESET_HISTORY" - path: "/fileset/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /fileset/{ident}/redirects: - get: - tags: - - "filesets" - operationId: "get_fileset_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_FILESET_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILESET_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILESET_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILESET_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_fileset_redirects" - uppercase_operation_id: "GET_FILESET_REDIRECTS" - path: "/fileset/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /fileset/edit/{edit_id}: - get: - tags: - - "filesets" - operationId: "get_fileset_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_FILESET_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_fileset_edit" - uppercase_operation_id: "GET_FILESET_EDIT" - path: "/fileset/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/fileset/edit/{edit_id}: - delete: - tags: - - "filesets" - operationId: "delete_fileset_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_FILESET_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_fileset_edit" - uppercase_operation_id: "DELETE_FILESET_EDIT" - path: "/editgroup/:editgroup_id/fileset/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/webcapture: - post: - tags: - - "webcaptures" - operationId: "create_webcapture" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/webcapture_entity" - uppercase_data_type: "WEBCAPTUREENTITY" - refName: "webcapture_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_WEBCAPTURE" - consumesJson: true - responses: - 201: - description: "Created Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "CreatedEntity" - x-uppercaseResponseId: "CREATED_ENTITY" - uppercase_operation_id: "CREATE_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_WEBCAPTURE" - 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_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_webcapture" - uppercase_operation_id: "CREATE_WEBCAPTURE" - path: "/editgroup/:editgroup_id/webcapture" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/webcapture/batch: - post: - tags: - - "webcaptures" - operationId: "create_webcapture_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/webcapture_auto_batch" - uppercase_data_type: "WEBCAPTUREAUTOBATCH" - refName: "webcapture_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_WEBCAPTURE_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_WEBCAPTURE_AUTO_BATCH" - 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_WEBCAPTURE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_WEBCAPTURE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_WEBCAPTURE_AUTO_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_WEBCAPTURE_AUTO_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_WEBCAPTURE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_webcapture_auto_batch" - uppercase_operation_id: "CREATE_WEBCAPTURE_AUTO_BATCH" - path: "/editgroup/auto/webcapture/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /webcapture/{ident}: - get: - tags: - - "webcaptures" - operationId: "get_webcapture" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For webcaptures,\ - \ `releases` is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For webcaptures,\ - \ 'cdx' is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/webcapture_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "GET_WEBCAPTURE" - uppercase_data_type: "WEBCAPTUREENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WEBCAPTURE" - 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_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_webcapture" - uppercase_operation_id: "GET_WEBCAPTURE" - path: "/webcapture/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/webcapture/{ident}: - put: - tags: - - "webcaptures" - operationId: "update_webcapture" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - in: "body" - name: "entity" - required: true - schema: - $ref: "#/definitions/webcapture_entity" - uppercase_data_type: "WEBCAPTUREENTITY" - refName: "webcapture_entity" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_WEBCAPTURE" - consumesJson: true - responses: - 200: - description: "Updated Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "UpdatedEntity" - x-uppercaseResponseId: "UPDATED_ENTITY" - uppercase_operation_id: "UPDATE_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "UPDATE_WEBCAPTURE" - 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_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "update_webcapture" - uppercase_operation_id: "UPDATE_WEBCAPTURE" - path: "/editgroup/:editgroup_id/webcapture/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "webcaptures" - operationId: "delete_webcapture" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Deleted Entity" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "DeletedEntity" - x-uppercaseResponseId: "DELETED_ENTITY" - uppercase_operation_id: "DELETE_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_WEBCAPTURE" - 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_WEBCAPTURE" - 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_WEBCAPTURE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_webcapture" - uppercase_operation_id: "DELETE_WEBCAPTURE" - path: "/editgroup/:editgroup_id/webcapture/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /webcapture/rev/{rev_id}: - get: - tags: - - "webcaptures" - operationId: "get_webcapture_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For webcaptures,\ - \ none accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For webcaptures,\ - \ 'cdx' is accepted." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/webcapture_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_WEBCAPTURE_REVISION" - uppercase_data_type: "WEBCAPTUREENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WEBCAPTURE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WEBCAPTURE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WEBCAPTURE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_webcapture_revision" - uppercase_operation_id: "GET_WEBCAPTURE_REVISION" - path: "/webcapture/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /webcapture/{ident}/history: - get: - tags: - - "webcaptures" - operationId: "get_webcapture_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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_WEBCAPTURE_HISTORY" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WEBCAPTURE_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_WEBCAPTURE_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_WEBCAPTURE_HISTORY" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_webcapture_history" - uppercase_operation_id: "GET_WEBCAPTURE_HISTORY" - path: "/webcapture/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /webcapture/{ident}/redirects: - get: - tags: - - "webcaptures" - operationId: "get_webcapture_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_WEBCAPTURE_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WEBCAPTURE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WEBCAPTURE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WEBCAPTURE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_webcapture_redirects" - uppercase_operation_id: "GET_WEBCAPTURE_REDIRECTS" - path: "/webcapture/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /webcapture/edit/{edit_id}: - get: - tags: - - "webcaptures" - operationId: "get_webcapture_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_WEBCAPTURE_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_webcapture_edit" - uppercase_operation_id: "GET_WEBCAPTURE_EDIT" - path: "/webcapture/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/webcapture/edit/{edit_id}: - delete: - tags: - - "webcaptures" - operationId: "delete_webcapture_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_webcapture_edit" - uppercase_operation_id: "DELETE_WEBCAPTURE_EDIT" - path: "/editgroup/:editgroup_id/webcapture/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/release: - post: - tags: - - "releases" - operationId: "create_release" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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: "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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "create_release" - uppercase_operation_id: "CREATE_RELEASE" - path: "/editgroup/:editgroup_id/release" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/release/batch: - post: - tags: - - "releases" - operationId: "create_release_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/release_auto_batch" - uppercase_data_type: "RELEASEAUTOBATCH" - refName: "release_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_RELEASE_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_RELEASE_AUTO_BATCH" - 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_RELEASE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_RELEASE_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_RELEASE_AUTO_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_AUTO_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_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_release_auto_batch" - uppercase_operation_id: "CREATE_RELEASE_AUTO_BATCH" - path: "/editgroup/auto/release/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /release/{ident}: - get: - tags: - - "releases" - operationId: "get_release" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For releases, 'files',\ - \ 'filesets, 'webcaptures', 'container', and 'creators' are valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For releases, 'abstracts',\ - \ 'refs', and 'contribs' are valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/release_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "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/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/release/{ident}: - put: - tags: - - "releases" - operationId: "update_release" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "update_release" - uppercase_operation_id: "UPDATE_RELEASE" - path: "/editgroup/:editgroup_id/release/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "releases" - operationId: "delete_release" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "delete_release" - uppercase_operation_id: "DELETE_RELEASE" - path: "/editgroup/:editgroup_id/release/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /release/rev/{rev_id}: - get: - tags: - - "releases" - operationId: "get_release_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For releases, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For releases, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/release_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_RELEASE_REVISION" - uppercase_data_type: "RELEASEENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_RELEASE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_RELEASE_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_revision" - uppercase_operation_id: "GET_RELEASE_REVISION" - path: "/release/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /release/{ident}/history: - get: - tags: - - "releases" - operationId: "get_release_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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" - 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/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /release/{ident}/files: - get: - tags: - - "releases" - operationId: "get_release_files" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For files, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/file_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_RELEASE_FILES" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_FILES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_RELEASE_FILES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_RELEASE_FILES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_files" - uppercase_operation_id: "GET_RELEASE_FILES" - path: "/release/:ident/files" - HttpMethod: "Get" - httpmethod: "get" - /release/{ident}/filesets: - get: - tags: - - "releases" - operationId: "get_release_filesets" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For filesets, 'manifest'\ - \ is valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/fileset_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_RELEASE_FILESETS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_FILESETS" - 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_FILESETS" - 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_FILESETS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_filesets" - uppercase_operation_id: "GET_RELEASE_FILESETS" - path: "/release/:ident/filesets" - HttpMethod: "Get" - httpmethod: "get" - /release/{ident}/webcaptures: - get: - tags: - - "releases" - operationId: "get_release_webcaptures" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For webcaptures,\ - \ 'cdx' is valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/webcapture_entity" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_RELEASE_WEBCAPTURES" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_WEBCAPTURES" - 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_WEBCAPTURES" - 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_WEBCAPTURES" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_webcaptures" - uppercase_operation_id: "GET_RELEASE_WEBCAPTURES" - path: "/release/:ident/webcaptures" - HttpMethod: "Get" - httpmethod: "get" - /release/{ident}/redirects: - get: - tags: - - "releases" - operationId: "get_release_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_RELEASE_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_RELEASE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_RELEASE_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_redirects" - uppercase_operation_id: "GET_RELEASE_REDIRECTS" - path: "/release/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /release/lookup: - get: - tags: - - "releases" - operationId: "lookup_release" - parameters: - - name: "doi" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"doi_example\".to_string())" - - name: "wikidata_qid" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"wikidata_qid_example\".to_string())" - - name: "isbn13" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"isbn13_example\".to_string())" - - name: "pmid" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"pmid_example\".to_string())" - - name: "pmcid" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"pmcid_example\".to_string())" - - name: "core" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"core_example\".to_string())" - - name: "arxiv" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"arxiv_example\".to_string())" - - name: "jstor" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"jstor_example\".to_string())" - - name: "ark" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"ark_example\".to_string())" - - name: "mag" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"mag_example\".to_string())" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of sub-entities to expand in response. For releases, 'files',\ - \ 'filesets, 'webcaptures', 'container', and 'creators' are valid." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - schema: - $ref: "#/definitions/release_entity" - x-responseId: "FoundEntity" - x-uppercaseResponseId: "FOUND_ENTITY" - uppercase_operation_id: "LOOKUP_RELEASE" - uppercase_data_type: "RELEASEENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "LOOKUP_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "LOOKUP_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "LOOKUP_RELEASE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "lookup_release" - uppercase_operation_id: "LOOKUP_RELEASE" - path: "/release/lookup" - HttpMethod: "Get" - httpmethod: "get" - /release/edit/{edit_id}: - get: - tags: - - "releases" - operationId: "get_release_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_RELEASE_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_release_edit" - uppercase_operation_id: "GET_RELEASE_EDIT" - path: "/release/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/release/edit/{edit_id}: - delete: - tags: - - "releases" - operationId: "delete_release_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_release_edit" - uppercase_operation_id: "DELETE_RELEASE_EDIT" - path: "/editgroup/:editgroup_id/release/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editgroup/{editgroup_id}/work: - post: - tags: - - "releases" - operationId: "create_work" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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: "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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_WORK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "create_work" - uppercase_operation_id: "CREATE_WORK" - path: "/editgroup/:editgroup_id/work" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/auto/work/batch: - post: - tags: - - "works" - operationId: "create_work_auto_batch" - parameters: - - in: "body" - name: "auto_batch" - required: true - schema: - $ref: "#/definitions/work_auto_batch" - uppercase_data_type: "WORKAUTOBATCH" - refName: "work_auto_batch" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_WORK_AUTO_BATCH" - consumesJson: true - responses: - 201: - description: "Created Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "CreatedEditgroup" - x-uppercaseResponseId: "CREATED_EDITGROUP" - uppercase_operation_id: "CREATE_WORK_AUTO_BATCH" - 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_WORK_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_WORK_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_WORK_AUTO_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_AUTO_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_AUTO_BATCH" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_work_auto_batch" - uppercase_operation_id: "CREATE_WORK_AUTO_BATCH" - path: "/editgroup/auto/work/batch" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /work/{ident}: - get: - tags: - - "works" - operationId: "get_work" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For works, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For works, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity" - 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/:ident" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/work/{ident}: - put: - tags: - - "works" - operationId: "update_work" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_WORK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "update_work" - uppercase_operation_id: "UPDATE_WORK" - path: "/editgroup/:editgroup_id/work/:ident" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - delete: - tags: - - "works" - operationId: "delete_work" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_WORK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "delete_work" - uppercase_operation_id: "DELETE_WORK" - path: "/editgroup/:editgroup_id/work/:ident" - HttpMethod: "Delete" - httpmethod: "delete" - /work/rev/{rev_id}: - get: - tags: - - "works" - operationId: "get_work_revision" - parameters: - - name: "rev_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"rev_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For works, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For works, none\ - \ accepted (yet)." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_example\".to_string())" - responses: - 200: - description: "Found Entity Revision" - schema: - $ref: "#/definitions/work_entity" - x-responseId: "FoundEntityRevision" - x-uppercaseResponseId: "FOUND_ENTITY_REVISION" - uppercase_operation_id: "GET_WORK_REVISION" - uppercase_data_type: "WORKENTITY" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WORK_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WORK_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WORK_REVISION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work_revision" - uppercase_operation_id: "GET_WORK_REVISION" - path: "/work/rev/:rev_id" - HttpMethod: "Get" - httpmethod: "get" - /work/{ident}/history: - get: - tags: - - "works" - operationId: "get_work_history" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_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" - 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/:ident/history" - HttpMethod: "Get" - httpmethod: "get" - /work/{ident}/redirects: - get: - tags: - - "works" - operationId: "get_work_redirects" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - responses: - 200: - description: "Found Entity Redirects" - schema: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - x-responseId: "FoundEntityRedirects" - x-uppercaseResponseId: "FOUND_ENTITY_REDIRECTS" - uppercase_operation_id: "GET_WORK_REDIRECTS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WORK_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WORK_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WORK_REDIRECTS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work_redirects" - uppercase_operation_id: "GET_WORK_REDIRECTS" - path: "/work/:ident/redirects" - HttpMethod: "Get" - httpmethod: "get" - /work/{ident}/releases: - get: - tags: - - "works" - operationId: "get_work_releases" - parameters: - - name: "ident" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"ident_example\".to_string()" - - name: "hide" - in: "query" - description: "List of entity fields to elide in response. For works, none\ - \ implemented yet." - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"hide_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" - 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/:ident/releases" - HttpMethod: "Get" - httpmethod: "get" - /work/edit/{edit_id}: - get: - tags: - - "works" - operationId: "get_work_edit" - parameters: - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Found Edit" - schema: - $ref: "#/definitions/entity_edit" - x-responseId: "FoundEdit" - x-uppercaseResponseId: "FOUND_EDIT" - uppercase_operation_id: "GET_WORK_EDIT" - uppercase_data_type: "ENTITYEDIT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_work_edit" - uppercase_operation_id: "GET_WORK_EDIT" - path: "/work/edit/:edit_id" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/work/edit/{edit_id}: - delete: - tags: - - "works" - operationId: "delete_work_edit" - parameters: - - name: "editgroup_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "edit_id" - in: "path" - description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" - required: true - type: "string" - 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}" - formatString: "\\\"{}\\\"" - example: "\"edit_id_example\".to_string()" - responses: - 200: - description: "Deleted Edit" - schema: - $ref: "#/definitions/success" - x-responseId: "DeletedEdit" - x-uppercaseResponseId: "DELETED_EDIT" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "SUCCESS" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 404: - description: "Not Found" - schema: - $ref: "#/definitions/error_response" - x-responseId: "NotFound" - x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 500: - description: "Generic Error" - schema: - $ref: "#/definitions/error_response" - x-responseId: "GenericError" - x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "DELETE_WORK_EDIT" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "delete_work_edit" - uppercase_operation_id: "DELETE_WORK_EDIT" - path: "/editgroup/:editgroup_id/work/edit/:edit_id" - HttpMethod: "Delete" - httpmethod: "delete" - /editor/{editor_id}: - get: - operationId: "get_editor" - parameters: - - name: "editor_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editor_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/:editor_id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_editor" - parameters: - - name: "editor_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editor_id_example\".to_string()" - - in: "body" - name: "editor" - required: true - schema: - $ref: "#/definitions/editor" - uppercase_data_type: "EDITOR" - refName: "editor" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_EDITOR" - consumesJson: true - responses: - 200: - description: "Updated Editor" - schema: - $ref: "#/definitions/editor" - x-responseId: "UpdatedEditor" - x-uppercaseResponseId: "UPDATED_EDITOR" - uppercase_operation_id: "UPDATE_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: "UPDATE_EDITOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_EDITOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "UPDATE_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: "UPDATE_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: "UPDATE_EDITOR" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "update_editor" - uppercase_operation_id: "UPDATE_EDITOR" - path: "/editor/:editor_id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - /editor/{editor_id}/editgroups: - get: - operationId: "get_editor_editgroups" - parameters: - - name: "editor_id" - in: "path" - required: true - type: "string" - formatString: "\\\"{}\\\"" - example: "\"editor_id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - - name: "before" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - - name: "since" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/editgroup" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITOR_EDITGROUPS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITOR_EDITGROUPS" - 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_EDITGROUPS" - 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_EDITGROUPS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editor_editgroups" - uppercase_operation_id: "GET_EDITOR_EDITGROUPS" - path: "/editor/:editor_id/editgroups" - HttpMethod: "Get" - httpmethod: "get" - /editor/{editor_id}/annotations: - get: - tags: - - "edit-lifecycle" - operationId: "get_editor_annotations" - parameters: - - name: "editor_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editor_id_example\".to_string()" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - - name: "before" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - - name: "since" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - responses: - 200: - description: "Success" - schema: - type: "array" - items: - $ref: "#/definitions/editgroup_annotation" - x-responseId: "Success" - x-uppercaseResponseId: "SUCCESS" - uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" - 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_ANNOTATIONS" - 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_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editor_annotations" - uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" - path: "/editor/:editor_id/annotations" - HttpMethod: "Get" - httpmethod: "get" - /editgroup: - post: - tags: - - "edit-lifecycle" - operationId: "create_editgroup" - parameters: - - in: "body" - name: "editgroup" - 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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_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: "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 - security: - - Bearer: [] - operation_id: "create_editgroup" - uppercase_operation_id: "CREATE_EDITGROUP" - path: "/editgroup" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/{editgroup_id}: - get: - tags: - - "edit-lifecycle" - operationId: "get_editgroup" - parameters: - - name: "editgroup_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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/:editgroup_id" - HttpMethod: "Get" - httpmethod: "get" - put: - operationId: "update_editgroup" - parameters: - - name: "editgroup_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - in: "body" - name: "editgroup" - required: true - schema: - $ref: "#/definitions/editgroup" - uppercase_data_type: "EDITGROUP" - refName: "editgroup" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "UPDATE_EDITGROUP" - consumesJson: true - - name: "submit" - in: "query" - required: false - type: "boolean" - formatString: "{:?}" - example: "Some(true)" - responses: - 200: - description: "Updated Editgroup" - schema: - $ref: "#/definitions/editgroup" - x-responseId: "UpdatedEditgroup" - x-uppercaseResponseId: "UPDATED_EDITGROUP" - uppercase_operation_id: "UPDATE_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: "UPDATE_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "UPDATE_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "UPDATE_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: "UPDATE_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: "UPDATE_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "update_editgroup" - uppercase_operation_id: "UPDATE_EDITGROUP" - path: "/editgroup/:editgroup_id" - HttpMethod: "Put" - httpmethod: "put" - noClientExample: true - /editgroup/{editgroup_id}/accept: - post: - tags: - - "edit-lifecycle" - operationId: "accept_editgroup" - parameters: - - name: "editgroup_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editgroup_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 - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "ACCEPT_EDITGROUP" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - 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 - security: - - Bearer: [] - operation_id: "accept_editgroup" - uppercase_operation_id: "ACCEPT_EDITGROUP" - path: "/editgroup/:editgroup_id/accept" - HttpMethod: "Post" - httpmethod: "post" - /editgroup/{editgroup_id}/annotations: - get: - tags: - - "edit-lifecycle" - operationId: "get_editgroup_annotations" - parameters: - - name: "editgroup_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For editgroups:\ - \ 'editors'" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - responses: - 200: - description: "Success" - schema: - type: "array" - items: - $ref: "#/definitions/editgroup_annotation" - x-responseId: "Success" - x-uppercaseResponseId: "SUCCESS" - uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" - 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_ANNOTATIONS" - 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_ANNOTATIONS" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editgroup_annotations" - uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" - path: "/editgroup/:editgroup_id/annotations" - HttpMethod: "Get" - httpmethod: "get" - /editgroup/{editgroup_id}/annotation: - post: - tags: - - "edit-lifecycle" - operationId: "create_editgroup_annotation" - parameters: - - name: "editgroup_id" - in: "path" - description: "base32-encoded unique identifier" - required: true - type: "string" - maxLength: 26 - minLength: 26 - pattern: "[a-zA-Z2-7]{26}" - formatString: "\\\"{}\\\"" - example: "\"editgroup_id_example\".to_string()" - - in: "body" - name: "annotation" - required: true - schema: - $ref: "#/definitions/editgroup_annotation" - uppercase_data_type: "EDITGROUPANNOTATION" - refName: "editgroup_annotation" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - consumesJson: true - responses: - 201: - description: "Created" - schema: - $ref: "#/definitions/editgroup_annotation" - x-responseId: "Created" - x-uppercaseResponseId: "CREATED" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - uppercase_data_type: "EDITGROUPANNOTATION" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - 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_EDITGROUP_ANNOTATION" - 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_ANNOTATION" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "create_editgroup_annotation" - uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" - path: "/editgroup/:editgroup_id/annotation" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /editgroup/reviewable: - get: - operationId: "get_editgroups_reviewable" - parameters: - - name: "expand" - in: "query" - description: "List of sub-entities to expand in response. For editgroups:\ - \ 'editors'" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"expand_example\".to_string())" - - name: "limit" - in: "query" - required: false - type: "integer" - format: "int64" - formatString: "{:?}" - example: "Some(789)" - - name: "before" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - - name: "since" - in: "query" - required: false - type: "string" - format: "date-time" - formatString: "{:?}" - example: "None" - responses: - 200: - description: "Found" - schema: - type: "array" - items: - $ref: "#/definitions/editgroup" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" - uppercase_data_type: "VEC" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" - 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_EDITGROUPS_REVIEWABLE" - 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_EDITGROUPS_REVIEWABLE" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_editgroups_reviewable" - uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" - path: "/editgroup/reviewable" - HttpMethod: "Get" - httpmethod: "get" - /changelog: - get: - tags: - - "edit-lifecycle" - 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" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_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_CHANGELOG" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - operation_id: "get_changelog" - uppercase_operation_id: "GET_CHANGELOG" - path: "/changelog" - HttpMethod: "Get" - httpmethod: "get" - /changelog/{index}: - get: - tags: - - "edit-lifecycle" - operationId: "get_changelog_entry" - parameters: - - name: "index" - 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 - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_CHANGELOG_ENTRY" - 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_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/:index" - HttpMethod: "Get" - httpmethod: "get" - /auth/oidc: - post: - operationId: "auth_oidc" - parameters: - - in: "body" - name: "oidc_params" - required: true - schema: - $ref: "#/definitions/auth_oidc" - uppercase_data_type: "AUTHOIDC" - refName: "auth_oidc" - formatString: "{:?}" - example: "???" - model_key: "editgroup_edits" - uppercase_operation_id: "AUTH_OIDC" - consumesJson: true - responses: - 200: - description: "Found" - schema: - $ref: "#/definitions/auth_oidc_result" - x-responseId: "Found" - x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "AUTH_OIDC" - uppercase_data_type: "AUTHOIDCRESULT" - producesJson: true - 201: - description: "Created" - schema: - $ref: "#/definitions/auth_oidc_result" - x-responseId: "Created" - x-uppercaseResponseId: "CREATED" - uppercase_operation_id: "AUTH_OIDC" - uppercase_data_type: "AUTHOIDCRESULT" - producesJson: true - 400: - description: "Bad Request" - schema: - $ref: "#/definitions/error_response" - x-responseId: "BadRequest" - x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "AUTH_OIDC" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "AUTH_OIDC" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "AUTH_OIDC" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 409: - description: "Conflict" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Conflict" - x-uppercaseResponseId: "CONFLICT" - uppercase_operation_id: "AUTH_OIDC" - 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: "AUTH_OIDC" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "auth_oidc" - uppercase_operation_id: "AUTH_OIDC" - path: "/auth/oidc" - HttpMethod: "Post" - httpmethod: "post" - noClientExample: true - /auth/check: - get: - operationId: "auth_check" - parameters: - - name: "role" - in: "query" - required: false - type: "string" - formatString: "{:?}" - example: "Some(\"role_example\".to_string())" - responses: - 200: - description: "Success" - schema: - $ref: "#/definitions/success" - x-responseId: "Success" - x-uppercaseResponseId: "SUCCESS" - uppercase_operation_id: "AUTH_CHECK" - 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: "AUTH_CHECK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - x-responseId: "NotAuthorized" - x-uppercaseResponseId: "NOT_AUTHORIZED" - uppercase_operation_id: "AUTH_CHECK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" - x-responseId: "Forbidden" - x-uppercaseResponseId: "FORBIDDEN" - uppercase_operation_id: "AUTH_CHECK" - 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: "AUTH_CHECK" - uppercase_data_type: "ERRORRESPONSE" - producesJson: true - security: - - Bearer: [] - operation_id: "auth_check" - uppercase_operation_id: "AUTH_CHECK" - path: "/auth/check" - HttpMethod: "Get" - httpmethod: "get" -securityDefinitions: - Bearer: - type: "apiKey" - name: "Authorization" - in: "header" -definitions: - error_response: - type: "object" - required: - - "error" - - "message" - - "success" - properties: - success: - type: "boolean" - error: - type: "string" - message: - type: "string" - example: "A really confusing, totally unexpected thing happened" - upperCaseName: "ERROR_RESPONSE" - success: - type: "object" - required: - - "message" - - "success" - properties: - success: - type: "boolean" - message: - type: "string" - example: "The computers did the thing successfully!" - example: - success: true - message: "The computers did the thing successfully!" - upperCaseName: "SUCCESS" - container_entity: - type: "object" - properties: - 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" - container_type: - type: "string" - description: "Eg, 'journal'" - name: - type: "string" - example: "Journal of Important Results" - description: "Required for valid entities" - edit_extra: - type: "object" - extra: - type: "object" - 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: "{}" - container_type: "container_type" - name: "Journal of Important Results" - publisher: "Society of Curious Students" - issnl: "1234-5678" - wikidata_qid: "wikidata_qid" - state: "wip" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "CONTAINER_ENTITY" - creator_entity: - type: "object" - 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" - description: "Required for valid entities" - 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}" - extra: - type: "object" - edit_extra: - type: "object" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "CREATOR_ENTITY" - file_entity: - type: "object" - properties: - releases: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/release_entity" - release_ids: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - mimetype: - type: "string" - example: "application/pdf" - urls: - type: "array" - items: - $ref: "#/definitions/file_url" - sha256: - type: "string" - example: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - minLength: 64 - maxLength: 64 - pattern: "[a-f0-9]{64}" - sha1: - type: "string" - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - minLength: 40 - maxLength: 40 - pattern: "[a-f0-9]{40}" - md5: - type: "string" - example: "1b39813549077b2347c0f370c3864b40" - minLength: 32 - maxLength: 32 - pattern: "[a-f0-9]{32}" - size: - type: "integer" - format: "int64" - example: 1048576 - edit_extra: - type: "object" - extra: - type: "object" - 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: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - mimetype: "application/pdf" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - upperCaseName: "FILE_ENTITY" - file_url: - type: "object" - 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_URL" - fileset_entity: - type: "object" - properties: - releases: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/release_entity" - release_ids: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - urls: - type: "array" - items: - $ref: "#/definitions/fileset_url" - manifest: - type: "array" - items: - $ref: "#/definitions/fileset_file" - 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}" - extra: - type: "object" - edit_extra: - type: "object" - example: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - manifest: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "FILESET_ENTITY" - fileset_url: - type: "object" - 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: "FILESET_URL" - fileset_file: - type: "object" - required: - - "path" - - "size" - properties: - path: - type: "string" - example: "img/cat.png" - size: - type: "integer" - format: "int64" - example: 1048576 - md5: - type: "string" - example: "1b39813549077b2347c0f370c3864b40" - minLength: 32 - maxLength: 32 - pattern: "[a-f0-9]{32}" - sha1: - type: "string" - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - minLength: 40 - maxLength: 40 - pattern: "[a-f0-9]{40}" - sha256: - type: "string" - example: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - minLength: 64 - maxLength: 64 - pattern: "[a-f0-9]{64}" - extra: - type: "object" - example: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - upperCaseName: "FILESET_FILE" - webcapture_entity: - type: "object" - properties: - releases: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/release_entity" - release_ids: - type: "array" - items: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - timestamp: - type: "string" - format: "date-time" - description: "same format as CDX line timestamp (UTC, etc). Corresponds to\ - \ the overall capture timestamp. Can be the earliest or average of CDX timestamps\ - \ if that makes sense." - original_url: - type: "string" - format: "url" - example: "http://asheesh.org" - archive_urls: - type: "array" - items: - $ref: "#/definitions/webcapture_url" - cdx: - type: "array" - items: - $ref: "#/definitions/webcapture_cdx_line" - edit_extra: - type: "object" - extra: - type: "object" - 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" - archive_urls: - - rel: "wayback" - url: "https://web.archive.org/web/" - - rel: "wayback" - url: "https://web.archive.org/web/" - original_url: "http://asheesh.org" - cdx: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - timestamp: "2000-01-23T04:56:07.000+00:00" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - upperCaseName: "WEBCAPTURE_ENTITY" - webcapture_cdx_line: - type: "object" - required: - - "sha1" - - "surt" - - "timestamp" - - "url" - properties: - surt: - type: "string" - example: "org,asheesh)/apus/ch1/node15.html" - timestamp: - type: "string" - format: "date-time" - example: "2016-09-19T17:20:24Z" - description: "UTC, 'Z'-terminated, second (or better) precision" - url: - type: "string" - example: "http://www.asheesh.org:80/APUS/ch1/node15.html" - mimetype: - type: "string" - example: "text/html" - status_code: - type: "integer" - format: "int64" - example: 200 - size: - type: "integer" - format: "int64" - example: 1048576 - sha1: - type: "string" - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - minLength: 40 - maxLength: 40 - pattern: "[a-f0-9]{40}" - sha256: - type: "string" - example: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - minLength: 64 - maxLength: 64 - pattern: "[a-f0-9]{64}" - example: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - upperCaseName: "WEBCAPTURE_CDX_LINE" - webcapture_url: - type: "object" - required: - - "rel" - - "url" - properties: - url: - type: "string" - format: "url" - example: "https://web.archive.org/web/" - rel: - type: "string" - example: "wayback" - example: - rel: "wayback" - url: "https://web.archive.org/web/" - upperCaseName: "WEBCAPTURE_URL" - release_entity: - type: "object" - required: - - "ext_ids" - properties: - abstracts: - type: "array" - items: - $ref: "#/definitions/release_abstract" - refs: - type: "array" - items: - $ref: "#/definitions/release_ref" - contribs: - type: "array" - items: - $ref: "#/definitions/release_contrib" - license_slug: - type: "string" - description: "Short version of license name. Eg, 'CC-BY'" - language: - type: "string" - description: "Two-letter RFC1766/ISO639-1 language code, with extensions" - publisher: - type: "string" - version: - type: "string" - number: - type: "string" - pages: - type: "string" - issue: - type: "string" - example: "12" - volume: - type: "string" - ext_ids: - $ref: "#/definitions/release_ext_ids" - withdrawn_year: - type: "integer" - format: "int64" - example: 2014 - withdrawn_date: - type: "string" - format: "date" - withdrawn_status: - type: "string" - release_year: - type: "integer" - format: "int64" - example: 2014 - release_date: - type: "string" - format: "date" - release_stage: - type: "string" - example: "preprint, retracted" - release_type: - type: "string" - example: "book" - container_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - webcaptures: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/webcapture_entity" - filesets: - type: "array" - description: "Optional; GET-only" - items: - $ref: "#/definitions/fileset_entity" - 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" - original_title: - type: "string" - description: "Title in original language (or, the language of the full text\ - \ of this release)" - subtitle: - type: "string" - description: "Avoid this field if possible, and merge with title; usually\ - \ English" - title: - type: "string" - description: "Required for valid entities. The title used in citations and\ - \ for display; usually English" - 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}" - extra: - type: "object" - edit_extra: - type: "object" - example: - container: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - container_type: "container_type" - name: "Journal of Important Results" - publisher: "Society of Curious Students" - issnl: "1234-5678" - wikidata_qid: "wikidata_qid" - state: "wip" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - archive_urls: - - rel: "wayback" - url: "https://web.archive.org/web/" - - rel: "wayback" - url: "https://web.archive.org/web/" - original_url: "http://asheesh.org" - cdx: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - timestamp: "2000-01-23T04:56:07.000+00:00" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - archive_urls: - - rel: "wayback" - url: "https://web.archive.org/web/" - - rel: "wayback" - url: "https://web.archive.org/web/" - original_url: "http://asheesh.org" - cdx: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - surt: "org,asheesh)/apus/ch1/node15.html" - status_code: 200 - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - mimetype: "text/html" - url: "http://www.asheesh.org:80/APUS/ch1/node15.html" - timestamp: "2016-09-19T17:20:24Z" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - timestamp: "2000-01-23T04:56:07.000+00:00" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - withdrawn_status: "withdrawn_status" - language: "language" - title: "title" - contribs: - - raw_affiliation: "raw_affiliation" - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - surname: "surname" - extra: "{}" - creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - index: 1 - given_name: "given_name" - - raw_affiliation: "raw_affiliation" - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - surname: "surname" - extra: "{}" - creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - index: 1 - given_name: "given_name" - number: "number" - pages: "pages" - extra: "{}" - state: "wip" - edit_extra: "{}" - withdrawn_year: 2014 - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - work_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - issue: "12" - original_title: "original_title" - abstracts: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - mimetype: "application/xml+jats" - lang: "en" - content: "Some abstract thing goes here" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - mimetype: "application/xml+jats" - lang: "en" - content: "Some abstract thing goes here" - release_year: 2014 - release_type: "book" - version: "version" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - volume: "volume" - ext_ids: - core: "core" - mag: "mag" - jstor: "jstor" - isbn13: "isbn13" - arxiv: "arxiv" - wikidata_qid: "wikidata_qid" - ark: "ark" - pmid: "pmid" - pmcid: "pmcid" - doi: "10.1234/abcde.789" - release_stage: "preprint, retracted" - license_slug: "license_slug" - withdrawn_date: "2000-01-23" - refs: - - target_release_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - container_name: "container_name" - year: 6 - extra: "{}" - index: 0 - title: "title" - locator: "p123" - key: "key" - - target_release_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - container_name: "container_name" - year: 6 - extra: "{}" - index: 0 - title: "title" - locator: "p123" - key: "key" - release_date: "2000-01-23" - subtitle: "subtitle" - publisher: "publisher" - files: - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - mimetype: "application/pdf" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - size: 1048576 - extra: "{}" - mimetype: "application/pdf" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - filesets: - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - manifest: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - urls: - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - - rel: "webarchive" - url: "https://example.edu/~frau/prcding.pdf" - manifest: - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - path: "img/cat.png" - size: 1048576 - sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - extra: "{}" - md5: "1b39813549077b2347c0f370c3864b40" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - state: "wip" - release_ids: - - "q3nouwy3nnbsvo3h5klxsx4a7y" - - "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_extra: "{}" - releases: - - null - - null - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - container_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - upperCaseName: "RELEASE_ENTITY" - release_ext_ids: - type: "object" - properties: - doi: - type: "string" - example: "10.1234/abcde.789" - wikidata_qid: - type: "string" - isbn13: - type: "string" - pmid: - type: "string" - pmcid: - type: "string" - core: - type: "string" - arxiv: - type: "string" - jstor: - type: "string" - ark: - type: "string" - mag: - type: "string" - example: - core: "core" - mag: "mag" - jstor: "jstor" - isbn13: "isbn13" - arxiv: "arxiv" - wikidata_qid: "wikidata_qid" - ark: "ark" - pmid: "pmid" - pmcid: "pmcid" - doi: "10.1234/abcde.789" - upperCaseName: "RELEASE_EXT_IDS" - release_abstract: - type: "object" - properties: - sha1: - type: "string" - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - minLength: 40 - maxLength: 40 - pattern: "[a-f0-9]{40}" - content: - type: "string" - example: "Some abstract thing goes here" - mimetype: - type: "string" - example: "application/xml+jats" - lang: - type: "string" - example: "en" - example: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - mimetype: "application/xml+jats" - lang: "en" - content: "Some abstract thing goes here" - upperCaseName: "RELEASE_ABSTRACT" - work_entity: - type: "object" - properties: - edit_extra: - type: "object" - extra: - type: "object" - 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: "{}" - state: "wip" - edit_extra: "{}" - 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: - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - changelog_index: 1048576 - submitted: "2000-01-23T04:56:07.000+00:00" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - filesets: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "description" - annotations: - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit: - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - changelog_entry: - editgroup: - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - changelog_index: 1048576 - submitted: "2000-01-23T04:56:07.000+00:00" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - filesets: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "description" - annotations: - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - editor_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: "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}" - 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}" - prev_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_ident: - 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: - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: - editor_id: - type: "string" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - username: - type: "string" - example: "zerocool93" - is_admin: - type: "boolean" - is_bot: - type: "boolean" - is_active: - type: "boolean" - example: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - upperCaseName: "EDITOR" - editgroup: - type: "object" - properties: - editgroup_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}" - editor: - $ref: "#/definitions/editor" - changelog_index: - type: "integer" - format: "int64" - example: 1048576 - created: - type: "string" - format: "date-time" - submitted: - type: "string" - format: "date-time" - description: - type: "string" - extra: - type: "object" - annotations: - type: "array" - items: - $ref: "#/definitions/editgroup_annotation" - edits: - $ref: "#/definitions/editgroup_edits" - example: - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - changelog_index: 1048576 - submitted: "2000-01-23T04:56:07.000+00:00" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - filesets: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "description" - annotations: - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - upperCaseName: "EDITGROUP" - editgroup_annotation: - type: "object" - properties: - annotation_id: - 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}" - editgroup_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}" - editor: - $ref: "#/definitions/editor" - created: - type: "string" - format: "date-time" - comment_markdown: - type: "string" - extra: - type: "object" - example: - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - upperCaseName: "EDITGROUP_ANNOTATION" - 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: - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - changelog_index: 1048576 - submitted: "2000-01-23T04:56:07.000+00:00" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - edits: - works: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - filesets: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "description" - annotations: - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - created: "2000-01-23T04:56:07.000+00:00" - extra: "{}" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - comment_markdown: "comment_markdown" - editor_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" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - extra: - type: "object" - key: - type: "string" - year: - type: "integer" - format: "int64" - container_name: - type: "string" - title: - type: "string" - locator: - type: "string" - example: "p123" - example: - target_release_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - container_name: "container_name" - year: 6 - 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" - example: "q3nouwy3nnbsvo3h5klxsx4a7y" - description: "base32-encoded unique identifier" - minLength: 26 - maxLength: 26 - pattern: "[a-zA-Z2-7]{26}" - creator: - description: "Optional; GET-only" - $ref: "#/definitions/creator_entity" - raw_name: - type: "string" - given_name: - type: "string" - surname: - type: "string" - role: - type: "string" - raw_affiliation: - type: "string" - description: "Raw affiliation string as displayed in text" - extra: - type: "object" - example: - raw_affiliation: "raw_affiliation" - creator: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" - surname: "surname" - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - extra: "{}" - orcid: "0000-0002-1825-0097" - wikidata_qid: "wikidata_qid" - state: "wip" - given_name: "given_name" - display_name: "Grace Hopper" - edit_extra: "{}" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - raw_name: "raw_name" - role: "role" - surname: "surname" - extra: "{}" - creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - index: 1 - given_name: "given_name" - upperCaseName: "RELEASE_CONTRIB" - container_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/container_entity" - upperCaseName: "CONTAINER_AUTO_BATCH" - creator_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/creator_entity" - upperCaseName: "CREATOR_AUTO_BATCH" - file_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/file_entity" - upperCaseName: "FILE_AUTO_BATCH" - fileset_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/fileset_entity" - upperCaseName: "FILESET_AUTO_BATCH" - webcapture_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/webcapture_entity" - upperCaseName: "WEBCAPTURE_AUTO_BATCH" - release_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/release_entity" - upperCaseName: "RELEASE_AUTO_BATCH" - work_auto_batch: - type: "object" - required: - - "editgroup" - - "entity_list" - properties: - editgroup: - $ref: "#/definitions/editgroup" - entity_list: - type: "array" - items: - $ref: "#/definitions/work_entity" - upperCaseName: "WORK_AUTO_BATCH" - auth_oidc: - type: "object" - required: - - "iss" - - "preferred_username" - - "provider" - - "sub" - properties: - provider: - type: "string" - sub: - type: "string" - iss: - type: "string" - preferred_username: - type: "string" - upperCaseName: "AUTH_OIDC" - auth_oidc_result: - type: "object" - required: - - "editor" - - "token" - properties: - editor: - $ref: "#/definitions/editor" - token: - type: "string" - example: - editor: - is_admin: true - is_active: true - editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - is_bot: true - username: "zerocool93" - token: "token" - upperCaseName: "AUTH_OIDC_RESULT" - 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" - filesets: - type: "array" - items: - $ref: "#/definitions/entity_edit" - webcaptures: - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - webcaptures: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - filesets: - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - extra: "{}" - redirect_ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - prev_revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - - ident: "q3nouwy3nnbsvo3h5klxsx4a7y" - edit_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - 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-md5: - type: "string" - example: "1b39813549077b2347c0f370c3864b40" - pattern: "[a-f0-9]{32}" - minLength: 32 - maxLength: 32 -x-sha1: - type: "string" - example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" - pattern: "[a-f0-9]{40}" - minLength: 40 - maxLength: 40 -x-sha256: - type: "string" - example: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" - pattern: "[a-f0-9]{64}" - minLength: 64 - maxLength: 64 -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" - extra: - type: "object" - additionalProperties: {} - edit_extra: - type: "object" - additionalProperties: {} -x-auth-responses: - 401: - description: "Not Authorized" - schema: - $ref: "#/definitions/error_response" - headers: - WWW_Authenticate: - type: "string" - 403: - description: "Forbidden" - schema: - $ref: "#/definitions/error_response" -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-spec/examples/ca.pem b/rust/fatcat-api-spec/examples/ca.pem deleted file mode 100644 index d2317fb5..00000000 --- a/rust/fatcat-api-spec/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-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs deleted file mode 100644 index 3cb0df50..00000000 --- a/rust/fatcat-api-spec/examples/client.rs +++ /dev/null @@ -1,685 +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, AuthCheckResponse, AuthOidcResponse, ContextWrapperExt, CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, - CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, - CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, - DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, - DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, - GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, - GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, - GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, - GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, - GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, - GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, - GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, - UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, 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(&[ - "DeleteContainer", - "DeleteContainerEdit", - "GetContainer", - "GetContainerEdit", - "GetContainerHistory", - "GetContainerRedirects", - "GetContainerRevision", - "LookupContainer", - "DeleteCreator", - "DeleteCreatorEdit", - "GetCreator", - "GetCreatorEdit", - "GetCreatorHistory", - "GetCreatorRedirects", - "GetCreatorReleases", - "GetCreatorRevision", - "LookupCreator", - "AuthCheck", - "GetEditgroupsReviewable", - "GetEditor", - "GetEditorEditgroups", - "AcceptEditgroup", - "GetChangelog", - "GetChangelogEntry", - "GetEditgroup", - "GetEditgroupAnnotations", - "GetEditorAnnotations", - "DeleteFile", - "DeleteFileEdit", - "GetFile", - "GetFileEdit", - "GetFileHistory", - "GetFileRedirects", - "GetFileRevision", - "LookupFile", - "DeleteFileset", - "DeleteFilesetEdit", - "GetFileset", - "GetFilesetEdit", - "GetFilesetHistory", - "GetFilesetRedirects", - "GetFilesetRevision", - "DeleteRelease", - "DeleteReleaseEdit", - "GetRelease", - "GetReleaseEdit", - "GetReleaseFiles", - "GetReleaseFilesets", - "GetReleaseHistory", - "GetReleaseRedirects", - "GetReleaseRevision", - "GetReleaseWebcaptures", - "LookupRelease", - "DeleteWebcapture", - "DeleteWebcaptureEdit", - "GetWebcapture", - "GetWebcaptureEdit", - "GetWebcaptureHistory", - "GetWebcaptureRedirects", - "GetWebcaptureRevision", - "DeleteWork", - "DeleteWorkEdit", - "GetWork", - "GetWorkEdit", - "GetWorkHistory", - "GetWorkRedirects", - "GetWorkReleases", - "GetWorkRevision", - ]) - .required(true) - .index(1), - ) - .arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) - .arg(Arg::with_name("host").long("host").takes_value(true).default_value("api.fatcat.wiki").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") { - // Disabled because there's no example. - // Some("CreateContainer") => { - // let result = client.create_container("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateContainerAutoBatch") => { - // let result = client.create_container_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteContainer") => { - let result = client.delete_container("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteContainerEdit") => { - let result = client.delete_container_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetContainer") => { - let result = client - .get_container("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetContainerEdit") => { - let result = client.get_container_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetContainerHistory") => { - let result = client.get_container_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetContainerRedirects") => { - let result = client.get_container_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetContainerRevision") => { - let result = client - .get_container_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("LookupContainer") => { - let result = client - .lookup_container( - Some("issnl_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateContainer") => { - // let result = client.update_container("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateCreator") => { - // let result = client.create_creator("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateCreatorAutoBatch") => { - // let result = client.create_creator_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteCreator") => { - let result = client.delete_creator("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteCreatorEdit") => { - let result = client.delete_creator_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreator") => { - let result = client - .get_creator("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreatorEdit") => { - let result = client.get_creator_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreatorHistory") => { - let result = client.get_creator_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreatorRedirects") => { - let result = client.get_creator_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreatorReleases") => { - let result = client.get_creator_releases("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetCreatorRevision") => { - let result = client - .get_creator_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("LookupCreator") => { - let result = client - .lookup_creator( - Some("orcid_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateCreator") => { - // let result = client.update_creator("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("AuthCheck") => { - let result = client.auth_check(Some("role_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("AuthOidc") => { - // let result = client.auth_oidc(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("GetEditgroupsReviewable") => { - let result = client.get_editgroups_reviewable(Some("expand_example".to_string()), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetEditor") => { - let result = client.get_editor("editor_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetEditorEditgroups") => { - let result = client.get_editor_editgroups("editor_id_example".to_string(), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateEditgroup") => { - // let result = client.update_editgroup("editgroup_id_example".to_string(), ???, Some(true)).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("UpdateEditor") => { - // let result = client.update_editor("editor_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("AcceptEditgroup") => { - let result = client.accept_editgroup("editgroup_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("CreateEditgroup") => { - // let result = client.create_editgroup(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateEditgroupAnnotation") => { - // let result = client.create_editgroup_annotation("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - 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(""))); - } - - 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(""))); - } - - Some("GetEditgroup") => { - let result = client.get_editgroup("editgroup_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetEditgroupAnnotations") => { - let result = client.get_editgroup_annotations("editgroup_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(""))); - } - - Some("GetEditorAnnotations") => { - let result = client.get_editor_annotations("editor_id_example".to_string(), Some(789), None, None).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("CreateFile") => { - // let result = client.create_file("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateFileAutoBatch") => { - // let result = client.create_file_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteFile") => { - let result = client.delete_file("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteFileEdit") => { - let result = client.delete_file_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFile") => { - let result = client - .get_file("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFileEdit") => { - let result = client.get_file_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFileHistory") => { - let result = client.get_file_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFileRedirects") => { - let result = client.get_file_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFileRevision") => { - let result = client - .get_file_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("LookupFile") => { - let result = client - .lookup_file( - Some("md5_example".to_string()), - Some("sha1_example".to_string()), - Some("sha256_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateFile") => { - // let result = client.update_file("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateFileset") => { - // let result = client.create_fileset("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateFilesetAutoBatch") => { - // let result = client.create_fileset_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteFileset") => { - let result = client.delete_fileset("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteFilesetEdit") => { - let result = client.delete_fileset_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFileset") => { - let result = client - .get_fileset("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFilesetEdit") => { - let result = client.get_fileset_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFilesetHistory") => { - let result = client.get_fileset_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFilesetRedirects") => { - let result = client.get_fileset_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetFilesetRevision") => { - let result = client - .get_fileset_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateFileset") => { - // let result = client.update_fileset("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateRelease") => { - // let result = client.create_release("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateReleaseAutoBatch") => { - // let result = client.create_release_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateWork") => { - // let result = client.create_work("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteRelease") => { - let result = client.delete_release("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteReleaseEdit") => { - let result = client.delete_release_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetRelease") => { - let result = client - .get_release("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseEdit") => { - let result = client.get_release_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseFiles") => { - let result = client.get_release_files("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseFilesets") => { - let result = client.get_release_filesets("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseHistory") => { - let result = client.get_release_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseRedirects") => { - let result = client.get_release_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseRevision") => { - let result = client - .get_release_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetReleaseWebcaptures") => { - let result = client.get_release_webcaptures("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("LookupRelease") => { - let result = client - .lookup_release( - Some("doi_example".to_string()), - Some("wikidata_qid_example".to_string()), - Some("isbn13_example".to_string()), - Some("pmid_example".to_string()), - Some("pmcid_example".to_string()), - Some("core_example".to_string()), - Some("arxiv_example".to_string()), - Some("jstor_example".to_string()), - Some("ark_example".to_string()), - Some("mag_example".to_string()), - Some("expand_example".to_string()), - Some("hide_example".to_string()), - ) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateRelease") => { - // let result = client.update_release("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateWebcapture") => { - // let result = client.create_webcapture("editgroup_id_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateWebcaptureAutoBatch") => { - // let result = client.create_webcapture_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteWebcapture") => { - let result = client.delete_webcapture("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteWebcaptureEdit") => { - let result = client.delete_webcapture_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWebcapture") => { - let result = client - .get_webcapture("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWebcaptureEdit") => { - let result = client.get_webcapture_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWebcaptureHistory") => { - let result = client.get_webcapture_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWebcaptureRedirects") => { - let result = client.get_webcapture_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWebcaptureRevision") => { - let result = client - .get_webcapture_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateWebcapture") => { - // let result = client.update_webcapture("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - - // Disabled because there's no example. - // Some("CreateWorkAutoBatch") => { - // let result = client.create_work_auto_batch(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - Some("DeleteWork") => { - let result = client.delete_work("editgroup_id_example".to_string(), "ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("DeleteWorkEdit") => { - let result = client.delete_work_edit("editgroup_id_example".to_string(), "edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWork") => { - let result = client - .get_work("ident_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWorkEdit") => { - let result = client.get_work_edit("edit_id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWorkHistory") => { - let result = client.get_work_history("ident_example".to_string(), Some(789)).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWorkRedirects") => { - let result = client.get_work_redirects("ident_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWorkReleases") => { - let result = client.get_work_releases("ident_example".to_string(), Some("hide_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - Some("GetWorkRevision") => { - let result = client - .get_work_revision("rev_id_example".to_string(), Some("expand_example".to_string()), Some("hide_example".to_string())) - .wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - } - - // Disabled because there's no example. - // Some("UpdateWork") => { - // let result = client.update_work("editgroup_id_example".to_string(), "ident_example".to_string(), ???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); - // }, - _ => panic!("Invalid operation provided"), - } -} diff --git a/rust/fatcat-api-spec/examples/server-chain.pem b/rust/fatcat-api-spec/examples/server-chain.pem deleted file mode 100644 index 47d7e201..00000000 --- a/rust/fatcat-api-spec/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-spec/examples/server-key.pem b/rust/fatcat-api-spec/examples/server-key.pem deleted file mode 100644 index 29c00682..00000000 --- a/rust/fatcat-api-spec/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-spec/examples/server.rs b/rust/fatcat-api-spec/examples/server.rs deleted file mode 100644 index 8d2e9b64..00000000 --- a/rust/fatcat-api-spec/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 ; -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 { - 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-spec/examples/server_lib/mod.rs b/rust/fatcat-api-spec/examples/server_lib/mod.rs deleted file mode 100644 index bf404d49..00000000 --- a/rust/fatcat-api-spec/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 { - Ok(server::Server {}) -} diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs deleted file mode 100644 index c9f92d33..00000000 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ /dev/null @@ -1,1057 +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, AuthCheckResponse, AuthOidcResponse, Context, CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, - CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, - CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, - DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, - DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, - GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, - GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, - GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, - GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, - GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, - GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, - GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, - UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, -}; - -#[derive(Copy, Clone)] -pub struct Server; - -impl Api for Server { - fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_container(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_container_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_container(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_container_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_container_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_container_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_container_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_container_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_container( - &self, - issnl: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - issnl, - wikidata_qid, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_container(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_creator(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_creator_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_creator(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_creator_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_creator_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_creator_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_creator_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_releases(&self, ident: String, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_creator_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_creator( - &self, - orcid: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - orcid, - wikidata_qid, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_creator(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn auth_check(&self, role: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("auth_check({:?}) - X-Span-ID: {:?}", role, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("auth_oidc({:?}) - X-Span-ID: {:?}", oidc_params, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroups_reviewable( - &self, - expand: Option, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - expand, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor_editgroups( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - editor_id, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - editgroup_id, - editgroup, - submit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}", - editor_id, - editor, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("create_editgroup({:?}) - X-Span-ID: {:?}", editgroup, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_editgroup_annotation( - &self, - editgroup_id: String, - annotation: models::EditgroupAnnotation, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - annotation, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_changelog_entry(&self, index: i64, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_changelog_entry({}) - X-Span-ID: {:?}", index, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - expand, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_editor_annotations( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - editor_id, - limit, - before, - since, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_file(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_file_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_file(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_file_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_file_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_file_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_file_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_file_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_file( - &self, - md5: Option, - sha1: Option, - sha256: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - md5, - sha1, - sha256, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_file(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_fileset(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_fileset_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_fileset(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_fileset_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_fileset_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_fileset_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_fileset_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_fileset_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_fileset(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_release(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_release_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_work(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_release_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_release_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_files(&self, ident: String, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_filesets(&self, ident: String, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release_filesets(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_release_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_release_webcaptures(&self, ident: String, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_release_webcaptures(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn lookup_release( - &self, - doi: Option, - wikidata_qid: Option, - isbn13: Option, - pmid: Option, - pmcid: Option, - core: Option, - arxiv: Option, - jstor: Option, - ark: Option, - mag: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send> { - let context = context.clone(); - println!( - "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", - doi, - wikidata_qid, - isbn13, - pmid, - pmcid, - core, - arxiv, - jstor, - ark, - mag, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_release(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_webcapture_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_webcapture(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_webcapture_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_webcapture_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_webcapture_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_webcapture_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_webcapture_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_webcapture(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "create_work_auto_batch({:?}) - X-Span-ID: {:?}", - auto_batch, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - ident, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn delete_work_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "delete_work_edit(\"{}\", \"{}\") - X-Span-ID: {:?}", - editgroup_id, - edit_id, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - ident, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_edit(&self, edit_id: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_work_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - limit, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_redirects(&self, ident: String, context: &Context) -> Box + Send> { - let context = context.clone(); - println!("get_work_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("")).clone()); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_releases(&self, ident: String, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}", - ident, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", - rev_id, - expand, - hide, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } - - fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity, context: &Context) -> Box + Send> { - let context = context.clone(); - println!( - "update_work(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}", - editgroup_id, - ident, - entity, - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) - } -} diff --git a/rust/fatcat-api-spec/rustfmt.toml b/rust/fatcat-api-spec/rustfmt.toml deleted file mode 100644 index cba42c2b..00000000 --- a/rust/fatcat-api-spec/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-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs deleted file mode 100644 index 378c546f..00000000 --- a/rust/fatcat-api-spec/src/client.rs +++ /dev/null @@ -1,7664 +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, AuthCheckResponse, AuthOidcResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, CreateCreatorResponse, - CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, CreateReleaseAutoBatchResponse, - CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, - DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, - DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, - GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, - GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, - GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, - GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, - GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, - GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, - UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, -}; - -/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. -fn into_base_path(input: T, correct_scheme: Option<&'static str>) -> Result { - // 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 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(base_path: T) -> Result - 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(base_path: T, ca_certificate: CA) -> Result - where - T: IntoUrl, - CA: AsRef, - { - 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(base_path: T, ca_certificate: CA, client_key: K, client_certificate: C) -> Result - where - T: IntoUrl, - CA: AsRef, - K: AsRef, - C: AsRef, - { - 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(base_path: T, hyper_client: Arc hyper::client::Client + Sync + Send>) -> Result - where - T: IntoUrl, - { - Ok(Client { - base_path: into_base_path(base_path, None)?, - hyper_client: hyper_client, - }) - } -} - -impl Api for Client { - fn create_container(&self, param_editgroup_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/container", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::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 { - 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::(&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::(&buf)?; - - Ok(CreateContainerResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateContainerResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateContainerResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_container_auto_batch(&self, param_auto_batch: models::ContainerAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/container/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_AUTO_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 { - 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::(&buf)?; - - Ok(CreateContainerAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateContainerAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateContainerAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateContainerAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateContainerAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateContainerAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_container(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/container/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(DeleteContainerResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteContainerResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_container_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/container/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteContainerEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteContainerEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_container(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/container/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_container_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/container/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_container_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/container/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_container_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/container/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetContainerRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_container_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/container/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetContainerRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn lookup_container( - &self, - param_issnl: Option, - param_wikidata_qid: Option, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_issnl = param_issnl.map_or_else(String::new, |query| format!("issnl={issnl}&", issnl = query.to_string())); - let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/container/lookup?{issnl}{wikidata_qid}{expand}{hide}", - self.base_path, - issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET), - wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_container( - &self, - param_editgroup_id: String, - param_ident: String, - param_entity: models::ContainerEntity, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/container/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(UpdateContainerResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateContainerResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateContainerResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_creator(&self, param_editgroup_id: String, param_entity: models::CreatorEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/creator", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::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 { - 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::(&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::(&buf)?; - - Ok(CreateCreatorResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateCreatorResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateCreatorResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_creator_auto_batch(&self, param_auto_batch: models::CreatorAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/creator/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_AUTO_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 { - 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::(&buf)?; - - Ok(CreateCreatorAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateCreatorAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateCreatorAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateCreatorAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateCreatorAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateCreatorAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_creator(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/creator/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(DeleteCreatorResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteCreatorResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_creator_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/creator/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteCreatorEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteCreatorEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/creator/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/creator/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/creator/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(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::(&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::(&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::(&buf)?; - - Ok(GetCreatorHistoryResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/creator/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetCreatorRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator_releases(&self, param_ident: String, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/creator/{ident}/releases?{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetCreatorReleasesResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorReleasesResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorReleasesResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_creator_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/creator/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetCreatorRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn lookup_creator( - &self, - param_orcid: Option, - param_wikidata_qid: Option, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_orcid = param_orcid.map_or_else(String::new, |query| format!("orcid={orcid}&", orcid = query.to_string())); - let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/creator/lookup?{orcid}{wikidata_qid}{expand}{hide}", - self.base_path, - orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET), - wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_creator( - &self, - param_editgroup_id: String, - param_ident: String, - param_entity: models::CreatorEntity, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/creator/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(UpdateCreatorResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateCreatorResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateCreatorResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn auth_check(&self, param_role: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_role = param_role.map_or_else(String::new, |query| format!("role={role}&", role = query.to_string())); - - let url = format!("{}/v0/auth/check?{role}", self.base_path, role = utf8_percent_encode(&query_role, QUERY_ENCODE_SET)); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthCheckResponse::Success(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthCheckResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(AuthCheckResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthCheckResponse::Forbidden(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthCheckResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn auth_oidc(&self, param_oidc_params: models::AuthOidc, context: &Context) -> Box + Send> { - let url = format!("{}/v0/auth/oidc", self.base_path); - - let body = serde_json::to_string(¶m_oidc_params).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::AUTH_OIDC.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthOidcResponse::Found(body)) - } - 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::(&buf)?; - - Ok(AuthOidcResponse::Created(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthOidcResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(AuthOidcResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthOidcResponse::Forbidden(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::(&buf)?; - - Ok(AuthOidcResponse::Conflict(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AuthOidcResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editgroups_reviewable( - &self, - param_expand: Option, - param_limit: Option, - param_before: Option>, - param_since: Option>, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); - let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); - - let url = format!( - "{}/v0/editgroup/reviewable?{expand}{limit}{before}{since}", - self.base_path, - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), - before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), - since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetEditgroupsReviewableResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupsReviewableResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupsReviewableResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupsReviewableResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editor(&self, param_editor_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editor/{editor_id}", - self.base_path, - editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editor_editgroups( - &self, - param_editor_id: String, - param_limit: Option, - param_before: Option>, - param_since: Option>, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); - let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); - - let url = format!( - "{}/v0/editor/{editor_id}/editgroups?{limit}{before}{since}", - self.base_path, - editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), - before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), - since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetEditorEditgroupsResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorEditgroupsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorEditgroupsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorEditgroupsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_editgroup( - &self, - param_editgroup_id: String, - param_editgroup: models::Editgroup, - param_submit: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_submit = param_submit.map_or_else(String::new, |query| format!("submit={submit}&", submit = query.to_string())); - - let url = format!( - "{}/v0/editgroup/{editgroup_id}?{submit}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - submit = utf8_percent_encode(&query_submit, QUERY_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_editgroup).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_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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditgroupResponse::UpdatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditgroupResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateEditgroupResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditgroupResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditgroupResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditgroupResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_editor(&self, param_editor_id: String, param_editor: models::Editor, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editor/{editor_id}", - self.base_path, - editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_editor).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_EDITOR.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditorResponse::UpdatedEditor(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditorResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateEditorResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditorResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditorResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateEditorResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn accept_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/accept", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(AcceptEditgroupResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(AcceptEditgroupResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(AcceptEditgroupResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_editgroup(&self, param_editgroup: models::Editgroup, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup", self.base_path); - - let body = serde_json::to_string(¶m_editgroup).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 { - 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::(&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::(&buf)?; - - Ok(CreateEditgroupResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateEditgroupResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_editgroup_annotation( - &self, - param_editgroup_id: String, - param_annotation: models::EditgroupAnnotation, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/annotation", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let body = serde_json::to_string(¶m_annotation).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_ANNOTATION.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 { - 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::(&buf)?; - - Ok(CreateEditgroupAnnotationResponse::Created(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupAnnotationResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateEditgroupAnnotationResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupAnnotationResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupAnnotationResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateEditgroupAnnotationResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_changelog(&self, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!("{}/v0/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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetChangelogResponse::Success(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetChangelogResponse::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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_changelog_entry(&self, param_index: i64, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/changelog/{index}", - self.base_path, - index = utf8_percent_encode(¶m_index.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetChangelogEntryResponse::FoundChangelogEntry(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetChangelogEntryResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editgroup_annotations(&self, param_editgroup_id: String, param_expand: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - - let url = format!( - "{}/v0/editgroup/{editgroup_id}/annotations?{expand}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetEditgroupAnnotationsResponse::Success(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupAnnotationsResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(GetEditgroupAnnotationsResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupAnnotationsResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupAnnotationsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditgroupAnnotationsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_editor_annotations( - &self, - param_editor_id: String, - param_limit: Option, - param_before: Option>, - param_since: Option>, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); - let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); - - let url = format!( - "{}/v0/editor/{editor_id}/annotations?{limit}{before}{since}", - self.base_path, - editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), - before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), - since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetEditorAnnotationsResponse::Success(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorAnnotationsResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(GetEditorAnnotationsResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorAnnotationsResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorAnnotationsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetEditorAnnotationsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_file(&self, param_editgroup_id: String, param_entity: models::FileEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/file", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::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 { - 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::(&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::(&buf)?; - - Ok(CreateFileResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateFileResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFileResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_file_auto_batch(&self, param_auto_batch: models::FileAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/file/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_AUTO_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 { - 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::(&buf)?; - - Ok(CreateFileAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFileAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateFileAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFileAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFileAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFileAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_file(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/file/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(DeleteFileResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteFileResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_file_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/file/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteFileEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFileEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_file(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/file/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileResponse::FoundEntity(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_file_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/file/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_file_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/file/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetFileHistoryResponse::FoundEntityHistory(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileHistoryResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileHistoryResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileHistoryResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_file_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/file/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetFileRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_file_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/file/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFileRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn lookup_file( - &self, - param_md5: Option, - param_sha1: Option, - param_sha256: Option, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_md5 = param_md5.map_or_else(String::new, |query| format!("md5={md5}&", md5 = query.to_string())); - let query_sha1 = param_sha1.map_or_else(String::new, |query| format!("sha1={sha1}&", sha1 = query.to_string())); - let query_sha256 = param_sha256.map_or_else(String::new, |query| format!("sha256={sha256}&", sha256 = query.to_string())); - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/file/lookup?{md5}{sha1}{sha256}{expand}{hide}", - self.base_path, - md5 = utf8_percent_encode(&query_md5, QUERY_ENCODE_SET), - sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET), - sha256 = utf8_percent_encode(&query_sha256, QUERY_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_file(&self, param_editgroup_id: String, param_ident: String, param_entity: models::FileEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/file/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(UpdateFileResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateFileResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateFileResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_fileset(&self, param_editgroup_id: String, param_entity: models::FilesetEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/fileset", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_FILESET.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 { - 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::(&buf)?; - - Ok(CreateFilesetResponse::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::(&buf)?; - - Ok(CreateFilesetResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateFilesetResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_fileset_auto_batch(&self, param_auto_batch: models::FilesetAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/fileset/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_FILESET_AUTO_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 { - 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::(&buf)?; - - Ok(CreateFilesetAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateFilesetAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateFilesetAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_fileset(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/fileset/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetResponse::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::(&buf)?; - - Ok(DeleteFilesetResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteFilesetResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_fileset_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/fileset/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteFilesetEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteFilesetEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_fileset(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/fileset/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetResponse::FoundEntity(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_fileset_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/fileset/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_fileset_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/fileset/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetFilesetHistoryResponse::FoundEntityHistory(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetHistoryResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetHistoryResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetHistoryResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_fileset_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/fileset/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetFilesetRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_fileset_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/fileset/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetFilesetRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_fileset( - &self, - param_editgroup_id: String, - param_ident: String, - param_entity: models::FilesetEntity, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/fileset/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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_FILESET.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateFilesetResponse::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::(&buf)?; - - Ok(UpdateFilesetResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateFilesetResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateFilesetResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateFilesetResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateFilesetResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_release(&self, param_editgroup_id: String, param_entity: models::ReleaseEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/release", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::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 { - 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::(&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::(&buf)?; - - Ok(CreateReleaseResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateReleaseResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateReleaseResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_release_auto_batch(&self, param_auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/release/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_AUTO_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 { - 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::(&buf)?; - - Ok(CreateReleaseAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateReleaseAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateReleaseAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateReleaseAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateReleaseAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateReleaseAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_work(&self, param_editgroup_id: String, param_entity: models::WorkEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/work", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::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 { - 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::(&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::(&buf)?; - - Ok(CreateWorkResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateWorkResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWorkResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_release(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/release/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(DeleteReleaseResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteReleaseResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_release_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/release/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteReleaseEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteReleaseEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/release/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_files(&self, param_ident: String, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/{ident}/files?{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetReleaseFilesResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_filesets(&self, param_ident: String, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/{ident}/filesets?{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetReleaseFilesetsResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesetsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesetsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseFilesetsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/release/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetReleaseHistoryResponse::FoundEntityHistory(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseHistoryResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseHistoryResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseHistoryResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/release/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetReleaseRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_release_webcaptures(&self, param_ident: String, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/{ident}/webcaptures?{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetReleaseWebcapturesResponse::Found(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseWebcapturesResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseWebcapturesResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetReleaseWebcapturesResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn lookup_release( - &self, - param_doi: Option, - param_wikidata_qid: Option, - param_isbn13: Option, - param_pmid: Option, - param_pmcid: Option, - param_core: Option, - param_arxiv: Option, - param_jstor: Option, - param_ark: Option, - param_mag: Option, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_doi = param_doi.map_or_else(String::new, |query| format!("doi={doi}&", doi = query.to_string())); - let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); - let query_isbn13 = param_isbn13.map_or_else(String::new, |query| format!("isbn13={isbn13}&", isbn13 = query.to_string())); - let query_pmid = param_pmid.map_or_else(String::new, |query| format!("pmid={pmid}&", pmid = query.to_string())); - let query_pmcid = param_pmcid.map_or_else(String::new, |query| format!("pmcid={pmcid}&", pmcid = query.to_string())); - let query_core = param_core.map_or_else(String::new, |query| format!("core={core}&", core = query.to_string())); - let query_arxiv = param_arxiv.map_or_else(String::new, |query| format!("arxiv={arxiv}&", arxiv = query.to_string())); - let query_jstor = param_jstor.map_or_else(String::new, |query| format!("jstor={jstor}&", jstor = query.to_string())); - let query_ark = param_ark.map_or_else(String::new, |query| format!("ark={ark}&", ark = query.to_string())); - let query_mag = param_mag.map_or_else(String::new, |query| format!("mag={mag}&", mag = query.to_string())); - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core}{arxiv}{jstor}{ark}{mag}{expand}{hide}", - self.base_path, - doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET), - wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), - isbn13 = utf8_percent_encode(&query_isbn13, QUERY_ENCODE_SET), - pmid = utf8_percent_encode(&query_pmid, QUERY_ENCODE_SET), - pmcid = utf8_percent_encode(&query_pmcid, QUERY_ENCODE_SET), - core = utf8_percent_encode(&query_core, QUERY_ENCODE_SET), - arxiv = utf8_percent_encode(&query_arxiv, QUERY_ENCODE_SET), - jstor = utf8_percent_encode(&query_jstor, QUERY_ENCODE_SET), - ark = utf8_percent_encode(&query_ark, QUERY_ENCODE_SET), - mag = utf8_percent_encode(&query_mag, QUERY_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_release( - &self, - param_editgroup_id: String, - param_ident: String, - param_entity: models::ReleaseEntity, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/release/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(UpdateReleaseResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateReleaseResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateReleaseResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_webcapture(&self, param_editgroup_id: String, param_entity: models::WebcaptureEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/webcapture", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_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::Post, &url); - let mut custom_headers = hyper::header::Headers::new(); - - let request = request.body(&body); - - custom_headers.set(ContentType(mimetypes::requests::CREATE_WEBCAPTURE.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 { - 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::(&buf)?; - - Ok(CreateWebcaptureResponse::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::(&buf)?; - - Ok(CreateWebcaptureResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateWebcaptureResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_webcapture_auto_batch(&self, param_auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/webcapture/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_WEBCAPTURE_AUTO_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 { - 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::(&buf)?; - - Ok(CreateWebcaptureAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateWebcaptureAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWebcaptureAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_webcapture(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureResponse::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::(&buf)?; - - Ok(DeleteWebcaptureResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteWebcaptureResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_webcapture_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/webcapture/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteWebcaptureEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWebcaptureEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_webcapture(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/webcapture/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureResponse::FoundEntity(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_webcapture_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/webcapture/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_webcapture_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/webcapture/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetWebcaptureHistoryResponse::FoundEntityHistory(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureHistoryResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureHistoryResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureHistoryResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_webcapture_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/webcapture/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetWebcaptureRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_webcapture_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/webcapture/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWebcaptureRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_webcapture( - &self, - param_editgroup_id: String, - param_ident: String, - param_entity: models::WebcaptureEntity, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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_WEBCAPTURE.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateWebcaptureResponse::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::(&buf)?; - - Ok(UpdateWebcaptureResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateWebcaptureResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateWebcaptureResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateWebcaptureResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateWebcaptureResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn create_work_auto_batch(&self, param_auto_batch: models::WorkAutoBatch, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/auto/work/batch", self.base_path); - - let body = serde_json::to_string(¶m_auto_batch).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_AUTO_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 { - 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::(&buf)?; - - Ok(CreateWorkAutoBatchResponse::CreatedEditgroup(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWorkAutoBatchResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(CreateWorkAutoBatchResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWorkAutoBatchResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWorkAutoBatchResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(CreateWorkAutoBatchResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_work(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/work/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(DeleteWorkResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteWorkResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn delete_work_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/work/edit/{edit_id}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Delete, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkEditResponse::DeletedEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkEditResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(DeleteWorkEditResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkEditResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(DeleteWorkEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work(&self, param_ident: String, param_expand: Option, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/work/{ident}?{expand}{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work_edit(&self, param_edit_id: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/work/edit/{edit_id}", - self.base_path, - edit_id = utf8_percent_encode(¶m_edit_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkEditResponse::FoundEdit(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkEditResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkEditResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkEditResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work_history(&self, param_ident: String, param_limit: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); - - let url = format!( - "{}/v0/work/{ident}/history?{limit}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work_redirects(&self, param_ident: String, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/work/{ident}/redirects", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(GetWorkRedirectsResponse::FoundEntityRedirects(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRedirectsResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRedirectsResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRedirectsResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work_releases(&self, param_ident: String, param_hide: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/work/{ident}/releases?{hide}", - self.base_path, - ident = utf8_percent_encode(¶m_ident.to_string(), PATH_SEGMENT_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; - - Ok(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn get_work_revision( - &self, - param_rev_id: String, - param_expand: Option, - param_hide: Option, - context: &Context, - ) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); - let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); - - let url = format!( - "{}/v0/work/rev/{rev_id}?{expand}{hide}", - self.base_path, - rev_id = utf8_percent_encode(¶m_rev_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), - hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) - ); - - let hyper_client = (self.hyper_client)(); - let request = hyper_client.request(hyper::method::Method::Get, &url); - let mut custom_headers = hyper::header::Headers::new(); - - context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); - - let request = request.headers(custom_headers); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRevisionResponse::FoundEntityRevision(body)) - } - 400 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRevisionResponse::BadRequest(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRevisionResponse::NotFound(body)) - } - 500 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(GetWorkRevisionResponse::GenericError(body)) - } - code => { - let mut buf = [0; 100]; - let debug_body = match response.read(&mut buf) { - Ok(len) => match str::from_utf8(&buf[..len]) { - Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } - - fn update_work(&self, param_editgroup_id: String, param_ident: String, param_entity: models::WorkEntity, context: &Context) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{editgroup_id}/work/{ident}", - self.base_path, - editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), - ident = utf8_percent_encode(¶m_ident.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 { - match response.status.to_u16() { - 200 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&buf)?; - - Ok(UpdateWorkResponse::BadRequest(body)) - } - 401 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - let response_www_authenticate = response - .headers - .get::() - .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; - - Ok(UpdateWorkResponse::NotAuthorized { - body: body, - www_authenticate: response_www_authenticate.0.clone(), - }) - } - 403 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(UpdateWorkResponse::Forbidden(body)) - } - 404 => { - let mut buf = String::new(); - response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::(&buf)?; - - Ok(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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", e)), - }; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) - } - } - } - - let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); - Box::new(futures::done(result)) - } -} - -#[derive(Debug)] -pub enum ClientInitError { - InvalidScheme, - InvalidUrl(hyper::error::ParseError), - MissingHost, - SslError(openssl::error::ErrorStack), -} - -impl From for ClientInitError { - fn from(err: hyper::error::ParseError) -> ClientInitError { - ClientInitError::InvalidUrl(err) - } -} - -impl From 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-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs deleted file mode 100644 index b19b5793..00000000 --- a/rust/fatcat-api-spec/src/lib.rs +++ /dev/null @@ -1,2282 +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 CreateContainerResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateContainerAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteContainerEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// 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 GetContainerEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetContainerHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetContainerRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetContainerRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::ContainerEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupContainerResponse { - /// Found Entity - FoundEntity(models::ContainerEntity), - /// 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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateCreatorAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteCreatorEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 GetCreatorEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorReleasesResponse { - /// Found - Found(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetCreatorRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::CreatorEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupCreatorResponse { - /// Found Entity - FoundEntity(models::CreatorEntity), - /// 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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum AuthCheckResponse { - /// Success - Success(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum AuthOidcResponse { - /// Found - Found(models::AuthOidcResult), - /// Created - Created(models::AuthOidcResult), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Conflict - Conflict(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetEditgroupsReviewableResponse { - /// Found - Found(Vec), - /// 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 GetEditorEditgroupsResponse { - /// Found - Found(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateEditgroupResponse { - /// Updated Editgroup - UpdatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateEditorResponse { - /// Updated Editor - UpdatedEditor(models::Editor), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum AcceptEditgroupResponse { - /// Merged Successfully - MergedSuccessfully(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Edit Conflict - EditConflict(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateEditgroupResponse { - /// Successfully Created - SuccessfullyCreated(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateEditgroupAnnotationResponse { - /// Created - Created(models::EditgroupAnnotation), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetChangelogResponse { - /// Success - Success(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetChangelogEntryResponse { - /// Found Changelog Entry - FoundChangelogEntry(models::ChangelogEntry), - /// 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 GetEditgroupAnnotationsResponse { - /// Success - Success(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetEditorAnnotationsResponse { - /// Success - Success(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFileResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFileAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteFileEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 GetFileEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFileHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFileRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFileRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::FileEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum LookupFileResponse { - /// Found Entity - FoundEntity(models::FileEntity), - /// 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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFilesetResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateFilesetAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteFilesetResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteFilesetEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFilesetResponse { - /// Found Entity - FoundEntity(models::FilesetEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFilesetEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFilesetHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFilesetRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetFilesetRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::FilesetEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateFilesetResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateReleaseAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteReleaseEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 GetReleaseEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseFilesResponse { - /// Found - Found(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseFilesetsResponse { - /// Found - Found(Vec), - /// 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), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::ReleaseEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetReleaseWebcapturesResponse { - /// Found - Found(Vec), - /// 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 UpdateReleaseResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateWebcaptureResponse { - /// Created Entity - CreatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateWebcaptureAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteWebcaptureResponse { - /// Deleted Entity - DeletedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteWebcaptureEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWebcaptureResponse { - /// Found Entity - FoundEntity(models::WebcaptureEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWebcaptureEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWebcaptureHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWebcaptureRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWebcaptureRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::WebcaptureEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateWebcaptureResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum CreateWorkAutoBatchResponse { - /// Created Editgroup - CreatedEditgroup(models::Editgroup), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(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 Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum DeleteWorkEditResponse { - /// Deleted Edit - DeletedEdit(models::Success), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// 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 GetWorkEditResponse { - /// Found Edit - FoundEdit(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkHistoryResponse { - /// Found Entity History - FoundEntityHistory(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkRedirectsResponse { - /// Found Entity Redirects - FoundEntityRedirects(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkReleasesResponse { - /// Found - Found(Vec), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum GetWorkRevisionResponse { - /// Found Entity Revision - FoundEntityRevision(models::WorkEntity), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -#[derive(Debug, PartialEq)] -pub enum UpdateWorkResponse { - /// Updated Entity - UpdatedEntity(models::EntityEdit), - /// Bad Request - BadRequest(models::ErrorResponse), - /// Not Authorized - NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, - /// Forbidden - Forbidden(models::ErrorResponse), - /// Not Found - NotFound(models::ErrorResponse), - /// Generic Error - GenericError(models::ErrorResponse), -} - -/// API -pub trait Api { - fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box + Send>; - - fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box + Send>; - - fn delete_container(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_container_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_container(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_container_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_container_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_container_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_container_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn lookup_container( - &self, - issnl: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send>; - - fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity, context: &Context) -> Box + Send>; - - fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity, context: &Context) -> Box + Send>; - - fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch, context: &Context) -> Box + Send>; - - fn delete_creator(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_creator_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_creator(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_creator_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_creator_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_creator_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_creator_releases(&self, ident: String, hide: Option, context: &Context) -> Box + Send>; - - fn get_creator_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn lookup_creator( - &self, - orcid: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send>; - - fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box + Send>; - - fn auth_check(&self, role: Option, context: &Context) -> Box + Send>; - - fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box + Send>; - - fn get_editgroups_reviewable( - &self, - expand: Option, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send>; - - fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send>; - - fn get_editor_editgroups( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send>; - - fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option, context: &Context) -> Box + Send>; - - fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box + Send>; - - fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send>; - - fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box + Send>; - - fn create_editgroup_annotation( - &self, - editgroup_id: String, - annotation: models::EditgroupAnnotation, - context: &Context, - ) -> Box + Send>; - - fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send>; - - fn get_changelog_entry(&self, index: i64, context: &Context) -> Box + Send>; - - fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send>; - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send>; - - fn get_editor_annotations( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - context: &Context, - ) -> Box + Send>; - - fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box + Send>; - - fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch, context: &Context) -> Box + Send>; - - fn delete_file(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_file_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_file(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_file_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_file_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_file_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_file_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn lookup_file( - &self, - md5: Option, - sha1: Option, - sha256: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send>; - - fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity, context: &Context) -> Box + Send>; - - fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity, context: &Context) -> Box + Send>; - - fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch, context: &Context) -> Box + Send>; - - fn delete_fileset(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_fileset(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_fileset_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_fileset_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_fileset_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity, context: &Context) -> Box + Send>; - - fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity, context: &Context) -> Box + Send>; - - fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box + Send>; - - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box + Send>; - - fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_release(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_release_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_release_files(&self, ident: String, hide: Option, context: &Context) -> Box + Send>; - - fn get_release_filesets(&self, ident: String, hide: Option, context: &Context) -> Box + Send>; - - fn get_release_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_release_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_release_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_release_webcaptures(&self, ident: String, hide: Option, context: &Context) -> Box + Send>; - - fn lookup_release( - &self, - doi: Option, - wikidata_qid: Option, - isbn13: Option, - pmid: Option, - pmcid: Option, - core: Option, - arxiv: Option, - jstor: Option, - ark: Option, - mag: Option, - expand: Option, - hide: Option, - context: &Context, - ) -> Box + Send>; - - fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity, context: &Context) -> Box + Send>; - - fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity, context: &Context) -> Box + Send>; - - fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box + Send>; - - fn delete_webcapture(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_webcapture(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_webcapture_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_webcapture_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_webcapture_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box + Send>; - - fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box + Send>; - - fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box + Send>; - - fn delete_work_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box + Send>; - - fn get_work(&self, ident: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn get_work_edit(&self, edit_id: String, context: &Context) -> Box + Send>; - - fn get_work_history(&self, ident: String, limit: Option, context: &Context) -> Box + Send>; - - fn get_work_redirects(&self, ident: String, context: &Context) -> Box + Send>; - - fn get_work_releases(&self, ident: String, hide: Option, context: &Context) -> Box + Send>; - - fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - - fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity, context: &Context) -> Box + Send>; -} - -/// API without a `Context` -pub trait ApiNoContext { - fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box + Send>; - - fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch) -> Box + Send>; - - fn delete_container(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_container_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_container(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_container_edit(&self, edit_id: String) -> Box + Send>; - - fn get_container_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_container_redirects(&self, ident: String) -> Box + Send>; - - fn get_container_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn lookup_container( - &self, - issnl: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - ) -> Box + Send>; - - fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity) -> Box + Send>; - - fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity) -> Box + Send>; - - fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch) -> Box + Send>; - - fn delete_creator(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_creator_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_creator(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_creator_edit(&self, edit_id: String) -> Box + Send>; - - fn get_creator_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_creator_redirects(&self, ident: String) -> Box + Send>; - - fn get_creator_releases(&self, ident: String, hide: Option) -> Box + Send>; - - fn get_creator_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, expand: Option, hide: Option) -> Box + Send>; - - fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity) -> Box + Send>; - - fn auth_check(&self, role: Option) -> Box + Send>; - - fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box + Send>; - - fn get_editgroups_reviewable( - &self, - expand: Option, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send>; - - fn get_editor(&self, editor_id: String) -> Box + Send>; - - fn get_editor_editgroups( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send>; - - fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option) -> Box + Send>; - - fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box + Send>; - - fn accept_editgroup(&self, editgroup_id: String) -> Box + Send>; - - fn create_editgroup(&self, editgroup: models::Editgroup) -> Box + Send>; - - fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box + Send>; - - fn get_changelog(&self, limit: Option) -> Box + Send>; - - fn get_changelog_entry(&self, index: i64) -> Box + Send>; - - fn get_editgroup(&self, editgroup_id: String) -> Box + Send>; - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option) -> Box + Send>; - - fn get_editor_annotations( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send>; - - fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box + Send>; - - fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch) -> Box + Send>; - - fn delete_file(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_file_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_file(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_file_edit(&self, edit_id: String) -> Box + Send>; - - fn get_file_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_file_redirects(&self, ident: String) -> Box + Send>; - - fn get_file_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn lookup_file( - &self, - md5: Option, - sha1: Option, - sha256: Option, - expand: Option, - hide: Option, - ) -> Box + Send>; - - fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity) -> Box + Send>; - - fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity) -> Box + Send>; - - fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch) -> Box + Send>; - - fn delete_fileset(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_fileset(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_fileset_edit(&self, edit_id: String) -> Box + Send>; - - fn get_fileset_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_fileset_redirects(&self, ident: String) -> Box + Send>; - - fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity) -> Box + Send>; - - fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity) -> Box + Send>; - - fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch) -> Box + Send>; - - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box + Send>; - - fn delete_release(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_release_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_release(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_release_edit(&self, edit_id: String) -> Box + Send>; - - fn get_release_files(&self, ident: String, hide: Option) -> Box + Send>; - - fn get_release_filesets(&self, ident: String, hide: Option) -> Box + Send>; - - fn get_release_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_release_redirects(&self, ident: String) -> Box + Send>; - - fn get_release_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_release_webcaptures(&self, ident: String, hide: Option) -> Box + Send>; - - fn lookup_release( - &self, - doi: Option, - wikidata_qid: Option, - isbn13: Option, - pmid: Option, - pmcid: Option, - core: Option, - arxiv: Option, - jstor: Option, - ark: Option, - mag: Option, - expand: Option, - hide: Option, - ) -> Box + Send>; - - fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity) -> Box + Send>; - - fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity) -> Box + Send>; - - fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch) -> Box + Send>; - - fn delete_webcapture(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_webcapture(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_webcapture_edit(&self, edit_id: String) -> Box + Send>; - - fn get_webcapture_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_webcapture_redirects(&self, ident: String) -> Box + Send>; - - fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity) -> Box + Send>; - - fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box + Send>; - - fn delete_work(&self, editgroup_id: String, ident: String) -> Box + Send>; - - fn delete_work_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send>; - - fn get_work(&self, ident: String, expand: Option, hide: Option) -> Box + Send>; - - fn get_work_edit(&self, edit_id: String) -> Box + Send>; - - fn get_work_history(&self, ident: String, limit: Option) -> Box + Send>; - - fn get_work_redirects(&self, ident: String) -> Box + Send>; - - fn get_work_releases(&self, ident: String, hide: Option) -> Box + Send>; - - fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send>; - - fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity) -> Box + 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::::new(self, context) - } -} - -impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { - fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box + Send> { - self.api().create_container(editgroup_id, entity, &self.context()) - } - - fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch) -> Box + Send> { - self.api().create_container_auto_batch(auto_batch, &self.context()) - } - - fn delete_container(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_container(editgroup_id, ident, &self.context()) - } - - fn delete_container_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_container_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_container(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_container(ident, expand, hide, &self.context()) - } - - fn get_container_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_container_edit(edit_id, &self.context()) - } - - fn get_container_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_container_history(ident, limit, &self.context()) - } - - fn get_container_redirects(&self, ident: String) -> Box + Send> { - self.api().get_container_redirects(ident, &self.context()) - } - - fn get_container_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_container_revision(rev_id, expand, hide, &self.context()) - } - - fn lookup_container( - &self, - issnl: Option, - wikidata_qid: Option, - expand: Option, - hide: Option, - ) -> Box + Send> { - self.api().lookup_container(issnl, wikidata_qid, expand, hide, &self.context()) - } - - fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity) -> Box + Send> { - self.api().update_container(editgroup_id, ident, entity, &self.context()) - } - - fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity) -> Box + Send> { - self.api().create_creator(editgroup_id, entity, &self.context()) - } - - fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch) -> Box + Send> { - self.api().create_creator_auto_batch(auto_batch, &self.context()) - } - - fn delete_creator(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_creator(editgroup_id, ident, &self.context()) - } - - fn delete_creator_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_creator_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_creator(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_creator(ident, expand, hide, &self.context()) - } - - fn get_creator_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_creator_edit(edit_id, &self.context()) - } - - fn get_creator_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_creator_history(ident, limit, &self.context()) - } - - fn get_creator_redirects(&self, ident: String) -> Box + Send> { - self.api().get_creator_redirects(ident, &self.context()) - } - - fn get_creator_releases(&self, ident: String, hide: Option) -> Box + Send> { - self.api().get_creator_releases(ident, hide, &self.context()) - } - - fn get_creator_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_creator_revision(rev_id, expand, hide, &self.context()) - } - - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, expand: Option, hide: Option) -> Box + Send> { - self.api().lookup_creator(orcid, wikidata_qid, expand, hide, &self.context()) - } - - fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity) -> Box + Send> { - self.api().update_creator(editgroup_id, ident, entity, &self.context()) - } - - fn auth_check(&self, role: Option) -> Box + Send> { - self.api().auth_check(role, &self.context()) - } - - fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box + Send> { - self.api().auth_oidc(oidc_params, &self.context()) - } - - fn get_editgroups_reviewable( - &self, - expand: Option, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send> { - self.api().get_editgroups_reviewable(expand, limit, before, since, &self.context()) - } - - fn get_editor(&self, editor_id: String) -> Box + Send> { - self.api().get_editor(editor_id, &self.context()) - } - - fn get_editor_editgroups( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send> { - self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context()) - } - - fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option) -> Box + Send> { - self.api().update_editgroup(editgroup_id, editgroup, submit, &self.context()) - } - - fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box + Send> { - self.api().update_editor(editor_id, editor, &self.context()) - } - - fn accept_editgroup(&self, editgroup_id: String) -> Box + Send> { - self.api().accept_editgroup(editgroup_id, &self.context()) - } - - fn create_editgroup(&self, editgroup: models::Editgroup) -> Box + Send> { - self.api().create_editgroup(editgroup, &self.context()) - } - - fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box + Send> { - self.api().create_editgroup_annotation(editgroup_id, annotation, &self.context()) - } - - fn get_changelog(&self, limit: Option) -> Box + Send> { - self.api().get_changelog(limit, &self.context()) - } - - fn get_changelog_entry(&self, index: i64) -> Box + Send> { - self.api().get_changelog_entry(index, &self.context()) - } - - fn get_editgroup(&self, editgroup_id: String) -> Box + Send> { - self.api().get_editgroup(editgroup_id, &self.context()) - } - - fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option) -> Box + Send> { - self.api().get_editgroup_annotations(editgroup_id, expand, &self.context()) - } - - fn get_editor_annotations( - &self, - editor_id: String, - limit: Option, - before: Option>, - since: Option>, - ) -> Box + Send> { - self.api().get_editor_annotations(editor_id, limit, before, since, &self.context()) - } - - fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box + Send> { - self.api().create_file(editgroup_id, entity, &self.context()) - } - - fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch) -> Box + Send> { - self.api().create_file_auto_batch(auto_batch, &self.context()) - } - - fn delete_file(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_file(editgroup_id, ident, &self.context()) - } - - fn delete_file_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_file_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_file(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_file(ident, expand, hide, &self.context()) - } - - fn get_file_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_file_edit(edit_id, &self.context()) - } - - fn get_file_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_file_history(ident, limit, &self.context()) - } - - fn get_file_redirects(&self, ident: String) -> Box + Send> { - self.api().get_file_redirects(ident, &self.context()) - } - - fn get_file_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_file_revision(rev_id, expand, hide, &self.context()) - } - - fn lookup_file( - &self, - md5: Option, - sha1: Option, - sha256: Option, - expand: Option, - hide: Option, - ) -> Box + Send> { - self.api().lookup_file(md5, sha1, sha256, expand, hide, &self.context()) - } - - fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity) -> Box + Send> { - self.api().update_file(editgroup_id, ident, entity, &self.context()) - } - - fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity) -> Box + Send> { - self.api().create_fileset(editgroup_id, entity, &self.context()) - } - - fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch) -> Box + Send> { - self.api().create_fileset_auto_batch(auto_batch, &self.context()) - } - - fn delete_fileset(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_fileset(editgroup_id, ident, &self.context()) - } - - fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_fileset_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_fileset(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_fileset(ident, expand, hide, &self.context()) - } - - fn get_fileset_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_fileset_edit(edit_id, &self.context()) - } - - fn get_fileset_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_fileset_history(ident, limit, &self.context()) - } - - fn get_fileset_redirects(&self, ident: String) -> Box + Send> { - self.api().get_fileset_redirects(ident, &self.context()) - } - - fn get_fileset_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_fileset_revision(rev_id, expand, hide, &self.context()) - } - - fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity) -> Box + Send> { - self.api().update_fileset(editgroup_id, ident, entity, &self.context()) - } - - fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity) -> Box + Send> { - self.api().create_release(editgroup_id, entity, &self.context()) - } - - fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch) -> Box + Send> { - self.api().create_release_auto_batch(auto_batch, &self.context()) - } - - fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box + Send> { - self.api().create_work(editgroup_id, entity, &self.context()) - } - - fn delete_release(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_release(editgroup_id, ident, &self.context()) - } - - fn delete_release_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_release_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_release(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_release(ident, expand, hide, &self.context()) - } - - fn get_release_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_release_edit(edit_id, &self.context()) - } - - fn get_release_files(&self, ident: String, hide: Option) -> Box + Send> { - self.api().get_release_files(ident, hide, &self.context()) - } - - fn get_release_filesets(&self, ident: String, hide: Option) -> Box + Send> { - self.api().get_release_filesets(ident, hide, &self.context()) - } - - fn get_release_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_release_history(ident, limit, &self.context()) - } - - fn get_release_redirects(&self, ident: String) -> Box + Send> { - self.api().get_release_redirects(ident, &self.context()) - } - - fn get_release_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_release_revision(rev_id, expand, hide, &self.context()) - } - - fn get_release_webcaptures(&self, ident: String, hide: Option) -> Box + Send> { - self.api().get_release_webcaptures(ident, hide, &self.context()) - } - - fn lookup_release( - &self, - doi: Option, - wikidata_qid: Option, - isbn13: Option, - pmid: Option, - pmcid: Option, - core: Option, - arxiv: Option, - jstor: Option, - ark: Option, - mag: Option, - expand: Option, - hide: Option, - ) -> Box + Send> { - self.api() - .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, expand, hide, &self.context()) - } - - fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity) -> Box + Send> { - self.api().update_release(editgroup_id, ident, entity, &self.context()) - } - - fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity) -> Box + Send> { - self.api().create_webcapture(editgroup_id, entity, &self.context()) - } - - fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch) -> Box + Send> { - self.api().create_webcapture_auto_batch(auto_batch, &self.context()) - } - - fn delete_webcapture(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_webcapture(editgroup_id, ident, &self.context()) - } - - fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_webcapture_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_webcapture(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_webcapture(ident, expand, hide, &self.context()) - } - - fn get_webcapture_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_webcapture_edit(edit_id, &self.context()) - } - - fn get_webcapture_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_webcapture_history(ident, limit, &self.context()) - } - - fn get_webcapture_redirects(&self, ident: String) -> Box + Send> { - self.api().get_webcapture_redirects(ident, &self.context()) - } - - fn get_webcapture_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_webcapture_revision(rev_id, expand, hide, &self.context()) - } - - fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity) -> Box + Send> { - self.api().update_webcapture(editgroup_id, ident, entity, &self.context()) - } - - fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box + Send> { - self.api().create_work_auto_batch(auto_batch, &self.context()) - } - - fn delete_work(&self, editgroup_id: String, ident: String) -> Box + Send> { - self.api().delete_work(editgroup_id, ident, &self.context()) - } - - fn delete_work_edit(&self, editgroup_id: String, edit_id: String) -> Box + Send> { - self.api().delete_work_edit(editgroup_id, edit_id, &self.context()) - } - - fn get_work(&self, ident: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_work(ident, expand, hide, &self.context()) - } - - fn get_work_edit(&self, edit_id: String) -> Box + Send> { - self.api().get_work_edit(edit_id, &self.context()) - } - - fn get_work_history(&self, ident: String, limit: Option) -> Box + Send> { - self.api().get_work_history(ident, limit, &self.context()) - } - - fn get_work_redirects(&self, ident: String) -> Box + Send> { - self.api().get_work_redirects(ident, &self.context()) - } - - fn get_work_releases(&self, ident: String, hide: Option) -> Box + Send> { - self.api().get_work_releases(ident, hide, &self.context()) - } - - fn get_work_revision(&self, rev_id: String, expand: Option, hide: Option) -> Box + Send> { - self.api().get_work_revision(rev_id, expand, hide, &self.context()) - } - - fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity) -> Box + Send> { - self.api().update_work(editgroup_id, ident, 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-spec/src/mimetypes.rs b/rust/fatcat-api-spec/src/mimetypes.rs deleted file mode 100644 index 0676f63b..00000000 --- a/rust/fatcat-api-spec/src/mimetypes.rs +++ /dev/null @@ -1,1973 +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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainer - lazy_static! { - pub static ref CREATE_CONTAINER_FORBIDDEN: 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 CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainer - lazy_static! { - pub static ref DELETE_CONTAINER_FORBIDDEN: 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 DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteContainerEdit - lazy_static! { - pub static ref DELETE_CONTAINER_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainer - lazy_static! { - pub static ref GET_CONTAINER_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 GetContainerEdit - lazy_static! { - pub static ref GET_CONTAINER_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerEdit - lazy_static! { - pub static ref GET_CONTAINER_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerEdit - lazy_static! { - pub static ref GET_CONTAINER_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerEdit - lazy_static! { - pub static ref GET_CONTAINER_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerHistory - lazy_static! { - pub static ref GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// 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 GetContainerRedirects - lazy_static! { - pub static ref GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRedirects - lazy_static! { - pub static ref GET_CONTAINER_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRedirects - lazy_static! { - pub static ref GET_CONTAINER_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRedirects - lazy_static! { - pub static ref GET_CONTAINER_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRevision - lazy_static! { - pub static ref GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRevision - lazy_static! { - pub static ref GET_CONTAINER_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRevision - lazy_static! { - pub static ref GET_CONTAINER_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetContainerRevision - lazy_static! { - pub static ref GET_CONTAINER_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupContainer - lazy_static! { - pub static ref LOOKUP_CONTAINER_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateContainer - lazy_static! { - pub static ref UPDATE_CONTAINER_FORBIDDEN: 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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR_FORBIDDEN: 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 CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreator - lazy_static! { - pub static ref DELETE_CREATOR_FORBIDDEN: 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 DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteCreatorEdit - lazy_static! { - pub static ref DELETE_CREATOR_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreator - lazy_static! { - pub static ref GET_CREATOR_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 GetCreatorEdit - lazy_static! { - pub static ref GET_CREATOR_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorEdit - lazy_static! { - pub static ref GET_CREATOR_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorEdit - lazy_static! { - pub static ref GET_CREATOR_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorEdit - lazy_static! { - pub static ref GET_CREATOR_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorHistory - lazy_static! { - pub static ref GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// 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 GetCreatorRedirects - lazy_static! { - pub static ref GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRedirects - lazy_static! { - pub static ref GET_CREATOR_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRedirects - lazy_static! { - pub static ref GET_CREATOR_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRedirects - lazy_static! { - pub static ref GET_CREATOR_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorReleases - lazy_static! { - pub static ref GET_CREATOR_RELEASES_FOUND: Mime = mime!(Application / Json); - } - /// 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 GetCreatorRevision - lazy_static! { - pub static ref GET_CREATOR_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRevision - lazy_static! { - pub static ref GET_CREATOR_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRevision - lazy_static! { - pub static ref GET_CREATOR_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetCreatorRevision - lazy_static! { - pub static ref GET_CREATOR_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupCreator - lazy_static! { - pub static ref LOOKUP_CREATOR_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateCreator - lazy_static! { - pub static ref UPDATE_CREATOR_FORBIDDEN: 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 AuthCheck - lazy_static! { - pub static ref AUTH_CHECK_SUCCESS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthCheck - lazy_static! { - pub static ref AUTH_CHECK_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthCheck - lazy_static! { - pub static ref AUTH_CHECK_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthCheck - lazy_static! { - pub static ref AUTH_CHECK_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthCheck - lazy_static! { - pub static ref AUTH_CHECK_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_CREATED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_CONFLICT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AuthOidc - lazy_static! { - pub static ref AUTH_OIDC_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupsReviewable - lazy_static! { - pub static ref GET_EDITGROUPS_REVIEWABLE_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupsReviewable - lazy_static! { - pub static ref GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupsReviewable - lazy_static! { - pub static ref GET_EDITGROUPS_REVIEWABLE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupsReviewable - lazy_static! { - pub static ref GET_EDITGROUPS_REVIEWABLE_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 GetEditorEditgroups - lazy_static! { - pub static ref GET_EDITOR_EDITGROUPS_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorEditgroups - lazy_static! { - pub static ref GET_EDITOR_EDITGROUPS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorEditgroups - lazy_static! { - pub static ref GET_EDITOR_EDITGROUPS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorEditgroups - lazy_static! { - pub static ref GET_EDITOR_EDITGROUPS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_UPDATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_UPDATED_EDITOR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for AcceptEditgroup - lazy_static! { - pub static ref ACCEPT_EDITGROUP_FORBIDDEN: 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 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_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroup - lazy_static! { - pub static ref CREATE_EDITGROUP_NOT_FOUND: 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 CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_CREATED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION_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_BAD_REQUEST: 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_BAD_REQUEST: 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 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 GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_SUCCESS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditgroupAnnotations - lazy_static! { - pub static ref GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_SUCCESS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetEditorAnnotations - lazy_static! { - pub static ref GET_EDITOR_ANNOTATIONS_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFile - lazy_static! { - pub static ref CREATE_FILE_FORBIDDEN: 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 CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFile - lazy_static! { - pub static ref DELETE_FILE_FORBIDDEN: 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 DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileEdit - lazy_static! { - pub static ref DELETE_FILE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFile - lazy_static! { - pub static ref GET_FILE_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 GetFileEdit - lazy_static! { - pub static ref GET_FILE_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileEdit - lazy_static! { - pub static ref GET_FILE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileEdit - lazy_static! { - pub static ref GET_FILE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileEdit - lazy_static! { - pub static ref GET_FILE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileHistory - lazy_static! { - pub static ref GET_FILE_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// 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 GetFileRedirects - lazy_static! { - pub static ref GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRedirects - lazy_static! { - pub static ref GET_FILE_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRedirects - lazy_static! { - pub static ref GET_FILE_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRedirects - lazy_static! { - pub static ref GET_FILE_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRevision - lazy_static! { - pub static ref GET_FILE_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRevision - lazy_static! { - pub static ref GET_FILE_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRevision - lazy_static! { - pub static ref GET_FILE_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileRevision - lazy_static! { - pub static ref GET_FILE_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for LookupFile - lazy_static! { - pub static ref LOOKUP_FILE_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFile - lazy_static! { - pub static ref UPDATE_FILE_FORBIDDEN: 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 CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFileset - lazy_static! { - pub static ref CREATE_FILESET_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFileset - lazy_static! { - pub static ref DELETE_FILESET_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteFilesetEdit - lazy_static! { - pub static ref DELETE_FILESET_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileset - lazy_static! { - pub static ref GET_FILESET_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileset - lazy_static! { - pub static ref GET_FILESET_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileset - lazy_static! { - pub static ref GET_FILESET_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFileset - lazy_static! { - pub static ref GET_FILESET_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetEdit - lazy_static! { - pub static ref GET_FILESET_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetEdit - lazy_static! { - pub static ref GET_FILESET_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetEdit - lazy_static! { - pub static ref GET_FILESET_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetEdit - lazy_static! { - pub static ref GET_FILESET_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetHistory - lazy_static! { - pub static ref GET_FILESET_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetHistory - lazy_static! { - pub static ref GET_FILESET_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetHistory - lazy_static! { - pub static ref GET_FILESET_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetHistory - lazy_static! { - pub static ref GET_FILESET_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRedirects - lazy_static! { - pub static ref GET_FILESET_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRedirects - lazy_static! { - pub static ref GET_FILESET_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRedirects - lazy_static! { - pub static ref GET_FILESET_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRedirects - lazy_static! { - pub static ref GET_FILESET_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRevision - lazy_static! { - pub static ref GET_FILESET_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRevision - lazy_static! { - pub static ref GET_FILESET_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRevision - lazy_static! { - pub static ref GET_FILESET_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetFilesetRevision - lazy_static! { - pub static ref GET_FILESET_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateRelease - lazy_static! { - pub static ref CREATE_RELEASE_FORBIDDEN: 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 CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWork - lazy_static! { - pub static ref CREATE_WORK_FORBIDDEN: 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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteRelease - lazy_static! { - pub static ref DELETE_RELEASE_FORBIDDEN: 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 DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteReleaseEdit - lazy_static! { - pub static ref DELETE_RELEASE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetRelease - lazy_static! { - pub static ref GET_RELEASE_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 GetReleaseEdit - lazy_static! { - pub static ref GET_RELEASE_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseEdit - lazy_static! { - pub static ref GET_RELEASE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseEdit - lazy_static! { - pub static ref GET_RELEASE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseEdit - lazy_static! { - pub static ref GET_RELEASE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFiles - lazy_static! { - pub static ref GET_RELEASE_FILES_FOUND: Mime = mime!(Application / Json); - } - /// 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 GetReleaseFilesets - lazy_static! { - pub static ref GET_RELEASE_FILESETS_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFilesets - lazy_static! { - pub static ref GET_RELEASE_FILESETS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFilesets - lazy_static! { - pub static ref GET_RELEASE_FILESETS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseFilesets - lazy_static! { - pub static ref GET_RELEASE_FILESETS_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 GetReleaseRedirects - lazy_static! { - pub static ref GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRedirects - lazy_static! { - pub static ref GET_RELEASE_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRedirects - lazy_static! { - pub static ref GET_RELEASE_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRedirects - lazy_static! { - pub static ref GET_RELEASE_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRevision - lazy_static! { - pub static ref GET_RELEASE_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRevision - lazy_static! { - pub static ref GET_RELEASE_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRevision - lazy_static! { - pub static ref GET_RELEASE_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseRevision - lazy_static! { - pub static ref GET_RELEASE_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseWebcaptures - lazy_static! { - pub static ref GET_RELEASE_WEBCAPTURES_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseWebcaptures - lazy_static! { - pub static ref GET_RELEASE_WEBCAPTURES_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseWebcaptures - lazy_static! { - pub static ref GET_RELEASE_WEBCAPTURES_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetReleaseWebcaptures - lazy_static! { - pub static ref GET_RELEASE_WEBCAPTURES_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 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE_FORBIDDEN: 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 CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_CREATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_DELETED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcapture - lazy_static! { - pub static ref DELETE_WEBCAPTURE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWebcaptureEdit - lazy_static! { - pub static ref DELETE_WEBCAPTURE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcapture - lazy_static! { - pub static ref GET_WEBCAPTURE_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcapture - lazy_static! { - pub static ref GET_WEBCAPTURE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcapture - lazy_static! { - pub static ref GET_WEBCAPTURE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcapture - lazy_static! { - pub static ref GET_WEBCAPTURE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureEdit - lazy_static! { - pub static ref GET_WEBCAPTURE_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureEdit - lazy_static! { - pub static ref GET_WEBCAPTURE_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureEdit - lazy_static! { - pub static ref GET_WEBCAPTURE_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureEdit - lazy_static! { - pub static ref GET_WEBCAPTURE_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureHistory - lazy_static! { - pub static ref GET_WEBCAPTURE_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureHistory - lazy_static! { - pub static ref GET_WEBCAPTURE_HISTORY_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureHistory - lazy_static! { - pub static ref GET_WEBCAPTURE_HISTORY_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureHistory - lazy_static! { - pub static ref GET_WEBCAPTURE_HISTORY_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRedirects - lazy_static! { - pub static ref GET_WEBCAPTURE_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRedirects - lazy_static! { - pub static ref GET_WEBCAPTURE_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRedirects - lazy_static! { - pub static ref GET_WEBCAPTURE_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRedirects - lazy_static! { - pub static ref GET_WEBCAPTURE_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRevision - lazy_static! { - pub static ref GET_WEBCAPTURE_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRevision - lazy_static! { - pub static ref GET_WEBCAPTURE_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRevision - lazy_static! { - pub static ref GET_WEBCAPTURE_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWebcaptureRevision - lazy_static! { - pub static ref GET_WEBCAPTURE_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH_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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWork - lazy_static! { - pub static ref DELETE_WORK_FORBIDDEN: 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 DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_DELETED_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_NOT_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_FORBIDDEN: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for DeleteWorkEdit - lazy_static! { - pub static ref DELETE_WORK_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWork - lazy_static! { - pub static ref GET_WORK_FOUND_ENTITY: Mime = mime!(Application / Json); - } - /// 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 GetWorkEdit - lazy_static! { - pub static ref GET_WORK_EDIT_FOUND_EDIT: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkEdit - lazy_static! { - pub static ref GET_WORK_EDIT_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkEdit - lazy_static! { - pub static ref GET_WORK_EDIT_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkEdit - lazy_static! { - pub static ref GET_WORK_EDIT_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkHistory - lazy_static! { - pub static ref GET_WORK_HISTORY_FOUND_ENTITY_HISTORY: Mime = mime!(Application / Json); - } - /// 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 GetWorkRedirects - lazy_static! { - pub static ref GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRedirects - lazy_static! { - pub static ref GET_WORK_REDIRECTS_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRedirects - lazy_static! { - pub static ref GET_WORK_REDIRECTS_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRedirects - lazy_static! { - pub static ref GET_WORK_REDIRECTS_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkReleases - lazy_static! { - pub static ref GET_WORK_RELEASES_FOUND: Mime = mime!(Application / Json); - } - /// 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 GetWorkRevision - lazy_static! { - pub static ref GET_WORK_REVISION_FOUND_ENTITY_REVISION: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRevision - lazy_static! { - pub static ref GET_WORK_REVISION_BAD_REQUEST: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRevision - lazy_static! { - pub static ref GET_WORK_REVISION_NOT_FOUND: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for GetWorkRevision - lazy_static! { - pub static ref GET_WORK_REVISION_GENERIC_ERROR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK_UPDATED_ENTITY: Mime = mime!(Application / Json); - } - /// 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_AUTHORIZED: Mime = mime!(Application / Json); - } - /// Create Mime objects for the response content types for UpdateWork - lazy_static! { - pub static ref UPDATE_WORK_FORBIDDEN: 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 CreateContainerAutoBatch - lazy_static! { - pub static ref CREATE_CONTAINER_AUTO_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 CreateCreator - lazy_static! { - pub static ref CREATE_CREATOR: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateCreatorAutoBatch - lazy_static! { - pub static ref CREATE_CREATOR_AUTO_BATCH: 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 AuthOidc - lazy_static! { - pub static ref AUTH_OIDC: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateEditgroup - lazy_static! { - pub static ref UPDATE_EDITGROUP: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateEditor - lazy_static! { - pub static ref UPDATE_EDITOR: 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 CreateEditgroupAnnotation - lazy_static! { - pub static ref CREATE_EDITGROUP_ANNOTATION: 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 CreateFileAutoBatch - lazy_static! { - pub static ref CREATE_FILE_AUTO_BATCH: 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 CreateFileset - lazy_static! { - pub static ref CREATE_FILESET: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateFilesetAutoBatch - lazy_static! { - pub static ref CREATE_FILESET_AUTO_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateFileset - lazy_static! { - pub static ref UPDATE_FILESET: 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 CreateReleaseAutoBatch - lazy_static! { - pub static ref CREATE_RELEASE_AUTO_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 UpdateRelease - lazy_static! { - pub static ref UPDATE_RELEASE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateWebcapture - lazy_static! { - pub static ref CREATE_WEBCAPTURE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateWebcaptureAutoBatch - lazy_static! { - pub static ref CREATE_WEBCAPTURE_AUTO_BATCH: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for UpdateWebcapture - lazy_static! { - pub static ref UPDATE_WEBCAPTURE: Mime = mime!(Application / Json); - } - /// Create Mime objects for the request content types for CreateWorkAutoBatch - lazy_static! { - pub static ref CREATE_WORK_AUTO_BATCH: 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-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs deleted file mode 100644 index c8b68328..00000000 --- a/rust/fatcat-api-spec/src/models.rs +++ /dev/null @@ -1,1433 +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 AuthOidc { - #[serde(rename = "provider")] - pub provider: String, - - #[serde(rename = "sub")] - pub sub: String, - - #[serde(rename = "iss")] - pub iss: String, - - #[serde(rename = "preferred_username")] - pub preferred_username: String, -} - -impl AuthOidc { - pub fn new(provider: String, sub: String, iss: String, preferred_username: String) -> AuthOidc { - AuthOidc { - provider: provider, - sub: sub, - iss: iss, - preferred_username: preferred_username, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct AuthOidcResult { - #[serde(rename = "editor")] - pub editor: models::Editor, - - #[serde(rename = "token")] - pub token: String, -} - -impl AuthOidcResult { - pub fn new(editor: models::Editor, token: String) -> AuthOidcResult { - AuthOidcResult { editor: editor, token: token } - } -} - -#[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, - - #[serde(rename = "editgroup")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup: Option, -} - -impl ChangelogEntry { - pub fn new(index: i64, editgroup_id: String, timestamp: chrono::DateTime) -> ChangelogEntry { - ChangelogEntry { - index: index, - editgroup_id: editgroup_id, - timestamp: timestamp, - editgroup: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ContainerAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl ContainerAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> ContainerAutoBatch { - ContainerAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ContainerEntity { - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option, - - #[serde(rename = "issnl")] - #[serde(skip_serializing_if = "Option::is_none")] - pub issnl: Option, - - #[serde(rename = "publisher")] - #[serde(skip_serializing_if = "Option::is_none")] - pub publisher: Option, - - /// Eg, 'journal' - #[serde(rename = "container_type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container_type: Option, - - /// Required for valid entities - #[serde(rename = "name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, -} - -impl ContainerEntity { - pub fn new() -> ContainerEntity { - ContainerEntity { - wikidata_qid: None, - issnl: None, - publisher: None, - container_type: None, - name: None, - edit_extra: None, - extra: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct CreatorAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl CreatorAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> CreatorAutoBatch { - CreatorAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct CreatorEntity { - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option, - - #[serde(rename = "orcid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub orcid: Option, - - #[serde(rename = "surname")] - #[serde(skip_serializing_if = "Option::is_none")] - pub surname: Option, - - #[serde(rename = "given_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub given_name: Option, - - /// Required for valid entities - #[serde(rename = "display_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub display_name: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, -} - -impl CreatorEntity { - pub fn new() -> CreatorEntity { - CreatorEntity { - wikidata_qid: None, - orcid: None, - surname: None, - given_name: None, - display_name: None, - state: None, - ident: None, - revision: None, - redirect: None, - extra: None, - edit_extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Editgroup { - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option, - - /// base32-encoded unique identifier - #[serde(rename = "editor_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editor_id: Option, - - #[serde(rename = "editor")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editor: Option, - - #[serde(rename = "changelog_index")] - #[serde(skip_serializing_if = "Option::is_none")] - pub changelog_index: Option, - - #[serde(rename = "created")] - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option>, - - #[serde(rename = "submitted")] - #[serde(skip_serializing_if = "Option::is_none")] - pub submitted: Option>, - - #[serde(rename = "description")] - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - #[serde(rename = "annotations")] - #[serde(skip_serializing_if = "Option::is_none")] - pub annotations: Option>, - - #[serde(rename = "edits")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edits: Option, -} - -impl Editgroup { - pub fn new() -> Editgroup { - Editgroup { - editgroup_id: None, - editor_id: None, - editor: None, - changelog_index: None, - created: None, - submitted: None, - description: None, - extra: None, - annotations: None, - edits: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EditgroupAnnotation { - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "annotation_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub annotation_id: Option, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editgroup_id: Option, - - /// base32-encoded unique identifier - #[serde(rename = "editor_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editor_id: Option, - - #[serde(rename = "editor")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editor: Option, - - #[serde(rename = "created")] - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option>, - - #[serde(rename = "comment_markdown")] - #[serde(skip_serializing_if = "Option::is_none")] - pub comment_markdown: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, -} - -impl EditgroupAnnotation { - pub fn new() -> EditgroupAnnotation { - EditgroupAnnotation { - annotation_id: None, - editgroup_id: None, - editor_id: None, - editor: None, - created: None, - comment_markdown: None, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EditgroupEdits { - #[serde(rename = "containers")] - #[serde(skip_serializing_if = "Option::is_none")] - pub containers: Option>, - - #[serde(rename = "creators")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creators: Option>, - - #[serde(rename = "files")] - #[serde(skip_serializing_if = "Option::is_none")] - pub files: Option>, - - #[serde(rename = "filesets")] - #[serde(skip_serializing_if = "Option::is_none")] - pub filesets: Option>, - - #[serde(rename = "webcaptures")] - #[serde(skip_serializing_if = "Option::is_none")] - pub webcaptures: Option>, - - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option>, - - #[serde(rename = "works")] - #[serde(skip_serializing_if = "Option::is_none")] - pub works: Option>, -} - -impl EditgroupEdits { - pub fn new() -> EditgroupEdits { - EditgroupEdits { - containers: None, - creators: None, - files: None, - filesets: None, - webcaptures: None, - releases: None, - works: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Editor { - /// base32-encoded unique identifier - #[serde(rename = "editor_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub editor_id: Option, - - #[serde(rename = "username")] - pub username: String, - - #[serde(rename = "is_admin")] - #[serde(skip_serializing_if = "Option::is_none")] - pub is_admin: Option, - - #[serde(rename = "is_bot")] - #[serde(skip_serializing_if = "Option::is_none")] - pub is_bot: Option, - - #[serde(rename = "is_active")] - #[serde(skip_serializing_if = "Option::is_none")] - pub is_active: Option, -} - -impl Editor { - pub fn new(username: String) -> Editor { - Editor { - editor_id: None, - username: username, - is_admin: None, - is_bot: None, - is_active: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct EntityEdit { - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "edit_id")] - pub edit_id: String, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - pub ident: String, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "prev_revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prev_revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect_ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect_ident: Option, - - /// base32-encoded unique identifier - #[serde(rename = "editgroup_id")] - pub editgroup_id: String, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, -} - -impl EntityEdit { - pub fn new(edit_id: String, 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 = "success")] - pub success: bool, - - #[serde(rename = "error")] - pub error: String, - - #[serde(rename = "message")] - pub message: String, -} - -impl ErrorResponse { - pub fn new(success: bool, error: String, message: String) -> ErrorResponse { - ErrorResponse { - success: success, - error: error, - message: message, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FileAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl FileAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> FileAutoBatch { - FileAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FileEntity { - /// Optional; GET-only - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option>, - - #[serde(rename = "release_ids")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_ids: Option>, - - #[serde(rename = "mimetype")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mimetype: Option, - - #[serde(rename = "urls")] - #[serde(skip_serializing_if = "Option::is_none")] - pub urls: Option>, - - #[serde(rename = "sha256")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha256: Option, - - #[serde(rename = "sha1")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha1: Option, - - #[serde(rename = "md5")] - #[serde(skip_serializing_if = "Option::is_none")] - pub md5: Option, - - #[serde(rename = "size")] - #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, -} - -impl FileEntity { - pub fn new() -> FileEntity { - FileEntity { - releases: None, - release_ids: None, - mimetype: None, - urls: None, - sha256: None, - sha1: None, - md5: None, - size: None, - edit_extra: None, - extra: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FileUrl { - #[serde(rename = "url")] - pub url: String, - - #[serde(rename = "rel")] - pub rel: String, -} - -impl FileUrl { - pub fn new(url: String, rel: String) -> FileUrl { - FileUrl { url: url, rel: rel } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FilesetAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl FilesetAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> FilesetAutoBatch { - FilesetAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FilesetEntity { - /// Optional; GET-only - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option>, - - #[serde(rename = "release_ids")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_ids: Option>, - - #[serde(rename = "urls")] - #[serde(skip_serializing_if = "Option::is_none")] - pub urls: Option>, - - #[serde(rename = "manifest")] - #[serde(skip_serializing_if = "Option::is_none")] - pub manifest: Option>, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, -} - -impl FilesetEntity { - pub fn new() -> FilesetEntity { - FilesetEntity { - releases: None, - release_ids: None, - urls: None, - manifest: None, - state: None, - ident: None, - revision: None, - redirect: None, - extra: None, - edit_extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FilesetFile { - #[serde(rename = "path")] - pub path: String, - - #[serde(rename = "size")] - pub size: i64, - - #[serde(rename = "md5")] - #[serde(skip_serializing_if = "Option::is_none")] - pub md5: Option, - - #[serde(rename = "sha1")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha1: Option, - - #[serde(rename = "sha256")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha256: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, -} - -impl FilesetFile { - pub fn new(path: String, size: i64) -> FilesetFile { - FilesetFile { - path: path, - size: size, - md5: None, - sha1: None, - sha256: None, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct FilesetUrl { - #[serde(rename = "url")] - pub url: String, - - #[serde(rename = "rel")] - pub rel: String, -} - -impl FilesetUrl { - pub fn new(url: String, rel: String) -> FilesetUrl { - FilesetUrl { url: url, rel: rel } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseAbstract { - #[serde(rename = "sha1")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha1: Option, - - #[serde(rename = "content")] - #[serde(skip_serializing_if = "Option::is_none")] - pub content: Option, - - #[serde(rename = "mimetype")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mimetype: Option, - - #[serde(rename = "lang")] - #[serde(skip_serializing_if = "Option::is_none")] - pub lang: Option, -} - -impl ReleaseAbstract { - pub fn new() -> ReleaseAbstract { - ReleaseAbstract { - sha1: None, - content: None, - mimetype: None, - lang: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl ReleaseAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> ReleaseAutoBatch { - ReleaseAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseContrib { - #[serde(rename = "index")] - #[serde(skip_serializing_if = "Option::is_none")] - pub index: Option, - - /// base32-encoded unique identifier - #[serde(rename = "creator_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creator_id: Option, - - /// Optional; GET-only - #[serde(rename = "creator")] - #[serde(skip_serializing_if = "Option::is_none")] - pub creator: Option, - - #[serde(rename = "raw_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub raw_name: Option, - - #[serde(rename = "given_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub given_name: Option, - - #[serde(rename = "surname")] - #[serde(skip_serializing_if = "Option::is_none")] - pub surname: Option, - - #[serde(rename = "role")] - #[serde(skip_serializing_if = "Option::is_none")] - pub role: Option, - - /// Raw affiliation string as displayed in text - #[serde(rename = "raw_affiliation")] - #[serde(skip_serializing_if = "Option::is_none")] - pub raw_affiliation: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, -} - -impl ReleaseContrib { - pub fn new() -> ReleaseContrib { - ReleaseContrib { - index: None, - creator_id: None, - creator: None, - raw_name: None, - given_name: None, - surname: None, - role: None, - raw_affiliation: None, - extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseEntity { - #[serde(rename = "abstracts")] - #[serde(skip_serializing_if = "Option::is_none")] - pub abstracts: Option>, - - #[serde(rename = "refs")] - #[serde(skip_serializing_if = "Option::is_none")] - pub refs: Option>, - - #[serde(rename = "contribs")] - #[serde(skip_serializing_if = "Option::is_none")] - pub contribs: Option>, - - /// Short version of license name. Eg, 'CC-BY' - #[serde(rename = "license_slug")] - #[serde(skip_serializing_if = "Option::is_none")] - pub license_slug: Option, - - /// Two-letter RFC1766/ISO639-1 language code, with extensions - #[serde(rename = "language")] - #[serde(skip_serializing_if = "Option::is_none")] - pub language: Option, - - #[serde(rename = "publisher")] - #[serde(skip_serializing_if = "Option::is_none")] - pub publisher: Option, - - #[serde(rename = "version")] - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option, - - #[serde(rename = "number")] - #[serde(skip_serializing_if = "Option::is_none")] - pub number: Option, - - #[serde(rename = "pages")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pages: Option, - - #[serde(rename = "issue")] - #[serde(skip_serializing_if = "Option::is_none")] - pub issue: Option, - - #[serde(rename = "volume")] - #[serde(skip_serializing_if = "Option::is_none")] - pub volume: Option, - - #[serde(rename = "ext_ids")] - pub ext_ids: models::ReleaseExtIds, - - #[serde(rename = "withdrawn_year")] - #[serde(skip_serializing_if = "Option::is_none")] - pub withdrawn_year: Option, - - #[serde(rename = "withdrawn_date")] - #[serde(skip_serializing_if = "Option::is_none")] - pub withdrawn_date: Option, - - #[serde(rename = "withdrawn_status")] - #[serde(skip_serializing_if = "Option::is_none")] - pub withdrawn_status: Option, - - #[serde(rename = "release_year")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_year: Option, - - #[serde(rename = "release_date")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_date: Option, - - #[serde(rename = "release_stage")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_stage: Option, - - #[serde(rename = "release_type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_type: Option, - - #[serde(rename = "container_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container_id: Option, - - /// Optional; GET-only - #[serde(rename = "webcaptures")] - #[serde(skip_serializing_if = "Option::is_none")] - pub webcaptures: Option>, - - /// Optional; GET-only - #[serde(rename = "filesets")] - #[serde(skip_serializing_if = "Option::is_none")] - pub filesets: Option>, - - /// Optional; GET-only - #[serde(rename = "files")] - #[serde(skip_serializing_if = "Option::is_none")] - pub files: Option>, - - /// Optional; GET-only - #[serde(rename = "container")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container: Option, - - #[serde(rename = "work_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub work_id: Option, - - /// Title in original language (or, the language of the full text of this release) - #[serde(rename = "original_title")] - #[serde(skip_serializing_if = "Option::is_none")] - pub original_title: Option, - - /// Avoid this field if possible, and merge with title; usually English - #[serde(rename = "subtitle")] - #[serde(skip_serializing_if = "Option::is_none")] - pub subtitle: Option, - - /// Required for valid entities. The title used in citations and for display; usually English - #[serde(rename = "title")] - #[serde(skip_serializing_if = "Option::is_none")] - pub title: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, -} - -impl ReleaseEntity { - pub fn new(ext_ids: models::ReleaseExtIds) -> ReleaseEntity { - ReleaseEntity { - abstracts: None, - refs: None, - contribs: None, - license_slug: None, - language: None, - publisher: None, - version: None, - number: None, - pages: None, - issue: None, - volume: None, - ext_ids: ext_ids, - withdrawn_year: None, - withdrawn_date: None, - withdrawn_status: None, - release_year: None, - release_date: None, - release_stage: None, - release_type: None, - container_id: None, - webcaptures: None, - filesets: None, - files: None, - container: None, - work_id: None, - original_title: None, - subtitle: None, - title: None, - state: None, - ident: None, - revision: None, - redirect: None, - extra: None, - edit_extra: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseExtIds { - #[serde(rename = "doi")] - #[serde(skip_serializing_if = "Option::is_none")] - pub doi: Option, - - #[serde(rename = "wikidata_qid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option, - - #[serde(rename = "isbn13")] - #[serde(skip_serializing_if = "Option::is_none")] - pub isbn13: Option, - - #[serde(rename = "pmid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmid: Option, - - #[serde(rename = "pmcid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmcid: Option, - - #[serde(rename = "core")] - #[serde(skip_serializing_if = "Option::is_none")] - pub core: Option, - - #[serde(rename = "arxiv")] - #[serde(skip_serializing_if = "Option::is_none")] - pub arxiv: Option, - - #[serde(rename = "jstor")] - #[serde(skip_serializing_if = "Option::is_none")] - pub jstor: Option, - - #[serde(rename = "ark")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ark: Option, - - #[serde(rename = "mag")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mag: Option, -} - -impl ReleaseExtIds { - pub fn new() -> ReleaseExtIds { - ReleaseExtIds { - doi: None, - wikidata_qid: None, - isbn13: None, - pmid: None, - pmcid: None, - core: None, - arxiv: None, - jstor: None, - ark: None, - mag: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ReleaseRef { - #[serde(rename = "index")] - #[serde(skip_serializing_if = "Option::is_none")] - pub index: Option, - - /// base32-encoded unique identifier - #[serde(rename = "target_release_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub target_release_id: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - #[serde(rename = "key")] - #[serde(skip_serializing_if = "Option::is_none")] - pub key: Option, - - #[serde(rename = "year")] - #[serde(skip_serializing_if = "Option::is_none")] - pub year: Option, - - #[serde(rename = "container_name")] - #[serde(skip_serializing_if = "Option::is_none")] - pub container_name: Option, - - #[serde(rename = "title")] - #[serde(skip_serializing_if = "Option::is_none")] - pub title: Option, - - #[serde(rename = "locator")] - #[serde(skip_serializing_if = "Option::is_none")] - pub locator: Option, -} - -impl ReleaseRef { - pub fn new() -> ReleaseRef { - ReleaseRef { - index: None, - target_release_id: None, - extra: None, - key: None, - year: None, - container_name: None, - title: None, - locator: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Success { - #[serde(rename = "success")] - pub success: bool, - - #[serde(rename = "message")] - pub message: String, -} - -impl Success { - pub fn new(success: bool, message: String) -> Success { - Success { success: success, message: message } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WebcaptureAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl WebcaptureAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> WebcaptureAutoBatch { - WebcaptureAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WebcaptureCdxLine { - #[serde(rename = "surt")] - pub surt: String, - - /// UTC, 'Z'-terminated, second (or better) precision - #[serde(rename = "timestamp")] - pub timestamp: chrono::DateTime, - - #[serde(rename = "url")] - pub url: String, - - #[serde(rename = "mimetype")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mimetype: Option, - - #[serde(rename = "status_code")] - #[serde(skip_serializing_if = "Option::is_none")] - pub status_code: Option, - - #[serde(rename = "size")] - #[serde(skip_serializing_if = "Option::is_none")] - pub size: Option, - - #[serde(rename = "sha1")] - pub sha1: String, - - #[serde(rename = "sha256")] - #[serde(skip_serializing_if = "Option::is_none")] - pub sha256: Option, -} - -impl WebcaptureCdxLine { - pub fn new(surt: String, timestamp: chrono::DateTime, url: String, sha1: String) -> WebcaptureCdxLine { - WebcaptureCdxLine { - surt: surt, - timestamp: timestamp, - url: url, - mimetype: None, - status_code: None, - size: None, - sha1: sha1, - sha256: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WebcaptureEntity { - /// Optional; GET-only - #[serde(rename = "releases")] - #[serde(skip_serializing_if = "Option::is_none")] - pub releases: Option>, - - #[serde(rename = "release_ids")] - #[serde(skip_serializing_if = "Option::is_none")] - pub release_ids: Option>, - - /// same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Can be the earliest or average of CDX timestamps if that makes sense. - #[serde(rename = "timestamp")] - #[serde(skip_serializing_if = "Option::is_none")] - pub timestamp: Option>, - - #[serde(rename = "original_url")] - #[serde(skip_serializing_if = "Option::is_none")] - pub original_url: Option, - - #[serde(rename = "archive_urls")] - #[serde(skip_serializing_if = "Option::is_none")] - pub archive_urls: Option>, - - #[serde(rename = "cdx")] - #[serde(skip_serializing_if = "Option::is_none")] - pub cdx: Option>, - - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, -} - -impl WebcaptureEntity { - pub fn new() -> WebcaptureEntity { - WebcaptureEntity { - releases: None, - release_ids: None, - timestamp: None, - original_url: None, - archive_urls: None, - cdx: None, - edit_extra: None, - extra: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WebcaptureUrl { - #[serde(rename = "url")] - pub url: String, - - #[serde(rename = "rel")] - pub rel: String, -} - -impl WebcaptureUrl { - pub fn new(url: String, rel: String) -> WebcaptureUrl { - WebcaptureUrl { url: url, rel: rel } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WorkAutoBatch { - #[serde(rename = "editgroup")] - pub editgroup: models::Editgroup, - - #[serde(rename = "entity_list")] - pub entity_list: Vec, -} - -impl WorkAutoBatch { - pub fn new(editgroup: models::Editgroup, entity_list: Vec) -> WorkAutoBatch { - WorkAutoBatch { - editgroup: editgroup, - entity_list: entity_list, - } - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct WorkEntity { - #[serde(rename = "edit_extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_extra: Option, - - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option, - - /// base32-encoded unique identifier - #[serde(rename = "redirect")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect: Option, - - /// UUID (lower-case, dash-separated, hex-encoded 128-bit) - #[serde(rename = "revision")] - #[serde(skip_serializing_if = "Option::is_none")] - pub revision: Option, - - /// base32-encoded unique identifier - #[serde(rename = "ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ident: Option, - - // Note: inline enums are not fully supported by swagger-codegen - #[serde(rename = "state")] - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option, -} - -impl WorkEntity { - pub fn new() -> WorkEntity { - WorkEntity { - edit_extra: None, - extra: None, - redirect: None, - revision: None, - ident: None, - state: None, - } - } -} diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs deleted file mode 100644 index 102b6e41..00000000 --- a/rust/fatcat-api-spec/src/server.rs +++ /dev/null @@ -1,10872 +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, AuthCheckResponse, AuthOidcResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, CreateCreatorResponse, - CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, CreateReleaseAutoBatchResponse, - CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, - DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, - DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, - GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, - GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, - GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, - GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, - GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, - GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, - UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, -}; - -header! { (Warning, "Warning") => [String] } - -/// Create a new router for `Api` -pub fn router(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(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(router: &mut Router, api: T) -where - T: Api + Send + Sync + Clone + 'static, -{ - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:editgroup_id/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_container(param_editgroup_id, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_FORBIDDEN.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/editgroup/auto/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_container_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateContainerAutoBatchResponse::CreatedEditgroup(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_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateContainerAutoBatchResponse::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_AUTO_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) - } - CreateContainerAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateContainerAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_AUTO_BATCH_FORBIDDEN.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) - } - CreateContainerAutoBatchResponse::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_AUTO_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) - } - CreateContainerAutoBatchResponse::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_AUTO_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) - }) - }, - "CreateContainerAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/container/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_container(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_FORBIDDEN.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/editgroup/:editgroup_id/container/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_container_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteContainerEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteContainerEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CONTAINER_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteContainerEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/container/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_container(param_ident, param_expand, param_hide, 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/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_container_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetContainerEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetContainerEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/container/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_container_history(param_ident, 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/container/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_container_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetContainerRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRedirectsResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRedirectsResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRedirectsResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetContainerRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/container/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_container_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetContainerRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRevisionResponse::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_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRevisionResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetContainerRevisionResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetContainerRevision", - ); - - 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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_issnl = query_params.get("issnl").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.lookup_container(param_issnl, param_wikidata_qid, param_expand, param_hide, 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.put( - "/v0/editgroup/:editgroup_id/container/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_container(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CONTAINER_FORBIDDEN.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.post( - "/v0/editgroup/:editgroup_id/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_creator(param_editgroup_id, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_FORBIDDEN.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/editgroup/auto/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_creator_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateCreatorAutoBatchResponse::CreatedEditgroup(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_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateCreatorAutoBatchResponse::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_AUTO_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) - } - CreateCreatorAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateCreatorAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_AUTO_BATCH_FORBIDDEN.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) - } - CreateCreatorAutoBatchResponse::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_AUTO_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) - } - CreateCreatorAutoBatchResponse::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_AUTO_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) - }) - }, - "CreateCreatorAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/creator/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_creator(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_FORBIDDEN.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/editgroup/:editgroup_id/creator/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_creator_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteCreatorEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteCreatorEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_CREATOR_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteCreatorEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_creator(param_ident, param_expand, param_hide, 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/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_creator_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetCreatorEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetCreatorEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_creator_history(param_ident, 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/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_creator_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetCreatorRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRedirectsResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRedirectsResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRedirectsResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetCreatorRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/creator/:ident/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_creator_releases(param_ident, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetCreatorReleasesResponse::Found(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - 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/creator/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_creator_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetCreatorRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRevisionResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRevisionResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetCreatorRevisionResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetCreatorRevision", - ); - - 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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_orcid = query_params.get("orcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.lookup_creator(param_orcid, param_wikidata_qid, param_expand, param_hide, 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.put( - "/v0/editgroup/:editgroup_id/creator/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_creator(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_CREATOR_FORBIDDEN.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.get( - "/v0/auth/check", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_role = query_params.get("role").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.auth_check(param_role, context).wait() { - Ok(rsp) => match rsp { - AuthCheckResponse::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::AUTH_CHECK_SUCCESS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AuthCheckResponse::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::AUTH_CHECK_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AuthCheckResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AuthCheckResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AuthCheckResponse::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::AUTH_CHECK_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) - }) - }, - "AuthCheck", - ); - - let api_clone = api.clone(); - router.post( - "/v0/auth/oidc", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_oidc_params = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_oidc_params = if let Some(param_oidc_params_raw) = param_oidc_params { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_oidc_params_raw); - - let param_oidc_params: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - doesn't match schema: {}", e))))?; - - param_oidc_params - } else { - None - }; - let param_oidc_params = param_oidc_params.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter oidc_params".to_string())))?; - - match api.auth_oidc(param_oidc_params, context).wait() { - Ok(rsp) => match rsp { - AuthOidcResponse::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::AUTH_OIDC_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) - } - AuthOidcResponse::Created(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::AUTH_OIDC_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) - } - AuthOidcResponse::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::AUTH_OIDC_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) - } - AuthOidcResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_NOT_AUTHORIZED.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) - } - AuthOidcResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_FORBIDDEN.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) - } - AuthOidcResponse::Conflict(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::AUTH_OIDC_CONFLICT.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) - } - AuthOidcResponse::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::AUTH_OIDC_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) - }) - }, - "AuthOidc", - ); - - let api_clone = api.clone(); - router.get( - "/v0/editgroup/reviewable", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - let param_before = query_params - .get("before") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - let param_since = query_params - .get("since") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - - match api.get_editgroups_reviewable(param_expand, param_limit, param_before, param_since, context).wait() { - Ok(rsp) => match rsp { - GetEditgroupsReviewableResponse::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_EDITGROUPS_REVIEWABLE_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupsReviewableResponse::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_EDITGROUPS_REVIEWABLE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupsReviewableResponse::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_EDITGROUPS_REVIEWABLE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupsReviewableResponse::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_EDITGROUPS_REVIEWABLE_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) - }) - }, - "GetEditgroupsReviewable", - ); - - let api_clone = api.clone(); - router.get( - "/v0/editor/: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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_editor_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editor_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_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 editor_id: {}", e))))? - }; - - match api.get_editor(param_editor_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/:editor_id/editgroups", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_editor_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editor_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_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 editor_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - let param_before = query_params - .get("before") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - let param_since = query_params - .get("since") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - - match api.get_editor_editgroups(param_editor_id, param_limit, param_before, param_since, context).wait() { - Ok(rsp) => match rsp { - GetEditorEditgroupsResponse::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_EDITGROUPS_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorEditgroupsResponse::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_EDITGROUPS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorEditgroupsResponse::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_EDITGROUPS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorEditgroupsResponse::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_EDITGROUPS_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) - }) - }, - "GetEditorEditgroups", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editgroup/:editgroup_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_submit = query_params - .get("submit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.to_lowercase().parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?; - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_editgroup = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_editgroup_raw); - - let param_editgroup: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; - - param_editgroup - } else { - None - }; - let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?; - - match api.update_editgroup(param_editgroup_id, param_editgroup, param_submit, context).wait() { - Ok(rsp) => match rsp { - UpdateEditgroupResponse::UpdatedEditgroup(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_EDITGROUP_UPDATED_EDITGROUP.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) - } - UpdateEditgroupResponse::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_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) - } - UpdateEditgroupResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_AUTHORIZED.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) - } - UpdateEditgroupResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_FORBIDDEN.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) - } - UpdateEditgroupResponse::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_EDITGROUP_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - UpdateEditgroupResponse::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_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) - }) - }, - "UpdateEditgroup", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editor/: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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editor_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editor_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_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 editor_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_editor = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_editor = if let Some(param_editor_raw) = param_editor { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_editor_raw); - - let param_editor: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - doesn't match schema: {}", e))))?; - - param_editor - } else { - None - }; - let param_editor = param_editor.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editor".to_string())))?; - - match api.update_editor(param_editor_id, param_editor, context).wait() { - Ok(rsp) => match rsp { - UpdateEditorResponse::UpdatedEditor(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_EDITOR_UPDATED_EDITOR.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) - } - UpdateEditorResponse::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_EDITOR_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - UpdateEditorResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_NOT_AUTHORIZED.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) - } - UpdateEditorResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_FORBIDDEN.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) - } - UpdateEditorResponse::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_EDITOR_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - UpdateEditorResponse::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_EDITOR_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - }, - 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) - }) - }, - "UpdateEditor", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/: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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - - match api.accept_editgroup(param_editgroup_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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - AcceptEditgroupResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_FORBIDDEN.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/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - - let param_editgroup = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_editgroup_raw); - - let param_editgroup: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; - - param_editgroup - } else { - None - }; - let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?; - - match api.create_editgroup(param_editgroup, context).wait() { - Ok(rsp) => match rsp { - CreateEditgroupResponse::SuccessfullyCreated(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_FORBIDDEN.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::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_EDITGROUP_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - 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/editgroup/:editgroup_id/annotation", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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_annotation = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_annotation = if let Some(param_annotation_raw) = param_annotation { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_annotation_raw); - - let param_annotation: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - doesn't match schema: {}", e))))?; - - param_annotation - } else { - None - }; - let param_annotation = param_annotation.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter annotation".to_string())))?; - - match api.create_editgroup_annotation(param_editgroup_id, param_annotation, context).wait() { - Ok(rsp) => match rsp { - CreateEditgroupAnnotationResponse::Created(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_ANNOTATION_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) - } - CreateEditgroupAnnotationResponse::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_ANNOTATION_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) - } - CreateEditgroupAnnotationResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED.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) - } - CreateEditgroupAnnotationResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_FORBIDDEN.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) - } - CreateEditgroupAnnotationResponse::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_EDITGROUP_ANNOTATION_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) - } - CreateEditgroupAnnotationResponse::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_ANNOTATION_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) - }) - }, - "CreateEditgroupAnnotation", - ); - - let api_clone = api.clone(); - router.get( - "/v0/changelog", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - 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::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_CHANGELOG_BAD_REQUEST.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/:index", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_index = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("index") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter index".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 index: {}", e))))? - }; - - match api.get_changelog_entry(param_index, 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::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_CHANGELOG_ENTRY_BAD_REQUEST.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/editgroup/:editgroup_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - - match api.get_editgroup(param_editgroup_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/editgroup/:editgroup_id/annotations", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_editgroup_annotations(param_editgroup_id, param_expand, context).wait() { - Ok(rsp) => match rsp { - GetEditgroupAnnotationsResponse::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_EDITGROUP_ANNOTATIONS_SUCCESS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupAnnotationsResponse::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_ANNOTATIONS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupAnnotationsResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupAnnotationsResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupAnnotationsResponse::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_ANNOTATIONS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditgroupAnnotationsResponse::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_ANNOTATIONS_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) - }) - }, - "GetEditgroupAnnotations", - ); - - let api_clone = api.clone(); - router.get( - "/v0/editor/:editor_id/annotations", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_editor_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editor_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_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 editor_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - let param_before = query_params - .get("before") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - let param_since = query_params - .get("since") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::>())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?; - - match api.get_editor_annotations(param_editor_id, param_limit, param_before, param_since, context).wait() { - Ok(rsp) => match rsp { - GetEditorAnnotationsResponse::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_EDITOR_ANNOTATIONS_SUCCESS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorAnnotationsResponse::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_ANNOTATIONS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorAnnotationsResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorAnnotationsResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorAnnotationsResponse::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_ANNOTATIONS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetEditorAnnotationsResponse::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_ANNOTATIONS_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) - }) - }, - "GetEditorAnnotations", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:editgroup_id/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_file(param_editgroup_id, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_FORBIDDEN.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/editgroup/auto/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_file_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateFileAutoBatchResponse::CreatedEditgroup(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_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateFileAutoBatchResponse::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_AUTO_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) - } - CreateFileAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateFileAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_AUTO_BATCH_FORBIDDEN.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) - } - CreateFileAutoBatchResponse::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_AUTO_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) - } - CreateFileAutoBatchResponse::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_AUTO_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) - }) - }, - "CreateFileAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/file/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_file(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_FORBIDDEN.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/editgroup/:editgroup_id/file/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_file_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteFileEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFileEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteFileEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_file(param_ident, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetFileResponse::FoundEntity(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFile", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_file_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetFileEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFileEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_file_history(param_ident, param_limit, context).wait() { - Ok(rsp) => match rsp { - GetFileHistoryResponse::FoundEntityHistory(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileHistoryResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileHistoryResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileHistoryResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_HISTORY_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFileHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_file_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetFileRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRedirectsResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRedirectsResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRedirectsResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFileRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_file_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetFileRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRevisionResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRevisionResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFileRevisionResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILE_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFileRevision", - ); - - let api_clone = api.clone(); - router.get( - "/v0/file/lookup", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_md5 = query_params.get("md5").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_sha1 = query_params.get("sha1").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_sha256 = query_params.get("sha256").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.lookup_file(param_md5, param_sha1, param_sha256, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - LookupFileResponse::FoundEntity(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - LookupFileResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - LookupFileResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - LookupFileResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "LookupFile", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editgroup/:editgroup_id/file/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_file(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - UpdateFileResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - UpdateFileResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILE_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "UpdateFile", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:editgroup_id/fileset", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_fileset(param_editgroup_id, param_entity, context).wait() { - Ok(rsp) => match rsp { - CreateFilesetResponse::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_FILESET_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) - } - CreateFilesetResponse::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_FILESET_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) - } - CreateFilesetResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_FILESET_NOT_AUTHORIZED.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) - } - CreateFilesetResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILESET_FORBIDDEN.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) - } - CreateFilesetResponse::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_FILESET_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) - } - CreateFilesetResponse::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_FILESET_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) - }) - }, - "CreateFileset", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/auto/fileset/batch", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_fileset_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateFilesetAutoBatchResponse::CreatedEditgroup(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_FILESET_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateFilesetAutoBatchResponse::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_FILESET_AUTO_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) - } - CreateFilesetAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_FILESET_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateFilesetAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_FILESET_AUTO_BATCH_FORBIDDEN.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) - } - CreateFilesetAutoBatchResponse::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_FILESET_AUTO_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) - } - CreateFilesetAutoBatchResponse::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_FILESET_AUTO_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) - }) - }, - "CreateFilesetAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/fileset/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_fileset(param_editgroup_id, param_ident, context).wait() { - Ok(rsp) => match rsp { - DeleteFilesetResponse::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_FILESET_DELETED_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetResponse::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_FILESET_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_FILESET_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILESET_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetResponse::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_FILESET_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetResponse::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_FILESET_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) - }) - }, - "DeleteFileset", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/fileset/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_fileset_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteFilesetEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILESET_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetEditResponse::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_FILESET_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_FILESET_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_FILESET_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetEditResponse::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_FILESET_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteFilesetEditResponse::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_FILESET_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteFilesetEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/fileset/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_fileset(param_ident, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetFilesetResponse::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_FILESET_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetResponse::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_FILESET_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetResponse::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_FILESET_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetResponse::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_FILESET_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) - }) - }, - "GetFileset", - ); - - let api_clone = api.clone(); - router.get( - "/v0/fileset/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_fileset_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetFilesetEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILESET_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetEditResponse::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_FILESET_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetEditResponse::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_FILESET_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetEditResponse::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_FILESET_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFilesetEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/fileset/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_fileset_history(param_ident, param_limit, context).wait() { - Ok(rsp) => match rsp { - GetFilesetHistoryResponse::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_FILESET_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetHistoryResponse::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_FILESET_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetHistoryResponse::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_FILESET_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetHistoryResponse::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_FILESET_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) - }) - }, - "GetFilesetHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/fileset/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_fileset_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetFilesetRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILESET_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRedirectsResponse::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_FILESET_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRedirectsResponse::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_FILESET_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRedirectsResponse::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_FILESET_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFilesetRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/fileset/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_fileset_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetFilesetRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_FILESET_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRevisionResponse::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_FILESET_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRevisionResponse::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_FILESET_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetFilesetRevisionResponse::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_FILESET_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetFilesetRevision", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editgroup/:editgroup_id/fileset/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_fileset(param_editgroup_id, param_ident, param_entity, context).wait() { - Ok(rsp) => match rsp { - UpdateFilesetResponse::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_FILESET_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) - } - UpdateFilesetResponse::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_FILESET_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) - } - UpdateFilesetResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILESET_NOT_AUTHORIZED.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) - } - UpdateFilesetResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_FILESET_FORBIDDEN.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) - } - UpdateFilesetResponse::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_FILESET_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) - } - UpdateFilesetResponse::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_FILESET_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) - }) - }, - "UpdateFileset", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:editgroup_id/release", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_release(param_editgroup_id, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_FORBIDDEN.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/editgroup/auto/release/batch", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_release_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateReleaseAutoBatchResponse::CreatedEditgroup(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_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateReleaseAutoBatchResponse::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_AUTO_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) - } - CreateReleaseAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateReleaseAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_AUTO_BATCH_FORBIDDEN.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) - } - CreateReleaseAutoBatchResponse::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_AUTO_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) - } - CreateReleaseAutoBatchResponse::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_AUTO_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) - }) - }, - "CreateReleaseAutoBatch", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/:editgroup_id/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_work(param_editgroup_id, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - CreateWorkResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - CreateWorkResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - if !unused_elements.is_empty() { - response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); - } - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "CreateWork", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/release/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_release(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_FORBIDDEN.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/editgroup/:editgroup_id/release/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_release_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteReleaseEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteReleaseEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_RELEASE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteReleaseEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_release(param_ident, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetReleaseResponse::FoundEntity(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetRelease", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_release_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetReleaseEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetReleaseEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/:ident/files", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_release_files(param_ident, param_hide, 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/:ident/filesets", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_release_filesets(param_ident, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetReleaseFilesetsResponse::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_FILESETS_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseFilesetsResponse::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_FILESETS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseFilesetsResponse::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_FILESETS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseFilesetsResponse::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_FILESETS_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) - }) - }, - "GetReleaseFilesets", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_release_history(param_ident, param_limit, context).wait() { - Ok(rsp) => match rsp { - GetReleaseHistoryResponse::FoundEntityHistory(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseHistoryResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseHistoryResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseHistoryResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_HISTORY_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetReleaseHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_release_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetReleaseRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRedirectsResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRedirectsResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRedirectsResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetReleaseRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_release_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetReleaseRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRevisionResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRevisionResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseRevisionResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetReleaseRevision", - ); - - let api_clone = api.clone(); - router.get( - "/v0/release/:ident/webcaptures", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_release_webcaptures(param_ident, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetReleaseWebcapturesResponse::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_WEBCAPTURES_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseWebcapturesResponse::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_WEBCAPTURES_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseWebcapturesResponse::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_WEBCAPTURES_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetReleaseWebcapturesResponse::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_WEBCAPTURES_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) - }) - }, - "GetReleaseWebcaptures", - ); - - 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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_doi = query_params.get("doi").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_isbn13 = query_params.get("isbn13").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_pmid = query_params.get("pmid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_pmcid = query_params.get("pmcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_core = query_params.get("core").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_arxiv = query_params.get("arxiv").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_jstor = query_params.get("jstor").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_ark = query_params.get("ark").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_mag = query_params.get("mag").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api - .lookup_release( - param_doi, - param_wikidata_qid, - param_isbn13, - param_pmid, - param_pmcid, - param_core, - param_arxiv, - param_jstor, - param_ark, - param_mag, - param_expand, - param_hide, - 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/editgroup/:editgroup_id/release/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_release(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_RELEASE_FORBIDDEN.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.post( - "/v0/editgroup/:editgroup_id/webcapture", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.create_webcapture(param_editgroup_id, param_entity, context).wait() { - Ok(rsp) => match rsp { - CreateWebcaptureResponse::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_WEBCAPTURE_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) - } - CreateWebcaptureResponse::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_WEBCAPTURE_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) - } - CreateWebcaptureResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_WEBCAPTURE_NOT_AUTHORIZED.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) - } - CreateWebcaptureResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WEBCAPTURE_FORBIDDEN.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) - } - CreateWebcaptureResponse::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_WEBCAPTURE_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) - } - CreateWebcaptureResponse::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_WEBCAPTURE_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) - }) - }, - "CreateWebcapture", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/auto/webcapture/batch", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_webcapture_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateWebcaptureAutoBatchResponse::CreatedEditgroup(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_WEBCAPTURE_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateWebcaptureAutoBatchResponse::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_WEBCAPTURE_AUTO_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) - } - CreateWebcaptureAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_WEBCAPTURE_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateWebcaptureAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WEBCAPTURE_AUTO_BATCH_FORBIDDEN.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) - } - CreateWebcaptureAutoBatchResponse::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_WEBCAPTURE_AUTO_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) - } - CreateWebcaptureAutoBatchResponse::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_WEBCAPTURE_AUTO_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) - }) - }, - "CreateWebcaptureAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/webcapture/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_webcapture(param_editgroup_id, param_ident, context).wait() { - Ok(rsp) => match rsp { - DeleteWebcaptureResponse::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_WEBCAPTURE_DELETED_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureResponse::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_WEBCAPTURE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_WEBCAPTURE_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WEBCAPTURE_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureResponse::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_WEBCAPTURE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureResponse::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_WEBCAPTURE_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) - }) - }, - "DeleteWebcapture", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/webcapture/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_webcapture_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteWebcaptureEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WEBCAPTURE_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureEditResponse::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_WEBCAPTURE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_WEBCAPTURE_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WEBCAPTURE_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureEditResponse::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_WEBCAPTURE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWebcaptureEditResponse::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_WEBCAPTURE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteWebcaptureEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/webcapture/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_webcapture(param_ident, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetWebcaptureResponse::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_WEBCAPTURE_FOUND_ENTITY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureResponse::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_WEBCAPTURE_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureResponse::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_WEBCAPTURE_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureResponse::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_WEBCAPTURE_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) - }) - }, - "GetWebcapture", - ); - - let api_clone = api.clone(); - router.get( - "/v0/webcapture/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_webcapture_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetWebcaptureEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WEBCAPTURE_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureEditResponse::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_WEBCAPTURE_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureEditResponse::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_WEBCAPTURE_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureEditResponse::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_WEBCAPTURE_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWebcaptureEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/webcapture/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_webcapture_history(param_ident, param_limit, context).wait() { - Ok(rsp) => match rsp { - GetWebcaptureHistoryResponse::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_WEBCAPTURE_HISTORY_FOUND_ENTITY_HISTORY.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureHistoryResponse::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_WEBCAPTURE_HISTORY_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureHistoryResponse::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_WEBCAPTURE_HISTORY_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureHistoryResponse::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_WEBCAPTURE_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) - }) - }, - "GetWebcaptureHistory", - ); - - let api_clone = api.clone(); - router.get( - "/v0/webcapture/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_webcapture_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetWebcaptureRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WEBCAPTURE_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRedirectsResponse::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_WEBCAPTURE_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRedirectsResponse::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_WEBCAPTURE_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRedirectsResponse::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_WEBCAPTURE_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWebcaptureRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/webcapture/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_webcapture_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetWebcaptureRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WEBCAPTURE_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRevisionResponse::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_WEBCAPTURE_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRevisionResponse::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_WEBCAPTURE_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWebcaptureRevisionResponse::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_WEBCAPTURE_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWebcaptureRevision", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editgroup/:editgroup_id/webcapture/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_webcapture(param_editgroup_id, param_ident, param_entity, context).wait() { - Ok(rsp) => match rsp { - UpdateWebcaptureResponse::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_WEBCAPTURE_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) - } - UpdateWebcaptureResponse::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_WEBCAPTURE_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) - } - UpdateWebcaptureResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_WEBCAPTURE_NOT_AUTHORIZED.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) - } - UpdateWebcaptureResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_WEBCAPTURE_FORBIDDEN.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) - } - UpdateWebcaptureResponse::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_WEBCAPTURE_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) - } - UpdateWebcaptureResponse::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_WEBCAPTURE_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) - }) - }, - "UpdateWebcapture", - ); - - let api_clone = api.clone(); - router.post( - "/v0/editgroup/auto/work/batch", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // 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_auto_batch = req - .get::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_auto_batch = if let Some(param_auto_batch_raw) = param_auto_batch { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_auto_batch_raw); - - let param_auto_batch: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e))))?; - - param_auto_batch - } else { - None - }; - let param_auto_batch = param_auto_batch.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter auto_batch".to_string())))?; - - match api.create_work_auto_batch(param_auto_batch, context).wait() { - Ok(rsp) => match rsp { - CreateWorkAutoBatchResponse::CreatedEditgroup(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_AUTO_BATCH_CREATED_EDITGROUP.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) - } - CreateWorkAutoBatchResponse::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_AUTO_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) - } - CreateWorkAutoBatchResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_AUTO_BATCH_NOT_AUTHORIZED.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) - } - CreateWorkAutoBatchResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_AUTO_BATCH_FORBIDDEN.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) - } - CreateWorkAutoBatchResponse::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_AUTO_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) - } - CreateWorkAutoBatchResponse::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_AUTO_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) - }) - }, - "CreateWorkAutoBatch", - ); - - let api_clone = api.clone(); - router.delete( - "/v0/editgroup/:editgroup_id/work/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.delete_work(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_FORBIDDEN.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.delete( - "/v0/editgroup/:editgroup_id/work/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.delete_work_edit(param_editgroup_id, param_edit_id, context).wait() { - Ok(rsp) => match rsp { - DeleteWorkEditResponse::DeletedEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_DELETED_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkEditResponse::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_NOT_AUTHORIZED.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkEditResponse::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_FORBIDDEN.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - DeleteWorkEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::DELETE_WORK_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "DeleteWorkEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_work(param_ident, param_expand, param_hide, 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/edit/:edit_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_edit_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("edit_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter edit_id".to_string())))?; - percent_decode(param.as_bytes()) - .decode_utf8() - .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? - .parse() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter edit_id: {}", e))))? - }; - - match api.get_work_edit(param_edit_id, context).wait() { - Ok(rsp) => match rsp { - GetWorkEditResponse::FoundEdit(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_FOUND_EDIT.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkEditResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkEditResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkEditResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_EDIT_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWorkEdit", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/:ident/history", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params - .get("limit") - .and_then(|list| list.first()) - .and_then(|x| Some(x.parse::())) - .map_or_else(|| Ok(None), |x| x.map(|v| Some(v))) - .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?; - - match api.get_work_history(param_ident, 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/:ident/redirects", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - match api.get_work_redirects(param_ident, context).wait() { - Ok(rsp) => match rsp { - GetWorkRedirectsResponse::FoundEntityRedirects(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRedirectsResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRedirectsResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRedirectsResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REDIRECTS_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWorkRedirects", - ); - - let api_clone = api.clone(); - router.get( - "/v0/work/:ident/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(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_work_releases(param_ident, param_hide, 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/work/rev/:rev_id", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - // Path parameters - let param_rev_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("rev_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter rev_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 rev_id: {}", e))))? - }; - - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - - match api.get_work_revision(param_rev_id, param_expand, param_hide, context).wait() { - Ok(rsp) => match rsp { - GetWorkRevisionResponse::FoundEntityRevision(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_FOUND_ENTITY_REVISION.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRevisionResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_BAD_REQUEST.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRevisionResponse::NotFound(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_NOT_FOUND.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - GetWorkRevisionResponse::GenericError(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_WORK_REVISION_GENERIC_ERROR.clone())); - - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - - Ok(response) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) - } - } - } - - handle_request(req, &api_clone, &mut context).or_else(|mut response| { - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); - Ok(response) - }) - }, - "GetWorkRevision", - ); - - let api_clone = api.clone(); - router.put( - "/v0/editgroup/:editgroup_id/work/:ident", - move |req: &mut Request| { - let mut context = Context::default(); - - // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result - where - T: Api, - { - context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); - context.auth_data = req.extensions.remove::(); - context.authorization = req.extensions.remove::(); - - let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - - // Path parameters - let param_editgroup_id = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("editgroup_id") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_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 editgroup_id: {}", e))))? - }; - let param_ident = { - let param = req - .extensions - .get::() - .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? - .find("ident") - .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter ident".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 ident: {}", 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::() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; - - let mut unused_elements = Vec::new(); - - let param_entity = if let Some(param_entity_raw) = param_entity { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - - let param_entity: Option = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - - param_entity - } else { - None - }; - let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - - match api.update_work(param_editgroup_id, param_ident, 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::NotAuthorized { body, www_authenticate } => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(401), body_string)); - header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } - response.headers.set(ResponseWwwAuthenticate(www_authenticate)); - - response.headers.set(ContentType(mimetypes::responses::UPDATE_WORK_NOT_AUTHORIZED.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::Forbidden(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - - let mut response = Response::with((status::Status::from_u16(403), body_string)); - response.headers.set(ContentType(mimetypes::responses::UPDATE_WORK_FORBIDDEN.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<()> { - { - header! { (ApiKey1, "Authorization") => [String] } - if let Some(header) = req.headers.get::() { - req.extensions.insert::(AuthData::ApiKey(header.0.clone())); - return Ok(()); - } - } - - Ok(()) - } -} -- cgit v1.2.3